Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9fe084b5
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,发现更多精彩内容 >>
提交
9fe084b5
编写于
11月 13, 2018
作者:
A
Andrew Hall (METAL)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
VB extract interface changes
上级
41a7c27a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
15 deletion
+58
-15
src/Features/CSharp/Portable/ExtractInterface/CSharpExtractInterfaceService.cs
...ortable/ExtractInterface/CSharpExtractInterfaceService.cs
+8
-5
src/Features/Core/Portable/ExtractInterface/AbstractExtractInterfaceService.cs
...table/ExtractInterface/AbstractExtractInterfaceService.cs
+12
-8
src/Features/VisualBasic/Portable/ExtractInterface/VisualBasicExtractInterfaceService.vb
...le/ExtractInterface/VisualBasicExtractInterfaceService.vb
+38
-2
未找到文件。
src/Features/CSharp/Portable/ExtractInterface/CSharpExtractInterfaceService.cs
浏览文件 @
9fe084b5
...
...
@@ -135,13 +135,16 @@ internal override bool ShouldIncludeAccessibilityModifier(SyntaxNode typeNode)
}
internal
override
Solution
GetSolutionWithSameFileUpdated
(
Solution
solution
,
INamedTypeSymbol
extractedInterfaceSymbol
,
Solution
solution
,
INamedTypeSymbol
extractedInterfaceSymbol
,
IEnumerable
<
ISymbol
>
includedMembers
,
Dictionary
<
ISymbol
,
SyntaxAnnotation
>
symbolToDeclarationAnnotationMap
,
List
<
DocumentId
>
documentIds
,
SyntaxAnnotation
typeNodeAnnotation
,
DocumentId
documentId
,
DocumentId
documentId
WithTypeNode
,
CancellationToken
cancellationToken
)
{
var
document
=
solution
.
GetDocument
(
documentId
);
var
document
=
solution
.
GetDocument
(
documentId
WithTypeNode
);
var
originalRoot
=
document
.
GetSyntaxRootSynchronously
(
cancellationToken
);
var
typeDeclaration
=
originalRoot
.
GetAnnotatedNodes
<
TypeDeclarationSyntax
>(
typeNodeAnnotation
).
Single
();
...
...
@@ -165,7 +168,7 @@ internal override bool ShouldIncludeAccessibilityModifier(SyntaxNode typeNode)
var
newRoot
=
Formatter
.
Format
(
editor
.
GetChangedRoot
(),
solution
.
Workspace
);
return
solution
.
WithDocumentSyntaxRoot
(
documentId
,
newRoot
,
PreservationMode
.
PreserveIdentity
);
return
solution
.
WithDocumentSyntaxRoot
(
documentId
WithTypeNode
,
newRoot
,
PreservationMode
.
PreserveIdentity
);
}
}
}
src/Features/Core/Portable/ExtractInterface/AbstractExtractInterfaceService.cs
浏览文件 @
9fe084b5
...
...
@@ -43,8 +43,11 @@ internal abstract class AbstractExtractInterfaceService : ILanguageService
internal
abstract
Solution
GetSolutionWithSameFileUpdated
(
Solution
solution
,
INamedTypeSymbol
extractedInterfaceSymbol
,
IEnumerable
<
ISymbol
>
includedMembers
,
Dictionary
<
ISymbol
,
SyntaxAnnotation
>
symbolToDeclarationAnnotationMap
,
List
<
DocumentId
>
documentIds
,
SyntaxAnnotation
typeNodeAnnotation
,
DocumentId
documentId
,
DocumentId
documentId
WithTypeNode
,
CancellationToken
cancellationToken
);
internal
abstract
string
GetGeneratedNameTypeParameterSuffix
(
IList
<
ITypeParameterSymbol
>
typeParameters
,
Workspace
workspace
);
...
...
@@ -180,9 +183,8 @@ public ExtractInterfaceResult ExtractInterfaceFromAnalyzedType(ExtractInterfaceT
private
ExtractInterfaceResult
ExtractInterfaceToNewFile
(
Solution
solution
,
string
containingNamespaceDisplay
,
INamedTypeSymbol
extractedInterfaceSymbol
,
SyntaxNode
typeNode
,
ProjectId
projectId
,
IReadOnlyList
<
string
>
documentFolders
,
DocumentId
documentId
,
INamedTypeSymbol
typeToExtractFrom
,
string
fileName
,
IEnumerable
<
ISymbol
>
includedMembers
,
CancellationToken
cancellationToken
)
SyntaxNode
typeNode
,
ProjectId
projectId
,
IReadOnlyList
<
string
>
documentFolders
,
DocumentId
documentId
,
INamedTypeSymbol
typeToExtractFrom
,
string
fileName
,
IEnumerable
<
ISymbol
>
includedMembers
,
CancellationToken
cancellationToken
)
{
var
symbolToDeclarationAnnotationMap
=
CreateSymbolToDeclarationAnnotationMap
(
includedMembers
,
...
...
@@ -223,9 +225,8 @@ public ExtractInterfaceResult ExtractInterfaceFromAnalyzedType(ExtractInterfaceT
}
private
ExtractInterfaceResult
ExtractInterfaceToSameFile
(
Solution
solution
,
INamedTypeSymbol
extractedInterfaceSymbol
,
SyntaxNode
typeNode
,
ProjectId
projectId
,
DocumentId
documentId
,
INamedTypeSymbol
typeToExtractFrom
,
IEnumerable
<
ISymbol
>
includedMembers
,
CancellationToken
cancellationToken
)
Solution
solution
,
INamedTypeSymbol
extractedInterfaceSymbol
,
SyntaxNode
typeNode
,
ProjectId
projectId
,
DocumentId
documentId
,
INamedTypeSymbol
typeToExtractFrom
,
IEnumerable
<
ISymbol
>
includedMembers
,
CancellationToken
cancellationToken
)
{
var
symbolToDeclarationAnnotationMap
=
CreateSymbolToDeclarationAnnotationMap
(
includedMembers
,
...
...
@@ -238,8 +239,11 @@ public ExtractInterfaceResult ExtractInterfaceFromAnalyzedType(ExtractInterfaceT
var
completedSolution
=
GetSolutionWithSameFileUpdated
(
solution
:
solution
,
extractedInterfaceSymbol
:
extractedInterfaceSymbol
,
includedMembers
:
includedMembers
,
symbolToDeclarationAnnotationMap
:
symbolToDeclarationAnnotationMap
,
documentIds
:
documentIds
,
typeNodeAnnotation
:
typeNodeSyntaxAnnotation
,
documentId
:
documentId
,
documentId
WithTypeNode
:
documentId
,
cancellationToken
:
cancellationToken
);
return
new
ExtractInterfaceResult
(
...
...
src/Features/VisualBasic/Portable/ExtractInterface/VisualBasicExtractInterfaceService.vb
浏览文件 @
9fe084b5
...
...
@@ -9,6 +9,7 @@ Imports Microsoft.CodeAnalysis.Formatting
Imports
Microsoft.CodeAnalysis.Host.Mef
Imports
Microsoft.CodeAnalysis.Text
Imports
Microsoft.CodeAnalysis.VisualBasic
Imports
Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
Imports
Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace
Microsoft.CodeAnalysis.VisualBasic.ExtractInterface
...
...
@@ -201,8 +202,43 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractInterface
Return
typeDeclaration
.
GetModifiers
().
Any
(
Function
(
m
)
SyntaxFacts
.
IsAccessibilityModifier
(
m
.
Kind
()))
End
Function
Friend
Overrides
Function
GetSolutionWithSameFileUpdated
(
solution
As
Solution
,
extractedInterfaceSymbol
As
INamedTypeSymbol
,
typeNodeAnnotation
As
SyntaxAnnotation
,
documentId
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
Solution
Throw
New
NotImplementedException
()
Friend
Overrides
Function
GetSolutionWithSameFileUpdated
(
solution
As
Solution
,
extractedInterfaceSymbol
As
INamedTypeSymbol
,
includedMembers
As
IEnumerable
(
Of
ISymbol
),
symbolToDeclarationAnnotationMap
As
Dictionary
(
Of
ISymbol
,
SyntaxAnnotation
),
documentIds
As
List
(
Of
DocumentId
),
typeNodeAnnotation
As
SyntaxAnnotation
,
documentIdWithTypeNode
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
Solution
Dim
updatedSolution
=
GetSolutionWithUpdatedOriginalType
(
solution
,
extractedInterfaceSymbol
,
includedMembers
,
symbolToDeclarationAnnotationMap
,
documentIds
,
typeNodeAnnotation
,
documentIdWithTypeNode
,
cancellationToken
)
Dim
document
=
updatedSolution
.
GetDocument
(
documentIdWithTypeNode
)
Dim
originalRoot
=
document
.
GetSyntaxRootSynchronously
(
cancellationToken
)
Dim
typeDeclaration
=
originalRoot
.
GetAnnotatedNodes
(
typeNodeAnnotation
).
Single
()
document
=
document
.
WithSyntaxRoot
(
originalRoot
.
TrackNodes
(
typeDeclaration
))
Dim
currentRoot
=
document
.
GetSyntaxRootSynchronously
(
cancellationToken
)
Dim
editor
=
New
SyntaxEditor
(
currentRoot
,
VisualBasicSyntaxGenerator
.
Instance
)
typeDeclaration
=
currentRoot
.
GetCurrentNode
(
typeDeclaration
)
Dim
codeGenService
=
updatedSolution
.
Workspace
.
Services
.
GetLanguageServices
(
LanguageNames
.
VisualBasic
).
GetService
(
Of
ICodeGenerationService
)
Dim
interfaceNode
=
codeGenService
.
CreateNamedTypeDeclaration
(
extractedInterfaceSymbol
)
editor
.
InsertBefore
(
typeDeclaration
,
interfaceNode
)
Dim
newRoot
=
Formatter
.
Format
(
editor
.
GetChangedRoot
(),
updatedSolution
.
Workspace
)
Return
updatedSolution
.
WithDocumentSyntaxRoot
(
documentIdWithTypeNode
,
newRoot
,
PreservationMode
.
PreserveIdentity
)
End
Function
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录