Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
07c8cac3
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,发现更多精彩内容 >>
提交
07c8cac3
编写于
5月 24, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support lists in Quick Info
上级
93bd62b3
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
557 addition
and
4 deletion
+557
-4
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
...ditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
+57
-3
src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs
...es/Test/DocCommentFormatting/DocCommentFormattingTests.cs
+1
-1
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Lists.vb
...2/IntelliSense/IntellisenseQuickInfoBuilderTests_Lists.vb
+381
-0
src/Features/Core/Portable/Common/TextTags.cs
src/Features/Core/Portable/Common/TextTags.cs
+2
-0
src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs
...Comments/AbstractDocumentationCommentFormattingService.cs
+116
-0
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
浏览文件 @
07c8cac3
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.VisualStudio.Text.Adornments
;
using
Microsoft.VisualStudio.Text.Adornments
;
using
Roslyn.Utilities
;
using
Roslyn.Utilities
;
...
@@ -10,18 +12,70 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
...
@@ -10,18 +12,70 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
internal
static
class
Helpers
internal
static
class
Helpers
{
{
internal
static
IEnumerable
<
object
>
BuildClassifiedTextElements
(
ImmutableArray
<
TaggedText
>
taggedTexts
)
internal
static
IEnumerable
<
object
>
BuildClassifiedTextElements
(
ImmutableArray
<
TaggedText
>
taggedTexts
)
{
var
index
=
0
;
return
BuildClassifiedTextElements
(
taggedTexts
,
ref
index
);
}
private
static
IReadOnlyCollection
<
object
>
BuildClassifiedTextElements
(
ImmutableArray
<
TaggedText
>
taggedTexts
,
ref
int
index
)
{
{
// This method produces a sequence of zero or more paragraphs
// This method produces a sequence of zero or more paragraphs
var
paragraphs
=
new
List
<
object
>();
var
paragraphs
=
new
List
<
object
>();
// Each paragraph is constructed from one or more lines
// Each paragraph is constructed from one or more lines
var
currentParagraph
=
new
List
<
ClassifiedTextElemen
t
>();
var
currentParagraph
=
new
List
<
objec
t
>();
// Each line is constructed from one or more inline elements
// Each line is constructed from one or more inline elements
var
currentRuns
=
new
List
<
ClassifiedTextRun
>();
var
currentRuns
=
new
List
<
ClassifiedTextRun
>();
for
each
(
var
part
in
taggedTexts
)
for
(;
index
<
taggedTexts
.
Length
;
index
++
)
{
{
var
part
=
taggedTexts
[
index
];
if
(
part
.
Tag
==
TextTags
.
ContainerStart
)
{
if
(
currentRuns
.
Count
>
0
)
{
// This line break means the end of a line within a paragraph.
currentParagraph
.
Add
(
new
ClassifiedTextElement
(
currentRuns
));
currentRuns
.
Clear
();
}
index
++;
var
nestedElements
=
BuildClassifiedTextElements
(
taggedTexts
,
ref
index
);
if
(
nestedElements
.
Count
<=
1
)
{
currentParagraph
.
Add
(
new
ContainerElement
(
ContainerElementStyle
.
Wrapped
,
new
ClassifiedTextElement
(
new
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
part
.
Text
)),
new
ContainerElement
(
ContainerElementStyle
.
Stacked
,
nestedElements
)));
}
else
{
currentParagraph
.
Add
(
new
ContainerElement
(
ContainerElementStyle
.
Wrapped
,
new
ClassifiedTextElement
(
new
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
part
.
Text
)),
new
ContainerElement
(
ContainerElementStyle
.
Stacked
,
nestedElements
.
First
(),
new
ContainerElement
(
ContainerElementStyle
.
Stacked
|
ContainerElementStyle
.
VerticalPadding
,
nestedElements
.
Skip
(
1
)))));
}
continue
;
}
else
if
(
part
.
Tag
==
TextTags
.
ContainerEnd
)
{
// Return the current result and let the caller continue
break
;
}
if
(
part
.
Tag
==
TextTags
.
ContainerStart
||
part
.
Tag
==
TextTags
.
ContainerEnd
)
{
continue
;
}
if
(
part
.
Tag
==
TextTags
.
LineBreak
)
if
(
part
.
Tag
==
TextTags
.
LineBreak
)
{
{
if
(
currentRuns
.
Count
>
0
)
if
(
currentRuns
.
Count
>
0
)
...
@@ -72,7 +126,7 @@ internal static IEnumerable<object> BuildClassifiedTextElements(ImmutableArray<T
...
@@ -72,7 +126,7 @@ internal static IEnumerable<object> BuildClassifiedTextElements(ImmutableArray<T
return
paragraphs
;
return
paragraphs
;
}
}
internal
static
object
CreateParagraphFromLines
(
IReadOnlyList
<
ClassifiedTextElemen
t
>
lines
)
internal
static
object
CreateParagraphFromLines
(
IReadOnlyList
<
objec
t
>
lines
)
{
{
Contract
.
ThrowIfFalse
(
lines
.
Count
>
0
);
Contract
.
ThrowIfFalse
(
lines
.
Count
>
0
);
...
...
src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs
浏览文件 @
07c8cac3
...
@@ -66,7 +66,7 @@ public void ListTag()
...
@@ -66,7 +66,7 @@ public void ListTag()
</item>
</item>
</list>"
;
</list>"
;
var
expected
=
@"Here is an example of a bulleted list: Item 1.
Item 2."
;
var
expected
=
"Here is an example of a bulleted list:\r\n\r\n• Item 1.\r\n•
Item 2."
;
TestFormat
(
comment
,
expected
);
TestFormat
(
comment
,
expected
);
}
}
...
...
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Lists.vb
0 → 100644
浏览文件 @
07c8cac3
此差异已折叠。
点击以展开。
src/Features/Core/Portable/Common/TextTags.cs
浏览文件 @
07c8cac3
...
@@ -39,5 +39,7 @@ public static class TextTags
...
@@ -39,5 +39,7 @@ public static class TextTags
public
const
string
EnumMember
=
nameof
(
EnumMember
);
public
const
string
EnumMember
=
nameof
(
EnumMember
);
public
const
string
ExtensionMethod
=
nameof
(
ExtensionMethod
);
public
const
string
ExtensionMethod
=
nameof
(
ExtensionMethod
);
public
const
string
Constant
=
nameof
(
Constant
);
public
const
string
Constant
=
nameof
(
Constant
);
internal
const
string
ContainerStart
=
nameof
(
ContainerStart
);
internal
const
string
ContainerEnd
=
nameof
(
ContainerEnd
);
}
}
}
}
src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs
浏览文件 @
07c8cac3
...
@@ -11,6 +11,14 @@ namespace Microsoft.CodeAnalysis.DocumentationComments
...
@@ -11,6 +11,14 @@ namespace Microsoft.CodeAnalysis.DocumentationComments
{
{
internal
abstract
class
AbstractDocumentationCommentFormattingService
:
IDocumentationCommentFormattingService
internal
abstract
class
AbstractDocumentationCommentFormattingService
:
IDocumentationCommentFormattingService
{
{
private
enum
DocumentationCommentListType
{
None
,
Bullet
,
Number
,
Table
,
}
private
class
FormatterState
private
class
FormatterState
{
{
private
bool
_anyNonWhitespaceSinceLastPara
;
private
bool
_anyNonWhitespaceSinceLastPara
;
...
@@ -22,6 +30,7 @@ private class FormatterState
...
@@ -22,6 +30,7 @@ private class FormatterState
private
static
TaggedText
s_newlinePart
=
new
TaggedText
(
TextTags
.
LineBreak
,
"\r\n"
);
private
static
TaggedText
s_newlinePart
=
new
TaggedText
(
TextTags
.
LineBreak
,
"\r\n"
);
internal
readonly
List
<
TaggedText
>
Builder
=
new
List
<
TaggedText
>();
internal
readonly
List
<
TaggedText
>
Builder
=
new
List
<
TaggedText
>();
private
readonly
List
<(
DocumentationCommentListType
type
,
int
index
,
bool
renderedItem
)>
_listStack
=
new
List
<(
DocumentationCommentListType
type
,
int
index
,
bool
renderedItem
)>();
internal
SemanticModel
SemanticModel
{
get
;
set
;
}
internal
SemanticModel
SemanticModel
{
get
;
set
;
}
internal
int
Position
{
get
;
set
;
}
internal
int
Position
{
get
;
set
;
}
...
@@ -59,6 +68,45 @@ public void AppendParts(IEnumerable<TaggedText> parts)
...
@@ -59,6 +68,45 @@ public void AppendParts(IEnumerable<TaggedText> parts)
_anyNonWhitespaceSinceLastPara
=
true
;
_anyNonWhitespaceSinceLastPara
=
true
;
}
}
public
void
PushList
(
DocumentationCommentListType
listType
)
{
_listStack
.
Add
((
listType
,
0
,
false
));
MarkBeginOrEndPara
();
}
public
void
NextListItem
()
{
if
(
_listStack
.
Count
==
0
)
{
return
;
}
var
(
type
,
index
,
renderedItem
)
=
_listStack
[
_listStack
.
Count
-
1
];
if
(
renderedItem
)
{
Builder
.
Add
(
new
TaggedText
(
TextTags
.
ContainerEnd
,
string
.
Empty
));
}
_listStack
[
_listStack
.
Count
-
1
]
=
(
type
,
index
+
1
,
false
);
MarkLineBreak
();
}
public
void
PopList
()
{
if
(
_listStack
.
Count
==
0
)
{
return
;
}
if
(
_listStack
[
_listStack
.
Count
-
1
].
renderedItem
)
{
Builder
.
Add
(
new
TaggedText
(
TextTags
.
ContainerEnd
,
string
.
Empty
));
}
_listStack
.
RemoveAt
(
_listStack
.
Count
-
1
);
MarkBeginOrEndPara
();
}
public
void
MarkBeginOrEndPara
()
public
void
MarkBeginOrEndPara
()
{
{
// If this is a <para> with nothing before it, then skip it.
// If this is a <para> with nothing before it, then skip it.
...
@@ -120,6 +168,33 @@ private void EmitPendingChars()
...
@@ -120,6 +168,33 @@ private void EmitPendingChars()
_pendingParagraphBreak
=
false
;
_pendingParagraphBreak
=
false
;
_pendingLineBreak
=
false
;
_pendingLineBreak
=
false
;
_pendingSingleSpace
=
false
;
_pendingSingleSpace
=
false
;
for
(
var
i
=
0
;
i
<
_listStack
.
Count
;
i
++)
{
if
(
_listStack
[
i
].
renderedItem
)
{
continue
;
}
switch
(
_listStack
[
i
].
type
)
{
case
DocumentationCommentListType
.
Bullet
:
Builder
.
Add
(
new
TaggedText
(
TextTags
.
ContainerStart
,
"• "
));
break
;
case
DocumentationCommentListType
.
Number
:
Builder
.
Add
(
new
TaggedText
(
TextTags
.
ContainerStart
,
$"
{
_listStack
[
i
].
index
}
. "
));
break
;
case
DocumentationCommentListType
.
Table
:
case
DocumentationCommentListType
.
None
:
default
:
Builder
.
Add
(
new
TaggedText
(
TextTags
.
ContainerStart
,
string
.
Empty
));
break
;
}
_listStack
[
i
]
=
(
_listStack
[
i
].
type
,
_listStack
[
i
].
index
,
renderedItem
:
true
);
}
}
}
}
}
...
@@ -204,6 +279,36 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
...
@@ -204,6 +279,36 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
return
;
return
;
}
}
if
(
name
==
DocumentationCommentXmlNames
.
ListElementName
)
{
var
rawListType
=
element
.
Attribute
(
DocumentationCommentXmlNames
.
TypeAttributeName
)?.
Value
;
DocumentationCommentListType
listType
;
switch
(
rawListType
)
{
case
"table"
:
listType
=
DocumentationCommentListType
.
Table
;
break
;
case
"number"
:
listType
=
DocumentationCommentListType
.
Number
;
break
;
case
"bullet"
:
listType
=
DocumentationCommentListType
.
Bullet
;
break
;
default
:
listType
=
DocumentationCommentListType
.
None
;
break
;
}
state
.
PushList
(
listType
);
}
else
if
(
name
==
DocumentationCommentXmlNames
.
ItemElementName
)
{
state
.
NextListItem
();
}
if
(
name
==
DocumentationCommentXmlNames
.
ParaElementName
if
(
name
==
DocumentationCommentXmlNames
.
ParaElementName
||
name
==
DocumentationCommentXmlNames
.
CodeElementName
)
||
name
==
DocumentationCommentXmlNames
.
CodeElementName
)
{
{
...
@@ -224,6 +329,17 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
...
@@ -224,6 +329,17 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
{
{
state
.
MarkBeginOrEndPara
();
state
.
MarkBeginOrEndPara
();
}
}
if
(
name
==
DocumentationCommentXmlNames
.
ListElementName
)
{
state
.
PopList
();
}
if
(
name
==
DocumentationCommentXmlNames
.
TermElementName
)
{
state
.
AppendSingleSpace
();
state
.
AppendString
(
"–"
);
}
}
}
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
XAttribute
attribute
,
string
attributeNameToParse
,
SymbolDisplayPartKind
kind
)
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
XAttribute
attribute
,
string
attributeNameToParse
,
SymbolDisplayPartKind
kind
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录