提交 39f7cda3 编写于 作者: Š Šimon Koníček

Fixing IsConstantExpressionContext inside CasePatternSwitchLabel

上级 65633ef3
......@@ -1263,9 +1263,15 @@ public async Task SwitchStatement()
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task SwitchLabelCase()
{
var content = @"switch(i)
{
case $$";
var content = @"switch(i) { case $$";
await VerifyItemExistsAsync(AddUsingDirectives("using System;", AddInsideMethod(content)), @"String");
await VerifyItemExistsAsync(AddUsingDirectives("using System;", AddInsideMethod(content)), @"System");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task SwitchPatternLabelCase()
{
var content = @"switch(i) { case $$ when";
await VerifyItemExistsAsync(AddUsingDirectives("using System;", AddInsideMethod(content)), @"String");
await VerifyItemExistsAsync(AddUsingDirectives("using System;", AddInsideMethod(content)), @"System");
}
......@@ -2701,6 +2707,24 @@ void M()
await VerifyItemExistsAsync(markup, "MAX_SIZE");
}
[WorkItem(25084, "https://github.com/dotnet/roslyn/issues/25084#issuecomment-370148553")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task ConstantsInSwitchPatternCase()
{
var markup = @"
class C
{
public const int MAX_SIZE = 10;
void M()
{
int i = 10;
switch (i)
{
case $$ when";
await VerifyItemExistsAsync(markup, "MAX_SIZE");
}
[WorkItem(542429, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542429")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task ConstantsInSwitchGotoCase()
......
......@@ -1802,7 +1802,7 @@ public static bool IsConstantExpressionContext(this SyntaxTree syntaxTree, int p
// case |
if (token.IsKind(SyntaxKind.CaseKeyword) &&
token.Parent.IsKind(SyntaxKind.CaseSwitchLabel))
token.Parent.IsKind(SyntaxKind.CaseSwitchLabel, SyntaxKind.CasePatternSwitchLabel))
{
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册