Пример #1
0
        public void Scope(string content, int lineNum, int expectedIndent)
        {
            var tv       = MakeTextView(content);
            var indenter = _provider.CreateSmartIndent(tv);

            var indent = indenter.GetDesiredIndentation(tv.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNum));

            indent.Should().HaveValue().And.Be(expectedIndent);
        }
Пример #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);
 }