Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
16954b49
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,体验更适合开发者的 AI 搜索 >>
提交
16954b49
编写于
2月 10, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - careful with proxy, use type PropertyKey and not string
上级
5f7dd088
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
13 deletion
+14
-13
src/vs/workbench/api/common/extHostConfiguration.ts
src/vs/workbench/api/common/extHostConfiguration.ts
+8
-8
src/vs/workbench/services/extensions/common/rpcProtocol.ts
src/vs/workbench/services/extensions/common/rpcProtocol.ts
+2
-2
src/vs/workbench/services/extensions/worker/extHost.services.ts
.../workbench/services/extensions/worker/extHost.services.ts
+1
-1
src/vs/workbench/test/browser/api/testRPCProtocol.ts
src/vs/workbench/test/browser/api/testRPCProtocol.ts
+3
-2
未找到文件。
src/vs/workbench/api/common/extHostConfiguration.ts
浏览文件 @
16954b49
...
...
@@ -198,7 +198,7 @@ export class ExtHostConfigProvider {
};
return
isObject
(
target
)
?
new
Proxy
(
target
,
{
get
:
(
target
:
any
,
property
:
string
)
=>
{
get
:
(
target
:
any
,
property
:
PropertyKey
)
=>
{
if
(
typeof
property
===
'
string
'
&&
property
.
toLowerCase
()
===
'
tojson
'
)
{
cloneTarget
();
return
()
=>
clonedTarget
;
...
...
@@ -213,21 +213,21 @@ export class ExtHostConfigProvider {
}
return
result
;
},
set
:
(
_target
:
any
,
property
:
string
,
value
:
any
)
=>
{
set
:
(
_target
:
any
,
property
:
PropertyKey
,
value
:
any
)
=>
{
cloneTarget
();
if
(
clonedTarget
)
{
clonedTarget
[
property
]
=
value
;
}
return
true
;
},
deleteProperty
:
(
_target
:
any
,
property
:
string
)
=>
{
deleteProperty
:
(
_target
:
any
,
property
:
PropertyKey
)
=>
{
cloneTarget
();
if
(
clonedTarget
)
{
delete
clonedTarget
[
property
];
}
return
true
;
},
defineProperty
:
(
_target
:
any
,
property
:
string
,
descriptor
:
any
)
=>
{
defineProperty
:
(
_target
:
any
,
property
:
PropertyKey
,
descriptor
:
any
)
=>
{
cloneTarget
();
if
(
clonedTarget
)
{
Object
.
defineProperty
(
clonedTarget
,
property
,
descriptor
);
...
...
@@ -284,10 +284,10 @@ export class ExtHostConfigProvider {
const
readonlyProxy
=
(
target
:
any
):
any
=>
{
return
isObject
(
target
)
?
new
Proxy
(
target
,
{
get
:
(
target
:
any
,
property
:
string
)
=>
readonlyProxy
(
target
[
property
]),
set
:
(
_target
:
any
,
property
:
string
,
_value
:
any
)
=>
{
throw
new
Error
(
`TypeError: Cannot assign to read only property '
${
property
}
' of object`
);
},
deleteProperty
:
(
_target
:
any
,
property
:
string
)
=>
{
throw
new
Error
(
`TypeError: Cannot delete read only property '
${
property
}
' of object`
);
},
defineProperty
:
(
_target
:
any
,
property
:
string
)
=>
{
throw
new
Error
(
`TypeError: Cannot define property '
${
property
}
' for a readonly object`
);
},
get
:
(
target
:
any
,
property
:
PropertyKey
)
=>
readonlyProxy
(
target
[
property
]),
set
:
(
_target
:
any
,
property
:
PropertyKey
,
_value
:
any
)
=>
{
throw
new
Error
(
`TypeError: Cannot assign to read only property '
${
String
(
property
)
}
' of object`
);
},
deleteProperty
:
(
_target
:
any
,
property
:
PropertyKey
)
=>
{
throw
new
Error
(
`TypeError: Cannot delete read only property '
${
String
(
property
)
}
' of object`
);
},
defineProperty
:
(
_target
:
any
,
property
:
PropertyKey
)
=>
{
throw
new
Error
(
`TypeError: Cannot define property '
${
String
(
property
)
}
' for a readonly object`
);
},
setPrototypeOf
:
(
_target
:
any
)
=>
{
throw
new
Error
(
`TypeError: Cannot set prototype for a readonly object`
);
},
isExtensible
:
()
=>
false
,
preventExtensions
:
()
=>
true
...
...
src/vs/workbench/services/extensions/common/rpcProtocol.ts
浏览文件 @
16954b49
...
...
@@ -180,8 +180,8 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
private
_createProxy
<
T
>
(
rpcId
:
number
):
T
{
let
handler
=
{
get
:
(
target
:
any
,
name
:
string
)
=>
{
if
(
!
target
[
name
]
&&
name
.
charCodeAt
(
0
)
===
CharCode
.
DollarSign
)
{
get
:
(
target
:
any
,
name
:
PropertyKey
)
=>
{
if
(
typeof
name
===
'
string
'
&&
!
target
[
name
]
&&
name
.
charCodeAt
(
0
)
===
CharCode
.
DollarSign
)
{
target
[
name
]
=
(...
myArgs
:
any
[])
=>
{
return
this
.
_remoteCall
(
rpcId
,
name
,
myArgs
);
};
...
...
src/vs/workbench/services/extensions/worker/extHost.services.ts
浏览文件 @
16954b49
...
...
@@ -43,7 +43,7 @@ function NotImplementedProxy<T>(name: ServiceIdentifier<T>): { new(): T } {
return
<
any
>
class
{
constructor
()
{
return
new
Proxy
({},
{
get
(
target
:
any
,
prop
:
string
|
number
)
{
get
(
target
:
any
,
prop
:
PropertyKey
)
{
if
(
target
[
prop
])
{
return
target
[
prop
];
}
...
...
src/vs/workbench/test/browser/api/testRPCProtocol.ts
浏览文件 @
16954b49
...
...
@@ -79,12 +79,13 @@ export class TestRPCProtocol implements IExtHostContext, IExtHostRpcService {
private
_createProxy
<
T
>
(
proxyId
:
string
):
T
{
let
handler
=
{
get
:
(
target
:
any
,
name
:
string
)
=>
{
if
(
!
target
[
name
]
&&
name
.
charCodeAt
(
0
)
===
CharCode
.
DollarSign
)
{
get
:
(
target
:
any
,
name
:
PropertyKey
)
=>
{
if
(
typeof
name
===
'
string
'
&&
!
target
[
name
]
&&
name
.
charCodeAt
(
0
)
===
CharCode
.
DollarSign
)
{
target
[
name
]
=
(...
myArgs
:
any
[])
=>
{
return
this
.
_remoteCall
(
proxyId
,
name
,
myArgs
);
};
}
return
target
[
name
];
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录