Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a740f664
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 搜索 >>
提交
a740f664
编写于
6月 17, 2020
作者:
A
Ankita Khera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial logic for tagging
上级
5c5d58d0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
199 addition
and
0 deletion
+199
-0
src/EditorFeatures/Core.Wpf/InlineParamNameHints/InlineParamNameHintsTag.cs
.../Core.Wpf/InlineParamNameHints/InlineParamNameHintsTag.cs
+37
-0
src/EditorFeatures/Core.Wpf/InlineParamNameHints/InlineParamNameHintsTaggerProvider.cs
...nlineParamNameHints/InlineParamNameHintsTaggerProvider.cs
+57
-0
src/Features/CSharp/Portable/InlineParameterNameHints/InlineParamNameHintsService.cs
...e/InlineParameterNameHints/InlineParamNameHintsService.cs
+87
-0
src/Features/Core/Portable/InlineParameterNameHints/IInlineParamNameHintsService.cs
.../InlineParameterNameHints/IInlineParamNameHintsService.cs
+17
-0
src/Workspaces/Core/Portable/Shared/TestHooks/FeatureAttribute_Names.cs
.../Core/Portable/Shared/TestHooks/FeatureAttribute_Names.cs
+1
-0
未找到文件。
src/EditorFeatures/Core.Wpf/InlineParamNameHints/InlineParamNameHintsTag.cs
0 → 100644
浏览文件 @
a740f664
using
System.Windows
;
using
System.Windows.Controls
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Formatting
;
namespace
Microsoft.CodeAnalysis.Editor.CSharp.InlineParamNameHints
{
class
InlineParamHintsTag
:
IntraTextAdornmentTag
{
public
readonly
int
TagLength
;
public
InlineParamHintsTag
(
string
text
,
int
tagLength
,
TextFormattingRunProperties
format
)
:
base
(
CreateElement
(
text
,
format
),
null
,
(
tagLength
==
0
)
?
((
PositionAffinity
?)
PositionAffinity
.
Predecessor
)
:
null
)
{
TagLength
=
tagLength
;
}
private
static
UIElement
CreateElement
(
string
text
,
TextFormattingRunProperties
format
)
{
var
block
=
new
TextBox
{
Text
=
text
,
Foreground
=
format
.
ForegroundBrush
,
FontFamily
=
format
.
Typeface
.
FontFamily
,
FontSize
=
format
.
FontRenderingEmSize
,
FontStyle
=
FontStyles
.
Normal
};
block
.
FontSize
=
format
.
FontRenderingEmSize
;
block
.
FontStyle
=
FontStyles
.
Italic
;
//.Oblique;
block
.
Measure
(
new
Size
(
double
.
PositiveInfinity
,
double
.
PositiveInfinity
));
return
block
;
}
}
}
src/EditorFeatures/Core.Wpf/InlineParamNameHints/InlineParamNameHintsTaggerProvider.cs
0 → 100644
浏览文件 @
a740f664
using
System.ComponentModel.Composition
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Tagging
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Editor.Tagging
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.CodeAnalysis.Text.Shared.Extensions
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Formatting
;
using
Microsoft.VisualStudio.Text.Tagging
;
using
Microsoft.VisualStudio.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.CSharp.InlineParamNameHints
{
[
Export
(
typeof
(
IViewTaggerProvider
))]
[
ContentType
(
"csharp"
)]
[
TagType
(
typeof
(
IntraTextAdornmentTag
))]
[
Name
(
"InlineParamNameHintsTaggerProvider"
)]
internal
class
InlineParamNameHintsTaggerProvider
:
AsynchronousTaggerProvider
<
InlineParamHintsTag
>
{
private
TextFormattingRunProperties
_format
;
[
ImportingConstructor
]
public
InlineParamNameHintsTaggerProvider
(
IThreadingContext
threadingContext
,
IAsynchronousOperationListenerProvider
listenerProvider
,
IForegroundNotificationService
notificationService
)
:
base
(
threadingContext
,
listenerProvider
.
GetListener
(
FeatureAttribute
.
InlineParamNameHints
),
notificationService
)
{
}
protected
override
ITaggerEventSource
CreateEventSource
(
ITextView
textViewOpt
,
ITextBuffer
subjectBuffer
)
{
return
TaggerEventSources
.
OnTextChanged
(
subjectBuffer
,
TaggerDelay
.
NearImmediate
);
}
protected
override
async
Task
ProduceTagsAsync
(
TaggerContext
<
InlineParamHintsTag
>
context
,
DocumentSnapshotSpan
documentSnapshotSpan
,
int
?
caretPosition
)
{
var
cancellationToken
=
context
.
CancellationToken
;
var
document
=
documentSnapshotSpan
.
Document
;
var
snapshotSpan
=
documentSnapshotSpan
.
SnapshotSpan
;
var
paramNameHintsService
=
document
.
GetLanguageService
<
InlineParameterNameHintsService
.
IInlineParamNameHintsService
>();
var
paramNameHintSpans
=
await
paramNameHintsService
.
GetInlineParameterNameHintsAsync
(
document
,
snapshotSpan
.
Span
.
ToTextSpan
(),
cancellationToken
).
ConfigureAwait
(
false
);
cancellationToken
.
ThrowIfCancellationRequested
();
foreach
(
var
span
in
paramNameHintSpans
)
{
context
.
AddTag
(
new
TagSpan
<
InlineParamHintsTag
>(
span
.
Item2
.
ToSnapshotSpan
(
snapshotSpan
.
Snapshot
),
new
InlineParamHintsTag
(
span
.
Item1
,
span
.
Item1
.
Length
+
1
,
_format
)));
}
}
}
}
src/Features/CSharp/Portable/InlineParameterNameHints/InlineParamNameHintsService.cs
0 → 100644
浏览文件 @
a740f664
using
System.Collections.Generic
;
using
System.Composition
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.InlineParameterNameHintsService
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
namespace
Microsoft.CodeAnalysis.CSharp.InlineParameterNameHints
{
[
ExportLanguageService
(
typeof
(
IInlineParamNameHintsService
),
LanguageNames
.
CSharp
),
Shared
]
internal
class
InlineParamNameHintsService
:
IInlineParamNameHintsService
{
[
ImportingConstructor
]
public
InlineParamNameHintsService
()
{
}
public
async
Task
<
IEnumerable
<(
string
,
TextSpan
)>>
GetInlineParameterNameHintsAsync
(
Document
document
,
TextSpan
textSpan
,
CancellationToken
cancellationToken
)
{
var
tree
=
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
node
=
await
tree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
spans
=
new
List
<(
string
name
,
TextSpan
span
)>();
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
invocations
=
node
.
Traverse
<
SyntaxNode
>(
textSpan
,
IsInvocationExpression
);
// var invocation = node.DescendantNodes()
foreach
(
var
invocationNode
in
invocations
)
{
var
invo
=
(
InvocationExpressionSyntax
)
invocationNode
;
foreach
(
var
argument
in
invo
.
ArgumentList
.
Arguments
)
{
if
(
argument
.
NameColon
==
null
&&
IsLiteralOrNoNamedExpression
(
argument
))
{
var
param
=
argument
.
DetermineParameter
(
semanticModel
,
cancellationToken
);
spans
.
Add
(
param
.
Name
,
argument
.
Span
);
}
}
}
return
spans
;
}
private
static
bool
IsLiteralOrNoNamedExpression
(
ArgumentSyntax
arg
)
{
if
(
arg
.
Expression
is
LiteralExpressionSyntax
)
{
return
true
;
}
if
(
arg
.
Expression
is
ObjectCreationExpressionSyntax
)
{
return
true
;
}
if
(
arg
.
Expression
is
CastExpressionSyntax
)
{
var
cast
=
(
CastExpressionSyntax
)
arg
.
Expression
;
if
(
cast
.
Expression
is
LiteralExpressionSyntax
)
{
return
true
;
}
return
false
;
}
if
(
arg
.
Expression
is
PrefixUnaryExpressionSyntax
)
{
var
negation
=
(
PrefixUnaryExpressionSyntax
)
arg
.
Expression
;
if
(
negation
.
Operand
is
LiteralExpressionSyntax
)
{
return
true
;
}
return
false
;
}
return
false
;
}
private
static
bool
IsInvocationExpression
(
SyntaxNode
node
)
{
return
node
is
InvocationExpressionSyntax
;
}
}
}
src/Features/Core/Portable/InlineParameterNameHints/IInlineParamNameHintsService.cs
0 → 100644
浏览文件 @
a740f664
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Text
;
namespace
Microsoft.CodeAnalysis.InlineParameterNameHintsService
{
internal
interface
IInlineParamNameHintsService
:
ILanguageService
{
Task
<
IEnumerable
<(
string
,
TextSpan
)>>
GetInlineParameterNameHintsAsync
(
Document
document
,
TextSpan
textSpan
,
CancellationToken
cancellationToken
=
default
);
}
}
src/Workspaces/Core/Portable/Shared/TestHooks/FeatureAttribute_Names.cs
浏览文件 @
a740f664
...
...
@@ -23,6 +23,7 @@ internal partial class FeatureAttribute
public
const
string
GoToImplementation
=
nameof
(
GoToImplementation
);
public
const
string
GraphProvider
=
nameof
(
GraphProvider
);
public
const
string
InfoBar
=
nameof
(
InfoBar
);
public
const
string
InlineParamNameHints
=
nameof
(
InlineParamNameHints
);
public
const
string
KeywordHighlighting
=
nameof
(
KeywordHighlighting
);
public
const
string
LightBulb
=
nameof
(
LightBulb
);
public
const
string
LineSeparators
=
nameof
(
LineSeparators
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录