Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1e1a7d25
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,发现更多精彩内容 >>
提交
1e1a7d25
编写于
1月 05, 2017
作者:
R
Ravi Chande
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include the non-special type names for special types in cref completion
上级
c337a61f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
3 deletion
+60
-3
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/CrefCompletionProviderTests.cs
...letion/CompletionProviders/CrefCompletionProviderTests.cs
+17
-0
src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs
.../Completion/CompletionProviders/CrefCompletionProvider.cs
+43
-3
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/CrefCompletionProviderTests.cs
浏览文件 @
1e1a7d25
...
@@ -443,5 +443,22 @@ class C
...
@@ -443,5 +443,22 @@ class C
Assert
.
True
(
called
);
Assert
.
True
(
called
);
}
}
}
}
[
WorkItem
(
16060
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/16060"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
SpecialTypeNames
()
{
var
text
=
@"
using System;
/// <see cref=""$$""/>
class C
{
public void foo(int x) { }
}
"
;
await
VerifyItemExistsAsync
(
text
,
"uint"
);
await
VerifyItemExistsAsync
(
text
,
"UInt32"
);
}
}
}
}
}
\ No newline at end of file
src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs
浏览文件 @
1e1a7d25
...
@@ -42,6 +42,16 @@ internal sealed class CrefCompletionProvider : AbstractCrefCompletionProvider
...
@@ -42,6 +42,16 @@ internal sealed class CrefCompletionProvider : AbstractCrefCompletionProvider
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
|
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
|
SymbolDisplayMiscellaneousOptions
.
UseSpecialTypes
);
SymbolDisplayMiscellaneousOptions
.
UseSpecialTypes
);
public
static
readonly
SymbolDisplayFormat
SpecialTypeCrefFormat
=
new
SymbolDisplayFormat
(
globalNamespaceStyle
:
SymbolDisplayGlobalNamespaceStyle
.
Omitted
,
typeQualificationStyle
:
SymbolDisplayTypeQualificationStyle
.
NameOnly
,
propertyStyle
:
SymbolDisplayPropertyStyle
.
NameOnly
,
genericsOptions
:
SymbolDisplayGenericsOptions
.
IncludeTypeParameters
,
parameterOptions
:
SymbolDisplayParameterOptions
.
None
,
miscellaneousOptions
:
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
);
private
readonly
Action
<
SyntaxNode
>
_testSpeculativeNodeCallbackOpt
;
private
readonly
Action
<
SyntaxNode
>
_testSpeculativeNodeCallbackOpt
;
public
CrefCompletionProvider
(
Action
<
SyntaxNode
>
testSpeculativeNodeCallbackOpt
=
null
)
public
CrefCompletionProvider
(
Action
<
SyntaxNode
>
testSpeculativeNodeCallbackOpt
=
null
)
...
@@ -251,8 +261,11 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -251,8 +261,11 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
{
{
foreach
(
var
symbol
in
symbols
)
foreach
(
var
symbol
in
symbols
)
{
{
builder
.
Clear
();
yield
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
yield
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
if
(
TryCreateSpecialTypeItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
out
var
item
))
{
yield
return
item
;
}
}
}
}
}
finally
finally
...
@@ -261,20 +274,42 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -261,20 +274,42 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
}
}
}
private
bool
TryCreateSpecialTypeItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
,
out
CompletionItem
item
)
{
var
typeSymbol
=
symbol
as
ITypeSymbol
;
if
(
typeSymbol
.
IsSpecialType
())
{
item
=
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
SpecialTypeCrefFormat
);
return
true
;
}
item
=
null
;
return
false
;
}
private
CompletionItem
CreateItem
(
private
CompletionItem
CreateItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
)
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
)
{
{
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormat
);
}
private
CompletionItem
CreateItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
,
SymbolDisplayFormat
unqualifiedCrefFormat
)
{
builder
.
Clear
();
if
(
symbol
is
INamespaceOrTypeSymbol
&&
token
.
IsKind
(
SyntaxKind
.
DotToken
))
if
(
symbol
is
INamespaceOrTypeSymbol
&&
token
.
IsKind
(
SyntaxKind
.
DotToken
))
{
{
// Handle qualified namespace and type names.
// Handle qualified namespace and type names.
builder
.
Append
(
symbol
.
ToDisplayString
(
QualifiedCrefFormat
));
builder
.
Append
(
symbol
.
ToDisplayString
(
QualifiedCrefFormat
));
}
}
else
else
{
{
// Handle unqualified namespace and type names, or member names.
// Handle unqualified namespace and type names, or member names.
builder
.
Append
(
symbol
.
ToMinimalDisplayString
(
semanticModel
,
token
.
SpanStart
,
CrefFormat
));
builder
.
Append
(
symbol
.
ToMinimalDisplayString
(
semanticModel
,
token
.
SpanStart
,
unqualified
CrefFormat
));
var
parameters
=
symbol
.
GetParameters
();
var
parameters
=
symbol
.
GetParameters
();
if
(!
parameters
.
IsDefaultOrEmpty
)
if
(!
parameters
.
IsDefaultOrEmpty
)
...
@@ -308,6 +343,11 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -308,6 +343,11 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
}
}
}
return
CreateItemFromBuilder
(
symbol
,
position
,
builder
,
options
);
}
private
CompletionItem
CreateItemFromBuilder
(
ISymbol
symbol
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
)
{
var
symbolText
=
builder
.
ToString
();
var
symbolText
=
builder
.
ToString
();
var
insertionText
=
builder
var
insertionText
=
builder
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录