Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dc6a3d1f
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,发现更多精彩内容 >>
提交
dc6a3d1f
编写于
11月 07, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweaks to transformer
上级
eb87600b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
50 addition
and
30 deletion
+50
-30
src/vs/base/common/uriIpc.ts
src/vs/base/common/uriIpc.ts
+11
-3
src/vs/workbench/node/extensionHostMain.ts
src/vs/workbench/node/extensionHostMain.ts
+5
-5
src/vs/workbench/services/extensions/node/rpcProtocol.ts
src/vs/workbench/services/extensions/node/rpcProtocol.ts
+34
-22
未找到文件。
src/vs/base/common/uriIpc.ts
浏览文件 @
dc6a3d1f
...
...
@@ -8,9 +8,17 @@ import { URI, UriComponents } from 'vs/base/common/uri';
export
interface
IURITransformer
{
transformIncoming
(
uri
:
UriComponents
):
UriComponents
;
transformOutgoing
(
uri
:
URI
):
URI
;
transformOutgoing
(
uri
:
UriComponents
):
UriComponents
;
}
export
const
DefaultURITransformer
:
IURITransformer
=
{
transformIncoming
:
(
uri
:
UriComponents
)
=>
uri
,
transformOutgoing
:
(
uri
:
URI
)
=>
uri
,
export
const
DefaultURITransformer
:
IURITransformer
=
new
class
{
transformIncoming
(
uri
:
UriComponents
)
{
return
uri
;
}
transformOutgoing
(
uri
:
URI
):
URI
;
transformOutgoing
(
uri
:
UriComponents
):
UriComponents
;
transformOutgoing
(
uri
:
URI
|
UriComponents
):
URI
|
UriComponents
{
return
uri
;
}
};
\ No newline at end of file
src/vs/workbench/node/extensionHostMain.ts
浏览文件 @
dc6a3d1f
...
...
@@ -316,11 +316,11 @@ export class ExtensionHostMain {
}
private
transform
(
initData
:
IInitData
,
rpcProtocol
:
RPCProtocol
):
IInitData
{
initData
.
extensions
.
forEach
((
ext
)
=>
(
<
any
>
ext
).
extensionLocation
=
URI
.
revive
(
ext
.
extensionLocation
));
initData
.
environment
.
appRoot
=
URI
.
revive
(
initData
.
environment
.
appRoot
);
initData
.
environment
.
appSettingsHome
=
URI
.
revive
(
initData
.
environment
.
appSettingsHome
);
initData
.
environment
.
extensionDevelopmentLocationURI
=
URI
.
revive
(
initData
.
environment
.
extensionDevelopmentLocationURI
);
initData
.
logsLocation
=
URI
.
revive
(
initData
.
logsLocation
);
initData
.
extensions
.
forEach
((
ext
)
=>
(
<
any
>
ext
).
extensionLocation
=
URI
.
revive
(
rpcProtocol
.
transformIncomingURIs
(
ext
.
extensionLocation
)
));
initData
.
environment
.
appRoot
=
URI
.
revive
(
rpcProtocol
.
transformIncomingURIs
(
initData
.
environment
.
appRoot
)
);
initData
.
environment
.
appSettingsHome
=
URI
.
revive
(
rpcProtocol
.
transformIncomingURIs
(
initData
.
environment
.
appSettingsHome
)
);
initData
.
environment
.
extensionDevelopmentLocationURI
=
URI
.
revive
(
rpcProtocol
.
transformIncomingURIs
(
initData
.
environment
.
extensionDevelopmentLocationURI
)
);
initData
.
logsLocation
=
URI
.
revive
(
rpcProtocol
.
transformIncomingURIs
(
initData
.
logsLocation
)
);
initData
.
workspace
=
rpcProtocol
.
transformIncomingURIs
(
initData
.
workspace
);
return
initData
;
}
...
...
src/vs/workbench/services/extensions/node/rpcProtocol.ts
浏览文件 @
dc6a3d1f
...
...
@@ -17,6 +17,30 @@ import { IMessagePassingProtocol } from 'vs/base/parts/ipc/node/ipc';
import
{
LazyPromise
}
from
'
vs/workbench/services/extensions/node/lazyPromise
'
;
import
{
IRPCProtocol
,
ProxyIdentifier
,
getStringIdentifierForProxy
}
from
'
vs/workbench/services/extensions/node/proxyIdentifier
'
;
export
interface
JSONStringifyReplacer
{
(
key
:
string
,
value
:
any
):
any
;
}
function
safeStringify
(
obj
:
any
,
replacer
:
JSONStringifyReplacer
|
null
):
string
{
try
{
return
JSON
.
stringify
(
obj
,
<
(
key
:
string
,
value
:
any
)
=>
any
>
replacer
);
}
catch
(
err
)
{
return
'
null
'
;
}
}
function
createURIReplacer
(
transformer
:
IURITransformer
|
null
):
JSONStringifyReplacer
|
null
{
if
(
!
transformer
)
{
return
null
;
}
return
(
key
:
string
,
value
:
any
):
any
=>
{
if
(
value
&&
value
.
$mid
===
1
)
{
return
transformer
.
transformOutgoing
(
value
);
}
return
value
;
};
}
function
_transformOutgoingURIs
(
obj
:
any
,
transformer
:
IURITransformer
,
depth
:
number
):
any
{
if
(
!
obj
||
depth
>
200
)
{
...
...
@@ -113,6 +137,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
private
readonly
_protocol
:
IMessagePassingProtocol
;
private
readonly
_logger
:
IRPCProtocolLogger
|
null
;
private
readonly
_uriTransformer
:
IURITransformer
|
null
;
private
readonly
_uriReplacer
:
JSONStringifyReplacer
|
null
;
private
_isDisposed
:
boolean
;
private
readonly
_locals
:
any
[];
private
readonly
_proxies
:
any
[];
...
...
@@ -129,6 +154,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
this
.
_protocol
=
protocol
;
this
.
_logger
=
logger
;
this
.
_uriTransformer
=
transformer
;
this
.
_uriReplacer
=
createURIReplacer
(
this
.
_uriTransformer
);
this
.
_isDisposed
=
false
;
this
.
_locals
=
[];
this
.
_proxies
=
[];
...
...
@@ -353,10 +379,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
promise
.
then
((
r
)
=>
{
delete
this
.
_cancelInvokedHandlers
[
callId
];
if
(
this
.
_uriTransformer
)
{
r
=
transformOutgoingURIs
(
r
,
this
.
_uriTransformer
);
}
const
msg
=
MessageIO
.
serializeReplyOK
(
req
,
r
);
const
msg
=
MessageIO
.
serializeReplyOK
(
req
,
r
,
this
.
_uriReplacer
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
OtherSide
,
`reply:`
,
r
);
}
...
...
@@ -469,10 +492,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
this
.
_pendingRPCReplies
[
callId
]
=
result
;
this
.
_onWillSendRequest
(
req
);
if
(
this
.
_uriTransformer
)
{
args
=
transformOutgoingURIs
(
args
,
this
.
_uriTransformer
);
}
const
msg
=
MessageIO
.
serializeRequest
(
req
,
rpcId
,
methodName
,
args
,
!!
cancellationToken
);
const
msg
=
MessageIO
.
serializeRequest
(
req
,
rpcId
,
methodName
,
args
,
!!
cancellationToken
,
this
.
_uriReplacer
);
if
(
this
.
_logger
)
{
this
.
_logger
.
logOutgoing
(
msg
.
byteLength
,
req
,
RequestInitiator
.
LocalSide
,
`request:
${
getStringIdentifierForProxy
(
rpcId
)}
.
${
methodName
}
(`
,
args
);
}
...
...
@@ -630,7 +650,7 @@ class MessageIO {
return
false
;
}
public
static
serializeRequest
(
req
:
number
,
rpcId
:
number
,
method
:
string
,
args
:
any
[],
usesCancellationToken
:
boolean
):
Buffer
{
public
static
serializeRequest
(
req
:
number
,
rpcId
:
number
,
method
:
string
,
args
:
any
[],
usesCancellationToken
:
boolean
,
replacer
:
JSONStringifyReplacer
|
null
):
Buffer
{
if
(
this
.
_arrayContainsBuffer
(
args
))
{
let
massagedArgs
:
(
string
|
Buffer
)[]
=
new
Array
(
args
.
length
);
let
argsLengths
:
number
[]
=
new
Array
(
args
.
length
);
...
...
@@ -640,13 +660,13 @@ class MessageIO {
massagedArgs
[
i
]
=
arg
;
argsLengths
[
i
]
=
arg
.
byteLength
;
}
else
{
massagedArgs
[
i
]
=
safeStringify
(
arg
);
massagedArgs
[
i
]
=
safeStringify
(
arg
,
replacer
);
argsLengths
[
i
]
=
Buffer
.
byteLength
(
massagedArgs
[
i
],
'
utf8
'
);
}
}
return
this
.
_requestMixedArgs
(
req
,
rpcId
,
method
,
massagedArgs
,
argsLengths
,
usesCancellationToken
);
}
return
this
.
_requestJSONArgs
(
req
,
rpcId
,
method
,
safeStringify
(
args
),
usesCancellationToken
);
return
this
.
_requestJSONArgs
(
req
,
rpcId
,
method
,
safeStringify
(
args
,
replacer
),
usesCancellationToken
);
}
private
static
_requestJSONArgs
(
req
:
number
,
rpcId
:
number
,
method
:
string
,
args
:
string
,
usesCancellationToken
:
boolean
):
Buffer
{
...
...
@@ -719,14 +739,14 @@ class MessageIO {
return
MessageBuffer
.
alloc
(
MessageType
.
Cancel
,
req
,
0
).
buffer
;
}
public
static
serializeReplyOK
(
req
:
number
,
res
:
any
):
Buffer
{
public
static
serializeReplyOK
(
req
:
number
,
res
:
any
,
replacer
:
JSONStringifyReplacer
|
null
):
Buffer
{
if
(
typeof
res
===
'
undefined
'
)
{
return
this
.
_serializeReplyOKEmpty
(
req
);
}
if
(
Buffer
.
isBuffer
(
res
))
{
return
this
.
_serializeReplyOKBuffer
(
req
,
res
);
}
return
this
.
_serializeReplyOKJSON
(
req
,
safeStringify
(
res
));
return
this
.
_serializeReplyOKJSON
(
req
,
safeStringify
(
res
,
replacer
));
}
private
static
_serializeReplyOKEmpty
(
req
:
number
):
Buffer
{
...
...
@@ -772,7 +792,7 @@ class MessageIO {
}
private
static
_serializeReplyErrEror
(
req
:
number
,
_err
:
Error
):
Buffer
{
const
err
=
safeStringify
(
errors
.
transformErrorForSerialization
(
_err
));
const
err
=
safeStringify
(
errors
.
transformErrorForSerialization
(
_err
)
,
null
);
const
errByteLength
=
Buffer
.
byteLength
(
err
,
'
utf8
'
);
let
len
=
0
;
...
...
@@ -793,14 +813,6 @@ class MessageIO {
}
}
function
safeStringify
(
obj
:
any
):
string
{
try
{
return
JSON
.
stringify
(
obj
);
}
catch
(
err
)
{
return
'
null
'
;
}
}
const
enum
MessageType
{
RequestJSONArgs
=
1
,
RequestJSONArgsWithCancellation
=
2
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录