Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f8e9ec65
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,发现更多精彩内容 >>
提交
f8e9ec65
编写于
9月 21, 2020
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup
上级
fcd63969
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
40 deletion
+17
-40
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+17
-40
未找到文件。
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
f8e9ec65
...
...
@@ -654,40 +654,6 @@ protected override void ApplyAnalyzerReferenceRemoved(ProjectId projectId, Analy
}
internal
override
void
ApplyMappedFileChanges
(
SolutionChanges
solutionChanges
)
{
// After normal project changes have been applied, we need to apply changes for
// generated razor documents that are mapped to a location in a file outside of our workspace.
// Since these generated documents have CanApplyChange() == false, they will not
// be applied when other project changes are applied.
var
projectChanges
=
solutionChanges
.
GetProjectChanges
();
var
changedMappedDocuments
=
new
Dictionary
<
ProjectChanges
,
ImmutableArray
<
DocumentId
>>();
foreach
(
var
projectChange
in
projectChanges
)
{
var
documents
=
projectChange
.
GetChangedDocuments
().
Where
(
ShouldApplyChangesToMappedDocuments
);
if
(
documents
.
Any
())
{
changedMappedDocuments
.
Add
(
projectChange
,
documents
.
ToImmutableArray
());
}
}
if
(
changedMappedDocuments
.
Any
())
{
ApplyChangesForMappedDocuments
(
changedMappedDocuments
);
}
return
;
bool
ShouldApplyChangesToMappedDocuments
(
DocumentId
id
)
{
var
document
=
this
.
CurrentSolution
.
GetDocument
(
id
);
// Only consider files that are mapped and that we are unable to apply changes to.
// TODO - refactor how this is determined - https://github.com/dotnet/roslyn/issues/47908
return
document
?.
Services
?.
GetService
<
ISpanMappingService
>()
!=
null
&&
document
?.
CanApplyChange
()
==
false
;
}
}
private
void
ApplyChangesForMappedDocuments
(
Dictionary
<
ProjectChanges
,
ImmutableArray
<
DocumentId
>>
changedMappedDocuments
)
{
// Get the original text changes from all documents and call the span mapping service to get span mappings for the text changes.
// Create mapped text changes using the mapped spans and original text changes' text.
...
...
@@ -698,7 +664,7 @@ private void ApplyChangesForMappedDocuments(Dictionary<ProjectChanges, Immutable
// Instead, we invoke this in JTF run which will mitigate deadlocks when the ConfigureAwait(true)
// tries to switch back to the main thread in the LSP client.
// Link to LSP client bug for ConfigureAwait(true) - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1216657
var
mappedChanges
=
_threadingContext
.
JoinableTaskFactory
.
Run
(()
=>
GetMappedTextChanges
(
changedMappedDocument
s
));
var
mappedChanges
=
_threadingContext
.
JoinableTaskFactory
.
Run
(()
=>
GetMappedTextChanges
(
solutionChange
s
));
// Group the mapped text changes by file, then apply all mapped text changes for the file.
foreach
(
var
changesForFile
in
mappedChanges
)
...
...
@@ -713,17 +679,20 @@ private void ApplyChangesForMappedDocuments(Dictionary<ProjectChanges, Immutable
return
;
static
async
Task
<
MultiDictionary
<
string
,
(
TextChange
TextChange
,
ProjectId
ProjectId
)>>
GetMappedTextChanges
(
Dictionary
<
ProjectChanges
,
ImmutableArray
<
DocumentId
>>
changedMappedDocument
s
)
async
Task
<
MultiDictionary
<
string
,
(
TextChange
TextChange
,
ProjectId
ProjectId
)>>
GetMappedTextChanges
(
SolutionChanges
solutionChange
s
)
{
var
filePathToMappedTextChanges
=
new
MultiDictionary
<
string
,
(
TextChange
TextChange
,
ProjectId
ProjectId
)>();
foreach
(
var
projectChanges
in
changedMappedDocuments
.
Keys
)
foreach
(
var
projectChanges
in
solutionChanges
.
GetProjectChanges
()
)
{
foreach
(
var
changedDocumentId
in
changedMappedDocuments
[
projectChanges
]
)
foreach
(
var
changedDocumentId
in
projectChanges
.
GetChangedDocuments
()
)
{
var
oldDocument
=
projectChanges
.
OldProject
.
GetRequiredDocument
(
changedDocumentId
);
var
newDocument
=
projectChanges
.
NewProject
.
GetRequiredDocument
(
changedDocumentId
);
if
(!
ShouldApplyChangesToMappedDocuments
(
oldDocument
,
out
var
mappingService
))
{
continue
;
}
var
mappingService
=
newDocument
.
Services
.
GetService
<
ISpanMappingService
>()!
;
var
newDocument
=
projectChanges
.
NewProject
.
GetRequiredDocument
(
changedDocumentId
)
;
var
textChanges
=
(
await
newDocument
.
GetTextChangesAsync
(
oldDocument
,
CancellationToken
.
None
).
ConfigureAwait
(
false
)).
ToImmutableArray
();
var
mappedSpanResults
=
await
mappingService
.
MapSpansAsync
(
oldDocument
,
textChanges
.
Select
(
tc
=>
tc
.
Span
),
CancellationToken
.
None
).
ConfigureAwait
(
false
);
...
...
@@ -744,6 +713,14 @@ private void ApplyChangesForMappedDocuments(Dictionary<ProjectChanges, Immutable
return
filePathToMappedTextChanges
;
}
bool
ShouldApplyChangesToMappedDocuments
(
CodeAnalysis
.
Document
document
,
[
NotNullWhen
(
true
)]
out
ISpanMappingService
?
spanMappingService
)
{
spanMappingService
=
document
.
Services
.
GetService
<
ISpanMappingService
>();
// Only consider files that are mapped and that we are unable to apply changes to.
// TODO - refactor how this is determined - https://github.com/dotnet/roslyn/issues/47908
return
spanMappingService
!=
null
&&
document
?.
CanApplyChange
()
==
false
;
}
}
protected
override
void
ApplyProjectReferenceAdded
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录