Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9b9ad519
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,发现更多精彩内容 >>
提交
9b9ad519
编写于
2月 12, 2016
作者:
D
Dustin Campbell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use constants for all tag name and attribute name string literals in VB XML doc comment completion
上级
0deeed44
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
25 deletion
+44
-25
src/EditorFeatures/VisualBasic/Completion/CompletionProviders/XmlDocCommentCompletionProvider.vb
...on/CompletionProviders/XmlDocCommentCompletionProvider.vb
+44
-25
未找到文件。
src/EditorFeatures/VisualBasic/Completion/CompletionProviders/XmlDocCommentCompletionProvider.vb
浏览文件 @
9b9ad519
...
...
@@ -14,6 +14,25 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
Partial
Friend
Class
XmlDocCommentCompletionProvider
Inherits
AbstractDocCommentCompletionProvider
' Tag names
Private
Const
CompletionListTagName
=
"completionlist"
Private
Const
ExampleTagName
=
"example"
Private
Const
ExceptionTagName
=
"exception"
Private
Const
IncludeTagName
=
"include"
Private
Const
ParamTagName
=
"param"
Private
Const
PermissionTagName
=
"permission"
Private
Const
RemarksTagName
=
"remarks"
Private
Const
ReturnsTagName
=
"returns"
Private
Const
SummaryTagName
=
"summary"
Private
Const
TypeParamTagName
=
"typeparam"
Private
Const
ValueTagName
=
"value"
' Attribute names
Private
Const
CrefAttributeName
=
"cref"
Private
Const
ListTagName
=
"list"
Private
Const
ListHeaderTagName
=
"listheader"
Private
Const
NameAttributeName
=
"name"
Public
Overrides
Function
IsTriggerCharacter
(
text
As
SourceText
,
characterPosition
As
Integer
,
options
As
OptionSet
)
As
Boolean
Return
text
(
characterPosition
)
=
"<"
c
OrElse
(
text
(
characterPosition
)
=
"/"
c
AndAlso
characterPosition
>
0
AndAlso
text
(
characterPosition
-
1
)
=
"<"
c
)
End
Function
...
...
@@ -48,7 +67,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
token
.
Parent
.
IsKind
(
SyntaxKind
.
XmlString
)
AndAlso
token
.
Parent
.
Parent
.
IsKind
(
SyntaxKind
.
XmlAttribute
)
Then
Dim
attribute
=
DirectCast
(
token
.
Parent
.
Parent
,
XmlAttributeSyntax
)
Dim
name
=
TryCast
(
attribute
.
Name
,
XmlNameSyntax
)
If
name
IsNot
Nothing
AndAlso
name
.
LocalName
.
ValueText
=
"cref"
Then
If
name
IsNot
Nothing
AndAlso
name
.
LocalName
.
ValueText
=
CrefAttributeName
Then
Return
Nothing
End
If
End
If
...
...
@@ -99,21 +118,21 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
grandParent
.
IsKind
(
SyntaxKind
.
XmlElement
)
Then
items
.
AddRange
(
GetNestedTags
(
span
))
If
GetStartTagName
(
grandParent
)
=
"list"
Then
If
GetStartTagName
(
grandParent
)
=
ListTagName
Then
items
.
AddRange
(
GetListItems
(
span
))
End
If
If
GetStartTagName
(
grandParent
)
=
"listheader"
Then
If
GetStartTagName
(
grandParent
)
=
ListHeaderTagName
Then
items
.
AddRange
(
GetListHeaderItems
(
span
))
End
If
ElseIf
token
.
Parent
.
IsKind
(
SyntaxKind
.
XmlText
)
AndAlso
token
.
Parent
.
Parent
.
IsKind
(
SyntaxKind
.
XmlElement
)
Then
items
.
AddRange
(
GetNestedTags
(
span
))
If
GetStartTagName
(
token
.
Parent
.
Parent
)
=
"list"
Then
If
GetStartTagName
(
token
.
Parent
.
Parent
)
=
ListTagName
Then
items
.
AddRange
(
GetListItems
(
span
))
End
If
If
GetStartTagName
(
token
.
Parent
.
Parent
)
=
"listheader"
Then
If
GetStartTagName
(
token
.
Parent
.
Parent
)
=
ListHeaderTagName
Then
items
.
AddRange
(
GetListHeaderItems
(
span
))
End
If
ElseIf
grandParent
.
IsKind
(
SyntaxKind
.
DocumentationCommentTrivia
)
Then
...
...
@@ -123,11 +142,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
token
.
Parent
.
IsKind
(
SyntaxKind
.
XmlElementStartTag
,
SyntaxKind
.
XmlName
)
Then
If
parentElement
.
IsParentKind
(
SyntaxKind
.
XmlElement
)
Then
If
GetStartTagName
(
parentElement
.
Parent
)
=
"list"
Then
If
GetStartTagName
(
parentElement
.
Parent
)
=
ListTagName
Then
items
.
AddRange
(
GetListItems
(
span
))
End
If
If
GetStartTagName
(
parentElement
.
Parent
)
=
"listheader"
Then
If
GetStartTagName
(
parentElement
.
Parent
)
=
ListHeaderTagName
Then
items
.
AddRange
(
GetListHeaderItems
(
span
))
End
If
End
If
...
...
@@ -209,12 +228,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
attributeName
=
DirectCast
(
targetToken
.
GetAncestor
(
Of
XmlAttributeSyntax
)().
Name
,
XmlNameSyntax
).
LocalName
.
ValueText
End
If
If
attributeName
=
"name"
Then
If
tagName
=
"param"
Then
If
attributeName
=
NameAttributeName
Then
If
tagName
=
ParamTagName
Then
items
.
AddRange
(
symbol
.
GetParameters
().
Select
(
Function
(
s
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
s
.
Name
,
GetCompletionItemRules
())))
End
If
If
tagName
=
"typeparam"
Then
If
tagName
=
TypeParamTagName
Then
items
.
AddRange
(
symbol
.
GetTypeArguments
().
Select
(
Function
(
s
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
s
.
Name
,
GetCompletionItemRules
())))
End
If
End
If
...
...
@@ -256,9 +275,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
Dim
items
=
New
List
(
Of
CompletionItem
)
Dim
typeParameters
=
type
.
GetTypeArguments
().
Select
(
Function
(
t
)
t
.
Name
).
ToSet
()
RemoveExistingTags
(
parent
,
typeParameters
,
Function
(
e
)
FindName
(
"typeparam"
,
e
))
RemoveExistingTags
(
parent
,
typeParameters
,
Function
(
e
)
FindName
(
TypeParamTagName
,
e
))
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
"typeparam"
,
p
),
GetCompletionItemRules
())))
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
TypeParamTagName
,
p
),
GetCompletionItemRules
())))
Return
items
End
Function
...
...
@@ -276,7 +295,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
element
IsNot
Nothing
AndAlso
Not
element
.
StartTag
.
IsMissing
AndAlso
Not
element
.
EndTag
.
IsMissing
Then
Dim
startTag
=
element
.
StartTag
If
startTag
.
ToString
()
=
"value"
Then
If
startTag
.
ToString
()
=
ValueTagName
Then
value
=
False
End
If
End
If
...
...
@@ -284,14 +303,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
[
property
]
.
IsIndexer
Then
Dim
parameters
=
[
property
]
.
Parameters
.
Select
(
Function
(
p
)
p
.
Name
).
ToSet
()
RemoveExistingTags
(
parent
,
parameters
,
Function
(
e
)
FindName
(
"param"
,
e
))
items
.
AddRange
(
parameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
"param"
,
p
),
GetCompletionItemRules
())))
RemoveExistingTags
(
parent
,
parameters
,
Function
(
e
)
FindName
(
ParamTagName
,
e
))
items
.
AddRange
(
parameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
ParamTagName
,
p
),
GetCompletionItemRules
())))
End
If
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
"typeparam"
,
p
),
GetCompletionItemRules
())))
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
TypeParamTagName
,
p
),
GetCompletionItemRules
())))
If
value
Then
items
.
Add
(
GetItem
(
"value"
,
span
))
items
.
Add
(
GetItem
(
ValueTagName
,
span
))
End
If
Return
items
...
...
@@ -304,25 +323,25 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
Dim
typeParameters
=
method
.
TypeParameters
.
Select
(
Function
(
t
)
t
.
Name
).
ToSet
()
Dim
returns
=
True
RemoveExistingTags
(
parent
,
parameters
,
Function
(
e
)
FindName
(
"param"
,
e
))
RemoveExistingTags
(
parent
,
typeParameters
,
Function
(
e
)
FindName
(
"typeparam"
,
e
))
RemoveExistingTags
(
parent
,
parameters
,
Function
(
e
)
FindName
(
ParamTagName
,
e
))
RemoveExistingTags
(
parent
,
typeParameters
,
Function
(
e
)
FindName
(
TypeParamTagName
,
e
))
For
Each
node
In
parent
.
ChildNodes
Dim
element
=
TryCast
(
node
,
XmlElementSyntax
)
If
element
IsNot
Nothing
AndAlso
Not
element
.
StartTag
.
IsMissing
AndAlso
Not
element
.
EndTag
.
IsMissing
Then
Dim
startTag
=
element
.
StartTag
If
startTag
.
ToString
()
=
"returns"
Then
If
startTag
.
ToString
()
=
ReturnsTagName
Then
returns
=
False
End
If
End
If
Next
items
.
AddRange
(
parameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
"param"
,
p
),
GetCompletionItemRules
())))
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
"typeparam"
,
p
),
GetCompletionItemRules
())))
items
.
AddRange
(
parameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
ParamTagName
,
p
),
GetCompletionItemRules
())))
items
.
AddRange
(
typeParameters
.
Select
(
Function
(
p
)
New
XmlDocCommentCompletionItem
(
Me
,
span
,
FormatParameter
(
TypeParamTagName
,
p
),
GetCompletionItemRules
())))
If
returns
Then
items
.
Add
(
GetItem
(
"returns"
,
span
))
items
.
Add
(
GetItem
(
ReturnsTagName
,
span
))
End
If
Return
items
...
...
@@ -334,7 +353,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
If
nameSyntax
.
LocalName
.
ValueText
=
name
Then
Return
startTag
.
Attributes
.
OfType
(
Of
XmlNameAttributeSyntax
)()
_
.
Where
(
Function
(
a
)
a
.
Name
.
ToString
()
=
"name"
)
_
.
Where
(
Function
(
a
)
a
.
Name
.
ToString
()
=
NameAttributeName
)
_
.
Select
(
Function
(
a
)
a
.
Reference
.
Identifier
.
ValueText
)
_
.
FirstOrDefault
()
End
If
...
...
@@ -343,7 +362,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion.CompletionProvide
End
Function
Private
Function
GetSingleUseTopLevelItems
(
parentTrivia
As
DocumentationCommentTriviaSyntax
,
span
As
TextSpan
)
As
IEnumerable
(
Of
CompletionItem
)
Dim
names
=
New
HashSet
(
Of
String
)({
"summary"
,
"remarks"
,
"exception"
,
"include"
,
"permission"
,
"example"
,
"completionlist"
})
Dim
names
=
New
HashSet
(
Of
String
)({
SummaryTagName
,
RemarksTagName
,
ExceptionTagName
,
IncludeTagName
,
PermissionTagName
,
ExampleTagName
,
CompletionListTagName
})
RemoveExistingTags
(
parentTrivia
,
names
,
Function
(
x
)
DirectCast
(
x
.
StartTag
.
Name
,
XmlNameSyntax
).
LocalName
.
ValueText
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录