public SmartIndentTest(IServiceContainer services) { _services = services; var locator = _services.GetService <IContentTypeServiceLocator>(); _provider = locator.GetService <ISmartIndentProvider>(RContentTypeDefinition.ContentType); }
private int?GetSmartIndent(string content, int lineNumber) { AstRoot ast; ITextView textView = TextViewTest.MakeTextView(content, 0, out ast); var document = new EditorDocumentMock(new EditorTreeMock(textView.TextBuffer, ast)); ISmartIndentProvider provider = EditorShell.Current.ExportProvider.GetExport <ISmartIndentProvider>().Value; ISmartIndent indenter = provider.CreateSmartIndent(textView); return(indenter.GetDesiredIndentation(textView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber))); }
public void Scope(string content, int lineNum, int expectedIndent) { AstRoot ast; ITextView textView = TextViewTest.MakeTextView(content, 0, out ast); var document = new EditorDocumentMock(new EditorTreeMock(textView.TextBuffer, ast)); ISmartIndentProvider provider = _exportProvider.GetExportedValue <ISmartIndentProvider>(); ISmartIndent indenter = provider.CreateSmartIndent(textView); int?indent = indenter.GetDesiredIndentation(textView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNum)); indent.Should().HaveValue().And.Be(expectedIndent); }
public void SmartIndentTest05() { AstRoot ast; ITextView textView = TextViewTest.MakeTextView(" x <- 1\r\n", 0, out ast); using (var document = new EditorDocumentMock(new EditorTreeMock(textView.TextBuffer, ast))) { ISmartIndentProvider provider = _exportProvider.GetExportedValue <ISmartIndentProvider>("ContentTypes", RContentTypeDefinition.ContentType); SmartIndenter indenter = (SmartIndenter)provider.CreateSmartIndent(textView); int?indent = indenter.GetDesiredIndentation(textView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1), IndentStyle.Block); indent.Should().HaveValue().And.Be(2); } }
private InteractiveSmartIndenter(IContentType contentType, ITextView view, ISmartIndentProvider provider) { this.contentType = contentType; this.view = view; this.indenter = provider.CreateSmartIndent(view); }