Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3b251db0
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,发现更多精彩内容 >>
提交
3b251db0
编写于
2月 07, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ficks speeling
上级
2100fde0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
8 deletion
+7
-8
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
...lineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
+7
-8
未找到文件。
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
浏览文件 @
3b251db0
...
...
@@ -9,7 +9,6 @@
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.CodeActions
;
using
Microsoft.CodeAnalysis.CodeFixes
;
using
Microsoft.CodeAnalysis.CSharp.CodeStyle
;
using
Microsoft.CodeAnalysis.CSharp.CodeStyle.TypeStyle
;
using
Microsoft.CodeAnalysis.CSharp.Extensions
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
...
...
@@ -46,7 +45,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
// Attempt to use an out-var declaration if that's the style the user prefers.
// Note: if using 'var' would cause a problem, we will use the actual type
// of
ht
e local. This is necessary in some cases (for example, when the
// of
th
e local. This is necessary in some cases (for example, when the
// type of the out-var-decl affects overload resolution or generic instantiation).
foreach
(
var
diagnostic
in
diagnostics
)
...
...
@@ -122,7 +121,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
// to the previous token. We're going to move it along with this declarator.
// If we don't, then the comment will stay with the previous token.
//
// Note that
ht
e moving of the comment happens later on when we make the
// Note that
th
e moving of the comment happens later on when we make the
// declaration expression.
if
(
sourceText
.
AreOnSameLine
(
declarator
.
GetFirstToken
(),
declarator
.
GetFirstToken
().
GetPreviousToken
(
includeSkipped
:
true
)))
{
...
...
@@ -138,8 +137,8 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
//
// Method(out var x)
//
// Then the type is not-app
erant, and we shoudl
not use var if the user only wants
// it for app
era
nt types
// Then the type is not-app
arent, and we should
not use var if the user only wants
// it for app
are
nt types
var
local
=
(
ILocalSymbol
)
semanticModel
.
GetDeclaredSymbol
(
declarator
);
var
newType
=
local
.
Type
.
GenerateTypeSyntaxOrVar
(
options
,
typeIsApperant
:
false
);
...
...
@@ -176,7 +175,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
{
// We're removing a single declarator. Copy any comments it has to the out-var.
//
// Note: this is tricky due to comment ownership. We want
ht
e comments that logically
// Note: this is tricky due to comment ownership. We want
th
e comments that logically
// belong to the declarator, even if our syntax model attaches them to other tokens.
var
precedingTrivia
=
declaratorOpt
.
GetAllPrecedingTriviaToPreviousToken
(
sourceText
,
includePreviousTokenTrailingTriviaOnlyIfOnSameLine
:
true
);
...
...
@@ -205,7 +204,7 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
else
if
(
trivia
.
IsWhitespace
())
{
// Condense whitespace down to single spaces. We don't want things like
// indentation spaces to be inserted in the out-var location. It is appropr
ai
te
// indentation spaces to be inserted in the out-var location. It is appropr
ia
te
// though to have single spaces to help separate out things like comments and
// tokens though.
yield
return
SyntaxFactory
.
Space
;
...
...
@@ -225,7 +224,7 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
if
(
newType
.
IsVar
)
{
// Options want us to use 'var' if we can. Make sure we didn't change
// the semantics of t
eh
call by doing this.
// the semantics of t
he
call by doing this.
// Find the symbol that the existing invocation points to.
var
root
=
await
document
.
GetSyntaxRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录