本文整理汇总了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");
}
}
}
示例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");
}
}
示例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, "*");
}
}
示例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));
}
}
}
示例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");
}
}
示例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);
}
}
示例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");
}
}
示例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");
}
}