提交 7f391d52 编写于 作者: P Petr Houška

Address feedback.

上级 964d1801
......@@ -555,24 +555,19 @@ void M()
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertLocalFunctionToMethod)]
public async Task TestWholeMethodSelectionPositon()
{
await TestAsync("[|C LocalFunction(C c)");
await TestMissingAsync("C LocalFunction(C c)[|");
async Task TestAsync(string signature)
public async Task TestWholeMethodSelection1()
{
await TestInRegularAndScriptAsync(
$@"class C
{{
@"class C
{
void M()
{{
{signature}
{{
{
[|C LocalFunction(C c)
{
return null;
}}|]
}}
}}",
}|]
}
}",
@"class C
{
void M()
......@@ -586,20 +581,22 @@ private static C LocalFunction(C c)
}");
}
async Task TestMissingAsync(string signature)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertLocalFunctionToMethod)]
public async Task TestWholeMethodSelection2()
{
await this.TestMissingAsync(
$@"class C
{{
@"class C
{
void M()
{{
{signature}
{{
{
C LocalFunction(C c)[|
{
return null;
}}|]
}}
}}");
}|]
}
}");
}
}
}
......@@ -75,6 +75,9 @@ public static bool IsScript(this SyntaxTree syntaxTree)
/// <summary>
/// Returns the first Token that passes <paramref name="predicate"/> within supplied <paramref name="span"/>.
/// </summary>
/// <remarks>
/// Only tokens whose <c>Span.End</c> fits within <paramref name="span"/> are considered.
/// </remarks>
public static async Task<SyntaxToken> GetLeftmostTokenInSpanAsync(
this SyntaxTree syntaxTree,
TextSpan span,
......@@ -97,7 +100,7 @@ public static bool IsScript(this SyntaxTree syntaxTree)
while (!predicate(token))
{
if (token.FullSpan.End >= syntaxTree.Length)
if (token.Span.End >= span.End || token.FullSpan.End >= syntaxTree.Length)
{
// SyntaxKind = None
return default;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册