예제 #1
0
        private async Task <Session> TriggerSessionAsync(string content, int caretPosition)
        {
            var s = new Session();

            s.Ast        = RParser.Parse(content);
            s.TextBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            QuickInfoSource      quickInfoSource  = new QuickInfoSource(s.TextBuffer, EditorShell);
            QuickInfoSessionMock quickInfoSession = new QuickInfoSessionMock(s.TextBuffer, caretPosition);

            s.QuickInfoContent = new List <object>();

            quickInfoSession.TriggerPoint = new SnapshotPoint(s.TextBuffer.CurrentSnapshot, caretPosition);
            s.ApplicableSpan = await quickInfoSource.AugmentQuickInfoSessionAsync(s.Ast, caretPosition, quickInfoSession, s.QuickInfoContent);

            return(s);
        }
예제 #2
0
        private async Task <Session> TriggerSessionAsync(string content, int position)
        {
            var s = new Session {
                Ast          = RParser.Parse(content),
                EditorBuffer = new TextBufferMock(content, RContentTypeDefinition.ContentType).ToEditorBuffer()
            };

            var tree             = new EditorTreeMock(s.EditorBuffer, s.Ast);
            var document         = new EditorDocumentMock(tree);
            var textBuffer       = s.EditorBuffer.As <ITextBuffer>();
            var quickInfoSource  = new QuickInfoSource(textBuffer, Services);
            var quickInfoSession = new QuickInfoSessionMock(textBuffer, position);

            s.QuickInfoContent = new List <object>();

            quickInfoSession.TriggerPoint = new SnapshotPoint(s.EditorBuffer.TextSnapshot(), position);
            s.ApplicableSpan = await quickInfoSource.AugmentQuickInfoSessionAsync(s.Ast, textBuffer, position, quickInfoSession, s.QuickInfoContent);

            return(s);
        }
예제 #3
0
        public async Task QuickInfoSourceTest01()
        {
            string  content = @"x <- as.matrix(x)";
            AstRoot ast     = RParser.Parse(content);

            int                  caretPosition    = 15; // in arguments
            ITextBuffer          textBuffer       = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            QuickInfoSource      quickInfoSource  = new QuickInfoSource(textBuffer);
            QuickInfoSessionMock quickInfoSession = new QuickInfoSessionMock(textBuffer, caretPosition);
            List <object>        quickInfoContent = new List <object>();

            quickInfoSession.TriggerPoint = new SnapshotPoint(textBuffer.CurrentSnapshot, caretPosition);
            var applicableSpan = await quickInfoSource.AugmentQuickInfoSessionAsync(ast, caretPosition, quickInfoSession, quickInfoContent);

            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(ast, textBuffer.CurrentSnapshot, 10);

            applicableSpan.Should().NotBeNull();
            quickInfoContent.Should().ContainSingle()
            .Which.ToString().Should().StartWith("as.matrix(x, data, nrow, ncol, byrow, dimnames, rownames.force, ...)");
        }
예제 #4
0
        public async Task QuickInfoSourceTest02()
        {
            // 'as.Date.character' RD contains no function info for 'as.Date.character', but the one for 'as.Date'
            // then, the current code expects to add 'as.Date' quick info, which is the first function info for as.Date.character
            string  content = @"x <- as.Date.character(x)";
            AstRoot ast     = RParser.Parse(content);

            int                  caretPosition    = 23; // in arguments
            ITextBuffer          textBuffer       = new TextBufferMock(content, RContentTypeDefinition.ContentType);
            QuickInfoSource      quickInfoSource  = new QuickInfoSource(textBuffer, EditorShell);
            QuickInfoSessionMock quickInfoSession = new QuickInfoSessionMock(textBuffer, caretPosition);
            List <object>        quickInfoContent = new List <object>();

            quickInfoSession.TriggerPoint = new SnapshotPoint(textBuffer.CurrentSnapshot, caretPosition);
            var applicableSpan = await quickInfoSource.AugmentQuickInfoSessionAsync(ast, caretPosition, quickInfoSession, quickInfoContent);

            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(ast, textBuffer.CurrentSnapshot, 10);

            applicableSpan.Should().NotBeNull();
            quickInfoContent.Should().ContainSingle()
            .Which.ToString().Should().StartWith("as.Date(x, ...)");
        }