Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e61e74f5
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e61e74f5
编写于
9月 22, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
incremental marker service stats update
上级
1d149b64
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
84 addition
and
26 deletion
+84
-26
src/vs/platform/markers/common/markerService.ts
src/vs/platform/markers/common/markerService.ts
+84
-26
未找到文件。
src/vs/platform/markers/common/markerService.ts
浏览文件 @
e61e74f5
...
...
@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
network
from
'
vs/base/common/network
'
;
// import * as collections from 'vs/base/common/collections
';
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
isEmptyObject
}
from
'
vs/base/common/types
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Event
,
{
Emitter
,
debounceEvent
}
from
'
vs/base/common/event
'
;
...
...
@@ -43,6 +43,78 @@ namespace MapMap {
}
}
class
MarkerStats
implements
MarkerStatistics
{
errors
:
number
=
0
;
infos
:
number
=
0
;
warnings
:
number
=
0
;
unknowns
:
number
=
0
;
private
_data
:
{
[
resource
:
string
]:
MarkerStatistics
}
=
Object
.
create
(
null
);
private
_service
:
IMarkerService
;
private
_subscription
:
IDisposable
;
constructor
(
service
:
IMarkerService
)
{
this
.
_service
=
service
;
this
.
_subscription
=
service
.
onMarkerChanged
(
this
.
_update
,
this
);
}
dispose
():
void
{
this
.
_subscription
.
dispose
();
this
.
_data
=
undefined
;
}
private
_update
(
resources
:
URI
[]):
void
{
for
(
const
resource
of
resources
)
{
const
key
=
resource
.
toString
();
const
oldStats
=
this
.
_data
[
key
];
if
(
oldStats
)
{
this
.
_substract
(
oldStats
);
}
const
newStats
=
this
.
_resourceStats
(
resource
);
this
.
_add
(
newStats
);
this
.
_data
[
key
]
=
newStats
;
}
}
private
_resourceStats
(
resource
:
URI
):
MarkerStatistics
{
const
result
:
MarkerStatistics
=
{
errors
:
0
,
warnings
:
0
,
infos
:
0
,
unknowns
:
0
};
// TODO this is a hack
if
(
resource
.
scheme
===
Schemas
.
inMemory
)
{
return
result
;
}
for
(
const
{
severity
}
of
this
.
_service
.
read
({
resource
}))
{
if
(
severity
===
Severity
.
Error
)
{
result
.
errors
+=
1
;
}
else
if
(
severity
===
Severity
.
Warning
)
{
result
.
warnings
+=
1
;
}
else
if
(
severity
===
Severity
.
Info
)
{
result
.
infos
+=
1
;
}
else
{
result
.
unknowns
+=
1
;
}
}
return
result
;
}
private
_substract
(
op
:
MarkerStatistics
)
{
this
.
errors
-=
op
.
errors
;
this
.
warnings
-=
op
.
warnings
;
this
.
infos
-=
op
.
infos
;
this
.
unknowns
-=
op
.
unknowns
;
}
private
_add
(
op
:
MarkerStatistics
)
{
this
.
errors
+=
op
.
errors
;
this
.
warnings
+=
op
.
warnings
;
this
.
infos
+=
op
.
infos
;
this
.
unknowns
+=
op
.
unknowns
;
}
}
export
class
MarkerService
implements
IMarkerService
{
_serviceBrand
:
any
;
...
...
@@ -51,10 +123,14 @@ export class MarkerService implements IMarkerService {
private
_onMarkerChangedEvent
:
Event
<
URI
[]
>
=
debounceEvent
(
this
.
_onMarkerChanged
.
event
,
MarkerService
.
_debouncer
,
0
);
private
_byResource
:
MapMap
<
IMarker
[]
>
=
Object
.
create
(
null
);
private
_byOwner
:
MapMap
<
IMarker
[]
>
=
Object
.
create
(
null
);
private
_stats
:
MarkerStat
istic
s
;
private
_stats
:
MarkerStats
;
constructor
()
{
this
.
_onMarkerChangedEvent
(()
=>
this
.
_stats
=
undefined
);
this
.
_stats
=
new
MarkerStats
(
this
);
}
dispose
():
void
{
this
.
_stats
.
dispose
();
}
get
onMarkerChanged
():
Event
<
URI
[]
>
{
...
...
@@ -62,29 +138,11 @@ export class MarkerService implements IMarkerService {
}
getStatistics
():
MarkerStatistics
{
if
(
!
this
.
_stats
)
{
this
.
_stats
=
{
errors
:
0
,
infos
:
0
,
warnings
:
0
,
unknowns
:
0
};
for
(
const
{
severity
,
resource
}
of
this
.
read
())
{
// TODO this is a hack
if
(
resource
.
scheme
===
network
.
Schemas
.
inMemory
)
{
continue
;
}
if
(
severity
===
Severity
.
Error
)
{
this
.
_stats
.
errors
+=
1
;
}
else
if
(
severity
===
Severity
.
Warning
)
{
this
.
_stats
.
warnings
+=
1
;
}
else
if
(
severity
===
Severity
.
Info
)
{
this
.
_stats
.
infos
+=
1
;
}
else
{
this
.
_stats
.
unknowns
+=
1
;
}
}
}
return
this
.
_stats
;
}
remove
(
owner
:
string
,
resources
:
URI
[]):
void
{
if
(
!
arrays
.
isFalsyOrEmpty
(
resources
))
{
if
(
!
isFalsyOrEmpty
(
resources
))
{
for
(
const
resource
of
resources
)
{
this
.
changeOne
(
owner
,
resource
,
undefined
);
}
...
...
@@ -93,7 +151,7 @@ export class MarkerService implements IMarkerService {
changeOne
(
owner
:
string
,
resource
:
URI
,
markerData
:
IMarkerData
[]):
void
{
if
(
arrays
.
isFalsyOrEmpty
(
markerData
))
{
if
(
isFalsyOrEmpty
(
markerData
))
{
// remove marker for this (owner,resource)-tuple
const
a
=
MapMap
.
remove
(
this
.
_byResource
,
resource
.
toString
(),
owner
);
const
b
=
MapMap
.
remove
(
this
.
_byOwner
,
owner
,
resource
.
toString
());
...
...
@@ -166,7 +224,7 @@ export class MarkerService implements IMarkerService {
}
// add new markers
if
(
!
arrays
.
isFalsyOrEmpty
(
data
))
{
if
(
!
isFalsyOrEmpty
(
data
))
{
// group by resource
const
groups
:
{
[
resource
:
string
]:
IMarker
[]
}
=
Object
.
create
(
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录