Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0152e511
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,发现更多精彩内容 >>
提交
0152e511
编写于
3月 17, 2017
作者:
R
Ravi Chande
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests
上级
4fc778fc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
42 deletion
+49
-42
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs
...letionProviders/DeclarationNameCompletionProviderTests.cs
+22
-20
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests_NameDeclarationInfoTests.cs
...onNameCompletionProviderTests_NameDeclarationInfoTests.cs
+12
-12
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
...ders/DeclarationNameCompletionProvider.DeclarationInfo.cs
+3
-3
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.cs
.../CompletionProviders/DeclarationNameCompletionProvider.cs
+12
-7
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs
浏览文件 @
0152e511
...
...
@@ -31,20 +31,21 @@ internal override CompletionProvider CreateCompletionProvider()
public
async
void
NameWithOnlyType1
()
{
var
markup
=
@"
public class
C
public class
MyClass
{
C
$$
MyClass
$$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"
C"
,
glyph
:
(
int
)
Glyph
.
Property
Public
);
await
VerifyItemExistsAsync
(
markup
,
"
c
"
,
glyph
:
(
int
)
Glyph
.
FieldPublic
);
await
VerifyItemExistsAsync
(
markup
,
"Get
C
"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
);
await
VerifyItemExistsAsync
(
markup
,
"
MyClass"
,
glyph
:
(
int
)
Glyph
.
Method
Public
);
await
VerifyItemExistsAsync
(
markup
,
"
myClass
"
,
glyph
:
(
int
)
Glyph
.
FieldPublic
);
await
VerifyItemExistsAsync
(
markup
,
"Get
MyClass
"
,
glyph
:
(
int
)
Glyph
.
MethodPublic
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
void
AsyncTaskOfT
()
{
var
markup
=
@"
using System.Threading.Tasks;
public class C
{
async Task<C> $$
...
...
@@ -53,7 +54,7 @@ public class C
await
VerifyItemExistsAsync
(
markup
,
"GetCAsync"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
[
Fact
(
Skip
=
"not yet implemented"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
void
NonAsyncTaskOfT
()
{
var
markup
=
@"
...
...
@@ -104,7 +105,7 @@ public class C
I $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"I"
);
await
VerifyItemExistsAsync
(
markup
,
"
Get
I"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
...
...
@@ -117,7 +118,7 @@ public class C
II $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"I"
);
await
VerifyItemExistsAsync
(
markup
,
"
Get
I"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
...
...
@@ -137,21 +138,21 @@ public class C
public
async
void
WordBreaking5
()
{
var
markup
=
@"
class
A
WonderfullyLongClassName {}
class
Some
WonderfullyLongClassName {}
public class C
{
A
WonderfullyLongClassName $$
Some
WonderfullyLongClassName $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"
A
"
);
await
VerifyItemExistsAsync
(
markup
,
"
A
Wonderfully"
);
await
VerifyItemExistsAsync
(
markup
,
"
A
WonderfullyLong"
);
await
VerifyItemExistsAsync
(
markup
,
"
A
WonderfullyLongClass"
);
await
VerifyItemExistsAsync
(
markup
,
"
Some
"
);
await
VerifyItemExistsAsync
(
markup
,
"
Some
Wonderfully"
);
await
VerifyItemExistsAsync
(
markup
,
"
Some
WonderfullyLong"
);
await
VerifyItemExistsAsync
(
markup
,
"
Some
WonderfullyLongClass"
);
await
VerifyItemExistsAsync
(
markup
,
"Name"
);
await
VerifyItemExistsAsync
(
markup
,
"ClassName"
);
await
VerifyItemExistsAsync
(
markup
,
"LongClassName"
);
await
VerifyItemExistsAsync
(
markup
,
"WonderfullyLongClassName"
);
await
VerifyItemExistsAsync
(
markup
,
"
A
WonderfullyLongClassName"
);
await
VerifyItemExistsAsync
(
markup
,
"
Some
WonderfullyLongClassName"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
...
...
@@ -371,7 +372,8 @@ public class C
C $$
}
"
;
await
VerifyNoItemsExistAsync
(
markup
);
await
VerifyItemIsAbsentAsync
(
markup
,
"C"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"c"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
...
...
@@ -379,12 +381,12 @@ public async void ArrayElementTypeSuggested()
{
var
markup
=
@"
using System.Threading;
public class
C
public class
MyClass
{
C
[] $$
MyClass
[] $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"
C
"
);
await
VerifyItemExistsAsync
(
markup
,
"
MyClass
"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"Array"
);
}
...
...
@@ -421,7 +423,7 @@ public class C
System.Collections.Generic.IEnumerable<C> $$
}
"
;
await
VerifyItemExistsAsync
(
markup
,
"C"
);
await
VerifyItemExistsAsync
(
markup
,
"
Get
C"
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
...
...
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests_NameDeclarationInfoTests.cs
浏览文件 @
0152e511
...
...
@@ -30,7 +30,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Field
,
SymbolKind
.
Method
,
SymbolKind
.
Property
);
await
VerifyNoModifiers
(
markup
);
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -45,7 +45,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Field
,
SymbolKind
.
Method
,
SymbolKind
.
Property
);
await
VerifyNoModifiers
(
markup
);
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
Public
);
}
...
...
@@ -60,7 +60,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Method
,
SymbolKind
.
Property
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
(
isVirtual
:
true
));
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
Public
);
}
...
...
@@ -75,7 +75,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Field
,
SymbolKind
.
Method
,
SymbolKind
.
Property
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
(
isStatic
:
true
));
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
Private
);
}
...
...
@@ -90,7 +90,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Field
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
(
isConst
:
true
));
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
Private
);
}
...
...
@@ -108,7 +108,7 @@ void foo()
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Local
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
());
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -126,7 +126,7 @@ void foo()
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Local
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
());
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -144,7 +144,7 @@ void foo()
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Local
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
(
isReadOnly
:
true
));
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -162,7 +162,7 @@ void foo()
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Local
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
(
isReadOnly
:
true
));
await
VerifyTypeName
(
markup
,
"
global::System.Int32
"
);
await
VerifyTypeName
(
markup
,
"
int
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -210,7 +210,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Parameter
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
());
await
VerifyTypeName
(
markup
,
"
global::System.S
tring"
);
await
VerifyTypeName
(
markup
,
"
s
tring"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -226,7 +226,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Parameter
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
());
await
VerifyTypeName
(
markup
,
"
global::System.S
tring"
);
await
VerifyTypeName
(
markup
,
"
s
tring"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
@@ -243,7 +243,7 @@ class C
"
;
await
VerifySymbolKinds
(
markup
,
SymbolKind
.
Parameter
);
await
VerifyModifiers
(
markup
,
new
DeclarationModifiers
());
await
VerifyTypeName
(
markup
,
"global::System.Collections.Generic.List"
);
await
VerifyTypeName
(
markup
,
"global::System.Collections.Generic.List
<string>
"
);
await
VerifyAccessibility
(
markup
,
Accessibility
.
NotApplicable
);
}
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
浏览文件 @
0152e511
...
...
@@ -107,7 +107,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfo(Document docu
Func
<
DeclarationModifiers
,
ImmutableArray
<
SymbolKind
>>
possibleDeclarationComputer
,
CancellationToken
cancellationToken
)
where
TSyntaxNode
:
SyntaxNode
{
if
(!
Is
ValidToken
(
t
oken
))
if
(!
Is
PossibleTypeToken
(
token
)
&&
!
token
.
IsKind
(
SyntaxKind
.
CommaT
oken
))
{
return
default
(
NameDeclarationInfo
);
}
...
...
@@ -151,7 +151,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfo(Document docu
Func
<
DeclarationModifiers
,
ImmutableArray
<
SymbolKind
>>
possibleDeclarationComputer
,
CancellationToken
cancellationToken
)
where
TSyntaxNode
:
SyntaxNode
{
if
(!
Is
Valid
Token
(
token
))
if
(!
Is
PossibleType
Token
(
token
))
{
return
default
(
NameDeclarationInfo
);
}
...
...
@@ -245,7 +245,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfo(Document docu
return
result
.
Type
!=
null
;
}
private
static
bool
Is
Valid
Token
(
SyntaxToken
token
)
=>
private
static
bool
Is
PossibleType
Token
(
SyntaxToken
token
)
=>
token
.
IsKind
(
SyntaxKind
.
IdentifierToken
,
SyntaxKind
.
GreaterThanToken
,
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.cs
浏览文件 @
0152e511
...
...
@@ -68,7 +68,12 @@ private bool IsValidType(ITypeSymbol type)
return
false
;
}
return
type
.
SpecialType
!=
SpecialType
.
System_Void
;
if
(
type
.
SpecialType
==
SpecialType
.
System_Void
)
{
return
false
;
}
return
!
type
.
IsSpecialType
();
}
private
Glyph
GetGlyph
(
SymbolKind
kind
,
Accessibility
declaredAccessibility
)
...
...
@@ -140,7 +145,7 @@ private ITypeSymbol UnwrapType(ITypeSymbol type, Compilation compilation)
var
taskOfTType
=
compilation
.
GetTypeByMetadataName
(
"System.Threading.Tasks.Task`1"
);
var
valueTaskType
=
compilation
.
GetTypeByMetadataName
(
"System.Threading.Tasks.ValueTask`1"
);
if
(
originalDefinition
==
taskOfTType
||
originalDefinition
==
valueTaskType
)
||
originalDefinition
==
valueTaskType
)
{
return
UnwrapType
(
namedType
.
TypeArguments
[
0
],
compilation
);
}
...
...
@@ -149,10 +154,10 @@ private ITypeSymbol UnwrapType(ITypeSymbol type, Compilation compilation)
return
type
;
}
private
async
Task
<
IEnumerable
<(
string
,
SymbolKind
)>>
GetRecommendedNamesAsync
(
IEnumerable
<
IEnumerable
<
string
>>
baseNames
,
NameDeclarationInfo
declarationInfo
,
CSharpSyntaxContext
context
,
private
async
Task
<
IEnumerable
<(
string
,
SymbolKind
)>>
GetRecommendedNamesAsync
(
IEnumerable
<
IEnumerable
<
string
>>
baseNames
,
NameDeclarationInfo
declarationInfo
,
CSharpSyntaxContext
context
,
Document
document
,
CancellationToken
cancellationToken
)
{
...
...
@@ -171,7 +176,7 @@ private ITypeSymbol UnwrapType(ITypeSymbol type, Compilation compilation)
foreach
(
var
baseName
in
baseNames
)
{
var
name
=
rule
.
NamingStyle
.
CreateName
(
baseName
);
if
(!
result
.
ContainsKey
(
name
))
// Don't add multiple items for the same name
if
(
name
.
Length
>
1
&&
!
result
.
ContainsKey
(
name
))
// Don't add multiple items for the same name
{
result
.
Add
(
name
,
symbolKind
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录