Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2b4ce134
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,发现更多精彩内容 >>
提交
2b4ce134
编写于
12月 13, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add RPCProtocol.getFastProxy (#36972)
上级
c1cf8ef3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
30 deletion
+51
-30
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+5
-22
src/vs/workbench/services/extensions/node/proxyIdentifier.ts
src/vs/workbench/services/extensions/node/proxyIdentifier.ts
+27
-0
src/vs/workbench/services/extensions/node/rpcProtocol.ts
src/vs/workbench/services/extensions/node/rpcProtocol.ts
+19
-8
未找到文件。
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
2b4ce134
...
...
@@ -7,7 +7,8 @@
import
{
createMainContextProxyIdentifier
as
createMainId
,
createExtHostContextProxyIdentifier
as
createExtId
,
ProxyIdentifier
ProxyIdentifier
,
IRPCProtocol
}
from
'
vs/workbench/services/extensions/node/proxyIdentifier
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -90,28 +91,10 @@ export interface IWorkspaceConfigurationChangeEventData {
changedConfigurationByResource
:
{
[
folder
:
string
]:
IConfigurationModel
};
}
export
interface
IExtHostContext
{
/**
* Returns a proxy to an object addressable/named in the extension host process.
*/
get
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
;
/**
* Register manually created instance.
*/
set
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
;
/**
* Assert these identifiers are already registered via `.set`.
*/
assertRegistered
(
identifiers
:
ProxyIdentifier
<
any
>
[]):
void
;
export
interface
IExtHostContext
extends
IRPCProtocol
{
}
export
interface
IMainContext
{
/**
* Returns a proxy to an object addressable/named in the main/renderer process.
*/
get
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
;
export
interface
IMainContext
extends
IRPCProtocol
{
}
// --- main thread
...
...
@@ -681,7 +664,7 @@ export interface ExtHostWindowShape {
// --- proxy identifiers
export
const
MainContext
=
{
MainThreadCommands
:
createMainId
<
MainThreadCommandsShape
>
(
'
MainThreadCommands
'
),
MainThreadCommands
:
<
ProxyIdentifier
<
MainThreadCommandsShape
>>
createMainId
<
MainThreadCommandsShape
>
(
'
MainThreadCommands
'
),
MainThreadConfiguration
:
createMainId
<
MainThreadConfigurationShape
>
(
'
MainThreadConfiguration
'
),
MainThreadDebugService
:
createMainId
<
MainThreadDebugServiceShape
>
(
'
MainThreadDebugService
'
),
MainThreadDecorations
:
createMainId
<
MainThreadDecorationsShape
>
(
'
MainThreadDecorations
'
),
...
...
src/vs/workbench/services/extensions/node/proxyIdentifier.ts
浏览文件 @
2b4ce134
...
...
@@ -4,6 +4,33 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
export
interface
IRPCProtocol
{
/**
* Returns a proxy to an object addressable/named in the extension host process.
* > **Note:** Arguments or results of type `URI` or `RegExp` will be serialized/deserialized automatically,
* > but this has a performance cost, as each argument/result must be visited.
* >
* > Use `getFast` for a proxy where such arguments are not automatically serialized/deserialized.
*/
get
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
;
/**
* Returns a proxy to an object addressable/named in the extension host process.
* > **Note:** Arguments or results of type `URI` or `RegExp` will **not** be serialized/deserialized automatically.
*/
getFastProxy
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
;
/**
* Register manually created instance.
*/
set
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
;
/**
* Assert these identifiers are already registered via `.set`.
*/
assertRegistered
(
identifiers
:
ProxyIdentifier
<
any
>
[]):
void
;
}
export
class
ProxyIdentifier
<
T
>
{
_proxyIdentifierBrand
:
void
;
_suppressCompilerUnusedWarning
:
T
;
...
...
src/vs/workbench/services/extensions/node/rpcProtocol.ts
浏览文件 @
2b4ce134
...
...
@@ -9,12 +9,12 @@ import * as marshalling from 'vs/base/common/marshalling';
import
*
as
errors
from
'
vs/base/common/errors
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
LazyPromise
}
from
'
vs/workbench/services/extensions/node/lazyPromise
'
;
import
{
ProxyIdentifier
}
from
'
vs/workbench/services/extensions/node/proxyIdentifier
'
;
import
{
ProxyIdentifier
,
IRPCProtocol
}
from
'
vs/workbench/services/extensions/node/proxyIdentifier
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
declare
var
Proxy
:
any
;
// TODO@TypeScript
export
class
RPCProtocol
{
export
class
RPCProtocol
implements
IRPCProtocol
{
private
_isDisposed
:
boolean
;
private
readonly
_locals
:
{
[
id
:
string
]:
any
;
};
...
...
@@ -46,17 +46,28 @@ export class RPCProtocol {
public
get
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
{
if
(
!
this
.
_proxies
[
identifier
.
id
])
{
this
.
_proxies
[
identifier
.
id
]
=
this
.
_createProxy
(
identifier
.
id
);
this
.
_proxies
[
identifier
.
id
]
=
this
.
_createProxy
(
identifier
.
id
,
true
);
}
return
this
.
_proxies
[
identifier
.
id
];
}
private
_createProxy
<
T
>
(
proxyId
:
string
):
T
{
public
getFastProxy
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
{
if
(
!
this
.
_proxies
[
identifier
.
id
])
{
this
.
_proxies
[
identifier
.
id
]
=
this
.
_createProxy
(
identifier
.
id
,
false
);
}
return
this
.
_proxies
[
identifier
.
id
];
}
private
_createProxy
<
T
>
(
proxyId
:
string
,
isFancy
:
boolean
):
T
{
let
handler
=
{
get
:
(
target
,
name
:
string
)
=>
{
if
(
!
target
[
name
]
&&
name
.
charCodeAt
(
0
)
===
CharCode
.
DollarSign
)
{
target
[
name
]
=
(...
myArgs
:
any
[])
=>
{
return
this
.
fancyRemoteCall
(
proxyId
,
name
,
myArgs
);
return
(
isFancy
?
this
.
fancyRemoteCall
(
proxyId
,
name
,
myArgs
)
:
this
.
remoteCall
(
proxyId
,
name
,
myArgs
)
);
};
}
return
target
[
name
];
...
...
@@ -186,11 +197,11 @@ export class RPCProtocol {
return
method
.
apply
(
actor
,
args
);
}
p
ublic
remoteCall
(
proxyId
:
string
,
methodName
:
string
,
args
:
any
[]):
TPromise
<
any
>
{
p
rivate
remoteCall
(
proxyId
:
string
,
methodName
:
string
,
args
:
any
[]):
TPromise
<
any
>
{
return
this
.
_remoteCall
(
proxyId
,
methodName
,
args
,
false
);
}
p
ublic
fancyRemoteCall
(
proxyId
:
string
,
methodName
:
string
,
args
:
any
[]):
TPromise
<
any
>
{
p
rivate
fancyRemoteCall
(
proxyId
:
string
,
methodName
:
string
,
args
:
any
[]):
TPromise
<
any
>
{
return
this
.
_remoteCall
(
proxyId
,
methodName
,
args
,
true
);
}
...
...
@@ -290,7 +301,7 @@ class MessageFactory {
}
}
export
const
enum
MessageType
{
const
enum
MessageType
{
Request
=
1
,
FancyRequest
=
2
,
Cancel
=
3
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录