Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8fc51455
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,发现更多精彩内容 >>
提交
8fc51455
编写于
7月 19, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properly support merge conflicts with empty sections.
上级
46a8a989
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
191 addition
and
32 deletion
+191
-32
src/EditorFeatures/CSharpTest/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
...ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
+132
-0
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
...MarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
+59
-32
未找到文件。
src/EditorFeatures/CSharpTest/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
浏览文件 @
8fc51455
...
...
@@ -157,5 +157,137 @@ static void Main2(string[] args)
}
}"
,
index
:
2
,
ignoreTrivia
:
false
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsResolveConflictMarker
)]
public
async
Task
TestEmptyTop_TakeTop
()
{
await
TestInRegularAndScript1Async
(
@"
using System;
namespace N
{
[|<<<<<<<|] This is mine!
=======
class Program2
{
static void Main2(string[] args)
{
Program2 p;
Console.WriteLine(""Their section"");
}
}
>>>>>>> This is theirs!
}"
,
@"
using System;
namespace N
{
}"
,
index
:
0
,
ignoreTrivia
:
false
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsResolveConflictMarker
)]
public
async
Task
TestEmptyTop_TakeBottom
()
{
await
TestInRegularAndScript1Async
(
@"
using System;
namespace N
{
[|<<<<<<<|] This is mine!
=======
class Program2
{
static void Main2(string[] args)
{
Program2 p;
Console.WriteLine(""Their section"");
}
}
>>>>>>> This is theirs!
}"
,
@"
using System;
namespace N
{
class Program2
{
static void Main2(string[] args)
{
Program2 p;
Console.WriteLine(""Their section"");
}
}
}"
,
index
:
1
,
ignoreTrivia
:
false
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsResolveConflictMarker
)]
public
async
Task
TestEmptyBottom_TakeTop
()
{
await
TestInRegularAndScript1Async
(
@"
using System;
namespace N
{
[|<<<<<<<|] This is mine!
class Program
{
static void Main(string[] args)
{
Program p;
Console.WriteLine(""My section"");
}
}
=======
>>>>>>> This is theirs!
}"
,
@"
using System;
namespace N
{
class Program
{
static void Main(string[] args)
{
Program p;
Console.WriteLine(""My section"");
}
}
}"
,
index
:
0
,
ignoreTrivia
:
false
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsResolveConflictMarker
)]
public
async
Task
TestEmptyBottom_TakeBottom
()
{
await
TestInRegularAndScript1Async
(
@"
using System;
namespace N
{
[|<<<<<<<|] This is mine!
class Program
{
static void Main(string[] args)
{
Program p;
Console.WriteLine(""My section"");
}
}
=======
>>>>>>> This is theirs!
}"
,
@"
using System;
namespace N
{
}"
,
index
:
1
,
ignoreTrivia
:
false
);
}
}
}
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
浏览文件 @
8fc51455
...
...
@@ -45,12 +45,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
while
(
true
)
{
token
=
token
.
GetNextToken
(
includeZeroWidth
:
true
);
if
(
token
.
RawKind
==
0
)
{
return
;
}
var
index
=
GetEqualsConflictMarkerIndex
(
text
,
token
);
if
(
index
>=
0
)
{
...
...
@@ -58,6 +52,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
if
(
index
+
3
<
token
.
LeadingTrivia
.
Count
)
{
// normal case where there us =====, then dead code, then >>>>>>
var
equalsTrivia
=
leadingTrivia
[
index
];
var
endOfLineTrivia
=
leadingTrivia
[
index
+
1
];
var
disabledTrivia
=
leadingTrivia
[
index
+
2
];
...
...
@@ -67,6 +63,41 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
IsDisabledText
(
disabledTrivia
)
&&
IsConflictMarker
(
text
,
endTrivia
,
'>'
))
{
RegisterCodeFixes
(
context
,
startTrivia
,
equalsTrivia
,
endTrivia
);
return
;
}
}
if
(
index
+
2
<
token
.
LeadingTrivia
.
Count
)
{
// case where there is ===== followed by >>>>>> on the next line.
var
equalsTrivia
=
leadingTrivia
[
index
];
var
endOfLineTrivia
=
leadingTrivia
[
index
+
1
];
var
endTrivia
=
leadingTrivia
[
index
+
2
];
if
(
IsEndOfLine
(
endOfLineTrivia
)
&&
IsConflictMarker
(
text
,
endTrivia
,
'>'
))
{
RegisterCodeFixes
(
context
,
startTrivia
,
equalsTrivia
,
endTrivia
);
return
;
}
}
}
token
=
token
.
GetNextToken
(
includeZeroWidth
:
true
);
if
(
token
.
RawKind
==
0
)
{
return
;
}
}
}
private
void
RegisterCodeFixes
(
CodeFixContext
context
,
SyntaxTrivia
startTrivia
,
SyntaxTrivia
equalsTrivia
,
SyntaxTrivia
endTrivia
)
{
var
document
=
context
.
Document
;
var
topText
=
startTrivia
.
ToString
().
Substring
(
s_mergeConflictLength
).
Trim
();
var
takeTopText
=
string
.
IsNullOrWhiteSpace
(
topText
)
?
FeaturesResources
.
Take_top
...
...
@@ -94,10 +125,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
c
=>
TakeBothAsync
(
document
,
startSpan
,
equalsSpan
,
endSpan
,
c
)),
context
.
Diagnostics
);
}
}
}
}
}
private
async
Task
<
Document
>
TakeTopAsync
(
Document
document
,
TextSpan
startSpan
,
TextSpan
equalsSpan
,
TextSpan
endSpan
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录