Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
44c572ce
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,发现更多精彩内容 >>
提交
44c572ce
编写于
10月 18, 2018
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup from code reviews
上级
c6c91360
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
16 deletion
+25
-16
src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs
...rFeatures/Core/Implementation/CodeFixes/CodeFixService.cs
+3
-3
src/Features/CSharp/Portable/CodeCleanup/CSharpCodeCleanupService.cs
...s/CSharp/Portable/CodeCleanup/CSharpCodeCleanupService.cs
+3
-3
src/Features/Core/Portable/CodeCleanup/ICodeCleanupService.cs
...Features/Core/Portable/CodeCleanup/ICodeCleanupService.cs
+1
-1
src/Features/Core/Portable/CodeCleanup/OrganizeUsingsSettings.cs
...tures/Core/Portable/CodeCleanup/OrganizeUsingsSettings.cs
+5
-5
src/VisualStudio/Core/Def/Implementation/CodeCleanup/CodeCleanUpFixer.cs
...o/Core/Def/Implementation/CodeCleanup/CodeCleanUpFixer.cs
+5
-1
src/VisualStudio/Core/Def/Implementation/CodeCleanup/CodeCleanupFixerProvider.cs
...ef/Implementation/CodeCleanup/CodeCleanupFixerProvider.cs
+8
-3
未找到文件。
src/EditorFeatures/Core/Implementation/CodeFixes/CodeFixService.cs
浏览文件 @
44c572ce
...
...
@@ -215,7 +215,7 @@ public async Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document docu
return
result
.
ToImmutableAndFree
();
}
public
async
Task
<
CodeFixCollection
>
GetDocumentFixAllForIdInSpan
(
Document
document
,
TextSpan
range
,
string
diagnosticId
,
CancellationToken
cancellationToken
)
public
async
Task
<
CodeFixCollection
>
GetDocumentFixAllForIdInSpan
Async
(
Document
document
,
TextSpan
range
,
string
diagnosticId
,
CancellationToken
cancellationToken
)
{
var
diagnostics
=
(
await
_diagnosticService
.
GetDiagnosticsForSpanAsync
(
document
,
range
,
diagnosticId
,
includeSuppressedDiagnostics
:
false
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
)).
ToList
();
if
(
diagnostics
.
Count
==
0
)
...
...
@@ -231,12 +231,12 @@ public async Task<CodeFixCollection> GetDocumentFixAllForIdInSpan(Document docum
return
result
.
ToImmutableAndFree
().
FirstOrDefault
();
}
public
async
Task
<
Document
>
ApplyCodeFixesForSpecificDiagnosticId
(
Document
document
,
string
diagnosticId
,
IProgressTracker
progressTracker
,
CancellationToken
cancellationToken
)
public
async
Task
<
Document
>
ApplyCodeFixesForSpecificDiagnosticId
Async
(
Document
document
,
string
diagnosticId
,
IProgressTracker
progressTracker
,
CancellationToken
cancellationToken
)
{
var
tree
=
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
textSpan
=
new
TextSpan
(
0
,
tree
.
Length
);
var
fixCollection
=
await
GetDocumentFixAllForIdInSpan
(
var
fixCollection
=
await
GetDocumentFixAllForIdInSpan
Async
(
document
,
textSpan
,
diagnosticId
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
fixCollection
==
null
)
{
...
...
src/Features/CSharp/Portable/CodeCleanup/CSharpCodeCleanupService.cs
浏览文件 @
44c572ce
...
...
@@ -206,13 +206,13 @@ public EnabledDiagnosticOptions GetAllDiagnostics()
return
new
EnabledDiagnosticOptions
(
diagnosticSets
,
new
OrganizeUsingsSet
(
true
,
true
));
}
public
EnabledDiagnosticOptions
GetEnabledDiagnostics
(
DocumentOptionSet
docOptions
)
public
EnabledDiagnosticOptions
GetEnabledDiagnostics
(
OptionSet
optionSet
)
{
var
diagnosticSets
=
ArrayBuilder
<
DiagnosticSet
>.
GetInstance
();
foreach
(
var
(
diagnosticSet
,
option
)
in
_optionDiagnosticsMappings
)
{
if
(
docOptions
.
GetOption
(
option
))
if
(
optionSet
.
GetOption
(
option
,
LanguageNames
.
CSharp
))
{
diagnosticSets
.
AddRange
(
diagnosticSet
);
}
...
...
@@ -220,7 +220,7 @@ public EnabledDiagnosticOptions GetEnabledDiagnostics(DocumentOptionSet docOptio
var
desc
=
CSharpFeaturesResources
.
Organize_Usings
;
return
new
EnabledDiagnosticOptions
(
diagnosticSets
.
ToImmutableArray
(),
new
OrganizeUsingsSet
(
docOptions
));
return
new
EnabledDiagnosticOptions
(
diagnosticSets
.
ToImmutableArray
(),
new
OrganizeUsingsSet
(
optionSet
,
LanguageNames
.
CSharp
));
}
}
}
src/Features/Core/Portable/CodeCleanup/ICodeCleanupService.cs
浏览文件 @
44c572ce
...
...
@@ -12,6 +12,6 @@ internal interface ICodeCleanupService : ILanguageService
{
Task
<
Document
>
CleanupAsync
(
Document
document
,
EnabledDiagnosticOptions
enabledDiagnostics
,
IProgressTracker
progressTracker
,
CancellationToken
cancellationToken
);
EnabledDiagnosticOptions
GetAllDiagnostics
();
EnabledDiagnosticOptions
GetEnabledDiagnostics
(
DocumentOptionSet
docOptions
);
EnabledDiagnosticOptions
GetEnabledDiagnostics
(
OptionSet
optionSet
);
}
}
src/Features/Core/Portable/CodeCleanup/OrganizeUsingsSettings.cs
浏览文件 @
44c572ce
...
...
@@ -6,13 +6,13 @@ namespace Microsoft.CodeAnalysis.CodeCleanup
{
internal
class
OrganizeUsingsSet
{
public
bool
IsRemoveUnusedImportEnabled
{
get
;
private
set
;
}
public
bool
IsSortImportsEnabled
{
get
;
private
set
;
}
public
bool
IsRemoveUnusedImportEnabled
{
get
;
}
public
bool
IsSortImportsEnabled
{
get
;
}
public
OrganizeUsingsSet
(
DocumentOptionSet
docOptions
)
public
OrganizeUsingsSet
(
OptionSet
optionSet
,
string
language
)
{
IsRemoveUnusedImportEnabled
=
docOptions
.
GetOption
(
CodeCleanupOptions
.
RemoveUnusedImports
);
IsSortImportsEnabled
=
docOptions
.
GetOption
(
CodeCleanupOptions
.
SortImports
);
IsRemoveUnusedImportEnabled
=
optionSet
.
GetOption
(
CodeCleanupOptions
.
RemoveUnusedImports
,
language
);
IsSortImportsEnabled
=
optionSet
.
GetOption
(
CodeCleanupOptions
.
SortImports
,
language
);
}
public
OrganizeUsingsSet
(
bool
isRemoveUnusedImportEnabled
,
bool
isSortImportsEnabled
)
...
...
src/VisualStudio/Core/Def/Implementation/CodeCleanup/CodeCleanUpFixer.cs
浏览文件 @
44c572ce
...
...
@@ -3,10 +3,14 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.VisualStudio.Language.CodeCleanUp
;
using
Microsoft.VisualStudio.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.CodeCleanup
{
/// <summary>
/// Roslyn implementations of <see cref="ICodeCleanUpFixer"/> extend this class. Since other extensions could also
/// be implementing the <see cref="ICodeCleanUpFixer"/> interface, this abstract base class allows Roslyn to operate
/// on MEF instances of fixers known to be relevant in the context of Roslyn languages.
/// </summary>
internal
abstract
class
CodeCleanUpFixer
:
ICodeCleanUpFixer
{
public
abstract
Task
<
bool
>
FixAsync
(
ICodeCleanUpScope
scope
,
ICodeCleanUpExecutionContext
context
,
CancellationToken
cancellationToken
);
...
...
src/VisualStudio/Core/Def/Implementation/CodeCleanup/CodeCleanupFixerProvider.cs
浏览文件 @
44c572ce
...
...
@@ -12,10 +12,15 @@
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.CodeCleanup
{
[
Export
(
typeof
(
CodeCleanUpFixerProvider
))]
/// <summary>
/// This is intentionally not exported as a concrete type and not an instance of
/// <see cref="ICodeCleanUpFixerProvider"/>. Roslyn is responsible for registering its own fixer provider, as
/// opposed to the implementation importing the instances of some interface.
/// </summary>
[
Export
]
internal
class
CodeCleanUpFixerProvider
:
ICodeCleanUpFixerProvider
{
private
IList
<
Lazy
<
CodeCleanUpFixer
,
ContentTypeMetadata
>>
_codeCleanUpFixers
=
new
List
<
Lazy
<
CodeCleanUpFixer
,
ContentTypeMetadata
>>()
;
private
readonly
IList
<
Lazy
<
CodeCleanUpFixer
,
ContentTypeMetadata
>>
_codeCleanUpFixers
;
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -41,7 +46,7 @@ public IReadOnlyCollection<ICodeCleanUpFixer> GetFixers(IContentType contentType
var
fixers
=
_codeCleanUpFixers
.
Where
(
handler
=>
handler
.
Metadata
.
ContentTypes
.
Contains
(
contentType
.
TypeName
)).
ToList
();
return
fixers
.
Any
()
?
fixers
.
ConvertAll
(
l
=>
l
.
Value
)
:
SpecializedCollections
.
EmptyReadOnlyList
<
ICodeCleanUpFixer
>(
);
return
fixers
.
ConvertAll
(
l
=>
l
.
Value
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录