Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
dc96a631
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 搜索 >>
提交
dc96a631
编写于
8月 05, 2020
作者:
A
Ankita Khera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changes made in response to feedback
上级
a384c36b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
36 deletion
+34
-36
src/EditorFeatures/Core.Wpf/InlineParameterNameHints/InlineParameterNameHintsTag.cs
...f/InlineParameterNameHints/InlineParameterNameHintsTag.cs
+26
-32
src/EditorFeatures/Core.Wpf/InlineParameterNameHints/InlineParameterNameHintsTagger.cs
...nlineParameterNameHints/InlineParameterNameHintsTagger.cs
+5
-1
src/EditorFeatures/Core/InlineParameterNameHints/InlineParameterNameHintDataTag.cs
...nlineParameterNameHints/InlineParameterNameHintDataTag.cs
+2
-2
src/Features/VisualBasic/Portable/InlineParameterNameHints/VisualBasicInlineParameterNameHintsService.vb
...erNameHints/VisualBasicInlineParameterNameHintsService.vb
+1
-1
未找到文件。
src/EditorFeatures/Core.Wpf/InlineParameterNameHints/InlineParameterNameHintsTag.cs
浏览文件 @
dc96a631
...
...
@@ -35,19 +35,11 @@ internal class InlineParameterNameHintsTag : IntraTextAdornmentTag
public
const
string
TagId
=
"inline parameter name hints"
;
private
readonly
IToolTipService
_toolTipService
;
private
readonly
ITextView
_textView
;
private
SnapshotSpan
_span
;
private
readonly
SnapshotSpan
_span
;
private
readonly
SymbolKey
_key
;
private
readonly
IThreadingContext
_threadingContext
;
public
Lazy
<
IStreamingFindUsagesPresenter
>
_s
treamingPresenter
;
public
readonly
Lazy
<
IStreamingFindUsagesPresenter
>
S
treamingPresenter
;
/// <summary>
/// Creates the UIElement on call
/// Uses PositionAffinity.Predecessor because we want the tag to be associated with the preceding character
/// </summary>
/// <param name="adornment">The adornment that we are creating</param>
/// <param name="textView">The view of the editor</param>
/// <param name="span">The span that has the location of the hint</param>
/// <param name="key">The symbolkey associated with each parameter</param>
private
InlineParameterNameHintsTag
(
FrameworkElement
adornment
,
ITextView
textView
,
SnapshotSpan
span
,
SymbolKey
key
,
InlineParameterNameHintsTaggerProvider
taggerProvider
)
:
base
(
adornment
,
removalCallback
:
null
,
PositionAffinity
.
Predecessor
)
...
...
@@ -55,7 +47,7 @@ internal class InlineParameterNameHintsTag : IntraTextAdornmentTag
_textView
=
textView
;
_span
=
span
;
_key
=
key
;
_s
treamingPresenter
=
taggerProvider
.
StreamingFindUsagesPresenter
;
S
treamingPresenter
=
taggerProvider
.
StreamingFindUsagesPresenter
;
_threadingContext
=
taggerProvider
.
ThreadingContext
;
_toolTipService
=
taggerProvider
.
ToolTipService
;
...
...
@@ -65,6 +57,13 @@ internal class InlineParameterNameHintsTag : IntraTextAdornmentTag
adornment
.
ToolTipOpening
+=
Border_ToolTipOpening
;
}
/// <summary>
/// Creates the UIElement on call
/// Uses PositionAffinity.Predecessor because we want the tag to be associated with the preceding character
/// </summary>
/// <param name="textView">The view of the editor</param>
/// <param name="span">The span that has the location of the hint</param>
/// <param name="key">The symbolkey associated with each parameter</param>
public
static
InlineParameterNameHintsTag
Create
(
string
text
,
double
lineHeight
,
TextFormattingRunProperties
format
,
ITextView
textView
,
SnapshotSpan
span
,
SymbolKey
key
,
InlineParameterNameHintsTaggerProvider
taggerProvider
)
...
...
@@ -82,19 +81,26 @@ public async Task<IReadOnlyCollection<object>> CreateDescriptionAsync(Cancellati
{
var
compilation
=
await
document
.
Project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
symbol
=
_key
.
Resolve
(
compilation
,
cancellationToken
:
cancellationToken
).
Symbol
;
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
var
semanticModel
=
await
document
.
GetRequiredSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
symbolDisplayService
=
workspace
.
Services
.
GetLanguageServices
(
semanticModel
.
Language
).
GetService
<
ISymbolDisplayService
>();
if
(
symbol
DisplayService
!=
null
)
if
(
symbol
!=
null
)
{
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
var
semanticModel
=
await
document
.
GetRequiredSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
symbolDisplayService
=
document
.
Project
.
LanguageServices
.
GetService
<
ISymbolDisplayService
>();
var
formatter
=
workspace
.
Services
.
GetLanguageServices
(
semanticModel
.
Language
).
GetService
<
IDocumentationCommentFormattingService
>();
var
sections
=
await
symbolDisplayService
.
ToDescriptionGroupsAsync
(
workspace
,
semanticModel
,
_span
.
Start
,
ImmutableArray
.
Create
(
symbol
),
cancellationToken
).
ConfigureAwait
(
false
);
textContentBuilder
.
AddRange
(
sections
[
SymbolDescriptionGroups
.
MainDescription
]);
if
(
formatter
!=
null
)
{
AddDocumentationPart
(
textContentBuilder
,
symbol
,
semanticModel
,
_span
.
Start
,
formatter
,
cancellationToken
);
var
documentation
=
symbol
.
GetDocumentationParts
(
semanticModel
,
_span
.
Start
,
formatter
,
cancellationToken
);
if
(
documentation
.
Any
())
{
textContentBuilder
.
AddLineBreak
();
textContentBuilder
.
AddRange
(
documentation
);
}
}
if
(
sections
.
TryGetValue
(
SymbolDescriptionGroups
.
AnonymousTypes
,
out
var
parts
))
{
if
(!
parts
.
IsDefaultOrEmpty
)
...
...
@@ -107,22 +113,11 @@ public async Task<IReadOnlyCollection<object>> CreateDescriptionAsync(Cancellati
}
}
var
uiCollection
=
Implementation
.
IntelliSense
.
Helpers
.
BuildInteractiveTextElements
(
textContentBuilder
.
ToImmutableArray
<
TaggedText
>(),
document
,
_threadingContext
,
_streamingPresenter
);
var
uiCollection
=
Implementation
.
IntelliSense
.
Helpers
.
BuildInteractiveTextElements
(
textContentBuilder
.
ToImmutableArray
<
TaggedText
>(),
document
,
_threadingContext
,
StreamingPresenter
);
return
uiCollection
;
}
private
static
void
AddDocumentationPart
(
List
<
TaggedText
>
textContentBuilder
,
ISymbol
symbol
,
SemanticModel
semanticModel
,
int
position
,
IDocumentationCommentFormattingService
formatter
,
CancellationToken
cancellationToken
)
{
var
documentation
=
symbol
.
GetDocumentationParts
(
semanticModel
,
position
,
formatter
,
cancellationToken
);
if
(
documentation
.
Any
())
{
textContentBuilder
.
AddLineBreak
();
textContentBuilder
.
AddRange
(
documentation
);
}
}
private
static
FrameworkElement
CreateElement
(
string
text
,
double
lineHeight
,
TextFormattingRunProperties
format
)
{
// Constructs the hint block which gets assigned parameter name and fontstyles according to the options
...
...
@@ -171,18 +166,17 @@ bool KeepOpen()
return
!(
mousePoint
.
X
>
border
.
ActualWidth
||
mousePoint
.
X
<
0
||
mousePoint
.
Y
>
border
.
ActualHeight
||
mousePoint
.
Y
<
0
);
}
var
toolTipPresenter
=
_toolTipService
.
CreatePresenter
(
_textView
,
new
ToolTipParameters
(
tr
ue
,
false
,
KeepOpen
));
var
toolTipPresenter
=
_toolTipService
.
CreatePresenter
(
_textView
,
new
ToolTipParameters
(
tr
ackMouse
:
true
,
ignoreBufferChange
:
false
,
KeepOpen
));
var
startToolTip
=
StartToolTipServiceAsync
(
toolTipPresenter
);
}
/// <summary>
/// Waits for the description to be created and updates the tooltip with the associated information
/// </summary>
private
async
Task
<
IReadOnlyCollection
<
object
>>
StartToolTipServiceAsync
(
IToolTipPresenter
toolTipPresenter
)
private
async
Task
StartToolTipServiceAsync
(
IToolTipPresenter
toolTipPresenter
)
{
var
uiList
=
await
CreateDescriptionAsync
(
CancellationToken
.
None
).
ConfigureAwait
(
false
);
toolTipPresenter
.
StartOrUpdate
(
_textView
.
TextSnapshot
.
CreateTrackingSpan
(
_span
.
Start
,
_span
.
Length
,
SpanTrackingMode
.
EdgeInclusive
),
uiList
);
return
uiList
;
}
}
}
src/EditorFeatures/Core.Wpf/InlineParameterNameHints/InlineParameterNameHintsTagger.cs
浏览文件 @
dc96a631
...
...
@@ -127,7 +127,11 @@ public IEnumerable<ITagSpan<IntraTextAdornmentTag>> GetTags(NormalizedSnapshotSp
if
(
dataTagSpans
.
Count
==
1
)
{
var
dataTagSpan
=
dataTagSpans
[
0
];
_cache
.
Add
(
new
TagSpan
<
IntraTextAdornmentTag
>(
new
SnapshotSpan
(
dataTagSpan
.
Start
,
0
),
InlineParameterNameHintsTag
.
Create
(
textTag
.
ParameterName
,
_textView
.
LineHeight
,
Format
,
_textView
,
dataTagSpan
,
textTag
.
ParameterSymbolKey
,
_inlineParameterNameHintsTaggerProvider
)));
var
parameterHintSnapshotSpan
=
new
SnapshotSpan
(
dataTagSpan
.
Start
,
0
);
var
parameterHintUITag
=
InlineParameterNameHintsTag
.
Create
(
textTag
.
ParameterName
,
_textView
.
LineHeight
,
Format
,
_textView
,
dataTagSpan
,
textTag
.
ParameterSymbolKey
,
_inlineParameterNameHintsTaggerProvider
);
_cache
.
Add
(
new
TagSpan
<
IntraTextAdornmentTag
>(
parameterHintSnapshotSpan
,
parameterHintUITag
));
}
}
}
...
...
src/EditorFeatures/Core/InlineParameterNameHints/InlineParameterNameHintDataTag.cs
浏览文件 @
dc96a631
...
...
@@ -17,14 +17,14 @@ internal class InlineParameterNameHintDataTag : ITag
public
readonly
SymbolKey
ParameterSymbolKey
;
public
readonly
string
ParameterName
;
public
InlineParameterNameHintDataTag
(
SymbolKey
s
ymbolKey
,
string
parameterName
)
public
InlineParameterNameHintDataTag
(
SymbolKey
parameterS
ymbolKey
,
string
parameterName
)
{
if
(
parameterName
.
Length
==
0
)
{
throw
new
ArgumentException
(
"Must have a length greater than 0"
,
nameof
(
parameterName
));
}
ParameterSymbolKey
=
s
ymbolKey
;
ParameterSymbolKey
=
parameterS
ymbolKey
;
ParameterName
=
parameterName
;
}
}
...
...
src/Features/VisualBasic/Portable/InlineParameterNameHints/VisualBasicInlineParameterNameHintsService.vb
浏览文件 @
dc96a631
...
...
@@ -28,7 +28,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.InlineParameterNameHints
If
Not
simpleArgument
.
IsNamed
AndAlso
simpleArgument
.
NameColonEquals
Is
Nothing
AndAlso
IsExpressionWithNoName
(
simpleArgument
.
Expression
)
Then
Dim
param
=
simpleArgument
.
DetermineParameter
(
semanticModel
,
allowParamArray
:
=
False
,
cancellationToken
)
If
param
IsNot
Nothing
AndAlso
param
.
Name
.
Length
>
0
Then
spans
.
Add
(
New
InlineParameterHint
(
param
.
GetSymbolKey
(),
param
.
Name
,
simpleArgument
.
Span
.
Start
))
spans
.
Add
(
New
InlineParameterHint
(
param
.
GetSymbolKey
(
cancellationToken
),
param
.
Name
,
simpleArgument
.
Span
.
Start
))
End
If
End
If
End
If
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录