コード例 #1
0
        public override BraceSmartIndenter Create(VisualStudioDocumentTracker documentTracker)
        {
            if (documentTracker == null)
            {
                throw new ArgumentNullException(nameof(documentTracker));
            }

            _dispatcher.AssertForegroundThread();

            var braceSmartIndenter = new BraceSmartIndenter(_dispatcher, documentTracker, _editorOperationsFactory);

            return(braceSmartIndenter);
        }
コード例 #2
0
        private static DefaultRazorEditorFactoryService CreateFactoryService(
            VisualStudioDocumentTracker documentTracker = null,
            VisualStudioRazorParser parser   = null,
            BraceSmartIndenter smartIndenter = null)
        {
            documentTracker = documentTracker ?? Mock.Of <VisualStudioDocumentTracker>();
            parser          = parser ?? Mock.Of <VisualStudioRazorParser>();
            smartIndenter   = smartIndenter ?? Mock.Of <BraceSmartIndenter>();

            var documentTrackerFactory = Mock.Of <VisualStudioDocumentTrackerFactory>(f => f.Create(It.IsAny <ITextBuffer>()) == documentTracker);
            var parserFactory          = Mock.Of <VisualStudioRazorParserFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == parser);
            var smartIndenterFactory   = Mock.Of <BraceSmartIndenterFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == smartIndenter);
            var factoryService         = new DefaultRazorEditorFactoryService(documentTrackerFactory, parserFactory, smartIndenterFactory);

            return(factoryService);
        }
コード例 #3
0
        internal override bool TryGetSmartIndenter(ITextBuffer textBuffer, out BraceSmartIndenter braceSmartIndenter)
        {
            if (textBuffer == null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            if (!textBuffer.IsRazorBuffer())
            {
                braceSmartIndenter = null;
                return(false);
            }

            EnsureTextBufferInitialized(textBuffer);

            if (!textBuffer.Properties.TryGetProperty(typeof(BraceSmartIndenter), out braceSmartIndenter))
            {
                Debug.Fail("Brace smart indenter should have been stored on the text buffer during initialization.");
                return(false);
            }

            return(true);
        }