Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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$$)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably good to have a comment saying that the normal symbolcompletionprovider gives us the values here, so we don't need to duplicate it. Also, we probably want a test in symbolcompletionprovidertests to make sure that we do get values from it.

}

static void M(E e) { }
}

enum E
{
A,
B,
}
}
";
await VerifyNoItemsExistAsync(markup);
}
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a problem for VB as well?


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;