Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
18f9cdaf
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,发现更多精彩内容 >>
未验证
提交
18f9cdaf
编写于
6月 18, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renames
上级
94bb8628
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
41 deletion
+40
-41
src/vs/workbench/services/extensions/common/extensionHostProcessManager.ts
...services/extensions/common/extensionHostProcessManager.ts
+40
-41
未找到文件。
src/vs/workbench/services/extensions/common/extensionHostProcessManager.ts
浏览文件 @
18f9cdaf
...
...
@@ -27,7 +27,6 @@ import { ExtensionActivationReason } from 'vs/workbench/api/common/extHostExtens
// Enable to see detailed message communication between window and extension host
const
LOG_EXTENSION_HOST_COMMUNICATION
=
false
;
const
LOG_USE_COLORS
=
true
;
const
NO_OP_VOID_PROMISE
=
Promise
.
resolve
<
void
>
(
undefined
);
export
class
ExtensionHostProcessManager
extends
Disposable
{
...
...
@@ -41,32 +40,32 @@ export class ExtensionHostProcessManager extends Disposable {
/**
* A map of already activated events to speed things up if the same activation event is triggered multiple times.
*/
private
readonly
_
extensionHostProcessF
inishedActivateEvents
:
{
[
activationEvent
:
string
]:
boolean
;
};
private
_
extensionHostProcessRPC
Protocol
:
RPCProtocol
|
null
;
private
readonly
_
extensionHostProcessC
ustomers
:
IDisposable
[];
private
readonly
_extensionHost
ProcessWorker
:
IExtensionHost
;
private
readonly
_
f
inishedActivateEvents
:
{
[
activationEvent
:
string
]:
boolean
;
};
private
_
rpc
Protocol
:
RPCProtocol
|
null
;
private
readonly
_
c
ustomers
:
IDisposable
[];
private
readonly
_extensionHost
:
IExtensionHost
;
/**
* winjs believes a proxy is a promise because it has a `then` method, so wrap the result in an object.
*/
private
_
extensionHostProcessP
roxy
:
Promise
<
{
value
:
ExtHostExtensionServiceShape
;
}
|
null
>
|
null
;
private
_
p
roxy
:
Promise
<
{
value
:
ExtHostExtensionServiceShape
;
}
|
null
>
|
null
;
private
_resolveAuthorityAttempt
:
number
;
constructor
(
extensionHost
ProcessWorker
:
IExtensionHost
,
extensionHost
:
IExtensionHost
,
private
readonly
_remoteAuthority
:
string
|
null
,
initialActivationEvents
:
string
[],
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IWorkbenchEnvironmentService
private
readonly
_environmentService
:
IWorkbenchEnvironmentService
,
)
{
super
();
this
.
_
extensionHostProcessF
inishedActivateEvents
=
Object
.
create
(
null
);
this
.
_
extensionHostProcessRPC
Protocol
=
null
;
this
.
_
extensionHostProcessC
ustomers
=
[];
this
.
_extensionHost
ProcessWorker
=
extensionHostProcessWorker
;
this
.
kind
=
this
.
_extensionHost
ProcessWorker
.
kind
;
this
.
onDidExit
=
this
.
_extensionHost
ProcessWorker
.
onExit
;
this
.
_
extensionHostProcessProxy
=
this
.
_extensionHostProcessWorker
.
start
()
!
.
then
(
this
.
_
f
inishedActivateEvents
=
Object
.
create
(
null
);
this
.
_
rpc
Protocol
=
null
;
this
.
_
c
ustomers
=
[];
this
.
_extensionHost
=
extensionHost
;
this
.
kind
=
this
.
_extensionHost
.
kind
;
this
.
onDidExit
=
this
.
_extensionHost
.
onExit
;
this
.
_
proxy
=
this
.
_extensionHost
.
start
()
!
.
then
(
(
protocol
)
=>
{
return
{
value
:
this
.
_createExtensionHostCustomers
(
protocol
)
};
},
...
...
@@ -76,7 +75,7 @@ export class ExtensionHostProcessManager extends Disposable {
return
null
;
}
);
this
.
_
extensionHostProcessP
roxy
.
then
(()
=>
{
this
.
_
p
roxy
.
then
(()
=>
{
initialActivationEvents
.
forEach
((
activationEvent
)
=>
this
.
activateByEvent
(
activationEvent
));
this
.
_register
(
registerLatencyTestProvider
({
measure
:
()
=>
this
.
measure
()
...
...
@@ -86,21 +85,21 @@ export class ExtensionHostProcessManager extends Disposable {
}
public
dispose
():
void
{
if
(
this
.
_extensionHost
ProcessWorker
)
{
this
.
_extensionHost
ProcessWorker
.
dispose
();
if
(
this
.
_extensionHost
)
{
this
.
_extensionHost
.
dispose
();
}
if
(
this
.
_
extensionHostProcessRPC
Protocol
)
{
this
.
_
extensionHostProcessRPC
Protocol
.
dispose
();
if
(
this
.
_
rpc
Protocol
)
{
this
.
_
rpc
Protocol
.
dispose
();
}
for
(
let
i
=
0
,
len
=
this
.
_
extensionHostProcessC
ustomers
.
length
;
i
<
len
;
i
++
)
{
const
customer
=
this
.
_
extensionHostProcessC
ustomers
[
i
];
for
(
let
i
=
0
,
len
=
this
.
_
c
ustomers
.
length
;
i
<
len
;
i
++
)
{
const
customer
=
this
.
_
c
ustomers
[
i
];
try
{
customer
.
dispose
();
}
catch
(
err
)
{
errors
.
onUnexpectedError
(
err
);
}
}
this
.
_
extensionHostProcessP
roxy
=
null
;
this
.
_
p
roxy
=
null
;
super
.
dispose
();
}
...
...
@@ -122,10 +121,10 @@ export class ExtensionHostProcessManager extends Disposable {
}
private
async
_getExtensionHostProcessProxy
():
Promise
<
ExtHostExtensionServiceShape
|
null
>
{
if
(
!
this
.
_
extensionHostProcessP
roxy
)
{
if
(
!
this
.
_
p
roxy
)
{
return
null
;
}
const
p
=
await
this
.
_
extensionHostProcessP
roxy
;
const
p
=
await
this
.
_
p
roxy
;
if
(
!
p
)
{
return
null
;
}
...
...
@@ -179,13 +178,13 @@ export class ExtensionHostProcessManager extends Disposable {
logger
=
new
RPCLogger
();
}
this
.
_
extensionHostProcessRPC
Protocol
=
new
RPCProtocol
(
protocol
,
logger
);
this
.
_register
(
this
.
_
extensionHostProcessRPC
Protocol
.
onDidChangeResponsiveState
((
responsiveState
:
ResponsiveState
)
=>
this
.
_onDidChangeResponsiveState
.
fire
(
responsiveState
)));
this
.
_
rpc
Protocol
=
new
RPCProtocol
(
protocol
,
logger
);
this
.
_register
(
this
.
_
rpc
Protocol
.
onDidChangeResponsiveState
((
responsiveState
:
ResponsiveState
)
=>
this
.
_onDidChangeResponsiveState
.
fire
(
responsiveState
)));
const
extHostContext
:
IExtHostContext
=
{
remoteAuthority
:
this
.
_remoteAuthority
!
/* TODO: alexdima, remove not-null assertion */
,
getProxy
:
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
=>
this
.
_
extensionHostProcessRPC
Protocol
!
.
getProxy
(
identifier
),
set
:
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
=>
this
.
_
extensionHostProcessRPC
Protocol
!
.
set
(
identifier
,
instance
),
assertRegistered
:
(
identifiers
:
ProxyIdentifier
<
any
>
[]):
void
=>
this
.
_
extensionHostProcessRPC
Protocol
!
.
assertRegistered
(
identifiers
),
getProxy
:
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
=>
this
.
_
rpc
Protocol
!
.
getProxy
(
identifier
),
set
:
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
=>
this
.
_
rpc
Protocol
!
.
set
(
identifier
,
instance
),
assertRegistered
:
(
identifiers
:
ProxyIdentifier
<
any
>
[]):
void
=>
this
.
_
rpc
Protocol
!
.
assertRegistered
(
identifiers
),
};
// Named customers
...
...
@@ -193,22 +192,22 @@ export class ExtensionHostProcessManager extends Disposable {
for
(
let
i
=
0
,
len
=
namedCustomers
.
length
;
i
<
len
;
i
++
)
{
const
[
id
,
ctor
]
=
namedCustomers
[
i
];
const
instance
=
this
.
_instantiationService
.
createInstance
(
ctor
,
extHostContext
);
this
.
_
extensionHostProcessC
ustomers
.
push
(
instance
);
this
.
_
extensionHostProcessRPC
Protocol
.
set
(
id
,
instance
);
this
.
_
c
ustomers
.
push
(
instance
);
this
.
_
rpc
Protocol
.
set
(
id
,
instance
);
}
// Customers
const
customers
=
ExtHostCustomersRegistry
.
getCustomers
();
for
(
const
ctor
of
customers
)
{
const
instance
=
this
.
_instantiationService
.
createInstance
(
ctor
,
extHostContext
);
this
.
_
extensionHostProcessC
ustomers
.
push
(
instance
);
this
.
_
c
ustomers
.
push
(
instance
);
}
// Check that no named customers are missing
const
expected
:
ProxyIdentifier
<
any
>
[]
=
Object
.
keys
(
MainContext
).
map
((
key
)
=>
(
<
any
>
MainContext
)[
key
]);
this
.
_
extensionHostProcessRPC
Protocol
.
assertRegistered
(
expected
);
this
.
_
rpc
Protocol
.
assertRegistered
(
expected
);
return
this
.
_
extensionHostProcessRPC
Protocol
.
getProxy
(
ExtHostContext
.
ExtHostExtensionService
);
return
this
.
_
rpc
Protocol
.
getProxy
(
ExtHostContext
.
ExtHostExtensionService
);
}
public
async
activate
(
extension
:
ExtensionIdentifier
,
reason
:
ExtensionActivationReason
):
Promise
<
boolean
>
{
...
...
@@ -220,10 +219,10 @@ export class ExtensionHostProcessManager extends Disposable {
}
public
activateByEvent
(
activationEvent
:
string
):
Promise
<
void
>
{
if
(
this
.
_
extensionHostProcessFinishedActivateEvents
[
activationEvent
]
||
!
this
.
_extensionHostProcessP
roxy
)
{
if
(
this
.
_
finishedActivateEvents
[
activationEvent
]
||
!
this
.
_p
roxy
)
{
return
NO_OP_VOID_PROMISE
;
}
return
this
.
_
extensionHostProcessP
roxy
.
then
((
proxy
)
=>
{
return
this
.
_
p
roxy
.
then
((
proxy
)
=>
{
if
(
!
proxy
)
{
// this case is already covered above and logged.
// i.e. the extension host could not be started
...
...
@@ -231,16 +230,16 @@ export class ExtensionHostProcessManager extends Disposable {
}
return
proxy
.
value
.
$activateByEvent
(
activationEvent
);
}).
then
(()
=>
{
this
.
_
extensionHostProcessF
inishedActivateEvents
[
activationEvent
]
=
true
;
this
.
_
f
inishedActivateEvents
[
activationEvent
]
=
true
;
});
}
public
async
getInspectPort
(
tryEnableInspector
:
boolean
):
Promise
<
number
>
{
if
(
this
.
_extensionHost
ProcessWorker
)
{
if
(
this
.
_extensionHost
)
{
if
(
tryEnableInspector
)
{
await
this
.
_extensionHost
ProcessWorker
.
enableInspectPort
();
await
this
.
_extensionHost
.
enableInspectPort
();
}
let
port
=
this
.
_extensionHost
ProcessWorker
.
getInspectPort
();
let
port
=
this
.
_extensionHost
.
getInspectPort
();
if
(
port
)
{
return
port
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录