Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cd420a0a
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,发现更多精彩内容 >>
提交
cd420a0a
编写于
1月 18, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
VB simplifications
上级
766f6489
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
28 deletion
+19
-28
src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb
...alBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb
+15
-19
src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb
...table/LanguageServices/VisualBasicSemanticFactsService.vb
+3
-3
src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicVariableDeclaratorReducer.vb
...fication/Reducers/VisualBasicVariableDeclaratorReducer.vb
+1
-6
未找到文件。
src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb
浏览文件 @
cd420a0a
...
...
@@ -322,7 +322,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End
Function
<
Extension
()
>
Public
Function
IsInOutContext
(
expression
As
ExpressionSyntax
,
semanticModel
As
SemanticModel
,
cancellationToken
As
CancellationToken
)
As
Boolean
Public
Function
IsInOutContext
(
expression
As
ExpressionSyntax
)
As
Boolean
' NOTE(cyrusn): VB has no concept of an out context. Even when a parameter has an
' '<Out>' attribute on it, it's still treated as ref by VB. So we always return false
' here.
...
...
@@ -370,19 +370,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End
Function
<
Extension
()
>
Public
Function
IsInInContext
(
expression
As
ExpressionSyntax
,
semanticModel
As
SemanticModel
,
cancellationToken
As
CancellationToken
)
As
Boolean
Public
Function
IsInInContext
(
expression
As
ExpressionSyntax
)
As
Boolean
' NOTE: VB does not support in parameters. Always return False here.
Return
False
End
Function
<
Extension
()
>
Public
Function
IsOnlyWrittenTo
(
expression
As
ExpressionSyntax
,
semanticModel
As
SemanticModel
,
cancellationToken
As
CancellationToken
)
As
Boolean
Public
Function
IsOnlyWrittenTo
(
expression
As
ExpressionSyntax
)
As
Boolean
If
expression
.
IsRightSideOfDot
()
Then
expression
=
TryCast
(
expression
.
Parent
,
ExpressionSyntax
)
End
If
If
expression
IsNot
Nothing
Then
If
expression
.
IsInOutContext
(
semanticModel
,
cancellationToken
)
Then
If
expression
.
IsInOutContext
()
Then
Return
True
End
If
...
...
@@ -413,7 +413,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
<
Extension
()
>
Public
Function
IsWrittenTo
(
expression
As
ExpressionSyntax
,
semanticModel
As
SemanticModel
,
cancellationToken
As
CancellationToken
)
As
Boolean
If
IsOnlyWrittenTo
(
expression
,
semanticModel
,
cancellationToken
)
Then
If
IsOnlyWrittenTo
(
expression
)
Then
Return
True
End
If
...
...
@@ -785,15 +785,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return
semanticModel
.
Compilation
.
CreateArrayTypeSymbol
(
type
,
rank
)
End
Function
<
Extension
()
>
<
Extension
>
Public
Function
TryReduceVariableDeclaratorWithoutType
(
variableDeclarator
As
VariableDeclaratorSyntax
,
semanticModel
As
SemanticModel
,
<
Out
()
>
ByRef
replacementNode
As
SyntaxNode
,
<
Out
()
>
ByRef
issueSpan
As
TextSpan
,
optionSet
As
OptionSet
,
cancellationToken
As
CancellationToken
)
As
Boolean
<
Out
>
ByRef
replacementNode
As
SyntaxNode
,
<
Out
>
ByRef
issueSpan
As
TextSpan
)
As
Boolean
replacementNode
=
Nothing
issueSpan
=
Nothing
...
...
@@ -831,7 +828,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return
False
End
If
Dim
initializerType
As
ITypeSymbol
=
Nothing
Dim
initializerType
As
ITypeSymbol
If
declaredSymbolType
.
IsArrayType
()
AndAlso
variableDeclarator
.
Initializer
.
Value
.
Kind
()
=
SyntaxKind
.
CollectionInitializer
Then
' Get type of the array literal in context without the target type
...
...
@@ -1255,7 +1252,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
issueSpan
=
name
.
Span
Return
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
,
semanticModel
,
cancellationToken
)
Return
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
)
Else
If
Not
name
.
IsRightSideOfDot
()
Then
...
...
@@ -1304,8 +1301,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End
If
End
If
If
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
,
semanticModel
,
cancellationToken
)
Then
If
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
)
Then
' check if the alias name ends with an Attribute suffix that can be omitted.
Dim
replacementNodeWithoutAttributeSuffix
As
ExpressionSyntax
=
Nothing
Dim
issueSpanWithoutAttributeSuffix
As
TextSpan
=
Nothing
...
...
@@ -1369,7 +1365,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
replacementNode
=
SyntaxFactory
.
PredefinedType
(
token
)
issueSpan
=
name
.
Span
Dim
canReplace
=
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
,
semanticModel
,
cancellationToken
)
Dim
canReplace
=
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
)
If
canReplace
Then
replacementNode
=
replacementNode
.
WithAdditionalAnnotations
(
New
SyntaxAnnotation
(
codeStyleOptionName
))
End
If
...
...
@@ -1397,7 +1393,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
issueSpan
=
name
.
Span
If
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
,
semanticModel
,
cancellationToken
)
Then
If
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
)
Then
Return
True
End
If
End
If
...
...
@@ -1829,11 +1825,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return
False
End
If
Return
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
,
semanticModel
,
cancellationToken
)
Return
name
.
CanReplaceWithReducedNameInContext
(
replacementNode
)
End
Function
<
Extension
>
Private
Function
CanReplaceWithReducedNameInContext
(
name
As
NameSyntax
,
replacementNode
As
ExpressionSyntax
,
semanticModel
As
SemanticModel
,
cancellationToken
As
CancellationToken
)
As
Boolean
Private
Function
CanReplaceWithReducedNameInContext
(
name
As
NameSyntax
,
replacementNode
As
ExpressionSyntax
)
As
Boolean
' Special case. if this new minimal name parses out to a predefined type, then we
' have to make sure that we're not in a using alias. That's the one place where the
...
...
src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSemanticFactsService.vb
浏览文件 @
cd420a0a
...
...
@@ -111,7 +111,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
Public
Function
IsOnlyWrittenTo
(
semanticModel
As
SemanticModel
,
node
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsOnlyWrittenTo
Return
TryCast
(
node
,
ExpressionSyntax
).
IsOnlyWrittenTo
(
semanticModel
,
cancellationToken
)
Return
TryCast
(
node
,
ExpressionSyntax
).
IsOnlyWrittenTo
()
End
Function
Public
Function
IsWrittenTo
(
semanticModel
As
SemanticModel
,
node
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsWrittenTo
...
...
@@ -119,7 +119,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
Public
Function
IsInOutContext
(
semanticModel
As
SemanticModel
,
node
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsInOutContext
Return
TryCast
(
node
,
ExpressionSyntax
).
IsInOutContext
(
semanticModel
,
cancellationToken
)
Return
TryCast
(
node
,
ExpressionSyntax
).
IsInOutContext
()
End
Function
Public
Function
IsInRefContext
(
semanticModel
As
SemanticModel
,
node
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsInRefContext
...
...
@@ -127,7 +127,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
Public
Function
IsInInContext
(
semanticModel
As
SemanticModel
,
node
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
IsInInContext
Return
TryCast
(
node
,
ExpressionSyntax
).
IsInInContext
(
semanticModel
,
cancellationToken
)
Return
TryCast
(
node
,
ExpressionSyntax
).
IsInInContext
()
End
Function
Public
Function
CanReplaceWithRValue
(
semanticModel
As
SemanticModel
,
expression
As
SyntaxNode
,
cancellationToken
As
CancellationToken
)
As
Boolean
Implements
ISemanticFactsService
.
CanReplaceWithRValue
...
...
src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicVariableDeclaratorReducer.vb
浏览文件 @
cd420a0a
...
...
@@ -30,12 +30,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification
Dim
replacementNode
As
SyntaxNode
=
Nothing
Dim
issueSpan
As
TextSpan
If
Not
node
.
TryReduceVariableDeclaratorWithoutType
(
semanticModel
,
replacementNode
,
issueSpan
,
optionSet
,
cancellationToken
)
Then
If
Not
node
.
TryReduceVariableDeclaratorWithoutType
(
semanticModel
,
replacementNode
,
issueSpan
)
Then
Return
node
End
If
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录