Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f170b506
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,发现更多精彩内容 >>
提交
f170b506
编写于
9月 23, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
https://github.com/microsoft/vscode/issues/105562
上级
8e826780
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
4 deletion
+42
-4
src/vs/platform/instantiation/common/instantiationService.ts
src/vs/platform/instantiation/common/instantiationService.ts
+9
-3
src/vs/platform/instantiation/test/common/instantiationService.test.ts
...rm/instantiation/test/common/instantiationService.test.ts
+33
-1
未找到文件。
src/vs/platform/instantiation/common/instantiationService.ts
浏览文件 @
f170b506
...
...
@@ -183,9 +183,15 @@ export class InstantiationService implements IInstantiationService {
}
for
(
const
{
data
}
of
roots
)
{
// create instance and overwrite the service collections
const
instance
=
this
.
_createServiceInstanceWithOwner
(
data
.
id
,
data
.
desc
.
ctor
,
data
.
desc
.
staticArguments
,
data
.
desc
.
supportsDelayedInstantiation
,
data
.
_trace
);
this
.
_setServiceInstance
(
data
.
id
,
instance
);
// Repeat the check for this still being a service sync descriptor. That's because
// instantiating a dependency might have side-effect and recursively trigger instantiation
// so that some dependencies are now fullfilled already.
const
instanceOrDesc
=
this
.
_getServiceInstanceOrDescriptor
(
data
.
id
);
if
(
instanceOrDesc
instanceof
SyncDescriptor
)
{
// create instance and overwrite the service collections
const
instance
=
this
.
_createServiceInstanceWithOwner
(
data
.
id
,
data
.
desc
.
ctor
,
data
.
desc
.
staticArguments
,
data
.
desc
.
supportsDelayedInstantiation
,
data
.
_trace
);
this
.
_setServiceInstance
(
data
.
id
,
instance
);
}
graph
.
removeNode
(
data
);
}
}
...
...
src/vs/platform/instantiation/test/common/instantiationService.test.ts
浏览文件 @
f170b506
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
createDecorator
,
optional
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
,
IInstantiationService
,
optional
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -392,4 +392,36 @@ suite('Instantiation Service', () => {
assert
.
equal
(
serviceInstanceCount
,
1
);
});
test
(
'
Remote window / integration tests is broken #105562
'
,
function
()
{
const
Service1
=
createDecorator
<
any
>
(
'
service1
'
);
class
Service1Impl
{
constructor
(@
IInstantiationService
insta
:
IInstantiationService
)
{
const
c
=
insta
.
invokeFunction
(
accessor
=>
accessor
.
get
(
Service2
));
// THIS is the recursive call
assert
.
ok
(
c
);
}
}
const
Service2
=
createDecorator
<
any
>
(
'
service2
'
);
class
Service2Impl
{
constructor
()
{
}
}
// This service depends on Service1 and Service2 BUT creating Service1 creates Service2 (via recursive invocation)
// and then Servce2 should not be created a second time
const
Service21
=
createDecorator
<
any
>
(
'
service21
'
);
class
Service21Impl
{
constructor
(@
Service2
readonly
service2
:
Service2Impl
,
@
Service1
readonly
service1
:
Service1Impl
)
{
}
}
const
insta
=
new
InstantiationService
(
new
ServiceCollection
(
[
Service1
,
new
SyncDescriptor
(
Service1Impl
)],
[
Service2
,
new
SyncDescriptor
(
Service2Impl
)],
[
Service21
,
new
SyncDescriptor
(
Service21Impl
)],
));
const
obj
=
insta
.
invokeFunction
(
accessor
=>
accessor
.
get
(
Service21
));
assert
.
ok
(
obj
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录