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); }
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); }
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); }