Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
afd49c62
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,发现更多精彩内容 >>
提交
afd49c62
编写于
11月 13, 2014
作者:
J
jmarolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support GFU inside nameof for C# and VB
***NO_CI*** (changeset 1371266)
上级
8f241a8d
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
329 addition
and
294 deletion
+329
-294
Src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+1
-1
Src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
.../CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
+254
-253
Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs
...es/CSharp/Portable/Extensions/ISemanticModelExtensions.cs
+43
-40
Src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
...p/Portable/LanguageServices/CSharpSemanticFactsService.cs
+5
-0
Src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs
...geServices/SemanticsFactsService/ISemanticFactsService.cs
+1
-0
Src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.vb
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.vb
+20
-0
Src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb
...table/LanguageServices/VisualBasicSemanticFactsService.vb
+5
-0
未找到文件。
Src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
afd49c62
...
...
@@ -2075,7 +2075,7 @@ public static bool IsLabelContext(this SyntaxTree syntaxTree, int position, Canc
return
false
;
}
public
static
bool
IsNameOfContext
(
this
SyntaxTree
syntaxTree
,
int
position
,
SemanticModel
semanticModelOpt
,
CancellationToken
cancellationToken
)
public
static
bool
IsNameOfContext
(
this
SyntaxTree
syntaxTree
,
int
position
,
SemanticModel
semanticModelOpt
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
)
)
{
var
token
=
syntaxTree
.
FindTokenOnLeftOfPosition
(
position
,
cancellationToken
);
token
=
token
.
GetPreviousTokenIfTouchingWord
(
position
);
...
...
Src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
浏览文件 @
afd49c62
此差异已折叠。
点击以展开。
Src/Workspaces/CSharp/Portable/Extensions/ISemanticModelExtensions.cs
浏览文件 @
afd49c62
...
...
@@ -60,42 +60,42 @@ private static void DecomposeName(ExpressionSyntax expression, out ExpressionSyn
{
switch
(
expression
.
CSharpKind
())
{
case
SyntaxKind
.
SimpleMemberAccessExpression
:
case
SyntaxKind
.
PointerMemberAccessExpression
:
var
max
=
(
MemberAccessExpressionSyntax
)
expression
;
qualifier
=
max
.
Expression
;
name
=
max
.
Name
.
Identifier
.
ValueText
;
arity
=
max
.
Name
.
Arity
;
break
;
case
SyntaxKind
.
QualifiedName
:
var
qn
=
(
QualifiedNameSyntax
)
expression
;
qualifier
=
qn
.
Left
;
name
=
qn
.
Right
.
Identifier
.
ValueText
;
arity
=
qn
.
Arity
;
break
;
case
SyntaxKind
.
AliasQualifiedName
:
var
aq
=
(
AliasQualifiedNameSyntax
)
expression
;
qualifier
=
aq
.
Alias
;
name
=
aq
.
Name
.
Identifier
.
ValueText
;
arity
=
aq
.
Name
.
Arity
;
break
;
case
SyntaxKind
.
GenericName
:
var
gx
=
(
GenericNameSyntax
)
expression
;
qualifier
=
null
;
name
=
gx
.
Identifier
.
ValueText
;
arity
=
gx
.
Arity
;
break
;
case
SyntaxKind
.
IdentifierName
:
var
nx
=
(
IdentifierNameSyntax
)
expression
;
qualifier
=
null
;
name
=
nx
.
Identifier
.
ValueText
;
arity
=
0
;
break
;
default
:
qualifier
=
null
;
name
=
null
;
arity
=
0
;
break
;
case
SyntaxKind
.
SimpleMemberAccessExpression
:
case
SyntaxKind
.
PointerMemberAccessExpression
:
var
max
=
(
MemberAccessExpressionSyntax
)
expression
;
qualifier
=
max
.
Expression
;
name
=
max
.
Name
.
Identifier
.
ValueText
;
arity
=
max
.
Name
.
Arity
;
break
;
case
SyntaxKind
.
QualifiedName
:
var
qn
=
(
QualifiedNameSyntax
)
expression
;
qualifier
=
qn
.
Left
;
name
=
qn
.
Right
.
Identifier
.
ValueText
;
arity
=
qn
.
Arity
;
break
;
case
SyntaxKind
.
AliasQualifiedName
:
var
aq
=
(
AliasQualifiedNameSyntax
)
expression
;
qualifier
=
aq
.
Alias
;
name
=
aq
.
Name
.
Identifier
.
ValueText
;
arity
=
aq
.
Name
.
Arity
;
break
;
case
SyntaxKind
.
GenericName
:
var
gx
=
(
GenericNameSyntax
)
expression
;
qualifier
=
null
;
name
=
gx
.
Identifier
.
ValueText
;
arity
=
gx
.
Arity
;
break
;
case
SyntaxKind
.
IdentifierName
:
var
nx
=
(
IdentifierNameSyntax
)
expression
;
qualifier
=
null
;
name
=
nx
.
Identifier
.
ValueText
;
arity
=
0
;
break
;
default
:
qualifier
=
null
;
name
=
null
;
arity
=
0
;
break
;
}
}
...
...
@@ -163,9 +163,9 @@ private static bool CanBindToken(SyntaxToken token)
// Add more token kinds if necessary;
switch
(
token
.
CSharpKind
())
{
case
SyntaxKind
.
CommaToken
:
case
SyntaxKind
.
DelegateKeyword
:
return
false
;
case
SyntaxKind
.
CommaToken
:
case
SyntaxKind
.
DelegateKeyword
:
return
false
;
}
return
true
;
...
...
@@ -315,7 +315,10 @@ public static ISet<INamespaceSymbol> GetUsingNamespacesInScope(this SemanticMode
TypeSyntax
type
,
CancellationToken
cancellationToken
)
{
type
=
GetOutermostType
(
type
);
if
(
type
!=
null
)
{
type
=
GetOutermostType
(
type
);
}
// Interesting cases based on 3.5.4 Accessibility constraints in the language spec.
// If any of the below hold, then we will override the default accessibility if the
...
...
Src/Workspaces/CSharp/Portable/LanguageServices/CSharpSemanticFactsService.cs
浏览文件 @
afd49c62
...
...
@@ -262,5 +262,10 @@ public bool IsAssignableTo(ITypeSymbol fromSymbol, ITypeSymbol toSymbol, Compila
toSymbol
!=
null
&&
((
CSharpCompilation
)
compilation
).
ClassifyConversion
(
fromSymbol
,
toSymbol
).
IsImplicit
;
}
public
bool
IsNameOfContext
(
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
)
{
return
semanticModel
.
SyntaxTree
.
IsNameOfContext
(
position
,
semanticModel
,
cancellationToken
);
}
}
}
\ No newline at end of file
Src/Workspaces/Core/Portable/LanguageServices/SemanticsFactsService/ISemanticFactsService.cs
浏览文件 @
afd49c62
...
...
@@ -48,6 +48,7 @@ internal interface ISemanticFactsService : ILanguageService
bool
IsGlobalStatementContext
(
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
);
bool
IsLabelContext
(
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
);
bool
IsAttributeNameContext
(
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
);
bool
IsNameOfContext
(
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
);
/// <summary>
/// True if a write is performed to the given expression. Note: reads may also be performed
...
...
Src/Workspaces/VisualBasic/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.vb
浏览文件 @
afd49c62
...
...
@@ -447,6 +447,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Return
token
.
IsChildToken
(
Of
SimpleAsClauseSyntax
)(
Function
(
asClause
)
asClause
.
AsKeyword
)
End
Function
<
Extension
()
>
Public
Function
IsNameOfContext
(
syntaxTree
As
SyntaxTree
,
position
As
Integer
,
token
As
SyntaxToken
,
Optional
cancellationToken
As
CancellationToken
=
Nothing
)
As
Boolean
' first do quick exit check
If
syntaxTree
.
IsInPreprocessorDirectiveContext
(
position
,
cancellationToken
)
OrElse
syntaxTree
.
IsInInactiveRegion
(
position
,
cancellationToken
)
OrElse
syntaxTree
.
IsEntirelyWithinComment
(
position
,
cancellationToken
)
OrElse
syntaxTree
.
IsEntirelyWithinStringOrCharLiteral
(
position
,
cancellationToken
)
Then
Return
False
End
If
Contract
.
Requires
(
token
=
syntaxTree
.
GetTargetToken
(
position
,
cancellationToken
))
If
token
.
IsChildToken
(
Of
NameOfExpressionSyntax
)(
Function
(
importAliasClause
)
importAliasClause
.
OpenParenToken
)
Then
Return
True
End
If
Return
False
End
Function
<
Extension
()
>
Friend
Function
IsSingleLineStatementContext
(
syntaxTree
As
SyntaxTree
,
position
As
Integer
,
cancellationToken
As
CancellationToken
)
As
Boolean
Dim
targetToken
=
syntaxTree
.
GetTargetToken
(
position
,
cancellationToken
)
...
...
Src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb
浏览文件 @
afd49c62
...
...
@@ -245,5 +245,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public
Function
IsAssignableTo
(
fromSymbol
As
ITypeSymbol
,
toSymbol
As
ITypeSymbol
,
compilation
As
Compilation
)
As
Boolean
Implements
ISemanticFactsService
.
IsAssignableTo
Return
fromSymbol
IsNot
Nothing
AndAlso
toSymbol
IsNot
Nothing
AndAlso
DirectCast
(
compilation
,
VisualBasicCompilation
).
ClassifyConversion
(
fromSymbol
,
toSymbol
).
IsWidening
End
Function
Public
Function
IsNameOfContext
(
semanticModel
As
SemanticModel
,
position
As
Integer
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsNameOfContext
Dim
token
=
semanticModel
.
SyntaxTree
.
GetTargetToken
(
position
,
cancellationToken
)
Return
semanticModel
.
SyntaxTree
.
IsNameOfContext
(
position
,
token
,
cancellationToken
)
End
Function
End
Class
End
Namespace
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录