本文整理汇总了C#中PythonToolsMockTests.PythonEditor.GetCompletionsAfter方法的典型用法代码示例。如果您正苦于以下问题:C# PythonEditor.GetCompletionsAfter方法的具体用法?C# PythonEditor.GetCompletionsAfter怎么用?C# PythonEditor.GetCompletionsAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonToolsMockTests.PythonEditor
的用法示例。
在下文中一共展示了PythonEditor.GetCompletionsAfter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ClassCompletionOutsideFunction
public void ClassCompletionOutsideFunction() {
// Note that "eggs_and_spam" is longer than the indentation of each
// scope.
string code = @"
eggs_and_spam = 'abc'
class Spam(object):
eggs_and_spam = 123
def f(self, eggs_and_spam = 3.14):
#1
pass
#2
#3
";
using (var view = new PythonEditor()) {
view.Text = code.Replace("#1", "eggs_and_spam.");
var completionList = view.GetCompletionsAfter("eggs_and_spam.");
AssertUtil.ContainsAtLeast(completionList, "real", "imag");
AssertUtil.DoesntContain(completionList, "lower");
view.Text = code.Replace("#2", "eggs_and_spam.");
AssertUtil.ContainsAtLeast(view.GetCompletionsAfter("eggs_and_spam."), "bit_length");
view.Text = code.Replace("#3", "eggs_and_spam.");
AssertUtil.ContainsAtLeast(view.GetCompletionsAfter("eggs_and_spam."), "lower", "center");
}
}
示例3: 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");
}
}
示例4: KeywordOrIdentifierCompletions
public void KeywordOrIdentifierCompletions() {
// http://pytools.codeplex.com/workitem/560
string code = @"
def h():
yiel
def f():
yield
def g():
yield_
yield_expression = 42
";
using (var view = new PythonEditor(code)) {
var completionList = view.GetCompletionsAfter("yield_");
AssertUtil.DoesntContain(completionList, "yield");
AssertUtil.Contains(completionList, "yield_expression");
completionList = view.GetCompletionsAfter("yield");
AssertUtil.Contains(completionList, "yield");
AssertUtil.Contains(completionList, "yield_expression");
completionList = view.GetCompletionsAfter("yiel");
AssertUtil.Contains(completionList, "yield");
AssertUtil.Contains(completionList, "yield_expression");
}
}
示例5: EditAndGetCompletions
private static IEnumerable<string> EditAndGetCompletions(
MockVs vs,
string code,
string editText,
int editInsert,
string completeAfter,
PythonLanguageVersion version = PythonLanguageVersion.V27
) {
using (var view = new PythonEditor(code, version, vs)) {
view.AdvancedOptions.HideAdvancedMembers = false;
var snapshot = view.CurrentSnapshot;
view.View.MoveCaret(new SnapshotPoint(snapshot, editInsert));
view.Type(editText);
var newSnapshot = view.CurrentSnapshot;
Assert.AreNotSame(snapshot, newSnapshot);
return view.GetCompletionsAfter(completeAfter);
}
}
示例6: AwaitExpressionCompletion
public void AwaitExpressionCompletion() {
const string code = @"
async def f():
return 1
async def g():
f().
await f().
(await f()).";
using (var view = new PythonEditor(code, PythonLanguageVersion.V35)) {
AssertUtil.CheckCollection(view.GetCompletionsAfter("f()."),
new[] { "next", "send", "throw" },
new[] { "real", "imag" }
);
AssertUtil.CheckCollection(view.GetCompletionsAfter("await f()."),
new[] { "next", "send", "throw" },
new[] { "real", "imag" }
);
AssertUtil.CheckCollection(view.GetCompletionsAfter("(await f())."),
new[] { "real", "imag" },
new[] { "next", "send", "throw" }
);
}
}
示例7: YieldFromExpressionCompletion
public void YieldFromExpressionCompletion() {
const string code = @"
def f():
yield 1
return 1
def g():
f().
yield from f().
(yield from f()).
";
using (var view = new PythonEditor(code, PythonLanguageVersion.V35)) {
AssertUtil.CheckCollection(view.GetCompletionsAfter("f()."),
new[] { "next", "send", "throw" },
new[] { "real", "imag" }
);
AssertUtil.CheckCollection(view.GetCompletionsAfter("yield from f()."),
new[] { "next", "send", "throw" },
new[] { "real", "imag" }
);
AssertUtil.CheckCollection(view.GetCompletionsAfter("(yield from f())."),
new[] { "real", "imag" },
new[] { "next", "send", "throw" }
);
}
}
示例8: LambdaCompletions
public void LambdaCompletions() {
// https://github.com/Microsoft/PTVS/issues/1000
string code = @"
l = (lambda b:b)
l(42)
";
using (var view = new PythonEditor(code)) {
var completionList = view.GetCompletionsAfter(":");
AssertUtil.Contains(completionList, "b");
}
}
示例9: EditAndGetCompletions
private static IEnumerable<string> EditAndGetCompletions(
MockVs vs,
string code,
string editText,
int editInsert,
string completeAfter,
PythonLanguageVersion version = PythonLanguageVersion.V27
) {
using (var view = new PythonEditor(code, version, vs)) {
view.AdvancedOptions.HideAdvancedMembers = false;
var snapshot = view.CurrentSnapshot;
ITextVersion afterEditVersion = null;
ManualResetEvent mre = new ManualResetEvent(false);
view.View.TextView.TextBuffer.RegisterForNewAnalysis(entry => {
if (afterEditVersion != null &&
entry.BufferParser.GetAnalysisVersion(snapshot.TextBuffer).VersionNumber >= afterEditVersion.VersionNumber) {
mre.Set();
}
});
view.View.MoveCaret(new SnapshotPoint(snapshot, editInsert));
view.Type(editText);
afterEditVersion = view.CurrentSnapshot.Version;
if (!mre.WaitOne(10000)) {
Assert.Fail("Failed to wait for new analysis");
}
var newSnapshot = view.CurrentSnapshot;
Assert.AreNotSame(snapshot, newSnapshot);
return view.GetCompletionsAfter(completeAfter);
}
}