Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1efb97af
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,发现更多精彩内容 >>
提交
1efb97af
编写于
8月 26, 2015
作者:
D
Dustin Campbell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properly support indentation within text of XML doc comment on ENTER
上级
47e6da37
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
302 addition
and
7 deletion
+302
-7
src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs
...rpTest/DocumentationComments/DocumentationCommentTests.cs
+150
-0
src/EditorFeatures/Core/Implementation/DocumentationComments/AbstractDocumentationCommentCommandHandler.cs
...ionComments/AbstractDocumentationCommentCommandHandler.cs
+27
-7
src/EditorFeatures/VisualBasicTest/DocumentationComments/DocumentationCommentTests.vb
...icTest/DocumentationComments/DocumentationCommentTests.vb
+125
-0
未找到文件。
src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs
浏览文件 @
1efb97af
...
...
@@ -1114,6 +1114,156 @@ void M()
VerifyPressingEnter
(
code
,
expected
);
}
[
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
PressingEnter_Indentation1
()
{
const
string
code
=
@"class C
{
/// <summary>
/// hello world$$
/// </summary>
void M()
{
}
}"
;
const
string
expected
=
@"class C
{
/// <summary>
/// hello world
/// $$
/// </summary>
void M()
{
}
}"
;
VerifyPressingEnter
(
code
,
expected
);
}
[
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
PressingEnter_Indentation2
()
{
const
string
code
=
@"class C
{
/// <summary>
/// hello $$world
/// </summary>
void M()
{
}
}"
;
const
string
expected
=
@"class C
{
/// <summary>
/// hello
/// $$world
/// </summary>
void M()
{
}
}"
;
VerifyPressingEnter
(
code
,
expected
);
}
[
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
PressingEnter_Indentation3
()
{
const
string
code
=
@"class C
{
/// <summary>
/// hello$$ world
/// </summary>
void M()
{
}
}"
;
const
string
expected
=
@"class C
{
/// <summary>
/// hello
/// $$world
/// </summary>
void M()
{
}
}"
;
VerifyPressingEnter
(
code
,
expected
);
}
[
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
PressingEnter_Indentation4
()
{
const
string
code
=
@"class C
{
/// <summary>
/// $$hello world
/// </summary>
void M()
{
}
}"
;
const
string
expected
=
@"class C
{
/// <summary>
///
/// $$hello world
/// </summary>
void M()
{
}
}"
;
VerifyPressingEnter
(
code
,
expected
);
}
[
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
PressingEnter_Indentation5_UseTabs
()
{
const
string
code
=
@"class C
{
/// <summary>
/// hello world$$
/// </summary>
void M()
{
}
}"
;
const
string
expected
=
@"class C
{
/// <summary>
/// hello world
/// $$
/// </summary>
void M()
{
}
}"
;
VerifyPressingEnter
(
code
,
expected
,
useTabs
:
true
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)]
public
void
Command_Class
()
{
...
...
src/EditorFeatures/Core/Implementation/DocumentationComments/AbstractDocumentationCommentCommandHandler.cs
浏览文件 @
1efb97af
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.Editor.Commands
;
using
Microsoft.CodeAnalysis.Editor.Host
;
...
...
@@ -657,20 +658,39 @@ private void InsertExteriorTriviaIfNeeded(ITextView view, ITextBuffer subjectBuf
private
void
InsertExteriorTrivia
(
ITextView
view
,
ITextBuffer
subjectBuffer
,
TextLine
currentLine
,
TextLine
previousLine
)
{
var
useTabs
=
subjectBuffer
.
GetOption
(
FormattingOptions
.
UseTabs
);
var
tabSize
=
subjectBuffer
.
GetOption
(
FormattingOptions
.
TabSize
);
var
firstNonWhitespaceColumn
=
previousLine
.
GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine
(
tabSize
);
var
indentText
=
firstNonWhitespaceColumn
.
CreateIndentationString
(
useTabs
,
tabSize
)
+
ExteriorTriviaText
+
" "
;
var
insertionText
=
CreateInsertionTextFromPreviousLine
(
previousLine
,
subjectBuffer
);
var
firstNonWhitespaceOffset
=
currentLine
.
GetFirstNonWhitespaceOffset
();
var
replaceSpan
=
firstNonWhitespaceOffset
!=
null
?
TextSpan
.
FromBounds
(
currentLine
.
Start
,
currentLine
.
Start
+
firstNonWhitespaceOffset
.
Value
)
:
currentLine
.
Span
;
subjectBuffer
.
Replace
(
replaceSpan
.
ToSpan
(),
indentText
);
subjectBuffer
.
Replace
(
replaceSpan
.
ToSpan
(),
insertionText
);
view
.
TryMoveCaretToAndEnsureVisible
(
subjectBuffer
.
CurrentSnapshot
.
GetPoint
(
replaceSpan
.
Start
+
insertionText
.
Length
));
}
private
string
CreateInsertionTextFromPreviousLine
(
TextLine
previousLine
,
ITextBuffer
subjectBuffer
)
{
var
useTabs
=
subjectBuffer
.
GetOption
(
FormattingOptions
.
UseTabs
);
var
tabSize
=
subjectBuffer
.
GetOption
(
FormattingOptions
.
TabSize
);
var
previousLineText
=
previousLine
.
ToString
();
var
firstNonWhitespaceColumn
=
previousLineText
.
GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine
(
tabSize
);
var
trimmedPreviousLine
=
previousLineText
.
Trim
();
Debug
.
Assert
(
trimmedPreviousLine
.
StartsWith
(
ExteriorTriviaText
),
"Unexpected: previous line does not begin with doc comment exterior trivia."
);
// skip exterior trivia.
trimmedPreviousLine
=
trimmedPreviousLine
.
Substring
(
3
);
var
firstNonWhitespaceOffsetInPreviousXmlText
=
trimmedPreviousLine
.
GetFirstNonWhitespaceOffset
();
var
extraIndent
=
firstNonWhitespaceOffsetInPreviousXmlText
!=
null
?
trimmedPreviousLine
.
Substring
(
0
,
firstNonWhitespaceOffsetInPreviousXmlText
.
Value
)
:
" "
;
view
.
TryMoveCaretToAndEnsureVisible
(
subjectBuffer
.
CurrentSnapshot
.
GetPoint
(
replaceSpan
.
Start
+
indentText
.
Length
))
;
return
firstNonWhitespaceColumn
.
CreateIndentationString
(
useTabs
,
tabSize
)
+
ExteriorTriviaText
+
extraIndent
;
}
private
bool
CurrentLineStartsWithExteriorTrivia
(
ITextBuffer
subjectBuffer
,
int
position
)
...
...
src/EditorFeatures/VisualBasicTest/DocumentationComments/DocumentationCommentTests.vb
浏览文件 @
1efb97af
...
...
@@ -611,6 +611,131 @@ End Class
VerifyPressingEnter
(
code
,
expected
)
End
Sub
<
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
PressingEnter_Indentation1
()
Const
code
=
"
Class C
''' <summary>
''' hello world$$
''' </summary>
Sub M()
End Sub
End Class
"
Const
expected
=
"
Class C
''' <summary>
''' hello world
''' $$
''' </summary>
Sub M()
End Sub
End Class
"
VerifyPressingEnter
(
code
,
expected
)
End
Sub
<
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
PressingEnter_Indentation2
()
Const
code
=
"
Class C
''' <summary>
''' hello $$world
''' </summary>
Sub M()
End Sub
End Class
"
Const
expected
=
"
Class C
''' <summary>
''' hello
''' $$world
''' </summary>
Sub M()
End Sub
End Class
"
VerifyPressingEnter
(
code
,
expected
)
End
Sub
<
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
PressingEnter_Indentation3
()
Const
code
=
"
Class C
''' <summary>
''' hello$$ world
''' </summary>
Sub M()
End Sub
End Class
"
Const
expected
=
"
Class C
''' <summary>
''' hello
''' $$world
''' </summary>
Sub M()
End Sub
End Class
"
VerifyPressingEnter
(
code
,
expected
)
End
Sub
<
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
PressingEnter_Indentation4
()
Const
code
=
"
Class C
''' <summary>
''' $$hello world
''' </summary>
Sub M()
End Sub
End Class
"
Const
expected
=
"
Class C
''' <summary>
'''
''' $$hello world
''' </summary>
Sub M()
End Sub
End Class
"
VerifyPressingEnter
(
code
,
expected
)
End
Sub
<
WorkItem
(
2108
,
"https://github.com/dotnet/roslyn/issues/2108"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
PressingEnter_Indentation5_UseTabs
()
Const
code
=
"
Class C
''' <summary>
''' hello world$$
''' </summary>
Sub M()
End Sub
End Class
"
Const
expected
=
"
Class C
''' <summary>
''' hello world
''' $$
''' </summary>
Sub M()
End Sub
End Class
"
VerifyPressingEnter
(
code
,
expected
,
useTabs
:
=
True
)
End
Sub
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
DocumentationComments
)
>
Public
Sub
Command_Class
()
Const
code
=
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录