Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5331a978
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,发现更多精彩内容 >>
提交
5331a978
编写于
4月 15, 2019
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the new `GetChangeAsync` with `completionListSpan`
上级
d18962b2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
13 deletion
+16
-13
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs
...on/CompletionProviders/OverrideCompletionProviderTests.cs
+1
-1
src/EditorFeatures/TestUtilities/Completion/AbstractCompletionProviderTests.cs
...stUtilities/Completion/AbstractCompletionProviderTests.cs
+8
-5
src/Features/Core/Portable/Completion/Providers/AbstractTypeImportCompletionProvider.cs
...pletion/Providers/AbstractTypeImportCompletionProvider.cs
+4
-4
src/Features/Core/Portable/SpellCheck/AbstractSpellCheckCodeFixProvider.cs
.../Portable/SpellCheck/AbstractSpellCheckCodeFixProvider.cs
+3
-3
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/OverrideCompletionProviderTests.cs
浏览文件 @
5331a978
...
@@ -2744,7 +2744,7 @@ public override void M(in int x)
...
@@ -2744,7 +2744,7 @@ public override void M(in int x)
var
completionList
=
await
GetCompletionListAsync
(
service
,
document
,
testDocument
.
CursorPosition
.
Value
,
CompletionTrigger
.
Invoke
);
var
completionList
=
await
GetCompletionListAsync
(
service
,
document
,
testDocument
.
CursorPosition
.
Value
,
CompletionTrigger
.
Invoke
);
var
completionItem
=
completionList
.
Items
.
Where
(
c
=>
c
.
DisplayText
==
"M(in int x)"
).
Single
();
var
completionItem
=
completionList
.
Items
.
Where
(
c
=>
c
.
DisplayText
==
"M(in int x)"
).
Single
();
var
commit
=
await
service
.
GetChangeAsync
(
document
,
completionItem
,
commitKey
:
null
,
CancellationToken
.
None
);
var
commit
=
await
service
.
GetChangeAsync
(
document
,
completionItem
,
com
pletionList
.
Span
,
com
mitKey
:
null
,
CancellationToken
.
None
);
var
text
=
await
document
.
GetTextAsync
();
var
text
=
await
document
.
GetTextAsync
();
var
newText
=
text
.
WithChanges
(
commit
.
TextChange
);
var
newText
=
text
.
WithChanges
(
commit
.
TextChange
);
...
...
src/EditorFeatures/TestUtilities/Completion/AbstractCompletionProviderTests.cs
浏览文件 @
5331a978
...
@@ -339,7 +339,8 @@ private async Task VerifyCustomCommitProviderCheckResultsAsync(Document document
...
@@ -339,7 +339,8 @@ private async Task VerifyCustomCommitProviderCheckResultsAsync(Document document
var
textBuffer
=
WorkspaceFixture
.
CurrentDocument
.
TextBuffer
;
var
textBuffer
=
WorkspaceFixture
.
CurrentDocument
.
TextBuffer
;
var
service
=
GetCompletionService
(
workspace
);
var
service
=
GetCompletionService
(
workspace
);
var
items
=
(
await
GetCompletionListAsync
(
service
,
document
,
position
,
RoslynCompletion
.
CompletionTrigger
.
Invoke
)).
Items
;
var
completionLlist
=
await
GetCompletionListAsync
(
service
,
document
,
position
,
RoslynCompletion
.
CompletionTrigger
.
Invoke
);
var
items
=
completionLlist
.
Items
;
var
firstItem
=
items
.
First
(
i
=>
CompareItems
(
i
.
DisplayText
,
itemToCommit
));
var
firstItem
=
items
.
First
(
i
=>
CompareItems
(
i
.
DisplayText
,
itemToCommit
));
if
(
service
.
GetTestAccessor
().
ExclusiveProviders
?[
0
]
is
ICustomCommitCompletionProvider
customCommitCompletionProvider
)
if
(
service
.
GetTestAccessor
().
ExclusiveProviders
?[
0
]
is
ICustomCommitCompletionProvider
customCommitCompletionProvider
)
...
@@ -350,7 +351,7 @@ private async Task VerifyCustomCommitProviderCheckResultsAsync(Document document
...
@@ -350,7 +351,7 @@ private async Task VerifyCustomCommitProviderCheckResultsAsync(Document document
}
}
else
else
{
{
await
VerifyCustomCommitWorkerAsync
(
service
,
document
,
firstItem
,
codeBeforeCommit
,
expectedCodeAfterCommit
,
commitChar
);
await
VerifyCustomCommitWorkerAsync
(
service
,
document
,
firstItem
,
co
mpletionLlist
.
Span
,
co
deBeforeCommit
,
expectedCodeAfterCommit
,
commitChar
);
}
}
}
}
...
@@ -362,6 +363,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
...
@@ -362,6 +363,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
CompletionServiceWithProviders
service
,
CompletionServiceWithProviders
service
,
Document
document
,
Document
document
,
RoslynCompletion
.
CompletionItem
completionItem
,
RoslynCompletion
.
CompletionItem
completionItem
,
TextSpan
completionListSpan
,
string
codeBeforeCommit
,
string
codeBeforeCommit
,
string
expectedCodeAfterCommit
,
string
expectedCodeAfterCommit
,
char
?
commitChar
=
null
)
char
?
commitChar
=
null
)
...
@@ -379,7 +381,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
...
@@ -379,7 +381,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
// changes to document, so the cursor position is tracked correctly.
// changes to document, so the cursor position is tracked correctly.
var
textView
=
WorkspaceFixture
.
CurrentDocument
.
GetTextView
();
var
textView
=
WorkspaceFixture
.
CurrentDocument
.
GetTextView
();
var
commit
=
await
service
.
GetChangeAsync
(
document
,
completionItem
,
commitChar
,
CancellationToken
.
None
);
var
commit
=
await
service
.
GetChangeAsync
(
document
,
completionItem
,
com
pletionListSpan
,
com
mitChar
,
CancellationToken
.
None
);
var
text
=
await
document
.
GetTextAsync
();
var
text
=
await
document
.
GetTextAsync
();
var
newText
=
text
.
WithChanges
(
commit
.
TextChange
);
var
newText
=
text
.
WithChanges
(
commit
.
TextChange
);
...
@@ -452,7 +454,8 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
...
@@ -452,7 +454,8 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
var
textSnapshot
=
textBuffer
.
CurrentSnapshot
.
AsText
();
var
textSnapshot
=
textBuffer
.
CurrentSnapshot
.
AsText
();
var
service
=
GetCompletionService
(
workspace
);
var
service
=
GetCompletionService
(
workspace
);
var
items
=
(
await
GetCompletionListAsync
(
service
,
document
,
position
,
RoslynCompletion
.
CompletionTrigger
.
Invoke
)).
Items
;
var
completionList
=
await
GetCompletionListAsync
(
service
,
document
,
position
,
RoslynCompletion
.
CompletionTrigger
.
Invoke
);
var
items
=
completionList
.
Items
;
var
firstItem
=
items
.
First
(
i
=>
CompareItems
(
i
.
DisplayText
+
i
.
DisplayTextSuffix
,
itemToCommit
));
var
firstItem
=
items
.
First
(
i
=>
CompareItems
(
i
.
DisplayText
+
i
.
DisplayTextSuffix
,
itemToCommit
));
var
completionRules
=
GetCompletionHelper
(
document
);
var
completionRules
=
GetCompletionHelper
(
document
);
...
@@ -463,7 +466,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
...
@@ -463,7 +466,7 @@ protected virtual void SetWorkspaceOptions(TestWorkspace workspace)
if
(
commitChar
==
'\t'
||
if
(
commitChar
==
'\t'
||
CommitManager
.
IsCommitCharacter
(
service
.
GetRules
(),
firstItem
,
commitChar
,
textTypedSoFar
+
commitChar
))
CommitManager
.
IsCommitCharacter
(
service
.
GetRules
(),
firstItem
,
commitChar
,
textTypedSoFar
+
commitChar
))
{
{
var
textChange
=
(
await
service
.
GetChangeAsync
(
document
,
firstItem
,
commitChar
,
CancellationToken
.
None
)).
TextChange
;
var
textChange
=
(
await
service
.
GetChangeAsync
(
document
,
firstItem
,
com
pletionList
.
Span
,
com
mitChar
,
CancellationToken
.
None
)).
TextChange
;
// Adjust TextChange to include commit character, so long as it isn't TAB.
// Adjust TextChange to include commit character, so long as it isn't TAB.
if
(
commitChar
!=
'\t'
)
if
(
commitChar
!=
'\t'
)
...
...
src/Features/Core/Portable/Completion/Providers/AbstractTypeImportCompletionProvider.cs
浏览文件 @
5331a978
...
@@ -157,7 +157,7 @@ private HashSet<string> GetNamespacesInScope(Document document, SyntaxContext sy
...
@@ -157,7 +157,7 @@ private HashSet<string> GetNamespacesInScope(Document document, SyntaxContext sy
return
namespacesInScope
;
return
namespacesInScope
;
}
}
public
override
async
Task
<
CompletionChange
>
GetChangeAsync
(
Document
document
,
CompletionItem
completionItem
,
char
?
commitKey
=
default
,
CancellationToken
cancellationToken
=
default
)
internal
override
async
Task
<
CompletionChange
>
GetChangeAsync
(
Document
document
,
CompletionItem
completionItem
,
TextSpan
completionListSpan
,
char
?
commitKey
,
CancellationToken
cancellationToken
)
{
{
var
containingNamespace
=
TypeImportCompletionItem
.
GetContainingNamespace
(
completionItem
);
var
containingNamespace
=
TypeImportCompletionItem
.
GetContainingNamespace
(
completionItem
);
Debug
.
Assert
(
containingNamespace
!=
null
);
Debug
.
Assert
(
containingNamespace
!=
null
);
...
@@ -167,7 +167,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
...
@@ -167,7 +167,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
// Find context node so we can use it to decide where to insert using/imports.
// Find context node so we can use it to decide where to insert using/imports.
var
tree
=
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
tree
=
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
root
=
await
tree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
root
=
await
tree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
addImportContextNode
=
root
.
FindToken
(
completion
Item
.
Span
.
Start
,
findInsideTrivia
:
true
).
Parent
;
var
addImportContextNode
=
root
.
FindToken
(
completion
List
Span
.
Start
,
findInsideTrivia
:
true
).
Parent
;
// Add required using/imports directive.
// Add required using/imports directive.
var
addImportService
=
document
.
GetLanguageService
<
IAddImportsService
>();
var
addImportService
=
document
.
GetLanguageService
<
IAddImportsService
>();
...
@@ -198,7 +198,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
...
@@ -198,7 +198,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
// above, we will get a TextChange of "AsnEncodedDat" with 0 length span, instead of a change of
// above, we will get a TextChange of "AsnEncodedDat" with 0 length span, instead of a change of
// the full display text with a span of length 1. This will later mess up span-tracking and end up
// the full display text with a span of length 1. This will later mess up span-tracking and end up
// with "AsnEncodedDatasd" in the code.
// with "AsnEncodedDatasd" in the code.
builder
.
Add
(
new
TextChange
(
completion
Item
.
Span
,
completionItem
.
DisplayText
));
builder
.
Add
(
new
TextChange
(
completion
List
Span
,
completionItem
.
DisplayText
));
// Then get the combined change
// Then get the combined change
var
text
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
text
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
@@ -211,7 +211,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
...
@@ -211,7 +211,7 @@ public override async Task<CompletionChange> GetChangeAsync(Document document, C
// For workspace that doesn't support document change, e.g. DebuggerIntellisense
// For workspace that doesn't support document change, e.g. DebuggerIntellisense
// we complete the type name in its fully qualified form instead.
// we complete the type name in its fully qualified form instead.
var
fullyQualifiedName
=
containingNamespace
+
completionItem
.
DisplayText
;
var
fullyQualifiedName
=
containingNamespace
+
completionItem
.
DisplayText
;
var
change
=
new
TextChange
(
completion
Item
.
Span
,
fullyQualifiedName
);
var
change
=
new
TextChange
(
completion
List
Span
,
fullyQualifiedName
);
return
CompletionChange
.
Create
(
change
);
return
CompletionChange
.
Create
(
change
);
}
}
...
...
src/Features/Core/Portable/SpellCheck/AbstractSpellCheckCodeFixProvider.cs
浏览文件 @
5331a978
...
@@ -153,7 +153,7 @@ private async Task CheckTokenAsync(CodeFixContext context, Document document, Sy
...
@@ -153,7 +153,7 @@ private async Task CheckTokenAsync(CodeFixContext context, Document document, Sy
continue
;
continue
;
}
}
var
insertionText
=
await
GetInsertionTextAsync
(
document
,
item
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
var
insertionText
=
await
GetInsertionTextAsync
(
document
,
item
,
c
ompletionList
.
Span
,
c
ancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
results
.
Add
(
matchCost
,
insertionText
);
results
.
Add
(
matchCost
,
insertionText
);
}
}
...
@@ -178,10 +178,10 @@ private async Task CheckTokenAsync(CodeFixContext context, Document document, Sy
...
@@ -178,10 +178,10 @@ private async Task CheckTokenAsync(CodeFixContext context, Document document, Sy
}
}
}
}
private
async
Task
<
string
>
GetInsertionTextAsync
(
Document
document
,
CompletionItem
item
,
CancellationToken
cancellationToken
)
private
async
Task
<
string
>
GetInsertionTextAsync
(
Document
document
,
CompletionItem
item
,
TextSpan
completionListSpan
,
CancellationToken
cancellationToken
)
{
{
var
service
=
CompletionService
.
GetService
(
document
);
var
service
=
CompletionService
.
GetService
(
document
);
var
change
=
await
service
.
GetChangeAsync
(
document
,
item
,
null
,
cancellationToken
).
ConfigureAwait
(
false
);
var
change
=
await
service
.
GetChangeAsync
(
document
,
item
,
completionListSpan
,
commitCharacter
:
null
,
cancellationToken
).
ConfigureAwait
(
false
);
return
change
.
TextChange
.
NewText
;
return
change
.
TextChange
.
NewText
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录