提交 3a8b4556 编写于 作者: D dustincampbell

[de minimis] IDE support for C# exception filters

* Add 'when' keyword recommender to the completion list
* Ensure that the completion appears inside exception filters.
* Add 'when' keyword span to keyword highlighting for try..catch statements.
* Ensure that parenthesis simplication works catch filter expressions
* Add tests for 'when' classification (it already was classified correctly) (changeset 1387214)
上级 806b177f
......@@ -2069,7 +2069,14 @@ public static bool IsLabelContext(this SyntaxTree syntaxTree, int position, Canc
return true;
}
// (SometType) |
// when ( |
if (token.CSharpKind() == SyntaxKind.OpenParenToken &&
token.GetPreviousToken(includeSkipped: true).CSharpKind() == SyntaxKind.WhenKeyword)
{
return true;
}
// (SomeType) |
if (token.IsAfterPossibleCast())
{
return true;
......
......@@ -33,6 +33,7 @@ public static bool CanRemoveParentheses(this ParenthesizedExpressionSyntax node)
// foreach (var y in (x)) -> foreach (var y in x)
// lock ((x)) -> lock (x)
// using ((x)) -> using (x)
// catch when ((x)) -> catch when (x)
if ((node.IsParentKind(SyntaxKind.EqualsValueClause) && ((EqualsValueClauseSyntax)node.Parent).Value == node) ||
(node.IsParentKind(SyntaxKind.IfStatement) && ((IfStatementSyntax)node.Parent).Condition == node) ||
(node.IsParentKind(SyntaxKind.ReturnStatement) && ((ReturnStatementSyntax)node.Parent).Expression == node) ||
......@@ -44,7 +45,8 @@ public static bool CanRemoveParentheses(this ParenthesizedExpressionSyntax node)
(node.IsParentKind(SyntaxKind.ForStatement) && ((ForStatementSyntax)node.Parent).Condition == node) ||
(node.IsParentKind(SyntaxKind.ForEachStatement) && ((ForEachStatementSyntax)node.Parent).Expression == node) ||
(node.IsParentKind(SyntaxKind.LockStatement) && ((LockStatementSyntax)node.Parent).Expression == node) ||
(node.IsParentKind(SyntaxKind.UsingStatement) && ((UsingStatementSyntax)node.Parent).Expression == node))
(node.IsParentKind(SyntaxKind.UsingStatement) && ((UsingStatementSyntax)node.Parent).Expression == node) ||
(node.IsParentKind(SyntaxKind.CatchFilterClause) && ((CatchFilterClauseSyntax)node.Parent).FilterExpression == node))
{
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册