Пример #1
0
        public void R_CompletionOnTab() {
            using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
                var provider = EditorShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
                using (var hostScript = new RHostScript(provider)) {

                    REditorSettings.ShowCompletionOnTab = true;
                    script.DoIdle(100);
                    script.Type("f1<-x");
                    EditorShell.Current.DispatchOnUIThread(() => script.GetCompletionSession().Dismiss());

                    script.DoIdle(300);
                    script.Type("{TAB}");
                    script.DoIdle(500);
                    script.Type("{TAB}");
                    script.DoIdle(200);

                    string actual = script.EditorText;
                    actual.Should().Be("f1<-x11");

                    REditorSettings.ShowCompletionOnTab = false;
                }
            }
        }
Пример #2
0
        public void R_LoadedPackageFunctionCompletion() {
            using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
                var provider = EditorShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
                using (new RHostScript(provider)) {
                    REvaluationResult result;

                    script.Type("c");
                    script.DoIdle(200);
                    var session = script.GetCompletionSession();
                    session.Should().NotBeNull();
                    script.DoIdle(500);

                    var list = session.SelectedCompletionSet.Completions.ToList();
                    var item = list.FirstOrDefault(x => x.DisplayText == "codoc");
                    item.Should().BeNull();

                    var rSession = provider.GetOrCreate(GuidList.InteractiveWindowRSessionGuid, null);
                    rSession.Should().NotBeNull();

                    using (var eval = rSession.BeginEvaluationAsync().Result) {
                        result = eval.EvaluateAsync("library('tools')").Result;
                    }

                    script.DoIdle(1000);

                    script.Type("{ESC}");
                    script.DoIdle(200);
                    script.Backspace();
                    script.Type("{ENTER}");
                    script.DoIdle(100);

                    script.Type("c");
                    script.DoIdle(500);
                    script.Backspace();

                    session = script.GetCompletionSession();
                    session.Should().NotBeNull();
                    list = session.SelectedCompletionSet.Completions.ToList();
                    item = list.FirstOrDefault(x => x.DisplayText == "codoc");
                    item.Should().NotBeNull();
                }
            }
        }
Пример #3
0
        public void R_CompletionFiles() {
            using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
                string asmPath = Assembly.GetExecutingAssembly().GetAssemblyPath();
                RToolsSettings.Current.WorkingDirectory = Path.GetDirectoryName(asmPath);

                script.DoIdle(100);
                script.Type("x <- \"");
                script.DoIdle(1000);
                script.Type("{TAB}");
                script.DoIdle(100);

                var session = script.GetCompletionSession();
                session.Should().NotBeNull();
                script.DoIdle(200);

                var list = session.SelectedCompletionSet.Completions.ToList();
                var item = list.FirstOrDefault(x => x.DisplayText == "ItemTemplates");
                item.Should().NotBeNull();
            }
        }
Пример #4
0
        public void R_SnippetsCompletion01() {
            using (var script = new TestScript(RContentTypeDefinition.ContentType)) {
                script.DoIdle(100);
                script.Type("whil");
                script.DoIdle(300);

                EditorShell.Current.DispatchOnUIThread(() => {
                    var session = script.GetCompletionSession();
                    session.Should().NotBeNull();

                    var infoSourceProvider = EditorShell.Current.ExportProvider.GetExportedValue<ISnippetInformationSourceProvider>();
                    var infoSource = infoSourceProvider.InformationSource;
                    var completion = session.SelectedCompletionSet.SelectionStatus.Completion;

                    bool isSnippet = infoSource.IsSnippet(completion.DisplayText);
                    isSnippet.Should().BeTrue();

                    var glyph = completion.IconSource;
                    var snippetGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);
                    glyph.Should().Be(snippetGlyph);
                });
            }
        }