Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
793e1265
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,发现更多精彩内容 >>
提交
793e1265
编写于
8月 30, 2017
作者:
C
CyrusNajmabadi
提交者:
GitHub
8月 30, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21820 from CyrusNajmabadi/completionCommitFormatting
Formation completion items after commit if they ask for that.
上级
18a9eba1
92a68117
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
13 deletion
+88
-13
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Commit.cs
...plementation/IntelliSense/Completion/Controller_Commit.cs
+16
-0
src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
...Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
+40
-0
src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb
src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb
+32
-10
src/EditorFeatures/TestUtilities2/ServicesTestUtilities2.vbproj
...itorFeatures/TestUtilities2/ServicesTestUtilities2.vbproj
+0
-3
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Commit.cs
浏览文件 @
793e1265
...
...
@@ -7,6 +7,7 @@
using
Microsoft.CodeAnalysis.Completion
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Text.Shared.Extensions
;
using
Microsoft.VisualStudio.Text
;
...
...
@@ -149,6 +150,21 @@ private CompletionProvider GetCompletionProvider(CompletionItem item)
nextHandler
();
}
if
(
item
.
Rules
.
FormatOnCommit
)
{
var
spanToFormat
=
triggerSnapshotSpan
.
TranslateTo
(
this
.
SubjectBuffer
.
CurrentSnapshot
,
SpanTrackingMode
.
EdgeInclusive
);
var
document
=
this
.
GetDocument
();
var
formattingService
=
document
?.
GetLanguageService
<
IEditorFormattingService
>();
if
(
formattingService
!=
null
)
{
var
changes
=
formattingService
.
GetFormattingChangesAsync
(
document
,
spanToFormat
.
Span
.
ToTextSpan
(),
CancellationToken
.
None
).
WaitAndGetResult
(
CancellationToken
.
None
);
document
.
Project
.
Solution
.
Workspace
.
ApplyTextChanges
(
document
.
Id
,
changes
,
CancellationToken
.
None
);
}
}
// If the insertion is long enough, the caret will scroll out of the visible area.
// Re-center the view.
this
.
TextView
.
Caret
.
EnsureVisible
();
...
...
src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb
浏览文件 @
793e1265
...
...
@@ -3314,6 +3314,46 @@ class C
End
Using
End
Sub
<
WorkItem
(
296512
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=296512"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)
>
Public
Async
Function
TestRegionDirectiveIndentation
()
As
Task
Using
state
=
TestState
.
CreateCSharpTestState
(
<
Document
>
class
C
{
$$
}
</
Document
>
,
includeFormatCommandHandler
:
=
True
)
state
.
SendTypeChars
(
"#"
)
Await
state
.
WaitForAsynchronousOperationsAsync
()
Assert
.
Equal
(
"#"
,
state
.
GetLineFromCurrentCaretPosition
().
GetText
())
Await
state
.
AssertNoCompletionSession
()
state
.
SendTypeChars
(
"reg"
)
Await
state
.
AssertSelectedCompletionItem
(
displayText
:
=
"region"
)
state
.
SendReturn
()
Await
state
.
AssertNoCompletionSession
()
Assert
.
Equal
(
" #region"
,
state
.
GetLineFromCurrentCaretPosition
().
GetText
())
Assert
.
Equal
(
state
.
GetLineFromCurrentCaretPosition
().
End
,
state
.
GetCaretPoint
().
BufferPosition
)
state
.
SendReturn
()
Assert
.
Equal
(
""
,
state
.
GetLineFromCurrentCaretPosition
().
GetText
())
state
.
SendTypeChars
(
"#"
)
Await
state
.
WaitForAsynchronousOperationsAsync
()
Assert
.
Equal
(
"#"
,
state
.
GetLineFromCurrentCaretPosition
().
GetText
())
Await
state
.
AssertNoCompletionSession
()
state
.
SendTypeChars
(
"endr"
)
Await
state
.
AssertSelectedCompletionItem
(
displayText
:
=
"endregion"
)
state
.
SendReturn
()
Await
state
.
AssertNoCompletionSession
()
Assert
.
Equal
(
" #endregion"
,
state
.
GetLineFromCurrentCaretPosition
().
GetText
())
Assert
.
Equal
(
state
.
GetLineFromCurrentCaretPosition
().
End
,
state
.
GetCaretPoint
().
BufferPosition
)
End
Using
End
Function
Private
Class
MultipleChangeCompletionProvider
Inherits
CompletionProvider
...
...
src/EditorFeatures/TestUtilities2/Intellisense/TestState.vb
浏览文件 @
793e1265
...
...
@@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Completion
Imports
Microsoft.CodeAnalysis.Editor.CommandHandlers
Imports
Microsoft.CodeAnalysis.Editor.Commands
Imports
Microsoft.CodeAnalysis.Editor.Host
Imports
Microsoft.CodeAnalysis.Editor.Implementation.Formatting
Imports
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion
Imports
Microsoft.CodeAnalysis.Editor.UnitTests
Imports
Microsoft.CodeAnalysis.Host.Mef
...
...
@@ -30,6 +31,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Friend
ReadOnly
AsyncCompletionService
As
IAsyncCompletionService
Friend
ReadOnly
SignatureHelpCommandHandler
As
SignatureHelpCommandHandler
Friend
ReadOnly
FormatCommandHandler
As
FormatCommandHandler
Friend
ReadOnly
CompletionCommandHandler
As
CompletionCommandHandler
Friend
ReadOnly
IntelliSenseCommandHandler
As
IntelliSenseCommandHandler
...
...
@@ -47,6 +49,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
extraCompletionProviders
As
IEnumerable
(
Of
Lazy
(
Of
CompletionProvider
,
OrderableLanguageAndRoleMetadata
)),
extraSignatureHelpProviders
As
IEnumerable
(
Of
Lazy
(
Of
ISignatureHelpProvider
,
OrderableLanguageMetadata
)),
Optional
extraExportedTypes
As
List
(
Of
Type
)
=
Nothing
,
Optional
includeFormatCommandHandler
As
Boolean
=
False
,
Optional
workspaceKind
As
String
=
Nothing
)
MyBase
.
New
(
workspaceElement
,
CreatePartCatalog
(
extraExportedTypes
),
workspaceKind
:
=
workspaceKind
)
...
...
@@ -75,6 +78,13 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
GetExports
(
Of
IAsynchronousOperationListener
,
FeatureMetadata
)())
Me
.
IntelliSenseCommandHandler
=
New
IntelliSenseCommandHandler
(
CompletionCommandHandler
,
SignatureHelpCommandHandler
,
Nothing
)
Me
.
FormatCommandHandler
=
If
(
includeFormatCommandHandler
,
New
FormatCommandHandler
(
GetService
(
Of
IWaitIndicator
),
GetService
(
Of
ITextUndoHistoryRegistry
),
GetService
(
Of
IEditorOperationsFactoryService
)),
Nothing
)
End
Sub
Private
Shared
Function
CreatePartCatalog
(
types
As
List
(
Of
Type
))
As
ComposableCatalog
...
...
@@ -108,7 +118,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
documentElement
As
XElement
,
Optional
extraCompletionProviders
As
CompletionProvider
()
=
Nothing
,
Optional
extraSignatureHelpProviders
As
ISignatureHelpProvider
()
=
Nothing
,
Optional
extraExportedTypes
As
List
(
Of
Type
)
=
Nothing
)
As
TestState
Optional
extraExportedTypes
As
List
(
Of
Type
)
=
Nothing
,
Optional
includeFormatCommandHandler
As
Boolean
=
False
)
As
TestState
Return
New
TestState
(
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
...
...
@@ -119,7 +130,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
</
Workspace
>
,
CreateLazyProviders
(
extraCompletionProviders
,
LanguageNames
.
CSharp
,
roles
:
=
Nothing
),
CreateLazyProviders
(
extraSignatureHelpProviders
,
LanguageNames
.
CSharp
),
extraExportedTypes
)
extraExportedTypes
,
includeFormatCommandHandler
)
End
Function
Public
Shared
Function
CreateTestStateFromWorkspace
(
...
...
@@ -133,7 +145,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
CreateLazyProviders
(
extraCompletionProviders
,
LanguageNames
.
VisualBasic
,
roles
:
=
Nothing
),
CreateLazyProviders
(
extraSignatureHelpProviders
,
LanguageNames
.
VisualBasic
),
extraExportedTypes
,
workspaceKind
)
workspaceKind
:
=
workspaceKind
)
End
Function
#Region "IntelliSense Operations"
...
...
@@ -287,15 +299,25 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
#Region "Signature Help and Completion Operations"
Private
Sub
ExecuteCommand
(
Of
TCommandArgs
As
CommandArgs
)(
args
As
TCommandArgs
,
finalHandler
As
Action
)
Dim
sigHelpHandler
=
DirectCast
(
SignatureHelpCommandHandler
,
ICommandHandler
(
Of
TCommandArgs
))
Dim
compHandler
=
DirectCast
(
DirectCast
(
CompletionCommandHandler
,
Object
),
ICommandHandler
(
Of
TCommandArgs
))
sigHelpHandler
.
ExecuteCommand
(
args
,
Sub
()
compHandler
.
ExecuteCommand
(
args
,
finalHandler
))
Private
Sub
ExecuteTypeCharCommand
(
args
As
TypeCharCommandArgs
,
finalHandler
As
Action
)
Dim
sigHelpHandler
=
DirectCast
(
SignatureHelpCommandHandler
,
ICommandHandler
(
Of
TypeCharCommandArgs
))
Dim
formatHandler
=
DirectCast
(
FormatCommandHandler
,
ICommandHandler
(
Of
TypeCharCommandArgs
))
Dim
compHandler
=
DirectCast
(
CompletionCommandHandler
,
ICommandHandler
(
Of
TypeCharCommandArgs
))
If
formatHandler
Is
Nothing
Then
sigHelpHandler
.
ExecuteCommand
(
args
,
Sub
()
compHandler
.
ExecuteCommand
(
args
,
finalHandler
))
Else
formatHandler
.
ExecuteCommand
(
args
,
Sub
()
sigHelpHandler
.
ExecuteCommand
(
args
,
Sub
()
compHandler
.
ExecuteCommand
(
args
,
finalHandler
)))
End
If
End
Sub
Public
Overloads
Sub
SendTypeChars
(
typeChars
As
String
)
MyBase
.
SendTypeChars
(
typeChars
,
Sub
(
a
,
n
)
ExecuteCommand
(
a
,
n
))
MyBase
.
SendTypeChars
(
typeChars
,
Sub
(
a
,
n
)
Execute
TypeChar
Command
(
a
,
n
))
End
Sub
Public
Overloads
Sub
SendBackspace
()
...
...
@@ -311,7 +333,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Public
Sub
SendTypeCharsToSpecificViewAndBuffer
(
typeChars
As
String
,
view
As
IWpfTextView
,
buffer
As
ITextBuffer
)
For
Each
ch
In
typeChars
Dim
localCh
=
ch
ExecuteCommand
(
New
TypeCharCommandArgs
(
view
,
buffer
,
localCh
),
Sub
()
EditorOperations
.
InsertText
(
localCh
.
ToString
()))
Execute
TypeChar
Command
(
New
TypeCharCommandArgs
(
view
,
buffer
,
localCh
),
Sub
()
EditorOperations
.
InsertText
(
localCh
.
ToString
()))
Next
End
Sub
#End Region
...
...
src/EditorFeatures/TestUtilities2/ServicesTestUtilities2.vbproj
浏览文件 @
793e1265
...
...
@@ -8,7 +8,6 @@
<PlatformTarget>
AnyCPU
</PlatformTarget>
<OutputType>
Library
</OutputType>
<AssemblyName>
Roslyn.Services.Test.Utilities2
</AssemblyName>
<OptionStrict>
Off
</OptionStrict>
<TargetFramework>
net46
</TargetFramework>
<RuntimeIdentifiers>
win7
</RuntimeIdentifiers>
</PropertyGroup>
...
...
@@ -35,8 +34,6 @@
<ProjectReference
Include=
"..\..\Compilers\Test\Utilities\VisualBasic\BasicCompilerTestUtilities.vbproj"
/>
<ProjectReference
Include=
"..\TestUtilities\ServicesTestUtilities.csproj"
/>
</ItemGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"
/>
<ItemGroup>
<Reference
Include=
"PresentationCore"
/>
<Reference
Include=
"PresentationFramework"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录