Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e7d2d3d0
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,发现更多精彩内容 >>
提交
e7d2d3d0
编写于
2月 02, 2017
作者:
R
Ravi Chande
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use SemanticModel to determine if we're in an instance context
上级
513b59cc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
5 addition
and
41 deletion
+5
-41
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs
...p/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+3
-36
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.cs
.../Portable/Extensions/MemberDeclarationSyntaxExtensions.cs
+1
-4
未找到文件。
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs
浏览文件 @
e7d2d3d0
...
...
@@ -237,7 +237,7 @@ private static CSharpSyntaxContext CreateContextWorker(Workspace workspace, Sema
syntaxTree
.
IsDelegateReturnTypeContext
(
position
,
leftToken
,
cancellationToken
),
syntaxTree
.
IsTypeOfExpressionContext
(
position
,
leftToken
,
cancellationToken
),
syntaxTree
.
GetPrecedingModifiers
(
position
,
leftToken
,
cancellationToken
),
syntaxTree
.
IsInstanceContext
(
position
,
leftToken
,
cancellationToken
),
syntaxTree
.
IsInstanceContext
(
targetToken
,
semanticModel
,
cancellationToken
),
syntaxTree
.
IsCrefContext
(
position
,
cancellationToken
)
&&
!
leftToken
.
IsKind
(
SyntaxKind
.
DotToken
),
syntaxTree
.
IsCatchFilterContext
(
position
,
leftToken
),
isDestructorTypeContext
,
...
...
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
e7d2d3d0
...
...
@@ -1708,7 +1708,7 @@ public static bool IsGlobalStatementContext(this SyntaxTree syntaxTree, int posi
return
token
.
IsBeginningOfGlobalStatementContext
();
}
public
static
bool
IsInstanceContext
(
this
SyntaxTree
syntaxTree
,
int
position
,
SyntaxToken
tokenOnLeftOfPosition
,
CancellationToken
cancellationToken
)
public
static
bool
IsInstanceContext
(
this
SyntaxTree
syntaxTree
,
SyntaxToken
targetToken
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
)
{
#if false
if
(
syntaxTree
.
IsInPreprocessorDirectiveContext
(
position
,
cancellationToken
))
...
...
@@ -1717,41 +1717,8 @@ public static bool IsInstanceContext(this SyntaxTree syntaxTree, int position, S
}
#endif
var
token
=
tokenOnLeftOfPosition
;
// We're in an instance context if we're in the body of an instance member
var
containingMember
=
token
.
GetAncestor
<
MemberDeclarationSyntax
>();
if
(
containingMember
==
null
)
{
return
false
;
}
var
modifiers
=
containingMember
.
GetModifiers
();
if
(
modifiers
.
Any
(
SyntaxKind
.
StaticKeyword
))
{
return
false
;
}
var
expressionBody
=
containingMember
.
GetExpressionBody
();
if
(
expressionBody
!=
null
)
{
return
TextSpan
.
FromBounds
(
expressionBody
.
ArrowToken
.
Span
.
End
,
expressionBody
.
FullSpan
.
End
).
IntersectsWith
(
position
);
}
// Must be a property or something method-like.
if
(
containingMember
.
HasMethodShape
())
{
var
body
=
containingMember
.
GetBody
();
return
IsInBlock
(
body
,
position
);
}
var
accessor
=
token
.
GetAncestor
<
AccessorDeclarationSyntax
>();
if
(
accessor
!=
null
)
{
return
IsInBlock
(
accessor
.
Body
,
position
);
}
return
false
;
var
enclosingSymbol
=
semanticModel
.
GetEnclosingSymbol
(
targetToken
.
SpanStart
,
cancellationToken
);
return
!
enclosingSymbol
.
IsStatic
;
}
private
static
bool
IsInBlock
(
BlockSyntax
bodyOpt
,
int
position
)
...
...
src/Workspaces/CSharp/Portable/Extensions/MemberDeclarationSyntaxExtensions.cs
浏览文件 @
e7d2d3d0
...
...
@@ -331,10 +331,7 @@ public static ArrowExpressionClauseSyntax GetExpressionBody(this MemberDeclarati
switch
(
memberDeclaration
?.
Kind
())
{
case
SyntaxKind
.
PropertyDeclaration
:
var
propertyDeclaration
=
(
PropertyDeclarationSyntax
)
memberDeclaration
;
return
propertyDeclaration
.
ExpressionBody
??
propertyDeclaration
.
AccessorList
.
Accessors
.
FirstOrDefault
(
a
=>
a
.
ExpressionBody
!=
null
)
?.
ExpressionBody
;
return
((
PropertyDeclarationSyntax
)
memberDeclaration
).
ExpressionBody
;
case
SyntaxKind
.
MethodDeclaration
:
return
((
MethodDeclarationSyntax
)
memberDeclaration
).
ExpressionBody
;
case
SyntaxKind
.
IndexerDeclaration
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录