Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9587a6c3
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,体验更适合开发者的 AI 搜索 >>
提交
9587a6c3
编写于
10月 06, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Suppress inline hints when parameter name isn't important given hte method name.
上级
d53c1f47
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
177 addition
and
16 deletion
+177
-16
src/EditorFeatures/Test2/InlineHints/VisualBasicInlineParameterNameHintsTests.vb
...2/InlineHints/VisualBasicInlineParameterNameHintsTests.vb
+132
-0
src/Features/VisualBasic/Portable/InlineParameterNameHints/VisualBasicInlineParameterNameHintsService.vb
...erNameHints/VisualBasicInlineParameterNameHintsService.vb
+43
-9
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb
...pace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb
+2
-7
未找到文件。
src/EditorFeatures/Test2/InlineHints/VisualBasicInlineParameterNameHintsTests.vb
浏览文件 @
9587a6c3
...
...
@@ -352,5 +352,137 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InlineHints
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestNotOnEnableDisableBoolean1
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
EnableLogging
(
value
as
boolean
)
end
sub
sub
Main
()
EnableLogging
(
true
)
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestNotOnEnableDisableBoolean2
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
DisableLogging
(
value
as
boolean
)
end
sub
sub
Main
()
DisableLogging
(
true
)
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestOnEnableDisableNonBoolean1
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
EnableLogging
(
value
as
string
)
end
sub
sub
Main
()
EnableLogging
({
|
value
:
"IO"
|
})
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestOnEnableDisableNonBoolean2
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
DisableLogging
(
value
as
string
)
end
sub
sub
Main
()
DisableLogging
({
|
value
:
"IO"
|
})
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestOnSetMethodWithClearContext
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
SetClassification
(
classification
as
string
)
end
sub
sub
Main
()
SetClassification
(
"IO"
)
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
<
WorkItem
(
47597
,
"https://github.com/dotnet/roslyn/issues/47597"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
InlineParameterNameHints
)
>
Public
Async
Function
TestOnSetMethodWithUnclearContext
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"Visual Basic"
CommonReferences
=
"true"
>
<
Document
>
class
A
sub
SetClassification
(
values
as
string
)
end
sub
sub
Main
()
SetClassification
({
|
values
:
"IO"
|
})
end
sub
end
class
</
Document
>
</
Project
>
</
Workspace
>
Await
VerifyParamHints
(
input
)
End
Function
End
Class
End
Namespace
src/Features/VisualBasic/Portable/InlineParameterNameHints/VisualBasicInlineParameterNameHintsService.vb
浏览文件 @
9587a6c3
...
...
@@ -6,7 +6,6 @@ Imports System.Composition
Imports
System.Threading
Imports
Microsoft.CodeAnalysis.Host.Mef
Imports
Microsoft.CodeAnalysis.InlineHints
Imports
Microsoft.CodeAnalysis.PooledObjects
Imports
Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace
Microsoft.CodeAnalysis.VisualBasic.InlineParameterNameHints
...
...
@@ -27,17 +26,52 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.InlineParameterNameHints
hideForParametersThatMatchMethodIntent
As
Boolean
,
CancellationToken
As
CancellationToken
)
Dim
simpleArgument
=
TryCast
(
node
,
SimpleArgumentSyntax
)
If
simpleArgument
?
.
Expression
IsNot
Nothing
Then
If
Not
simpleArgument
.
IsNamed
AndAlso
simpleArgument
.
NameColonEquals
Is
Nothing
Then
Dim
param
=
simpleArgument
.
DetermineParameter
(
semanticModel
,
allowParamArray
:
=
False
,
CancellationToken
)
If
Not
String
.
IsNullOrEmpty
(
param
?
.
Name
)
Then
addHint
(
New
InlineParameterHint
(
param
.
GetSymbolKey
(
CancellationToken
),
param
.
Name
,
simpleArgument
.
Span
.
Start
,
GetKind
(
simpleArgument
.
Expression
)))
End
If
End
If
Dim
argument
=
TryCast
(
node
,
SimpleArgumentSyntax
)
If
argument
?
.
Expression
Is
Nothing
Then
Return
End
If
If
argument
.
IsNamed
OrElse
argument
.
NameColonEquals
IsNot
Nothing
Then
Return
End
If
Dim
parameter
=
argument
.
DetermineParameter
(
semanticModel
,
allowParamArray
:
=
False
,
CancellationToken
)
If
String
.
IsNullOrEmpty
(
parameter
?
.
Name
)
Then
Return
End
If
If
hideForParametersThatMatchMethodIntent
AndAlso
MatchesMethodIntent
(
argument
,
parameter
)
Then
Return
End
If
addHint
(
New
InlineParameterHint
(
parameter
.
GetSymbolKey
(
CancellationToken
),
parameter
.
Name
,
argument
.
Span
.
Start
,
GetKind
(
argument
.
Expression
)))
End
Sub
Private
Overloads
Shared
Function
MatchesMethodIntent
(
argument
As
ArgumentSyntax
,
parameter
As
IParameterSymbol
)
As
Boolean
' Methods Like `SetColor(color: "y")` `FromResult(result: "x")` `Enable/DisablePolling(bool)` don't need
' parameter names to improve clarity. The parameter Is clear from the context of the method name.
Dim
argumentList
=
TryCast
(
argument
.
Parent
,
ArgumentListSyntax
)
If
argumentList
Is
Nothing
Then
Return
False
End
If
If
argumentList
.
Arguments
(
0
)
IsNot
argument
Then
Return
False
End
If
Dim
invocationExpression
=
TryCast
(
argumentList
.
Parent
,
InvocationExpressionSyntax
)
If
invocationExpression
Is
Nothing
Then
Return
False
End
If
Dim
rightMostName
=
invocationExpression
.
Expression
.
GetRightmostName
()
If
rightMostName
Is
Nothing
Then
Return
False
End
If
Return
AbstractInlineParameterNameHintsService
.
MatchesMethodIntent
(
rightMostName
.
Identifier
.
ValueText
,
parameter
)
End
Function
Private
Function
GetKind
(
arg
As
ExpressionSyntax
)
As
InlineParameterHintKind
If
TypeOf
arg
Is
LiteralExpressionSyntax
OrElse
TypeOf
arg
Is
InterpolatedStringExpressionSyntax
Then
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Extensions/ExpressionSyntaxExtensions.vb
浏览文件 @
9587a6c3
...
...
@@ -254,7 +254,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End
Function
<
Extension
>
Public
Function
GetRightmostName
(
node
As
ExpressionSyntax
)
As
NameSyntax
Public
Function
GetRightmostName
(
node
As
ExpressionSyntax
)
As
Simple
NameSyntax
Dim
memberAccess
=
TryCast
(
node
,
MemberAccessExpressionSyntax
)
If
memberAccess
IsNot
Nothing
AndAlso
memberAccess
.
Name
IsNot
Nothing
Then
Return
memberAccess
.
Name
...
...
@@ -265,12 +265,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return
qualified
.
Right
End
If
Dim
simple
=
TryCast
(
node
,
SimpleNameSyntax
)
If
simple
IsNot
Nothing
Then
Return
simple
End
If
Return
Nothing
Return
TryCast
(
node
,
SimpleNameSyntax
)
End
Function
<
Extension
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录