Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a5561ad9
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a5561ad9
编写于
9月 11, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't update markers when there is no real change, #57875
上级
5bd80f00
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
4 deletion
+80
-4
src/vs/base/common/arrays.ts
src/vs/base/common/arrays.ts
+8
-0
src/vs/workbench/api/node/extHostDiagnostics.ts
src/vs/workbench/api/node/extHostDiagnostics.ts
+17
-3
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+30
-1
src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts
...ench/test/electron-browser/api/extHostDiagnostics.test.ts
+25
-0
未找到文件。
src/vs/base/common/arrays.ts
浏览文件 @
a5561ad9
...
@@ -27,6 +27,14 @@ export function tail2<T>(arr: T[]): [T[], T] {
...
@@ -27,6 +27,14 @@ export function tail2<T>(arr: T[]): [T[], T] {
}
}
export
function
equals
<
T
>
(
one
:
ReadonlyArray
<
T
>
,
other
:
ReadonlyArray
<
T
>
,
itemEquals
:
(
a
:
T
,
b
:
T
)
=>
boolean
=
(
a
,
b
)
=>
a
===
b
):
boolean
{
export
function
equals
<
T
>
(
one
:
ReadonlyArray
<
T
>
,
other
:
ReadonlyArray
<
T
>
,
itemEquals
:
(
a
:
T
,
b
:
T
)
=>
boolean
=
(
a
,
b
)
=>
a
===
b
):
boolean
{
if
(
one
===
other
)
{
return
true
;
}
if
(
!
one
||
!
other
)
{
return
false
;
}
if
(
one
.
length
!==
other
.
length
)
{
if
(
one
.
length
!==
other
.
length
)
{
return
false
;
return
false
;
}
}
...
...
src/vs/workbench/api/node/extHostDiagnostics.ts
浏览文件 @
a5561ad9
...
@@ -9,9 +9,9 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers'
...
@@ -9,9 +9,9 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers'
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
MainContext
,
MainThreadDiagnosticsShape
,
ExtHostDiagnosticsShape
,
IMainContext
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadDiagnosticsShape
,
ExtHostDiagnosticsShape
,
IMainContext
}
from
'
./extHost.protocol
'
;
import
{
DiagnosticSeverity
}
from
'
./extHostTypes
'
;
import
{
DiagnosticSeverity
,
Diagnostic
}
from
'
./extHostTypes
'
;
import
*
as
converter
from
'
./extHostTypeConverters
'
;
import
*
as
converter
from
'
./extHostTypeConverters
'
;
import
{
mergeSort
}
from
'
vs/base/common/arrays
'
;
import
{
mergeSort
,
equals
}
from
'
vs/base/common/arrays
'
;
import
{
Event
,
Emitter
,
debounceEvent
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
,
debounceEvent
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
keys
}
from
'
vs/base/common/map
'
;
import
{
keys
}
from
'
vs/base/common/map
'
;
...
@@ -62,9 +62,13 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -62,9 +62,13 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
this
.
_checkDisposed
();
this
.
_checkDisposed
();
let
toSync
:
vscode
.
Uri
[];
let
toSync
:
vscode
.
Uri
[];
let
hasChanged
=
true
;
if
(
first
instanceof
URI
)
{
if
(
first
instanceof
URI
)
{
// check if this has actually changed
hasChanged
=
hasChanged
&&
!
equals
(
diagnostics
,
this
.
get
(
first
),
Diagnostic
.
isEqual
);
if
(
!
diagnostics
)
{
if
(
!
diagnostics
)
{
// remove this entry
// remove this entry
this
.
delete
(
first
);
this
.
delete
(
first
);
...
@@ -103,6 +107,17 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -103,6 +107,17 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
}
}
}
}
// send event for extensions
this
.
_onDidChangeDiagnostics
.
fire
(
toSync
);
// if nothing has changed then there is nothing else to do
// we have updated the diagnostics but we don't send a message
// to the renderer. tho we have still send an event for other
// extensions because the diagnostic might carry more information
// than known to us
if
(
!
hasChanged
)
{
return
;
}
// compute change and send to main side
// compute change and send to main side
const
entries
:
[
URI
,
IMarkerData
[]][]
=
[];
const
entries
:
[
URI
,
IMarkerData
[]][]
=
[];
for
(
let
uri
of
toSync
)
{
for
(
let
uri
of
toSync
)
{
...
@@ -142,7 +157,6 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
...
@@ -142,7 +157,6 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
entries
.
push
([
uri
,
marker
]);
entries
.
push
([
uri
,
marker
]);
}
}
this
.
_onDidChangeDiagnostics
.
fire
(
toSync
);
this
.
_proxy
.
$changeMany
(
this
.
_owner
,
entries
);
this
.
_proxy
.
$changeMany
(
this
.
_owner
,
entries
);
}
}
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
a5561ad9
...
@@ -14,7 +14,7 @@ import { IRelativePattern } from 'vs/base/common/glob';
...
@@ -14,7 +14,7 @@ import { IRelativePattern } from 'vs/base/common/glob';
import
{
relative
}
from
'
path
'
;
import
{
relative
}
from
'
path
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
coalesce
,
equals
}
from
'
vs/base/common/arrays
'
;
export
class
Disposable
{
export
class
Disposable
{
...
@@ -771,6 +771,18 @@ export class DiagnosticRelatedInformation {
...
@@ -771,6 +771,18 @@ export class DiagnosticRelatedInformation {
this
.
location
=
location
;
this
.
location
=
location
;
this
.
message
=
message
;
this
.
message
=
message
;
}
}
static
isEqual
(
a
:
DiagnosticRelatedInformation
,
b
:
DiagnosticRelatedInformation
):
boolean
{
if
(
a
===
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
return
a
.
message
===
b
.
message
&&
a
.
location
.
range
.
isEqual
(
b
.
location
.
range
)
&&
a
.
location
.
uri
.
toString
()
===
b
.
location
.
uri
.
toString
();
}
}
}
export
class
Diagnostic
{
export
class
Diagnostic
{
...
@@ -798,6 +810,23 @@ export class Diagnostic {
...
@@ -798,6 +810,23 @@ export class Diagnostic {
code
:
this
.
code
,
code
:
this
.
code
,
};
};
}
}
static
isEqual
(
a
:
Diagnostic
,
b
:
Diagnostic
):
boolean
{
if
(
a
===
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
return
a
.
message
===
b
.
message
&&
a
.
severity
===
b
.
severity
&&
a
.
code
===
b
.
code
&&
a
.
severity
===
b
.
severity
&&
a
.
source
===
b
.
source
&&
a
.
range
.
isEqual
(
b
.
range
)
&&
equals
(
a
.
tags
,
b
.
tags
)
&&
equals
(
a
.
relatedInformation
,
b
.
relatedInformation
,
DiagnosticRelatedInformation
.
isEqual
);
}
}
}
export
class
Hover
{
export
class
Hover
{
...
...
src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts
浏览文件 @
a5561ad9
...
@@ -190,6 +190,31 @@ suite('ExtHostDiagnostics', () => {
...
@@ -190,6 +190,31 @@ suite('ExtHostDiagnostics', () => {
lastEntries
=
undefined
;
lastEntries
=
undefined
;
});
});
test
(
'
don
\'
t send message when not making a change
'
,
function
()
{
let
changeCount
=
0
;
let
eventCount
=
0
;
const
emitter
=
new
Emitter
<
any
>
();
emitter
.
event
(
_
=>
eventCount
+=
1
);
const
collection
=
new
DiagnosticCollection
(
'
test
'
,
'
test
'
,
100
,
new
class
extends
DiagnosticsShape
{
$changeMany
()
{
changeCount
+=
1
;
}
},
emitter
);
let
uri
=
URI
.
parse
(
'
sc:hightower
'
);
let
diag
=
new
Diagnostic
(
new
Range
(
0
,
0
,
0
,
1
),
'
ffff
'
);
collection
.
set
(
uri
,
[
diag
]);
assert
.
equal
(
changeCount
,
1
);
assert
.
equal
(
eventCount
,
1
);
collection
.
set
(
uri
,
[
diag
]);
assert
.
equal
(
changeCount
,
1
);
assert
.
equal
(
eventCount
,
2
);
});
test
(
'
diagnostics collection, tuples and undefined (small array), #15585
'
,
function
()
{
test
(
'
diagnostics collection, tuples and undefined (small array), #15585
'
,
function
()
{
const
collection
=
new
DiagnosticCollection
(
'
test
'
,
'
test
'
,
100
,
new
DiagnosticsShape
(),
new
Emitter
());
const
collection
=
new
DiagnosticCollection
(
'
test
'
,
'
test
'
,
100
,
new
DiagnosticsShape
(),
new
Emitter
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录