当前位置: 首页>>代码示例>>C#>>正文


C# PythonEditor.GetCompletions方法代码示例

本文整理汇总了C#中PythonToolsMockTests.PythonEditor.GetCompletions方法的典型用法代码示例。如果您正苦于以下问题:C# PythonEditor.GetCompletions方法的具体用法?C# PythonEditor.GetCompletions怎么用?C# PythonEditor.GetCompletions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PythonToolsMockTests.PythonEditor的用法示例。


在下文中一共展示了PythonEditor.GetCompletions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CtrlSpaceCompletions

        public void CtrlSpaceCompletions() {
            using (var view = new PythonEditor()) {
                view.Text = @"def f(param1, param2):
    g()";

                AssertUtil.ContainsAtLeast(view.GetCompletionsAfter("g("), "param1", "param2");

                view.Text = @"def f(param1, param2):
    g(param1, )";

                AssertUtil.ContainsAtLeast(view.GetCompletionsAfter("g(param1, "), "param1", "param2");

                // verify Ctrl-Space inside of a function gives proper completions
                foreach (var codeSnippet in new[] { @"def f():
    
    pass", @"def f():
    x = (2 + 3)
    
    pass
", @"def f():
    yield (2 + 3)
    
    pass" }) {

                    Debug.WriteLine(String.Format("Testing {0}", codeSnippet));

                    view.Text = codeSnippet;
                    AssertUtil.ContainsAtLeast(view.GetCompletions(codeSnippet.IndexOf("\r\n    pass")), "min", "assert");
                }
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:31,代码来源:CompletionTests.cs

示例2: ArgumentNameCompletion

        public void ArgumentNameCompletion() {
            const string code = @"
def f(param1 = 123, param2 : int = 234):
    pass

x = f(";

            using (var view = new PythonEditor(code)) {
                view.Text = view.Text;
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "param1", "param2");
                AssertUtil.DoesntContain(view.GetCompletions(0), "param1");
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:13,代码来源:CompletionTests.cs

示例3: FromImportCompletions

        public void FromImportCompletions() {
            using (var view = new PythonEditor()) {
                view.Text = "from ";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "nt", "sys");

                view.Text = "from s";
                var completions = view.GetCompletions(-1);
                AssertUtil.ContainsAtLeast(completions, "sys");
                AssertUtil.DoesntContain(completions, "nt");

                view.Text = "from sys ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "import");

                view.Text = "from sys import";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "import");

                view.Text = "from sys import ";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1),
                    "*",                    // Contains *
                    "settrace",             // Contains functions
                    "api_version"           // Contains data members
                );

                view.Text = "from sys.";
                // There will be one completion saying that there are no completions
                Assert.AreEqual(1, view.GetCompletions(-1).Count());

                // Error case - no completions
                view.Text = "from sys. import ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1));

                view.Text = "from sys import settrace ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "as");

                view.Text = "from sys import settrace as";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "as");

                view.Text = "from sys import settrace,";
                completions = view.GetCompletions(-1);
                AssertUtil.ContainsAtLeast(completions, "api_version", "settrace");
                AssertUtil.DoesntContain(completions, "*");

                // No more completions after a *
                view.Text = "from sys import *, ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1));

                view.Text = "from sys import settrace as ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1));

                view.Text = "from sys import settrace as st ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1));

                view.Text = "from sys import settrace as st, ";
                completions = view.GetCompletions(-1);
                AssertUtil.ContainsAtLeast(completions, "api_version", "settrace");
                AssertUtil.DoesntContain(completions, "*");
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:58,代码来源:CompletionTests.cs

示例4: Scenario_CompletionInTripleQuotedString

        public void Scenario_CompletionInTripleQuotedString() {
            string code = @"
'''
import 
from 
except 
@
sys.
'''
";

            using (var view = new PythonEditor(code)) {
                for (int i = code.IndexOfEnd("'''"); i < code.LastIndexOf("'''"); ++i) {
                    AssertUtil.ContainsExactly(view.GetCompletions(i));
                }
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:17,代码来源:CompletionTests.cs

示例5: ImportCompletions

        public void ImportCompletions() {
            using (var view = new PythonEditor()) {
                view.Text ="import ";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "sys");

                view.Text ="import sys";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "sys");

                view.Text ="import sys ";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "as");

                view.Text ="import sys as";
                AssertUtil.ContainsExactly(view.GetCompletions(-1), "as");

                view.Text ="import sys as s, ";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "sys");

                view.Text ="import sys, ";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "datetime");

                view.Text ="import sys, da";
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "datetime");
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:24,代码来源:CompletionTests.cs

示例6: GetCompletions

 private static IEnumerable<string> GetCompletions(MockVs vs, int index, string code, PythonLanguageVersion version = PythonLanguageVersion.V27) {
     using (var view = new PythonEditor(code, version, vs)) {
         return view.GetCompletions(index);
     }
 }
开发者ID:sadapple,项目名称:PTVS,代码行数:5,代码来源:CompletionTests.cs

示例7: KeywordCompletions

        public void KeywordCompletions() {
            using (var view = new PythonEditor(version: PythonLanguageVersion.V35)) {
                var completionList = new HashSet<string>(view.GetCompletions(0));

                // not in a function
                AssertUtil.DoesntContain(completionList, "yield");
                AssertUtil.DoesntContain(completionList, "return");
                AssertUtil.DoesntContain(completionList, "await");

                AssertUtil.ContainsAtLeast(completionList, "assert", "and", "async");

                var code = @"def f():
    |
    pass";

                view.Text = code.Replace("|", "");
                AssertUtil.ContainsAtLeast(view.GetCompletions(code.IndexOf("|")), "yield", "return", "async", "await");


                view.Text = "x = (abc, oar, )";
                completionList = new HashSet<string>(view.GetCompletionsAfter("oar, "));

                AssertUtil.ContainsAtLeast(completionList, "and");
                AssertUtil.DoesntContain(completionList, "def");
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:26,代码来源:CompletionTests.cs

示例8: MethodArgumentNameCompletion

        public void MethodArgumentNameCompletion() {
            const string code = @"
class MyClass:
    def f(self, param1 = 123, param2 : int = 234):
        pass

m = MyClass()
x = m.f(";

            using (var view = new PythonEditor(code)) {
                for (int retries = 3; retries >= 0; --retries) {
                    var sigs = GetSignatureAnalysis(view, code.Length - 1);
                    if (sigs.Signatures.Count > 0) {
                        break;
                    }
                    Console.WriteLine("Retry {0}", retries);
                    view.Text = view.Text;
                }
                AssertUtil.ContainsAtLeast(view.GetCompletions(-1), "param1", "param2");
                AssertUtil.DoesntContain(view.GetCompletions(0), "param1");
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:22,代码来源:CompletionTests.cs


注:本文中的PythonToolsMockTests.PythonEditor.GetCompletions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。