Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4648361f
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,发现更多精彩内容 >>
提交
4648361f
编写于
11月 16, 2018
作者:
A
Andrew Hall (METAL)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code cleanup and styling
上级
a401308c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
31 deletion
+32
-31
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
...xtractInterface/AbstractExtractInterfaceCommandHandler.cs
+3
-2
src/EditorFeatures/TestUtilities/ExtractInterface/ExtractInterfaceTestState.cs
...stUtilities/ExtractInterface/ExtractInterfaceTestState.cs
+3
-2
src/Features/Core/Portable/ExtractInterface/AbstractExtractInterfaceService.cs
...table/ExtractInterface/AbstractExtractInterfaceService.cs
+23
-22
src/VisualStudio/Core/Def/Implementation/Utilities/EnumBoolConverter.cs
...io/Core/Def/Implementation/Utilities/EnumBoolConverter.cs
+3
-5
未找到文件。
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
浏览文件 @
4648361f
...
...
@@ -11,6 +11,7 @@
using
Microsoft.VisualStudio.Commanding
;
using
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
;
using
VSCommanding
=
Microsoft
.
VisualStudio
.
Commanding
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.ExtractInterface
{
...
...
@@ -70,11 +71,11 @@ public bool ExecuteCommand(ExtractInterfaceCommandArgs args, CommandExecutionCon
// and also will take it into consideration when measuring command handling duration.
context
.
OperationContext
.
TakeOwnership
();
var
extractInterfaceService
=
document
.
GetLanguageService
<
AbstractExtractInterfaceService
>();
var
result
=
extractInterfaceService
.
ExtractInterface
(
var
result
=
extractInterfaceService
.
ExtractInterface
Async
(
document
,
caretPoint
.
Value
.
Position
,
(
errorMessage
,
severity
)
=>
workspace
.
Services
.
GetService
<
INotificationService
>().
SendNotification
(
errorMessage
,
severity
:
severity
),
CancellationToken
.
None
);
CancellationToken
.
None
)
.
WaitAndGetResult_CanCallOnBackground
(
CancellationToken
.
None
)
;
if
(
result
==
null
||
!
result
.
Succeeded
)
{
...
...
src/EditorFeatures/TestUtilities/ExtractInterface/ExtractInterfaceTestState.cs
浏览文件 @
4648361f
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.VisualBasic.ExtractInterface
;
using
Microsoft.VisualStudio.Composition
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.UnitTests.ExtractInterface
{
...
...
@@ -77,7 +78,7 @@ public Task<ExtractInterfaceTypeAnalysisResult> GetTypeAnalysisResultAsync(TypeD
public
ExtractInterfaceResult
ExtractViaCommand
()
{
return
ExtractInterfaceService
.
ExtractInterface
(
return
ExtractInterfaceService
.
ExtractInterface
Async
(
ExtractFromDocument
,
_testDocument
.
CursorPosition
.
Value
,
(
errorMessage
,
severity
)
=>
...
...
@@ -85,7 +86,7 @@ public ExtractInterfaceResult ExtractViaCommand()
this
.
ErrorMessage
=
errorMessage
;
this
.
ErrorSeverity
=
severity
;
},
CancellationToken
.
None
);
CancellationToken
.
None
)
.
WaitAndGetResult_CanCallOnBackground
(
CancellationToken
.
None
)
;
}
public
void
Dispose
()
...
...
src/Features/Core/Portable/ExtractInterface/AbstractExtractInterfaceService.cs
浏览文件 @
4648361f
...
...
@@ -54,22 +54,17 @@ public async Task<ImmutableArray<ExtractInterfaceCodeAction>> GetExtractInterfac
:
ImmutableArray
<
ExtractInterfaceCodeAction
>.
Empty
;
}
public
ExtractInterfaceResult
ExtractInterface
(
public
async
Task
<
ExtractInterfaceResult
>
ExtractInterfaceAsync
(
Document
documentWithTypeToExtractFrom
,
int
position
,
Action
<
string
,
NotificationSeverity
>
errorHandler
,
CancellationToken
cancellationToken
)
{
return
ExtractInterfaceAsync
(
documentWithTypeToExtractFrom
,
position
,
errorHandler
,
cancellationToken
).
WaitAndGetResult_CanCallOnBackground
(
cancellationToken
);
}
private
async
Task
<
ExtractInterfaceResult
>
ExtractInterfaceAsync
(
Document
documentWithTypeToExtractFrom
,
int
position
,
Action
<
string
,
NotificationSeverity
>
errorHandler
,
CancellationToken
cancellationToken
)
{
var
typeAnalysisResult
=
await
AnalyzeTypeAtPositionAsync
(
documentWithTypeToExtractFrom
,
position
,
TypeDiscoveryRule
.
TypeDeclaration
,
cancellationToken
).
ConfigureAwait
(
false
);
var
typeAnalysisResult
=
await
AnalyzeTypeAtPositionAsync
(
documentWithTypeToExtractFrom
,
position
,
TypeDiscoveryRule
.
TypeDeclaration
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(!
typeAnalysisResult
.
CanExtractInterface
)
{
...
...
@@ -77,7 +72,7 @@ public async Task<ImmutableArray<ExtractInterfaceCodeAction>> GetExtractInterfac
return
new
ExtractInterfaceResult
(
succeeded
:
false
);
}
return
await
ExtractInterfaceFromAnalyzedType
(
typeAnalysisResult
,
cancellationToken
);
return
await
ExtractInterfaceFromAnalyzedType
Async
(
typeAnalysisResult
,
cancellationToken
).
ConfigureAwait
(
false
);
}
public
async
Task
<
ExtractInterfaceTypeAnalysisResult
>
AnalyzeTypeAtPositionAsync
(
...
...
@@ -112,7 +107,7 @@ public async Task<ImmutableArray<ExtractInterfaceCodeAction>> GetExtractInterfac
return
new
ExtractInterfaceTypeAnalysisResult
(
this
,
document
,
typeNode
,
typeToExtractFrom
,
extractableMembers
);
}
public
Task
<
ExtractInterfaceResult
>
ExtractInterfaceFromAnalyzedType
(
ExtractInterfaceTypeAnalysisResult
refactoringResult
,
CancellationToken
cancellationToken
)
public
Task
<
ExtractInterfaceResult
>
ExtractInterfaceFromAnalyzedType
Async
(
ExtractInterfaceTypeAnalysisResult
refactoringResult
,
CancellationToken
cancellationToken
)
{
var
containingNamespaceDisplay
=
refactoringResult
.
TypeToExtractFrom
.
ContainingNamespace
.
IsGlobalNamespace
?
string
.
Empty
...
...
@@ -133,7 +128,10 @@ public Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedType(ExtractInte
return
ExtractInterfaceFromAnalyzedTypeAsync
(
refactoringResult
,
extractInterfaceOptions
,
cancellationToken
);
}
public
async
Task
<
ExtractInterfaceResult
>
ExtractInterfaceFromAnalyzedTypeAsync
(
ExtractInterfaceTypeAnalysisResult
refactoringResult
,
ExtractInterfaceOptionsResult
extractInterfaceOptions
,
CancellationToken
cancellationToken
)
public
async
Task
<
ExtractInterfaceResult
>
ExtractInterfaceFromAnalyzedTypeAsync
(
ExtractInterfaceTypeAnalysisResult
refactoringResult
,
ExtractInterfaceOptionsResult
extractInterfaceOptions
,
CancellationToken
cancellationToken
)
{
var
solution
=
refactoringResult
.
DocumentToExtractFrom
.
Project
.
Solution
;
...
...
@@ -193,7 +191,7 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
var
interfaceDocumentId
=
DocumentId
.
CreateNewId
(
projectId
,
debugName
:
fileName
);
var
unformattedInterfaceDocument
=
await
GetUnformattedInterfaceDocument
(
var
unformattedInterfaceDocument
=
await
GetUnformattedInterfaceDocument
Async
(
solution
,
containingNamespaceDisplay
,
fileName
,
...
...
@@ -202,7 +200,10 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
interfaceDocumentId
,
cancellationToken
);
var
solutionWithFormattedInterfaceDocument
=
await
GetFormattedSolutionAsync
(
unformattedInterfaceDocument
.
Project
.
Solution
,
SpecializedCollections
.
SingletonList
(
unformattedInterfaceDocument
.
Id
)).
ConfigureAwait
(
false
);
var
solutionWithFormattedInterfaceDocument
=
await
GetFormattedSolutionAsync
(
unformattedInterfaceDocument
.
Project
.
Solution
,
SpecializedCollections
.
SingletonList
(
unformattedInterfaceDocument
.
Id
),
cancellationToken
).
ConfigureAwait
(
false
);
var
completedSolution
=
await
GetSolutionWithOriginalTypeUpdatedAsync
(
solutionWithFormattedInterfaceDocument
,
...
...
@@ -246,9 +247,9 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
var
interfaceNode
=
codeGenService
.
CreateNamedTypeDeclaration
(
extractedInterfaceSymbol
).
WithAdditionalAnnotations
(
SimplificationHelpers
.
SimplifyModuleNameAnnotation
);
typeDeclaration
=
currentRoot
.
GetCurrentNode
(
typeDeclaration
);
editor
.
InsertBefore
(
typeDeclaration
,
interfaceNode
.
WithAdditionalAnnotations
(
Simplifier
.
Annotation
)
);
editor
.
InsertBefore
(
typeDeclaration
,
interfaceNode
);
var
unformattedSolution
=
solution
.
WithDocumentSyntaxRoot
(
documentId
,
editor
.
GetChangedRoot
(),
PreservationMode
.
PreserveIdentity
)
;
var
unformattedSolution
=
document
.
WithSyntaxRoot
(
editor
.
GetChangedRoot
()).
Project
.
Solution
;
var
completedSolution
=
await
GetSolutionWithOriginalTypeUpdatedAsync
(
unformattedSolution
,
documentIds
,
...
...
@@ -299,7 +300,7 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
foreach
(
var
root
in
currentRoots
)
{
var
document
=
solution
.
GetDocument
(
root
.
Key
);
solution
=
solution
.
WithDocumentSyntaxRoot
(
document
.
Id
,
root
.
Value
,
PreservationMode
.
PreserveIdentity
)
;
solution
=
document
.
WithSyntaxRoot
(
root
.
Value
).
Project
.
Solution
;
}
return
symbolToDeclarationAnnotationMap
;
...
...
@@ -331,7 +332,7 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
document
.
Project
.
Language
);
}
private
async
Task
<
Document
>
GetUnformattedInterfaceDocument
(
private
async
Task
<
Document
>
GetUnformattedInterfaceDocument
Async
(
Solution
solution
,
string
containingNamespaceDisplay
,
string
name
,
...
...
@@ -355,7 +356,7 @@ public async Task<ExtractInterfaceResult> ExtractInterfaceFromAnalyzedTypeAsync(
return
unformattedInterfaceDocument
;
}
private
static
async
Task
<
Solution
>
GetSolutionWithFormattedInterfaceDocument
(
Document
unformattedInterfaceDocument
,
CancellationToken
cancellationToken
)
private
static
async
Task
<
Solution
>
GetSolutionWithFormattedInterfaceDocument
Async
(
Document
unformattedInterfaceDocument
,
CancellationToken
cancellationToken
)
{
Solution
solutionWithInterfaceDocument
;
var
formattedRoot
=
Formatter
.
Format
(
unformattedInterfaceDocument
.
GetSyntaxRootSynchronously
(
cancellationToken
),
...
...
@@ -414,7 +415,7 @@ private async Task<Solution> GetFormattedSolutionAsync(Solution unformattedSolut
{
editor
.
AddInterfaceType
(
typeDeclaration
,
typeReference
);
}
unformattedSolution
=
unformattedSolution
.
WithDocumentSyntaxRoot
(
documentId
,
editor
.
GetChangedRoot
(),
PreservationMode
.
PreserveIdentity
)
;
unformattedSolution
=
document
.
WithSyntaxRoot
(
editor
.
GetChangedRoot
()).
Project
.
Solution
;
}
var
updatedUnformattedSolution
=
UpdateMembersWithExplicitImplementations
(
...
...
src/VisualStudio/Core/Def/Implementation/Utilities/EnumBoolConverter.cs
浏览文件 @
4648361f
using
System
;
using
System.Collections.Generic
;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Data
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录