Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fdc48b3f
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,发现更多精彩内容 >>
提交
fdc48b3f
编写于
4月 08, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor DiagnosticsCollection so that it holds data on ext host side
上级
63c85fb3
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
57 addition
and
59 deletion
+57
-59
src/vs/workbench/api/node/extHostDiagnostics.ts
src/vs/workbench/api/node/extHostDiagnostics.ts
+57
-59
未找到文件。
src/vs/workbench/api/node/extHostDiagnostics.ts
浏览文件 @
fdc48b3f
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
'
use strict
'
;
'
use strict
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
IMarkerService
,
I
ResourceMarker
,
I
MarkerData
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IMarkerService
,
IMarkerData
}
from
'
vs/platform/markers/common/markers
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
Severity
from
'
vs/base/common/severity
'
;
...
@@ -17,7 +17,9 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -17,7 +17,9 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
private
_name
:
string
;
private
_name
:
string
;
private
_proxy
:
MainThreadDiagnostics
;
private
_proxy
:
MainThreadDiagnostics
;
private
_isDisposed
:
boolean
;
private
_isDisposed
=
false
;
private
_data
:
{[
uri
:
string
]:
vscode
.
Diagnostic
[]}
=
Object
.
create
(
null
);
constructor
(
name
:
string
,
proxy
:
MainThreadDiagnostics
)
{
constructor
(
name
:
string
,
proxy
:
MainThreadDiagnostics
)
{
this
.
_name
=
name
;
this
.
_name
=
name
;
...
@@ -26,10 +28,10 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -26,10 +28,10 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
dispose
():
void
{
dispose
():
void
{
if
(
!
this
.
_isDisposed
)
{
if
(
!
this
.
_isDisposed
)
{
this
.
_proxy
.
_changeAll
(
this
.
name
,
undefined
).
then
(()
=>
{
this
.
_proxy
=
undefined
;
this
.
_isDisposed
=
true
;
this
.
_isDisposed
=
true
;
});
this
.
_proxy
.
$clear
(
this
.
name
);
this
.
_proxy
=
undefined
;
this
.
_data
=
undefined
;
}
}
}
}
...
@@ -41,71 +43,64 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -41,71 +43,64 @@ class DiagnosticCollection implements vscode.DiagnosticCollection {
set
(
uri
:
vscode
.
Uri
,
diagnostics
:
vscode
.
Diagnostic
[]):
void
;
set
(
uri
:
vscode
.
Uri
,
diagnostics
:
vscode
.
Diagnostic
[]):
void
;
set
(
entries
:
[
vscode
.
Uri
,
vscode
.
Diagnostic
[]][]):
void
;
set
(
entries
:
[
vscode
.
Uri
,
vscode
.
Diagnostic
[]][]):
void
;
set
(
first
:
vscode
.
Uri
|
[
vscode
.
Uri
,
vscode
.
Diagnostic
[]][],
diagnostics
?:
vscode
.
Diagnostic
[])
{
set
(
first
:
vscode
.
Uri
|
[
vscode
.
Uri
,
vscode
.
Diagnostic
[]][],
diagnostics
?:
vscode
.
Diagnostic
[])
{
this
.
_checkDisposed
();
if
(
first
instanceof
URI
)
{
// change markers of resource only (max 500)
let
data
:
IMarkerData
[];
if
(
!
first
)
{
if
(
diagnostics
)
{
// this set-call is a clear-call
data
=
[];
this
.
clear
();
let
len
=
diagnostics
.
length
;
return
;
if
(
len
>
DiagnosticCollection
.
_maxDiagnosticsPerFile
)
{
console
.
warn
(
'
diagnostics for %s will be capped to %d (actually is %d)
'
,
first
.
toString
(),
DiagnosticCollection
.
_maxDiagnosticsPerFile
,
len
);
len
=
DiagnosticCollection
.
_maxDiagnosticsPerFile
;
}
}
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
// the actual implementation for #set
data
.
push
(
DiagnosticCollection
.
_toMarkerData
(
diagnostics
[
i
]));
}
}
// set or reset for this resource
this
.
_checkDisposed
();
return
this
.
_proxy
.
_changeOne
(
this
.
name
,
first
,
data
)
;
let
toSync
:
vscode
.
Uri
[]
;
}
else
{
if
(
first
instanceof
URI
)
{
// change all marker of owner
// update single row
let
entries
=
<
[
vscode
.
Uri
,
vscode
.
Diagnostic
[]][]
>
first
;
this
.
_data
[
first
.
toString
()]
=
diagnostics
;
let
data
:
IResourceMarker
[];
toSync
=
[
first
];
if
(
entries
)
{
let
total
=
0
;
}
else
if
(
Array
.
isArray
(
first
))
{
data
=
[];
// update many rows
for
(
let
entry
of
entries
)
{
toSync
=
[];
for
(
let
entry
of
first
)
{
let
[
uri
,
diagnostics
]
=
entry
;
let
[
uri
,
diagnostics
]
=
entry
;
if
(
diagnostics
)
{
this
.
_data
[
uri
.
toString
()]
=
diagnostics
;
let
len
=
diagnostics
.
length
;
toSync
.
push
(
uri
);
if
(
len
>
DiagnosticCollection
.
_maxDiagnosticsPerFile
)
{
console
.
warn
(
'
diagnostics for %s will be capped to %d (actually is %d)
'
,
uri
.
toString
(),
DiagnosticCollection
.
_maxDiagnosticsPerFile
,
len
);
len
=
DiagnosticCollection
.
_maxDiagnosticsPerFile
;
}
}
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
data
.
push
({
resource
:
<
URI
>
uri
,
marker
:
DiagnosticCollection
.
_toMarkerData
(
diagnostics
[
i
])
});
}
}
total
+=
len
;
// compute change and send to main side
if
(
total
>
10
*
DiagnosticCollection
.
_maxDiagnosticsPerFile
)
{
const
entries
:
[
URI
,
IMarkerData
[]][]
=
[];
console
.
warn
(
'
too many diagnostics will cap to %d
'
,
10
*
DiagnosticCollection
.
_maxDiagnosticsPerFile
);
for
(
let
uri
of
toSync
)
{
break
;
let
marker
:
IMarkerData
[];
}
let
diagnostics
=
this
.
_data
[
uri
.
toString
()];
}
if
(
diagnostics
)
{
// no more than 250 diagnostics per file
if
(
diagnostics
.
length
>
DiagnosticCollection
.
_maxDiagnosticsPerFile
)
{
console
.
warn
(
'
diagnostics for %s will be capped to %d (actually is %d)
'
,
uri
,
DiagnosticCollection
.
_maxDiagnosticsPerFile
,
diagnostics
.
length
);
diagnostics
=
diagnostics
.
slice
(
0
,
DiagnosticCollection
.
_maxDiagnosticsPerFile
);
}
}
marker
=
diagnostics
.
map
(
DiagnosticCollection
.
_toMarkerData
);
}
}
// set or reset all
entries
.
push
([
<
URI
>
uri
,
marker
]);
this
.
_proxy
.
_changeAll
(
this
.
name
,
data
);
}
}
this
.
_proxy
.
$changeMany
(
this
.
name
,
entries
);
}
}
delete
(
uri
:
vscode
.
Uri
):
void
{
delete
(
uri
:
vscode
.
Uri
):
void
{
return
this
.
set
(
uri
,
undefined
);
this
.
_checkDisposed
();
delete
this
.
_data
[
uri
.
toString
()];
this
.
_proxy
.
$changeMany
(
this
.
name
,
[[
<
URI
>
uri
,
undefined
]]);
}
}
clear
():
void
{
clear
():
void
{
return
this
.
set
(
undefined
);
this
.
_checkDisposed
();
this
.
_data
=
Object
.
create
(
null
);
this
.
_proxy
.
$clear
(
this
.
name
);
}
}
private
_checkDisposed
()
{
private
_checkDisposed
()
{
...
@@ -167,13 +162,16 @@ export class MainThreadDiagnostics {
...
@@ -167,13 +162,16 @@ export class MainThreadDiagnostics {
this
.
_markerService
=
markerService
;
this
.
_markerService
=
markerService
;
}
}
_changeOne
(
owner
:
string
,
resource
:
URI
,
markers
:
IMarkerData
[]):
TPromise
<
any
>
{
$changeMany
(
owner
:
string
,
entries
:
[
URI
,
IMarkerData
[]][]):
TPromise
<
any
>
{
this
.
_markerService
.
changeOne
(
owner
,
resource
,
markers
);
for
(
let
entry
of
entries
)
{
let
[
uri
,
markers
]
=
entry
;
this
.
_markerService
.
changeOne
(
owner
,
uri
,
markers
);
}
return
undefined
;
return
undefined
;
}
}
_changeAll
(
owner
:
string
,
data
:
IResourceMarker
[]
):
TPromise
<
any
>
{
$clear
(
owner
:
string
):
TPromise
<
any
>
{
this
.
_markerService
.
changeAll
(
owner
,
data
);
this
.
_markerService
.
changeAll
(
owner
,
undefined
);
return
undefined
;
return
undefined
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录