Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d0d71a79
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,发现更多精彩内容 >>
提交
d0d71a79
编写于
11月 05, 2019
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add/remove todos
上级
86897dd0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
31 deletion
+29
-31
src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/ExtensionMethodImportCompletionHelper.cs
...mpletionProvider/ExtensionMethodImportCompletionHelper.cs
+6
-1
src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs
...ble/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs
+7
-11
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
...Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
+4
-5
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
...Services/SyntaxFactsService/AbstractSyntaxFactsService.cs
+5
-4
src/Workspaces/VisualBasic/Portable/FindSymbols/VisualBasicDeclaredSymbolInfoFactoryService.vb
...indSymbols/VisualBasicDeclaredSymbolInfoFactoryService.vb
+7
-10
未找到文件。
src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/ExtensionMethodImportCompletionHelper.cs
浏览文件 @
d0d71a79
...
...
@@ -269,7 +269,12 @@ internal static partial class ExtensionMethodImportCompletionHelper
// Container of extension method (static class in C# and Module in VB) can't be generic or nested.
// Note that we might incorrectly ignore valid types, because, for example, calling `GetTypeByMetadataName`
// would return null if we have multiple definitions of a type even though only one is accessible from here
// (e.g. an internal type declared inside a shared document).
// (e.g. an internal type declared inside a shared document). In this case, we have to handle the conflicted
// types explicitly here.
//
// TODO:
// Alternatively, we can try to get symbols out of each assembly, instead of the compilation (which includes all references),
// to avoid such conflict. We should give this approach a try and see if any perf improvement can be archieved.
var
containerSymbol
=
compilation
.
GetTypeByMetadataName
(
fullyQualifiedContainerName
);
if
(
containerSymbol
!=
null
)
...
...
src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs
浏览文件 @
d0d71a79
...
...
@@ -3,6 +3,7 @@
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Composition
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
Microsoft.CodeAnalysis
;
...
...
@@ -512,19 +513,14 @@ public override bool TryGetAliasesFromUsingDirective(SyntaxNode node, out Immuta
return
false
;
}
public
override
bool
TryGetTargetTypeName
(
SyntaxNode
node
,
out
string
targetTypeNam
e
)
public
override
string
GetTargetTypeName
(
SyntaxNode
nod
e
)
{
if
(
node
is
MethodDeclarationSyntax
methodDeclaration
&&
IsExtensionMethod
(
methodDeclaration
))
{
var
typeParameterNames
=
methodDeclaration
.
TypeParameterList
?.
Parameters
.
SelectAsArray
(
p
=>
p
.
Identifier
.
Text
);
TryGetSimpleTypeName
(
methodDeclaration
.
ParameterList
.
Parameters
[
0
].
Type
,
typeParameterNames
,
out
targetTypeName
);
// We always return true here, which indicates we have a valid taget type name. (which would be null for a complex type though).
return
true
;
}
var
methodDeclaration
=
(
MethodDeclarationSyntax
)
node
;
Debug
.
Assert
(
IsExtensionMethod
(
methodDeclaration
));
targetTypeName
=
null
;
return
false
;
var
typeParameterNames
=
methodDeclaration
.
TypeParameterList
?.
Parameters
.
SelectAsArray
(
p
=>
p
.
Identifier
.
Text
);
TryGetSimpleTypeName
(
methodDeclaration
.
ParameterList
.
Parameters
[
0
].
Type
,
typeParameterNames
,
out
var
targetTypeName
);
return
targetTypeName
;
}
private
static
bool
TryGetSimpleTypeName
(
SyntaxNode
node
,
ImmutableArray
<
string
>?
typeParameterNames
,
out
string
simpleTypeName
)
...
...
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
浏览文件 @
d0d71a79
...
...
@@ -23,7 +23,9 @@ internal interface IDeclaredSymbolInfoFactoryService : ILanguageService
// otherwise we would not be able to get correct data from syntax.
bool
TryGetDeclaredSymbolInfo
(
StringTable
stringTable
,
SyntaxNode
node
,
string
rootNamespace
,
out
DeclaredSymbolInfo
declaredSymbolInfo
);
bool
TryGetTargetTypeName
(
SyntaxNode
node
,
out
string
instanceTypeName
);
// Get the name of the target type of specified extension method declaration node.
// The returned value would be null for complex type.
string
GetTargetTypeName
(
SyntaxNode
node
);
bool
TryGetAliasesFromUsingDirective
(
SyntaxNode
node
,
out
ImmutableArray
<(
string
aliasName
,
string
name
)>
aliases
);
...
...
@@ -304,10 +306,7 @@ internal sealed partial class SyntaxTreeIndex
return
;
}
if
(!
infoFactory
.
TryGetTargetTypeName
(
node
,
out
var
targetTypeName
))
{
return
;
}
var
targetTypeName
=
infoFactory
.
GetTargetTypeName
(
node
);
// complex method
if
(
targetTypeName
==
null
)
...
...
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
浏览文件 @
d0d71a79
...
...
@@ -94,11 +94,12 @@ public static string GetMetadataAritySuffix(int arity)
public
abstract
bool
TryGetDeclaredSymbolInfo
(
StringTable
stringTable
,
SyntaxNode
node
,
string
rootNamespace
,
out
DeclaredSymbolInfo
declaredSymbolInfo
);
/// <summary>
/// If <paramref name="node"/> is an extension method declaration, this will return true, otherwise it returns false.
/// If the return value is true and <paramref name="targetTypeName"/> is null, then it means this is a "complex" method
/// (as described at <see cref="SyntaxTreeIndex.ExtensionMethodInfo"/>).
/// Get the name of the target type of specified extension method declaration.
/// The node provided must be an extension method declaration, i.e. calling `TryGetDeclaredSymbolInfo()`
/// on `node` should return a `DeclaredSymbolInfo` of kind `ExtensionMethod`.
/// If the return value is null, then it means this is a "complex" method (as described at <see cref="SyntaxTreeIndex.ExtensionMethodInfo"/>).
/// </summary>
public
abstract
bool
TryGetTargetTypeName
(
SyntaxNode
node
,
out
string
targetTypeNam
e
);
public
abstract
string
GetTargetTypeName
(
SyntaxNode
nod
e
);
public
abstract
bool
TryGetAliasesFromUsingDirective
(
SyntaxNode
node
,
out
ImmutableArray
<(
string
aliasName
,
string
name
)>
aliases
);
...
...
src/Workspaces/VisualBasic/Portable/FindSymbols/VisualBasicDeclaredSymbolInfoFactoryService.vb
浏览文件 @
d0d71a79
...
...
@@ -460,18 +460,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.FindSymbols
Next
End
Sub
Public
Overrides
Function
TryGetTargetTypeName
(
node
As
SyntaxNode
,
ByRef
targetTypeName
As
String
)
As
Boolean
Dim
funcDecl
=
TryCast
(
node
,
MethodBlockSyntax
)
'TODO: don't call `IsExtensionMethod` again
If
funcDecl
IsNot
Nothing
AndAlso
IsExtensionMethod
(
funcDecl
)
Then
Public
Overrides
Function
GetTargetTypeName
(
node
As
SyntaxNode
)
As
String
Dim
funcDecl
=
CType
(
node
,
MethodBlockSyntax
)
Debug
.
Assert
(
IsExtensionMethod
(
funcDecl
))
Dim
typeParameterNames
=
funcDecl
.
SubOrFunctionStatement
.
TypeParameterList
?
.
Parameters
.
SelectAsArray
(
Function
(
p
)
p
.
Identifier
.
Text
)
TryGetSimpleTypeNameWorker
(
funcDecl
.
BlockStatement
.
ParameterList
.
Parameters
(
0
).
AsClause
?
.
Type
,
typeParameterNames
,
targetTypeName
)
Return
True
End
If
Dim
typeParameterNames
=
funcDecl
.
SubOrFunctionStatement
.
TypeParameterList
?
.
Parameters
.
SelectAsArray
(
Function
(
p
)
p
.
Identifier
.
Text
)
Dim
targetTypeName
As
String
=
Nothing
TryGetSimpleTypeNameWorker
(
funcDecl
.
BlockStatement
.
ParameterList
.
Parameters
(
0
).
AsClause
?
.
Type
,
typeParameterNames
,
targetTypeName
)
targetTypeName
=
Nothing
Return
False
Return
targetTypeName
End
Function
Public
Overrides
Function
TryGetAliasesFromUsingDirective
(
node
As
SyntaxNode
,
ByRef
aliases
As
ImmutableArray
(
Of
(
aliasName
As
String
,
name
As
String
)))
As
Boolean
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录