Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
558a22d1
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,发现更多精彩内容 >>
提交
558a22d1
编写于
9月 27, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - remove unsued code
上级
a272ebcf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
65 deletion
+10
-65
src/vs/base/common/graph.ts
src/vs/base/common/graph.ts
+5
-21
src/vs/base/test/common/graph.test.ts
src/vs/base/test/common/graph.test.ts
+4
-43
src/vs/platform/instantiation/common/instantiationService.ts
src/vs/platform/instantiation/common/instantiationService.ts
+1
-1
未找到文件。
src/vs/base/common/graph.ts
浏览文件 @
558a22d1
...
@@ -39,25 +39,6 @@ export class Graph<T> {
...
@@ -39,25 +39,6 @@ export class Graph<T> {
return
ret
;
return
ret
;
}
}
traverse
(
start
:
T
,
inwards
:
boolean
,
callback
:
(
data
:
T
)
=>
void
):
void
{
const
startNode
=
this
.
lookup
(
start
);
if
(
!
startNode
)
{
return
;
}
this
.
_traverse
(
startNode
,
inwards
,
Object
.
create
(
null
),
callback
);
}
private
_traverse
(
node
:
Node
<
T
>
,
inwards
:
boolean
,
seen
:
{
[
key
:
string
]:
boolean
},
callback
:
(
data
:
T
)
=>
void
):
void
{
const
key
=
this
.
_hashFn
(
node
.
data
);
if
(
seen
[
key
])
{
return
;
}
seen
[
key
]
=
true
;
callback
(
node
.
data
);
const
nodes
=
inwards
?
node
.
outgoing
:
node
.
incoming
;
forEach
(
nodes
,
(
entry
)
=>
this
.
_traverse
(
entry
.
value
,
inwards
,
seen
,
callback
));
}
insertEdge
(
from
:
T
,
to
:
T
):
void
{
insertEdge
(
from
:
T
,
to
:
T
):
void
{
const
fromNode
=
this
.
lookupOrInsertNode
(
from
),
const
fromNode
=
this
.
lookupOrInsertNode
(
from
),
toNode
=
this
.
lookupOrInsertNode
(
to
);
toNode
=
this
.
lookupOrInsertNode
(
to
);
...
@@ -91,8 +72,11 @@ export class Graph<T> {
...
@@ -91,8 +72,11 @@ export class Graph<T> {
return
this
.
_nodes
[
this
.
_hashFn
(
data
)];
return
this
.
_nodes
[
this
.
_hashFn
(
data
)];
}
}
get
length
():
number
{
isEmpty
():
boolean
{
return
Object
.
keys
(
this
.
_nodes
).
length
;
for
(
const
_key
in
this
.
_nodes
)
{
return
false
;
}
return
true
;
}
}
toString
():
string
{
toString
():
string
{
...
...
src/vs/base/test/common/graph.test.ts
浏览文件 @
558a22d1
...
@@ -14,12 +14,6 @@ suite('Graph', () => {
...
@@ -14,12 +14,6 @@ suite('Graph', () => {
graph
=
new
Graph
<
string
>
(
s
=>
s
);
graph
=
new
Graph
<
string
>
(
s
=>
s
);
});
});
test
(
'
cannot be traversed when empty
'
,
function
()
{
graph
.
traverse
(
'
foo
'
,
true
,
()
=>
assert
(
false
));
graph
.
traverse
(
'
foo
'
,
false
,
()
=>
assert
(
false
));
assert
(
true
);
});
test
(
'
is possible to lookup nodes that don
\'
t exist
'
,
function
()
{
test
(
'
is possible to lookup nodes that don
\'
t exist
'
,
function
()
{
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
});
});
...
@@ -31,46 +25,13 @@ suite('Graph', () => {
...
@@ -31,46 +25,13 @@ suite('Graph', () => {
});
});
test
(
'
can remove nodes and get length
'
,
function
()
{
test
(
'
can remove nodes and get length
'
,
function
()
{
assert
.
equal
(
graph
.
length
,
0
);
assert
.
ok
(
graph
.
isEmpty
()
);
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
assert
.
deepEqual
(
graph
.
lookupOrInsertNode
(
'
ddd
'
).
data
,
'
ddd
'
);
assert
.
deepEqual
(
graph
.
lookupOrInsertNode
(
'
ddd
'
).
data
,
'
ddd
'
);
assert
.
equal
(
graph
.
length
,
1
);
assert
.
ok
(
!
graph
.
isEmpty
()
);
graph
.
removeNode
(
'
ddd
'
);
graph
.
removeNode
(
'
ddd
'
);
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
assert
.
deepEqual
(
graph
.
lookup
(
'
ddd
'
),
null
);
assert
.
equal
(
graph
.
length
,
0
);
assert
.
ok
(
graph
.
isEmpty
());
});
test
(
'
traverse from leaf
'
,
function
()
{
graph
.
insertEdge
(
'
foo
'
,
'
bar
'
);
graph
.
traverse
(
'
bar
'
,
true
,
(
node
)
=>
assert
.
equal
(
node
,
'
bar
'
));
var
items
=
[
'
bar
'
,
'
foo
'
];
graph
.
traverse
(
'
bar
'
,
false
,
(
node
)
=>
assert
.
equal
(
node
,
items
.
shift
()));
});
test
(
'
traverse from center
'
,
function
()
{
graph
.
insertEdge
(
'
1
'
,
'
3
'
);
graph
.
insertEdge
(
'
2
'
,
'
3
'
);
graph
.
insertEdge
(
'
3
'
,
'
4
'
);
graph
.
insertEdge
(
'
3
'
,
'
5
'
);
var
items
=
[
'
3
'
,
'
4
'
,
'
5
'
];
graph
.
traverse
(
'
3
'
,
true
,
(
node
)
=>
assert
.
equal
(
node
,
items
.
shift
()));
items
=
[
'
3
'
,
'
1
'
,
'
2
'
];
graph
.
traverse
(
'
3
'
,
false
,
(
node
)
=>
assert
.
equal
(
node
,
items
.
shift
()));
});
test
(
'
traverse a chain
'
,
function
()
{
graph
.
insertEdge
(
'
1
'
,
'
2
'
);
graph
.
insertEdge
(
'
2
'
,
'
3
'
);
graph
.
insertEdge
(
'
3
'
,
'
4
'
);
graph
.
insertEdge
(
'
4
'
,
'
5
'
);
var
items
=
[
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
];
graph
.
traverse
(
'
1
'
,
true
,
(
node
)
=>
assert
.
equal
(
node
,
items
.
shift
()));
items
=
[
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
].
reverse
();
graph
.
traverse
(
'
5
'
,
false
,
(
node
)
=>
assert
.
equal
(
node
,
items
.
shift
()));
});
});
test
(
'
root
'
,
function
()
{
test
(
'
root
'
,
function
()
{
...
@@ -93,4 +54,4 @@ suite('Graph', () => {
...
@@ -93,4 +54,4 @@ suite('Graph', () => {
assert
.
equal
(
roots
.
length
,
2
);
assert
.
equal
(
roots
.
length
,
2
);
assert
([
'
2
'
,
'
4
'
].
every
(
n
=>
roots
.
some
(
node
=>
node
.
data
===
n
)));
assert
([
'
2
'
,
'
4
'
].
every
(
n
=>
roots
.
some
(
node
=>
node
.
data
===
n
)));
});
});
});
});
\ No newline at end of file
src/vs/platform/instantiation/common/instantiationService.ts
浏览文件 @
558a22d1
...
@@ -182,7 +182,7 @@ export class InstantiationService implements IInstantiationService {
...
@@ -182,7 +182,7 @@ export class InstantiationService implements IInstantiationService {
// if there is no more roots but still
// if there is no more roots but still
// nodes in the graph we have a cycle
// nodes in the graph we have a cycle
if
(
roots
.
length
===
0
)
{
if
(
roots
.
length
===
0
)
{
if
(
graph
.
length
!==
0
)
{
if
(
!
graph
.
isEmpty
()
)
{
throwCycleError
();
throwCycleError
();
}
}
break
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录