Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
98473e0e
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,发现更多精彩内容 >>
提交
98473e0e
编写于
12月 09, 2015
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call extension deactivate(), dispose subscriptions on extension host shutdown
上级
9f7989d3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
109 addition
and
7 deletion
+109
-7
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+4
-0
src/vs/editor/common/worker/editorWorkerServer.ts
src/vs/editor/common/worker/editorWorkerServer.ts
+4
-0
src/vs/editor/test/common/servicesTestUtils.ts
src/vs/editor/test/common/servicesTestUtils.ts
+4
-0
src/vs/platform/plugins/common/abstractPluginService.ts
src/vs/platform/plugins/common/abstractPluginService.ts
+3
-2
src/vs/platform/plugins/common/nativePluginService.ts
src/vs/platform/plugins/common/nativePluginService.ts
+27
-0
src/vs/platform/plugins/common/plugins.ts
src/vs/platform/plugins/common/plugins.ts
+15
-0
src/vs/workbench/node/pluginHostMain.ts
src/vs/workbench/node/pluginHostMain.ts
+30
-1
src/vs/workbench/node/pluginHostProcess.ts
src/vs/workbench/node/pluginHostProcess.ts
+19
-3
src/vs/workbench/services/thread/electron-browser/threadService.ts
...rkbench/services/thread/electron-browser/threadService.ts
+3
-1
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
98473e0e
...
...
@@ -272,4 +272,8 @@ export class SimplePluginService extends AbstractPluginService {
console
.
log
(
msg
);
}
}
public
deactivate
(
pluginId
:
string
):
void
{
// nothing to do
}
}
src/vs/editor/common/worker/editorWorkerServer.ts
浏览文件 @
98473e0e
...
...
@@ -73,6 +73,10 @@ class WorkerPluginService extends AbstractPluginService {
}
}
public
deactivate
(
pluginId
:
string
):
void
{
// nothing to do
}
}
export
class
EditorWorkerServer
{
...
...
src/vs/editor/test/common/servicesTestUtils.ts
浏览文件 @
98473e0e
...
...
@@ -123,6 +123,10 @@ class MockPluginService extends AbstractPluginService {
console
.
log
(
msg
);
}
}
public
deactivate
(
pluginId
:
string
):
void
{
// nothing to do
}
}
class
MockModelService
extends
ModelServiceImpl
{}
...
...
src/vs/platform/plugins/common/abstractPluginService.ts
浏览文件 @
98473e0e
...
...
@@ -21,8 +21,8 @@ export interface IPluginExports {
}
export
interface
IPluginModule
{
activate
(
subscriptions
:
IDisposable
[]
):
WinJS
.
TPromise
<
IPluginExports
>
;
deactivate
(
callback
:(
err
:
any
,
success
:
boolean
)
=>
void
):
void
;
activate
(
ctx
:
IPluginContext
):
WinJS
.
TPromise
<
IPluginExports
>
;
deactivate
():
void
;
}
export
interface
IPluginContext
{
...
...
@@ -83,6 +83,7 @@ export abstract class AbstractPluginService implements IPluginService {
this
.
activatedPlugins
=
{};
}
public
abstract
deactivate
(
pluginId
:
string
):
void
;
protected
abstract
_showMessage
(
severity
:
Severity
,
message
:
string
):
void
;
protected
showMessage
(
severity
:
Severity
,
source
:
string
,
message
:
string
):
void
{
...
...
src/vs/platform/plugins/common/nativePluginService.ts
浏览文件 @
98473e0e
...
...
@@ -15,6 +15,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import
{
PluginHostStorage
}
from
'
vs/platform/storage/common/remotable.storage
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
IWorkspaceContextService
,
IConfiguration
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
disposeAll
}
from
'
vs/base/common/lifecycle
'
;
class
PluginMemento
implements
IPluginMemento
{
...
...
@@ -168,6 +169,10 @@ export class MainProcessPluginService extends AbstractPluginService {
return
this
.
_pluginsStatus
;
}
public
deactivate
(
pluginId
:
string
):
void
{
this
.
_proxy
.
deactivate
(
pluginId
);
}
// -- overwriting AbstractPluginService
protected
_actualActivatePlugin
(
pluginDescription
:
IPluginDescription
):
WinJS
.
TPromise
<
ActivatedPlugin
>
{
...
...
@@ -232,6 +237,28 @@ export class PluginHostPluginService extends AbstractPluginService {
}
}
public
deactivate
(
pluginId
:
string
):
void
{
let
plugin
=
this
.
activatedPlugins
[
pluginId
];
if
(
!
plugin
)
{
return
;
}
// call deactivate if available
try
{
if
(
typeof
plugin
.
module
.
deactivate
===
'
function
'
)
{
plugin
.
module
.
deactivate
();
}
}
catch
(
err
)
{
// TODO: Do something with err if this is not the shutdown case
}
// clean up subscriptions
try
{
disposeAll
(
plugin
.
subscriptions
)
}
catch
(
err
)
{
// TODO: Do something with err if this is not the shutdown case
}
}
// -- overwriting AbstractPluginService
...
...
src/vs/platform/plugins/common/plugins.ts
浏览文件 @
98473e0e
...
...
@@ -46,15 +46,30 @@ export interface IPluginStatus {
export
interface
IPluginService
{
serviceId
:
ServiceIdentifier
<
any
>
;
activateByEvent
(
activationEvent
:
string
):
TPromise
<
any
>
;
activateAndGet
(
pluginId
:
string
):
TPromise
<
any
>
;
activateAndGet
<
T
>
(
pluginId
:
string
):
TPromise
<
T
>
;
isActivated
(
pluginId
:
string
):
boolean
;
/**
* This method should be called only on shutdown!
* More work is needed for this to be called any time!
*/
deactivate
(
pluginId
:
string
):
void
;
/**
* To be used only by the platform once on startup.
*/
registrationDone
(
errors
?:
IMessage
[]):
void
;
registerOneTimeActivationEventListener
(
activationEvent
:
string
,
listener
:
IActivationEventListener
):
void
;
get
(
pluginId
:
string
):
any
;
/**
* Block on this signal any interactions with extensions.
*/
onReady
():
TPromise
<
boolean
>
;
getPluginsStatus
():
{
[
id
:
string
]:
IPluginStatus
};
}
...
...
src/vs/workbench/node/pluginHostMain.ts
浏览文件 @
98473e0e
...
...
@@ -104,16 +104,45 @@ interface ITestRunner {
export
class
PluginHostMain
{
private
_isTerminating
:
boolean
;
constructor
(
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IPluginService
private
pluginService
:
IPluginService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{}
)
{
this
.
_isTerminating
=
false
;
}
public
start
():
TPromise
<
void
>
{
return
this
.
readPlugins
();
}
public
terminate
():
void
{
if
(
this
.
_isTerminating
)
{
// we are already shutting down...
return
;
}
this
.
_isTerminating
=
true
;
try
{
let
allExtensions
=
PluginsRegistry
.
getAllPluginDescriptions
();
let
allExtensionsIds
=
allExtensions
.
map
(
ext
=>
ext
.
id
);
let
activatedExtensions
=
allExtensionsIds
.
filter
(
id
=>
this
.
pluginService
.
isActivated
(
id
));
activatedExtensions
.
forEach
((
extensionId
)
=>
{
this
.
pluginService
.
deactivate
(
extensionId
);
});
}
catch
(
err
)
{
// TODO: write to log once we have one
}
// Give extensions 1 second to wrap up any async dispose, then exit
setTimeout
(()
=>
{
exit
()
},
1000
);
}
private
readPlugins
():
TPromise
<
void
>
{
let
collector
=
new
PluginsMessageCollector
();
let
env
=
this
.
contextService
.
getConfiguration
().
env
;
...
...
src/vs/workbench/node/pluginHostProcess.ts
浏览文件 @
98473e0e
...
...
@@ -16,8 +16,14 @@ interface IRendererConnection {
initData
:
IInitData
;
}
// This calls exit directly in case the initialization is not finished and we need to exit
// Otherwise, if initialization completed we go to pluginHostMain.terminate()
var
onTerminate
=
function
()
{
exit
();
};
function
connectToRenderer
():
TPromise
<
IRendererConnection
>
{
return
new
TPromise
((
c
,
e
)
=>
{
return
new
TPromise
<
IRendererConnection
>
((
c
,
e
)
=>
{
const
stats
:
number
[]
=
[];
// Listen init data message
...
...
@@ -28,7 +34,13 @@ function connectToRenderer(): TPromise<IRendererConnection> {
});
// Listen to all other messages
process
.
on
(
'
message
'
,
msg
=>
remoteCom
.
handle
(
msg
));
process
.
on
(
'
message
'
,
(
msg
)
=>
{
if
(
msg
.
type
===
'
__$terminate
'
)
{
onTerminate
();
return
;
}
remoteCom
.
handle
(
msg
);
});
// Print a console message when rejection isn't handled. For details
// see https://nodejs.org/api/process.html#process_event_unhandledrejection
...
...
@@ -50,7 +62,7 @@ function connectToRenderer(): TPromise<IRendererConnection> {
try
{
process
.
kill
(
msg
.
parentPid
,
0
);
// throws an exception if the main process doesn't exist anymore.
}
catch
(
e
)
{
exit
();
onTerminate
();
}
},
5000
);
...
...
@@ -86,6 +98,10 @@ TPromise.join<any>([connectToRenderer(), connectToSharedProcess()])
const
instantiationService
=
createServices
(
renderer
.
remoteCom
,
renderer
.
initData
,
sharedProcessClient
);
const
pluginHostMain
=
instantiationService
.
createInstance
(
PluginHostMain
);
onTerminate
=
()
=>
{
pluginHostMain
.
terminate
();
};
pluginHostMain
.
start
()
.
done
(
null
,
err
=>
console
.
error
(
err
));
});
\ No newline at end of file
src/vs/workbench/services/thread/electron-browser/threadService.ts
浏览文件 @
98473e0e
...
...
@@ -305,7 +305,9 @@ class PluginHostProcessManager {
this
.
terminating
=
true
;
if
(
this
.
pluginHostProcessHandle
)
{
this
.
pluginHostProcessHandle
.
kill
();
this
.
pluginHostProcessHandle
.
send
({
type
:
'
__$terminate
'
});
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录