Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bca104c3
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,发现更多精彩内容 >>
提交
bca104c3
编写于
4月 28, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Validate Quick Info hyperlinks
上级
23634733
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
106 addition
and
19 deletion
+106
-19
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsAdornmentTaggerProvider.cs
...Diagnostics/AbstractDiagnosticsAdornmentTaggerProvider.cs
+2
-6
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
...ditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
+13
-10
src/EditorFeatures/Core/Implementation/IntelliSense/QuickInfo/QuickInfoHyperLink.cs
...plementation/IntelliSense/QuickInfo/QuickInfoHyperLink.cs
+59
-0
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Links.vb
...2/IntelliSense/IntellisenseQuickInfoBuilderTests_Links.vb
+3
-2
src/EditorFeatures/TestUtilities/QuickInfo/ToolTipAssert.cs
src/EditorFeatures/TestUtilities/QuickInfo/ToolTipAssert.cs
+29
-1
未找到文件。
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsAdornmentTaggerProvider.cs
浏览文件 @
bca104c3
...
...
@@ -8,6 +8,7 @@
using
System.Threading
;
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.VisualStudio.Text
;
...
...
@@ -59,12 +60,7 @@ protected object CreateToolTipContent(Workspace workspace, DiagnosticData diagno
&&
diagnostic
.
HelpLink
is
{
}
helpLink
&&
Uri
.
TryCreate
(
helpLink
,
UriKind
.
Absolute
,
out
var
helpLinkUri
))
{
navigationAction
=
()
=>
{
var
navigateToLinkService
=
workspace
.
Services
.
GetRequiredService
<
INavigateToLinkService
>();
_
=
navigateToLinkService
.
TryNavigateToLinkAsync
(
helpLinkUri
,
CancellationToken
.
None
);
};
navigationAction
=
new
QuickInfoHyperLink
(
workspace
,
helpLinkUri
).
NavigationAction
;
tooltip
=
helpLink
;
}
...
...
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
浏览文件 @
bca104c3
...
...
@@ -10,6 +10,7 @@
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.CodeAnalysis.Editor.GoToDefinition
;
using
Microsoft.CodeAnalysis.Editor.Host
;
using
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
;
using
Microsoft.VisualStudio.Text.Adornments
;
using
Roslyn.Utilities
;
...
...
@@ -118,9 +119,18 @@ private static IReadOnlyCollection<object> BuildInteractiveTextElements(Immutabl
var
style
=
GetClassifiedTextRunStyle
(
part
.
Style
);
if
(
part
.
NavigationTarget
is
object
)
{
var
target
=
part
.
NavigationTarget
;
var
tooltip
=
part
.
NavigationHint
;
currentRuns
.
Add
(
new
ClassifiedTextRun
(
part
.
Tag
.
ToClassificationTypeName
(),
part
.
Text
,
()
=>
NavigateToQuickInfoTarget
(
target
,
document
,
streamingPresenter
.
Value
),
tooltip
,
style
));
if
(
Uri
.
TryCreate
(
part
.
NavigationTarget
,
UriKind
.
Absolute
,
out
var
absoluteUri
))
{
var
target
=
new
QuickInfoHyperLink
(
document
.
Project
.
Solution
.
Workspace
,
absoluteUri
);
var
tooltip
=
part
.
NavigationHint
;
currentRuns
.
Add
(
new
ClassifiedTextRun
(
part
.
Tag
.
ToClassificationTypeName
(),
part
.
Text
,
target
.
NavigationAction
,
tooltip
,
style
));
}
else
{
var
target
=
part
.
NavigationTarget
;
var
tooltip
=
part
.
NavigationHint
;
currentRuns
.
Add
(
new
ClassifiedTextRun
(
part
.
Tag
.
ToClassificationTypeName
(),
part
.
Text
,
()
=>
NavigateToQuickInfoTarget
(
target
,
document
,
streamingPresenter
.
Value
),
tooltip
,
style
));
}
}
else
{
...
...
@@ -148,13 +158,6 @@ private static IReadOnlyCollection<object> BuildInteractiveTextElements(Immutabl
private
static
void
NavigateToQuickInfoTarget
(
string
navigationTarget
,
Document
document
,
IStreamingFindUsagesPresenter
streamingPresenter
)
{
var
navigateToLinkService
=
document
.
Project
.
Solution
.
Workspace
.
Services
.
GetRequiredService
<
INavigateToLinkService
>();
if
(
Uri
.
TryCreate
(
navigationTarget
,
UriKind
.
Absolute
,
out
var
absoluteUri
))
{
navigateToLinkService
.
TryNavigateToLinkAsync
(
absoluteUri
,
CancellationToken
.
None
);
return
;
}
SymbolKeyResolution
resolvedSymbolKey
;
try
{
...
...
src/EditorFeatures/Core/Implementation/IntelliSense/QuickInfo/QuickInfoHyperLink.cs
0 → 100644
浏览文件 @
bca104c3
// 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.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Threading
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
{
internal
sealed
class
QuickInfoHyperLink
:
IEquatable
<
QuickInfoHyperLink
?>
{
private
readonly
Workspace
_workspace
;
public
QuickInfoHyperLink
(
Workspace
workspace
,
Uri
uri
)
{
_workspace
=
workspace
;
Uri
=
uri
;
NavigationAction
=
OpenLink
;
}
public
Action
NavigationAction
{
get
;
}
public
Uri
Uri
{
get
;
}
public
override
bool
Equals
(
object
?
obj
)
{
return
Equals
(
obj
as
QuickInfoHyperLink
);
}
public
bool
Equals
(
QuickInfoHyperLink
?
other
)
{
return
EqualityComparer
<
Uri
?>.
Default
.
Equals
(
Uri
,
other
?.
Uri
);
}
public
override
int
GetHashCode
()
{
return
Uri
.
GetHashCode
();
}
private
void
OpenLink
()
{
var
navigateToLinkService
=
_workspace
.
Services
.
GetRequiredService
<
INavigateToLinkService
>();
_
=
navigateToLinkService
.
TryNavigateToLinkAsync
(
Uri
,
CancellationToken
.
None
);
}
internal
readonly
struct
TestAccessor
{
public
static
Action
CreateNavigationAction
(
Uri
uri
)
{
// The workspace is not validated by tests
return
new
QuickInfoHyperLink
(
null
!,
uri
).
NavigationAction
;
}
}
}
}
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Links.vb
浏览文件 @
bca104c3
...
...
@@ -3,6 +3,7 @@
' See the LICENSE file in the project root for more information.
Imports
Microsoft.CodeAnalysis.Classification
Imports
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
Imports
Microsoft.CodeAnalysis.Test.Utilities.QuickInfo
Imports
Microsoft.VisualStudio.Core.Imaging
Imports
Microsoft.VisualStudio.Imaging
...
...
@@ -53,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"This contains a link to"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"https://github.com/dotnet/roslyn"
,
navigationAction
:
=
Sub
()
Return
,
"https://github.com/dotnet/roslyn"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"https://github.com/dotnet/roslyn"
,
QuickInfoHyperLink
.
TestAccessor
.
CreateNavigationAction
(
New
Uri
(
"https://github.com/dotnet/roslyn"
,
UriKind
.
Absolute
))
,
"https://github.com/dotnet/roslyn"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"."
))))
ToolTipAssert
.
EqualContent
(
expected
,
intellisenseQuickInfo
.
Item
)
...
...
@@ -100,7 +101,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"This contains a link to"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"dotnet/roslyn"
,
navigationAction
:
=
Sub
()
Return
,
"https://github.com/dotnet/roslyn"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"dotnet/roslyn"
,
QuickInfoHyperLink
.
TestAccessor
.
CreateNavigationAction
(
New
Uri
(
"https://github.com/dotnet/roslyn"
,
UriKind
.
Absolute
))
,
"https://github.com/dotnet/roslyn"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"."
))))
ToolTipAssert
.
EqualContent
(
expected
,
intellisenseQuickInfo
.
Item
)
...
...
src/EditorFeatures/TestUtilities/QuickInfo/ToolTipAssert.cs
浏览文件 @
bca104c3
...
...
@@ -8,6 +8,7 @@
using
System.Linq
;
using
System.Text
;
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
;
using
Microsoft.VisualStudio.Core.Imaging
;
using
Microsoft.VisualStudio.Imaging
;
using
Microsoft.VisualStudio.Text.Adornments
;
...
...
@@ -94,6 +95,24 @@ private static void EqualClassifiedTextRun(ClassifiedTextRun expected, Classifie
Assert
.
Equal
(
expected
.
Text
,
actual
.
Text
);
Assert
.
Equal
(
expected
.
Tooltip
,
actual
.
Tooltip
);
Assert
.
Equal
(
expected
.
Style
,
actual
.
Style
);
if
(
expected
.
NavigationAction
is
null
)
{
Assert
.
Equal
(
expected
.
NavigationAction
,
actual
.
NavigationAction
);
}
else
if
(
expected
.
NavigationAction
.
Target
is
QuickInfoHyperLink
hyperLink
)
{
Assert
.
Same
(
expected
.
NavigationAction
,
hyperLink
.
NavigationAction
);
var
actualTarget
=
Assert
.
IsType
<
QuickInfoHyperLink
>(
actual
.
NavigationAction
.
Target
);
Assert
.
Same
(
actual
.
NavigationAction
,
actualTarget
.
NavigationAction
);
Assert
.
Equal
(
hyperLink
,
actualTarget
);
}
else
{
// Cannot validate this navigation action
Assert
.
NotNull
(
actual
.
NavigationAction
);
Assert
.
IsNotType
<
QuickInfoHyperLink
>(
actual
.
NavigationAction
.
Target
);
}
}
private
static
string
ContainerToString
(
object
element
)
...
...
@@ -159,7 +178,16 @@ private static void ContainerToString(object element, string indent, StringBuild
if
(
classifiedTextRun
.
NavigationAction
is
object
||
!
string
.
IsNullOrEmpty
(
classifiedTextRun
.
Tooltip
))
{
var
tooltip
=
classifiedTextRun
.
Tooltip
is
object
?
$"\"
{
classifiedTextRun
.
Tooltip
.
Replace
(
"\""
,
"\"\""
)}
\""
:
"Nothing"
;
result
.
Append
(
$", navigationAction:=Sub() Return,
{
tooltip
}
"
);
if
(
classifiedTextRun
.
NavigationAction
?.
Target
is
QuickInfoHyperLink
hyperLink
)
{
result
.
Append
(
$", QuickInfoHyperLink.TestAccessor.CreateNavigationAction(new Uri(\"
{
hyperLink
.
Uri
}
\", UriKind.Absolute))"
);
}
else
{
result
.
Append
(
", navigationAction:=Sub() Return"
);
}
result
.
Append
(
$",
{
tooltip
}
"
);
}
if
(
classifiedTextRun
.
Style
!=
ClassifiedTextRunStyle
.
Plain
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录