protected void GetCompletions(string content, int caretPosition, IList <CompletionSet> completionSets, ITextRange selectedRange = null)
        {
            AstRoot ast = RParser.Parse(content);

            TextBufferMock textBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            TextViewMock   textView   = new TextViewMock(textBuffer, caretPosition);

            if (selectedRange != null)
            {
                textView.Selection.Select(new SnapshotSpan(textBuffer.CurrentSnapshot, selectedRange.Start, selectedRange.Length), false);
            }

            CompletionSessionMock completionSession = new CompletionSessionMock(textView, completionSets, caretPosition);
            RCompletionSource     completionSource  = new RCompletionSource(textBuffer, _exportProvider.GetExportedValue <ICoreShell>());

            completionSource.PopulateCompletionList(caretPosition, completionSession, completionSets, ast);
        }
        public static void GetCompletions(ICoreShell coreShell, string content, int caretPosition, IList <CompletionSet> completionSets, ITextRange selectedRange = null)
        {
            var ast = RParser.Parse(content);

            var textBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            var textView   = new TextViewMock(textBuffer, caretPosition);

            if (selectedRange != null)
            {
                textView.Selection.Select(new SnapshotSpan(textBuffer.CurrentSnapshot, selectedRange.Start, selectedRange.Length), false);
            }

            var completionSession = new CompletionSessionMock(textView, completionSets, caretPosition);
            var completionSource  = new RCompletionSource(textBuffer, coreShell);

            completionSource.PopulateCompletionList(caretPosition, completionSession, completionSets, ast);
        }
Beispiel #3
0
        private void GetCompletions(string content, int position, IList <CompletionSet> completionSets, ITextRange selectedRange = null)
        {
            AstRoot ast = RParser.Parse(content);

            TextBufferMock textBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            TextViewMock   textView   = new TextViewMock(textBuffer, position);

            if (selectedRange != null)
            {
                textView.Selection.Select(new SnapshotSpan(textBuffer.CurrentSnapshot, selectedRange.Start, selectedRange.Length), false);
            }

            CompletionSessionMock completionSession = new CompletionSessionMock(textView, completionSets, position);
            RCompletionSource     completionSource  = new RCompletionSource(textBuffer);

            completionSource.PopulateCompletionList(position, completionSession, completionSets, ast);
        }
Beispiel #4
0
        public static void GetCompletions(IServiceContainer services, string content, int caretPosition, IList <CompletionSet> completionSets, ITextRange selectedRange = null)
        {
            var ast = RParser.Parse(content);

            var textBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            var textView   = new TextViewMock(textBuffer, caretPosition);

            var document = Substitute.For <IREditorDocument>();

            document.EditorTree.AstRoot.Returns(ast);
            textBuffer.AddService(document);

            if (selectedRange != null)
            {
                textView.Selection.Select(new SnapshotSpan(textBuffer.CurrentSnapshot, selectedRange.Start, selectedRange.Length), false);
            }

            var completionSession = new CompletionSessionMock(textView, completionSets, caretPosition);
            var completionSource  = new RCompletionSource(textBuffer, services);

            completionSource.PopulateCompletionList(caretPosition, completionSession, completionSets, ast);
        }