Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
750d4e94
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
750d4e94
编写于
4月 21, 2020
作者:
A
Allison Chou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code review feedback + additional tests
上级
2fd1b357
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
155 addition
and
9 deletion
+155
-9
src/EditorFeatures/CSharpTest2/Recommendations/AndKeywordRecommenderTests.cs
...CSharpTest2/Recommendations/AndKeywordRecommenderTests.cs
+64
-0
src/EditorFeatures/CSharpTest2/Recommendations/NotKeywordRecommenderTests.cs
...CSharpTest2/Recommendations/NotKeywordRecommenderTests.cs
+19
-1
src/EditorFeatures/CSharpTest2/Recommendations/OrKeywordRecommenderTests.cs
.../CSharpTest2/Recommendations/OrKeywordRecommenderTests.cs
+64
-0
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
...ce/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+8
-8
未找到文件。
src/EditorFeatures/CSharpTest2/Recommendations/AndKeywordRecommenderTests.cs
浏览文件 @
750d4e94
...
...
@@ -42,6 +42,56 @@ public async Task TestAfterRelationalOperator()
@"if (e is >= 0 $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterGenericType
()
{
await
VerifyKeywordAsync
(
@"class C<T>
{
void M()
{
var e = new object();
if (e is T $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterArrayType
()
{
await
VerifyKeywordAsync
(
@"class C
{
void M()
{
var e = new object();
if (e is int[] $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterListType
()
{
await
VerifyKeywordAsync
(
@"using System.Collections.Generic;
class C
{
void M()
{
var e = new object();
if (e is List<int> $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterListType_FullyQualified
()
{
await
VerifyKeywordAsync
(
@"class C
{
void M()
{
var e = new object();
if (e is System.Collections.Generic.List<int> $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInsideSubpattern
()
{
...
...
@@ -384,6 +434,13 @@ public async Task TestMissingAfterNotKeyword()
@"if (e is not $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterVarKeyword
()
{
await
VerifyAbsenceAsync
(
AddInsideMethod
(
InitializeObjectE
+
@"if (e is var $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterAndKeyword
()
{
...
...
@@ -405,6 +462,13 @@ public async Task TestMissingAfterOpenParen()
@"if (e is ($$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterOpenBracket
()
{
await
VerifyAbsenceAsync
(
AddInsideMethod
(
InitializeObjectE
+
@"if (e is { $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAtBeginningOfSwitchExpression
()
{
...
...
src/EditorFeatures/CSharpTest2/Recommendations/NotKeywordRecommenderTests.cs
浏览文件 @
750d4e94
...
...
@@ -79,7 +79,7 @@ public async Task TestInMiddleofCompletePattern()
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInMiddle
o
fCompleteQualifiedPattern
()
public
async
Task
TestInMiddle
O
fCompleteQualifiedPattern
()
{
await
VerifyKeywordAsync
(
@"namespace N
...
...
@@ -96,6 +96,24 @@ void M()
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInMiddleOfCompleteQualifiedPattern_List
()
{
await
VerifyKeywordAsync
(
@"namespace N
{
class C
{
const int P = 1;
void M()
{
if (e is $$ System.Collections.Generic.List<int> or 2) { }
}
}
}"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInMiddleofCompletePattern_MultipleParens
()
{
...
...
src/EditorFeatures/CSharpTest2/Recommendations/OrKeywordRecommenderTests.cs
浏览文件 @
750d4e94
...
...
@@ -42,6 +42,56 @@ public async Task TestAfterRelationalOperator()
@"if (e is >= 0 $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterGenericType
()
{
await
VerifyKeywordAsync
(
@"class C<T>
{
void M()
{
var e = new object();
if (e is T $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterArrayType
()
{
await
VerifyKeywordAsync
(
@"class C
{
void M()
{
var e = new object();
if (e is int[] $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterListType
()
{
await
VerifyKeywordAsync
(
@"using System.Collections.Generic;
class C
{
void M()
{
var e = new object();
if (e is List<int> $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestAfterListType_FullyQualified
()
{
await
VerifyKeywordAsync
(
@"class C
{
void M()
{
var e = new object();
if (e is System.Collections.Generic.List<int> $$"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestInsideSubpattern
()
{
...
...
@@ -384,6 +434,13 @@ public async Task TestMissingAfterNotKeyword()
@"if (e is not $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterVarKeyword
()
{
await
VerifyAbsenceAsync
(
AddInsideMethod
(
InitializeObjectE
+
@"if (e is var $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterAndKeyword
()
{
...
...
@@ -405,6 +462,13 @@ public async Task TestMissingAfterOpenParen()
@"if (e is ($$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAfterOpenBracket
()
{
await
VerifyAbsenceAsync
(
AddInsideMethod
(
InitializeObjectE
+
@"if (e is { $$"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
KeywordRecommending
)]
public
async
Task
TestMissingAtBeginningOfSwitchExpression
()
{
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
750d4e94
...
...
@@ -1259,15 +1259,15 @@ public static bool IsAtStartOfPattern(this SyntaxTree syntaxTree, SyntaxToken le
if
(
leftToken
.
IsKind
(
SyntaxKind
.
OpenParenToken
))
{
if
(
leftToken
.
Parent
.
IsKind
(
SyntaxKind
.
ParenthesizedExpression
))
if
(
leftToken
.
Parent
.
IsKind
(
SyntaxKind
.
ParenthesizedExpression
,
out
ParenthesizedExpressionSyntax
parenthesizedExpression
))
{
// If we're dealing with an expression surrounded by one or more sets of open parentheses, we need to
// walk up the parens in order to see if we're actually at the start of a valid pattern or not.
var
tokenPrecedingParenthesizedExpression
=
leftToken
.
Parent
.
GetFirstToken
().
GetPreviousToken
();
return
IsAtStartOfPattern
(
syntaxTree
,
tokenPrecedingParenthesizedExpression
,
tokenPrecedingParenthesizedExpression
.
Span
.
End
+
1
);
return
IsAtStartOfPattern
(
syntaxTree
,
parenthesizedExpression
.
GetFirstToken
().
GetPreviousToken
(),
parenthesizedExpression
.
SpanStart
);
}
#if !CODE_STYLE
// e is ((($$ 1 or 2)))
if
(
leftToken
.
Parent
.
IsKind
(
SyntaxKind
.
ParenthesizedPattern
))
{
return
true
;
...
...
@@ -1367,14 +1367,14 @@ public static bool IsAtEndOfPattern(this SyntaxTree syntaxTree, SyntaxToken left
// If typeSyntax is part of a qualified name, we want to get the fully-qualified name so that we can
// later accurately perform the check comparing the right side of the BinaryExpressionSyntax to
// the typeSyntax.
while
(
typeSyntax
.
Parent
is
QualifiedNameSyntax
qualifiedNam
eSyntax
)
while
(
typeSyntax
.
Parent
is
TypeSyntax
parentTyp
eSyntax
)
{
typeSyntax
=
qualifiedNam
eSyntax
;
typeSyntax
=
parentTyp
eSyntax
;
}
var
binaryExpressionSyntax
=
typeSyntax
.
GetAncestor
<
BinaryExpressionSyntax
>();
if
(
binaryExpressionSyntax
!=
null
&&
binaryExpressionSyntax
.
OperatorToken
.
IsKind
(
SyntaxKind
.
IsKeyword
)
&&
binaryExpressionSyntax
.
Right
==
typeSyntax
)
if
(
typeSyntax
.
Parent
is
BinaryExpressionSyntax
binaryExpressionSyntax
&&
binaryExpressionSyntax
.
OperatorToken
.
IsKind
(
SyntaxKind
.
IsKeyword
)
&&
binaryExpressionSyntax
.
Right
==
typeSyntax
&&
!
typeSyntax
.
IsVar
)
{
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录