Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1ee40be6
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,发现更多精彩内容 >>
提交
1ee40be6
编写于
10月 05, 2015
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5618 from CyrusNajmabadi/outliningCrash
Filter out bad outlining spans.
上级
a70ab7e4
a7695c29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
2 deletion
+53
-2
src/EditorFeatures/Core/EditorFeatures.csproj
src/EditorFeatures/Core/EditorFeatures.csproj
+1
-0
src/EditorFeatures/Core/Implementation/Outlining/InvalidOutliningRegionException.cs
...plementation/Outlining/InvalidOutliningRegionException.cs
+27
-0
src/EditorFeatures/Core/Implementation/Outlining/OutliningTaggerProvider.cs
.../Core/Implementation/Outlining/OutliningTaggerProvider.cs
+25
-2
未找到文件。
src/EditorFeatures/Core/EditorFeatures.csproj
浏览文件 @
1ee40be6
...
...
@@ -270,6 +270,7 @@
<Compile
Include=
"Implementation\GoToImplementation\AbstractGoToImplementationService.cs"
/>
<Compile
Include=
"Implementation\GoToImplementation\IGoToImplementationService.cs"
/>
<Compile
Include=
"Implementation\Intellisense\Completion\OptionSetExtensions.cs"
/>
<Compile
Include=
"Implementation\Outlining\InvalidOutliningRegionException.cs"
/>
<Compile
Include=
"Implementation\Suggestions\FixMultipleOccurrencesService.cs"
/>
<Compile
Include=
"Implementation\Suggestions\FixMultipleSuggestedAction.cs"
/>
<Compile
Include=
"Implementation\GoToImplementation\GoToImplementationCommandHandler.cs"
/>
...
...
src/EditorFeatures/Core/Implementation/Outlining/InvalidOutliningRegionException.cs
0 → 100644
浏览文件 @
1ee40be6
using
System
;
using
Microsoft.VisualStudio.Text
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.Outlining
{
internal
class
InvalidOutliningRegionException
:
Exception
{
private
readonly
IOutliningService
_service
;
private
readonly
ITextSnapshot
_snapshot
;
private
readonly
Span
_snapshotSpan
;
private
readonly
Span
_regionSpan
;
public
InvalidOutliningRegionException
(
IOutliningService
service
,
ITextSnapshot
snapshot
,
Span
snapshotSpan
,
Span
regionSpan
)
:
base
(
GetExceptionMessage
(
service
,
snapshot
,
snapshotSpan
,
regionSpan
))
{
_service
=
service
;
_snapshot
=
snapshot
;
_snapshotSpan
=
snapshotSpan
;
_regionSpan
=
regionSpan
;
}
private
static
string
GetExceptionMessage
(
IOutliningService
service
,
ITextSnapshot
snapshot
,
Span
snapshotSpan
,
Span
regionSpan
)
{
return
$"OutliningService(
{
service
.
GetType
()}
) produced an invalid region. ITextSnapshot span is
{
snapshotSpan
}
. OutliningSpan is
{
regionSpan
}
."
;
}
}
}
\ No newline at end of file
src/EditorFeatures/Core/Implementation/Outlining/OutliningTaggerProvider.cs
浏览文件 @
1ee40be6
...
...
@@ -112,7 +112,7 @@ protected override async Task ProduceTagsAsync(TaggerContext<IOutliningRegionTag
var
regions
=
await
outliningService
.
GetOutliningSpansAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
regions
!=
null
)
{
regions
=
GetMultiLineRegions
(
regions
,
snapshotSpan
.
Snapshot
);
regions
=
GetMultiLineRegions
(
outliningService
,
regions
,
snapshotSpan
.
Snapshot
);
// Create the outlining tags.
var
tagSpans
=
...
...
@@ -143,7 +143,9 @@ protected override async Task ProduceTagsAsync(TaggerContext<IOutliningRegionTag
}
}
private
IList
<
OutliningSpan
>
GetMultiLineRegions
(
IList
<
OutliningSpan
>
regions
,
ITextSnapshot
snapshot
)
private
static
bool
exceptionReported
=
false
;
private
IList
<
OutliningSpan
>
GetMultiLineRegions
(
IOutliningService
service
,
IList
<
OutliningSpan
>
regions
,
ITextSnapshot
snapshot
)
{
// Remove any spans that aren't multiline.
var
multiLineRegions
=
new
List
<
OutliningSpan
>(
regions
.
Count
);
...
...
@@ -151,6 +153,27 @@ private IList<OutliningSpan> GetMultiLineRegions(IList<OutliningSpan> regions, I
{
if
(
region
!=
null
&&
region
.
TextSpan
.
Length
>
0
)
{
// Check if any clients produced an invalid OutliningSpan. If so, filter them
// out and report a non-fatal watson so we can attempt to determine the source
// of the issue.
var
snapshotSpan
=
snapshot
.
GetFullSpan
().
Span
;
var
regionSpan
=
region
.
TextSpan
.
ToSpan
();
if
(!
snapshotSpan
.
Contains
(
regionSpan
))
{
if
(!
exceptionReported
)
{
exceptionReported
=
true
;
try
{
throw
new
InvalidOutliningRegionException
(
service
,
snapshot
,
snapshotSpan
,
regionSpan
);
}
catch
(
InvalidOutliningRegionException
e
)
when
(
FatalError
.
ReportWithoutCrash
(
e
))
{
}
}
continue
;
}
var
startLine
=
snapshot
.
GetLineNumberFromPosition
(
region
.
TextSpan
.
Start
);
var
endLine
=
snapshot
.
GetLineNumberFromPosition
(
region
.
TextSpan
.
End
);
if
(
startLine
!=
endLine
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录