예제 #1
0
        public SmartIndentTest(IServiceContainer services)
        {
            _services = services;

            var locator = _services.GetService <IContentTypeServiceLocator>();

            _provider = locator.GetService <ISmartIndentProvider>(RContentTypeDefinition.ContentType);
        }
예제 #2
0
        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)));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
 private InteractiveSmartIndenter(IContentType contentType, ITextView view, ISmartIndentProvider provider)
 {
     this.contentType = contentType;
     this.view        = view;
     this.indenter    = provider.CreateSmartIndent(view);
 }
예제 #6
0
 private InteractiveSmartIndenter(IContentType contentType, ITextView view, ISmartIndentProvider provider)
 {
     this.contentType = contentType;
     this.view = view;
     this.indenter = provider.CreateSmartIndent(view);
 }