提交 5602a0a7 编写于 作者: N Neal Gafter 提交者: GitHub

Enable finding the breakpoint location for a pattern switch case (#14426)

Fixes #12378
上级 317c810b
......@@ -3984,6 +3984,149 @@ public void OnSetter()
@"class C
{
public int Id { get { return 42; } set { [|}|] $$}
}");
}
[Fact]
public void WhenClause_1()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
$$ case string s [|when b|]:
break;
}
}
}");
}
[Fact]
public void WhenClause_2()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
case string s [|whe$$n b|]:
break;
}
}
}");
}
[Fact]
public void WhenClause_3()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
case string s [|when b|]:$$
break;
}
}
}");
}
[Fact]
public void PatternSwitchCase_1()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
$$ case string s:
default:
[|break;|]
}
}
}");
}
[Fact]
public void PatternSwitchCase_2()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
$$case string s:
default:
[|break;|]
}
}
}");
}
[Fact]
public void PatternSwitchCase_3()
{
TestSpan(
@"class C
{
string s;
bool b;
void Foo()
{
switch (s)
{
case string s:$$
default:
[|break;|]
}
}
}");
}
[Fact]
public void DeconstructionDeclarationStatement_1()
{
TestSpan(
@"class C
{
void Foo()
{
$$ [|var (x, y) = (1, 2);|]
}
}");
}
[Fact]
public void DeconstructionDeclarationStatement_2()
{
TestSpan(
@"class C
{
void Foo()
{
[|var (x, y) = $$(1, 2);|]
}
}");
}
}
......
......@@ -193,6 +193,15 @@ private static int GetEndPosition(SyntaxNodeOrToken nodeOrToken)
case SyntaxKind.DefaultSwitchLabel:
return TryCreateSpanForSwitchLabel((SwitchLabelSyntax)node, position);
case SyntaxKind.CasePatternSwitchLabel:
var caseClause = (CasePatternSwitchLabelSyntax)node;
return caseClause.WhenClause == null
? TryCreateSpanForSwitchLabel((SwitchLabelSyntax)node, position)
: CreateSpan(caseClause.WhenClause);
case SyntaxKind.WhenClause:
return CreateSpan(node);
case SyntaxKind.GetAccessorDeclaration:
case SyntaxKind.SetAccessorDeclaration:
var body = ((AccessorDeclarationSyntax)node).Body;
......@@ -535,6 +544,7 @@ private static TextSpan CreateSpanForBlock(BlockSyntax block, int position)
case SyntaxKind.ThrowStatement:
case SyntaxKind.ExpressionStatement:
case SyntaxKind.EmptyStatement:
case SyntaxKind.DeconstructionDeclarationStatement:
default:
// Fallback case. If it was none of the above types of statements, then we make a span
// over the entire statement. Note: this is not a very desirable thing to do (as
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册