Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
068f7bb9
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,发现更多精彩内容 >>
提交
068f7bb9
编写于
12月 13, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify RPCProtocol usage (#36972)
上级
64375e46
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
36 deletion
+32
-36
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+3
-2
src/vs/workbench/node/extensionHostProcess.ts
src/vs/workbench/node/extensionHostProcess.ts
+3
-5
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
.../services/extensions/electron-browser/extensionService.ts
+25
-1
src/vs/workbench/services/thread/electron-browser/threadService.ts
...rkbench/services/thread/electron-browser/threadService.ts
+1
-28
未找到文件。
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
068f7bb9
...
...
@@ -26,6 +26,7 @@ import { EnvironmentService } from 'vs/platform/environment/node/environmentServ
import
{
createLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
// const nativeExit = process.exit.bind(process);
function
patchProcess
(
allowExit
:
boolean
)
{
...
...
@@ -80,7 +81,7 @@ export class ExtensionHostMain {
private
_logService
:
ILogService
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
rpcProtocol
:
RPC
Protocol
,
initData
:
IInitData
)
{
constructor
(
protocol
:
IMessagePassing
Protocol
,
initData
:
IInitData
)
{
this
.
_environment
=
initData
.
environment
;
this
.
_workspace
=
initData
.
workspace
;
...
...
@@ -88,7 +89,7 @@ export class ExtensionHostMain {
patchProcess
(
allowExit
);
// services
const
threadService
=
new
ExtHostThreadService
(
rpcProtocol
);
const
threadService
=
new
ExtHostThreadService
(
new
RPCProtocol
(
protocol
)
);
const
extHostWorkspace
=
new
ExtHostWorkspace
(
threadService
,
initData
.
workspace
);
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
initData
.
execPath
);
this
.
_logService
=
createLogService
(
`exthost
${
initData
.
windowId
}
`
,
environmentService
);
...
...
src/vs/workbench/node/extensionHostProcess.ts
浏览文件 @
068f7bb9
...
...
@@ -7,7 +7,6 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
ExtensionHostMain
,
exit
}
from
'
vs/workbench/node/extensionHostMain
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
parse
}
from
'
vs/base/common/marshalling
'
;
import
{
IInitData
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
...
...
@@ -16,7 +15,7 @@ import { createConnection } from 'net';
import
Event
,
{
filterEvent
}
from
'
vs/base/common/event
'
;
interface
IRendererConnection
{
rpcProtocol
:
RPC
Protocol
;
protocol
:
IMessagePassing
Protocol
;
initData
:
IInitData
;
}
...
...
@@ -70,7 +69,6 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
first
.
dispose
();
const
initData
=
parse
(
raw
);
const
rpcProtocol
=
new
RPCProtocol
(
protocol
);
// Print a console message when rejection isn't handled within N seconds. For details:
// see https://nodejs.org/api/process.html#process_event_unhandledrejection
...
...
@@ -111,7 +109,7 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
// Tell the outside that we are initialized
protocol
.
send
(
'
initialized
'
);
c
({
rpcP
rotocol
,
initData
});
c
({
p
rotocol
,
initData
});
});
// Tell the outside that we are ready to receive messages
...
...
@@ -126,7 +124,7 @@ createExtHostProtocol().then(protocol => {
return
connectToRenderer
(
protocol
);
}).
then
(
renderer
=>
{
// setup things
const
extensionHostMain
=
new
ExtensionHostMain
(
renderer
.
rpcP
rotocol
,
renderer
.
initData
);
const
extensionHostMain
=
new
ExtensionHostMain
(
renderer
.
p
rotocol
,
renderer
.
initData
);
onTerminate
=
()
=>
extensionHostMain
.
terminate
();
return
extensionHostMain
.
start
();
}).
catch
(
err
=>
console
.
error
(
err
));
...
...
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
浏览文件 @
068f7bb9
...
...
@@ -41,9 +41,13 @@ import Event, { Emitter } from 'vs/base/common/event';
import
{
ExtensionHostProfiler
}
from
'
vs/workbench/services/extensions/electron-browser/extensionHostProfiler
'
;
import
{
ReloadWindowAction
}
from
'
vs/workbench/electron-browser/actions
'
;
import
product
from
'
vs/platform/node/product
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
const
SystemExtensionsRoot
=
path
.
normalize
(
path
.
join
(
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
,
'
..
'
,
'
extensions
'
));
// Enable to see detailed message communication between window and extension host
const
logExtensionHostCommunication
=
false
;
function
messageWithSource
(
msg
:
IMessage
):
string
{
return
messageWithSource2
(
msg
.
source
,
msg
.
message
);
}
...
...
@@ -230,7 +234,11 @@ export class ExtensionService extends Disposable implements IExtensionService {
private
_createExtensionHostCustomers
(
protocol
:
IMessagePassingProtocol
):
ExtHostExtensionServiceShape
{
this
.
_extensionHostProcessThreadService
=
this
.
_instantiationService
.
createInstance
(
MainThreadService
,
protocol
);
if
(
logExtensionHostCommunication
||
this
.
_environmentService
.
logExtensionHostCommunication
)
{
protocol
=
asLoggingProtocol
(
protocol
);
}
this
.
_extensionHostProcessThreadService
=
new
MainThreadService
(
protocol
);
const
extHostContext
:
IExtHostContext
=
this
.
_extensionHostProcessThreadService
;
// Named customers
...
...
@@ -695,6 +703,22 @@ export class ExtensionService extends Disposable implements IExtensionService {
}
}
function
asLoggingProtocol
(
protocol
:
IMessagePassingProtocol
):
IMessagePassingProtocol
{
protocol
.
onMessage
(
msg
=>
{
console
.
log
(
'
%c[Extension
\
u2192 Window]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
});
return
{
onMessage
:
protocol
.
onMessage
,
send
(
msg
:
any
)
{
protocol
.
send
(
msg
);
console
.
log
(
'
%c[Window
\
u2192 Extension]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
}
};
}
interface
IExtensionCacheData
{
input
:
ExtensionScannerInput
;
result
:
IExtensionDescription
[];
...
...
src/vs/workbench/services/thread/electron-browser/threadService.ts
浏览文件 @
068f7bb9
...
...
@@ -5,40 +5,13 @@
'
use strict
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
AbstractThreadService
}
from
'
vs/workbench/services/thread/node/abstractThreadService
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
// Enable to see detailed message communication between window and extension host
const
logExtensionHostCommunication
=
false
;
function
asLoggingProtocol
(
protocol
:
IMessagePassingProtocol
):
IMessagePassingProtocol
{
protocol
.
onMessage
(
msg
=>
{
console
.
log
(
'
%c[Extension
\
u2192 Window]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
});
return
{
onMessage
:
protocol
.
onMessage
,
send
(
msg
:
any
)
{
protocol
.
send
(
msg
);
console
.
log
(
'
%c[Window
\
u2192 Extension]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
}
};
}
export
class
MainThreadService
extends
AbstractThreadService
implements
IThreadService
{
constructor
(
protocol
:
IMessagePassingProtocol
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
)
{
if
(
logExtensionHostCommunication
||
environmentService
.
logExtensionHostCommunication
)
{
protocol
=
asLoggingProtocol
(
protocol
);
}
constructor
(
protocol
:
IMessagePassingProtocol
)
{
super
(
new
RPCProtocol
(
protocol
),
true
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录