提交 f418671f 编写于 作者: R Ravi Chande 提交者: GitHub

Don't show enum completion if text is typed after dot (#18577)

Don't show enum completion if text is typed after dot
上级 b986dbd7
......@@ -488,6 +488,33 @@ enum E
B,
}
}
";
await VerifyNoItemsExistAsync(markup);
}
[WorkItem(18359, "https://github.com/dotnet/roslyn/issues/18359")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task NotAfterDotWithTextTyped()
{
var markup =
@"namespace ConsoleApplication253
{
class Program
{
static void Main(string[] args)
{
M(E.a$$)
}
static void M(E e) { }
}
enum E
{
A,
B,
}
}
";
await VerifyNoItemsExistAsync(markup);
}
......
......@@ -9077,5 +9077,34 @@ Action<int> Local(string x, ref var @class, params Func<int, string> f)
}
}", "Local", "Action<int> Local(string x, ref var @class, params Func<int, string> f)");
}
[WorkItem(18359, "https://github.com/dotnet/roslyn/issues/18359")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task EnumMemberAfterDot()
{
var markup =
@"namespace ConsoleApplication253
{
class Program
{
static void Main(string[] args)
{
M(E.$$)
}
static void M(E e) { }
}
enum E
{
A,
B,
}
}
";
// VerifyItemExistsAsync also tests with the item typed.
await VerifyItemExistsAsync(markup, "A");
await VerifyItemExistsAsync(markup, "B");
}
}
}
\ No newline at end of file
......@@ -52,7 +52,9 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
return;
}
var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken);
var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken)
.GetPreviousTokenIfTouchingWord(position);
if (token.IsMandatoryNamedParameterPosition())
{
return;
......@@ -61,6 +63,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
// Don't show up within member access
// This previously worked because the type inferrer didn't work
// in member access expressions.
// The regular SymbolCompletionProvider will handle completion after .
if (token.IsKind(SyntaxKind.DotToken))
{
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册