Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
849e4310
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,发现更多精彩内容 >>
提交
849e4310
编写于
3月 26, 2019
作者:
D
David Poeschl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Targeted Completion Prototype
上级
3b71c1c0
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
151 addition
and
11 deletion
+151
-11
src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs
src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs
+3
-0
src/Features/Core/Portable/Common/Glyph.cs
src/Features/Core/Portable/Common/Glyph.cs
+2
-1
src/Features/Core/Portable/Common/GlyphExtensions.cs
src/Features/Core/Portable/Common/GlyphExtensions.cs
+3
-0
src/Features/Core/Portable/Completion/CompletionItemFilter.cs
...Features/Core/Portable/Completion/CompletionItemFilter.cs
+4
-1
src/Features/Core/Portable/Completion/Providers/AbstractSymbolCompletionProvider.cs
.../Completion/Providers/AbstractSymbolCompletionProvider.cs
+60
-9
src/Features/Core/Portable/FeaturesResources.Designer.cs
src/Features/Core/Portable/FeaturesResources.Designer.cs
+9
-0
src/Features/Core/Portable/FeaturesResources.resx
src/Features/Core/Portable/FeaturesResources.resx
+3
-0
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
+5
-0
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
+5
-0
src/Workspaces/Core/Portable/Tags/WellKnownTags.cs
src/Workspaces/Core/Portable/Tags/WellKnownTags.cs
+2
-0
未找到文件。
src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs
浏览文件 @
849e4310
...
...
@@ -207,6 +207,9 @@ public static ImageId GetImageId(this Glyph glyph)
case
Glyph
.
NuGet
:
return
new
ImageId
(
ImageCatalogGuid
,
KnownImageIds
.
NuGet
);
case
Glyph
.
MatchingType
:
return
new
ImageId
(
ImageCatalogGuid
,
KnownImageIds
.
Sync
);
default
:
throw
new
ArgumentException
(
nameof
(
glyph
));
}
...
...
src/Features/Core/Portable/Common/Glyph.cs
浏览文件 @
849e4310
...
...
@@ -109,6 +109,7 @@ internal enum Glyph
CompletionWarning
,
AddReference
,
NuGet
NuGet
,
MatchingType
}
}
src/Features/Core/Portable/Common/GlyphExtensions.cs
浏览文件 @
849e4310
...
...
@@ -174,6 +174,9 @@ private static Glyph GetGlyph(string tag, ImmutableArray<string> allTags)
return
Glyph
.
InterfacePublic
;
}
case
WellKnownTags
.
MatchingType
:
return
Glyph
.
MatchingType
;
case
WellKnownTags
.
Intrinsic
:
return
Glyph
.
Intrinsic
;
...
...
src/Features/Core/Portable/Completion/CompletionItemFilter.cs
浏览文件 @
849e4310
...
...
@@ -78,6 +78,7 @@ public bool Matches(CompletionItem item)
public
static
readonly
CompletionItemFilter
LocalAndParameterFilter
=
new
CompletionItemFilter
(
FeaturesResources
.
Locals_and_parameters
,
ImmutableArray
.
Create
(
WellKnownTags
.
Local
,
WellKnownTags
.
Parameter
),
'l'
);
public
static
readonly
CompletionItemFilter
KeywordFilter
=
new
CompletionItemFilter
(
FeaturesResources
.
Keywords
,
ImmutableArray
.
Create
(
WellKnownTags
.
Keyword
),
'k'
);
public
static
readonly
CompletionItemFilter
SnippetFilter
=
new
CompletionItemFilter
(
FeaturesResources
.
Snippets
,
ImmutableArray
.
Create
(
WellKnownTags
.
Snippet
),
't'
);
public
static
readonly
CompletionItemFilter
MatchingTypeFilter
=
new
CompletionItemFilter
(
FeaturesResources
.
Matching_type
,
ImmutableArray
.
Create
(
WellKnownTags
.
MatchingType
),
'j'
);
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
NamespaceFilters
=
ImmutableArray
.
Create
(
NamespaceFilter
);
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
ClassFilters
=
ImmutableArray
.
Create
(
ClassFilter
);
...
...
@@ -95,6 +96,7 @@ public bool Matches(CompletionItem item)
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
LocalAndParameterFilters
=
ImmutableArray
.
Create
(
LocalAndParameterFilter
);
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
KeywordFilters
=
ImmutableArray
.
Create
(
KeywordFilter
);
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
SnippetFilters
=
ImmutableArray
.
Create
(
SnippetFilter
);
public
static
readonly
ImmutableArray
<
CompletionItemFilter
>
MatchingTypeFilters
=
ImmutableArray
.
Create
(
MatchingTypeFilter
);
public
static
ImmutableArray
<
CompletionItemFilter
>
AllFilters
{
get
;
}
=
ImmutableArray
.
Create
(
...
...
@@ -113,6 +115,7 @@ public bool Matches(CompletionItem item)
DelegateFilter
,
NamespaceFilter
,
KeywordFilter
,
SnippetFilter
);
SnippetFilter
,
MatchingTypeFilter
);
}
}
src/Features/Core/Portable/Completion/Providers/AbstractSymbolCompletionProvider.cs
浏览文件 @
849e4310
...
...
@@ -46,18 +46,65 @@ protected virtual CompletionItemRules GetCompletionItemRules(IReadOnlyList<ISymb
private
ImmutableArray
<
CompletionItem
>
CreateItems
(
ImmutableArray
<
ISymbol
>
symbols
,
SyntaxContext
context
,
bool
preselect
)
bool
preselect
,
ImmutableArray
<
ITypeSymbol
>
inferredTypes
=
default
)
{
var
tree
=
context
.
SyntaxTree
;
var
symbolGroups
=
from
symbol
in
symbols
let
texts
=
GetDisplayAndSuffixAndInsertionText
(
symbol
,
context
)
group
symbol
by
texts
into
g
select
g
;
var
q
=
from
symbol
in
symbols
let
texts
=
GetDisplayAndSuffixAndInsertionText
(
symbol
,
context
)
group
symbol
by
texts
into
g
select
this
.
CreateItem
(
g
.
Key
.
displayText
,
g
.
Key
.
suffix
,
g
.
Key
.
insertionText
,
g
.
ToList
(),
context
,
var
itemListBuilder
=
ImmutableArray
.
CreateBuilder
<
CompletionItem
>();
foreach
(
var
symbolGroup
in
symbolGroups
)
{
var
item
=
this
.
CreateItem
(
symbolGroup
.
Key
.
displayText
,
symbolGroup
.
Key
.
suffix
,
symbolGroup
.
Key
.
insertionText
,
symbolGroup
.
ToList
(),
context
,
invalidProjectMap
:
null
,
totalProjects
:
null
,
preselect
:
preselect
);
return
q
.
ToImmutableArray
();
if
(
symbolGroup
.
Any
(
s
=>
ShouldIncludeInTargetTypedCompletionList
(
s
,
inferredTypes
,
context
.
SemanticModel
,
context
.
Position
)))
{
item
=
item
.
AddTag
(
"MatchingType"
);
}
itemListBuilder
.
Add
(
item
);
}
return
itemListBuilder
.
ToImmutable
();
}
private
bool
ShouldIncludeInTargetTypedCompletionList
(
ISymbol
symbol
,
ImmutableArray
<
ITypeSymbol
>
inferredTypes
,
SemanticModel
semanticModel
,
int
position
)
{
// When searching for identifiers of type C, exclude the symbol for the `C` type itself.
if
(
symbol
.
Kind
==
SymbolKind
.
NamedType
)
{
return
false
;
}
// Avoid offering object.ToString() when a string is expected, for example.
if
(
symbol
.
ContainingType
?.
SpecialType
==
SpecialType
.
System_Object
)
{
return
false
;
}
// Don't offer locals on the right-hand-side of their declaration: `int x = x`
if
(
symbol
.
Kind
==
SymbolKind
.
Local
)
{
var
local
=
(
ILocalSymbol
)
symbol
;
var
declarationSyntax
=
symbol
.
DeclaringSyntaxReferences
.
Select
(
r
=>
r
.
GetSyntax
()).
SingleOrDefault
();
if
(
declarationSyntax
!=
null
&&
position
<
declarationSyntax
.
FullSpan
.
End
)
{
return
false
;
}
}
var
type
=
symbol
.
GetMemberType
()
??
symbol
.
GetSymbolType
();
if
(
type
==
null
)
{
return
false
;
}
return
inferredTypes
.
Any
(
inferredType
=>
semanticModel
.
Compilation
.
ClassifyCommonConversion
(
type
,
inferredType
).
IsImplicit
);
}
/// <summary>
...
...
@@ -203,7 +250,11 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
if
(
relatedDocumentIds
.
IsEmpty
)
{
var
itemsForCurrentDocument
=
await
GetSymbolsWorker
(
position
,
preselect
,
context
,
options
,
cancellationToken
).
ConfigureAwait
(
false
);
return
CreateItems
(
itemsForCurrentDocument
,
context
,
preselect
);
var
inferenceService
=
document
.
GetLanguageService
<
ITypeInferenceService
>();
var
inferredTypes
=
inferenceService
.
InferTypes
(
context
.
SemanticModel
,
position
,
cancellationToken
);
return
CreateItems
(
itemsForCurrentDocument
,
context
,
preselect
,
inferredTypes
);
}
var
contextAndSymbolLists
=
await
GetPerContextSymbols
(
document
,
position
,
options
,
new
[]
{
document
.
Id
}.
Concat
(
relatedDocumentIds
),
preselect
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
src/Features/Core/Portable/FeaturesResources.Designer.cs
浏览文件 @
849e4310
...
...
@@ -2304,6 +2304,15 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Matching type.
/// </summary>
internal
static
string
Matching_type
{
get
{
return
ResourceManager
.
GetString
(
"Matching_type"
,
resourceCulture
);
}
}
/// <summary>
/// Looks up a localized string similar to Member name can be simplified.
/// </summary>
...
...
src/Features/Core/Portable/FeaturesResources.resx
浏览文件 @
849e4310
...
...
@@ -1614,4 +1614,7 @@ This version used in: {2}</value>
<data
name=
"Add_parameter_to_constructor"
xml:space=
"preserve"
>
<value>
Add parameter to constructor
</value>
</data>
<data
name=
"Matching_type"
xml:space=
"preserve"
>
<value>
Matching type
</value>
</data>
</root>
\ No newline at end of file
src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.de.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.es.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.it.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf
浏览文件 @
849e4310
...
...
@@ -192,6 +192,11 @@
<target
state=
"new"
>
Make local function 'static'
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Matching_type"
>
<source>
Matching type
</source>
<target
state=
"new"
>
Matching type
</target>
<note
/>
</trans-unit>
<trans-unit
id=
"Merge_with_nested_0_statement"
>
<source>
Merge with nested '{0}' statement
</source>
<target
state=
"new"
>
Merge with nested '{0}' statement
</target>
...
...
src/Workspaces/Core/Portable/Tags/WellKnownTags.cs
浏览文件 @
849e4310
...
...
@@ -52,6 +52,7 @@ public static class WellKnownTags
internal
const
string
AddReference
=
nameof
(
AddReference
);
internal
const
string
NuGet
=
nameof
(
NuGet
);
internal
const
string
MatchingType
=
nameof
(
MatchingType
);
}
internal
static
class
WellKnownTagArrays
...
...
@@ -128,6 +129,7 @@ internal static class WellKnownTagArrays
internal
static
readonly
ImmutableArray
<
string
>
AddReference
=
ImmutableArray
.
Create
(
WellKnownTags
.
AddReference
);
internal
static
readonly
ImmutableArray
<
string
>
NuGet
=
ImmutableArray
.
Create
(
WellKnownTags
.
NuGet
);
internal
static
readonly
ImmutableArray
<
string
>
MatchingType
=
ImmutableArray
.
Create
(
WellKnownTags
.
MatchingType
);
internal
static
readonly
ImmutableArray
<
string
>
CSharpFile
=
ImmutableArray
.
Create
(
WellKnownTags
.
File
,
LanguageNames
.
CSharp
);
internal
static
readonly
ImmutableArray
<
string
>
VisualBasicFile
=
ImmutableArray
.
Create
(
WellKnownTags
.
File
,
LanguageNames
.
VisualBasic
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录