Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cb865f93
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,发现更多精彩内容 >>
提交
cb865f93
编写于
6月 14, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove extHostHeapService, use normal cache in commands converter, #74846
上级
8e91c0db
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
23 addition
and
62 deletion
+23
-62
src/vs/workbench/api/common/extHostApiCommands.ts
src/vs/workbench/api/common/extHostApiCommands.ts
+1
-1
src/vs/workbench/api/common/extHostCommands.ts
src/vs/workbench/api/common/extHostCommands.ts
+16
-13
src/vs/workbench/api/common/extHostHeapService.ts
src/vs/workbench/api/common/extHostHeapService.ts
+0
-33
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-3
src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts
...ench/test/electron-browser/api/extHostApiCommands.test.ts
+1
-4
src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts
...rkbench/test/electron-browser/api/extHostCommands.test.ts
+2
-2
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+1
-4
src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts
...kbench/test/electron-browser/api/extHostTreeViews.test.ts
+1
-2
未找到文件。
src/vs/workbench/api/common/extHostApiCommands.ts
浏览文件 @
cb865f93
...
...
@@ -473,7 +473,7 @@ export class ExtHostApiCommands {
});
}
private
_executeCodeActionProvider
(
resource
:
URI
,
range
:
types
.
Range
,
kind
?:
string
):
Promise
<
(
vscode
.
CodeAction
|
vscode
.
Command
)[]
|
undefined
>
{
private
_executeCodeActionProvider
(
resource
:
URI
,
range
:
types
.
Range
,
kind
?:
string
):
Promise
<
(
vscode
.
CodeAction
|
vscode
.
Command
|
undefined
)[]
|
undefined
>
{
const
args
=
{
resource
,
range
:
typeConverters
.
Range
.
from
(
range
),
...
...
src/vs/workbench/api/common/extHostCommands.ts
浏览文件 @
cb865f93
...
...
@@ -9,7 +9,6 @@ import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
import
*
as
extHostTypeConverter
from
'
vs/workbench/api/common/extHostTypeConverters
'
;
import
{
cloneAndChange
}
from
'
vs/base/common/objects
'
;
import
{
MainContext
,
MainThreadCommandsShape
,
ExtHostCommandsShape
,
ObjectIdentifier
,
IMainContext
,
CommandDto
}
from
'
./extHost.protocol
'
;
import
{
ExtHostHeapService
}
from
'
vs/workbench/api/common/extHostHeapService
'
;
import
{
isNonEmptyArray
}
from
'
vs/base/common/arrays
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -40,12 +39,11 @@ export class ExtHostCommands implements ExtHostCommandsShape {
constructor
(
mainContext
:
IMainContext
,
heapService
:
ExtHostHeapService
,
logService
:
ILogService
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadCommands
);
this
.
_logService
=
logService
;
this
.
_converter
=
new
CommandsConverter
(
this
,
heapService
);
this
.
_converter
=
new
CommandsConverter
(
this
);
this
.
_argumentProcessors
=
[
{
processArgument
(
a
)
{
...
...
@@ -201,14 +199,14 @@ export class ExtHostCommands implements ExtHostCommandsShape {
export
class
CommandsConverter
{
private
readonly
_delegatingCommandId
:
string
;
private
_commands
:
ExtHostCommands
;
private
_heap
:
ExtHostHeapService
;
private
readonly
_commands
:
ExtHostCommands
;
private
readonly
_cache
=
new
Map
<
number
,
vscode
.
Command
>
();
private
_cachIdPool
=
0
;
// --- conversion between internal and api commands
constructor
(
commands
:
ExtHostCommands
,
heap
:
ExtHostHeapService
)
{
constructor
(
commands
:
ExtHostCommands
)
{
this
.
_delegatingCommandId
=
`_internal_command_delegation_
${
Date
.
now
()}
`
;
this
.
_commands
=
commands
;
this
.
_heap
=
heap
;
this
.
_commands
.
registerCommand
(
true
,
this
.
_delegatingCommandId
,
this
.
_executeConvertedCommand
,
this
);
}
...
...
@@ -229,8 +227,9 @@ export class CommandsConverter {
// we have a contributed command with arguments. that
// means we don't want to send the arguments around
const
id
=
this
.
_heap
.
keep
(
command
);
disposables
.
add
(
toDisposable
(()
=>
this
.
_heap
.
delete
(
id
)));
const
id
=
++
this
.
_cachIdPool
;
this
.
_cache
.
set
(
id
,
command
);
disposables
.
add
(
toDisposable
(()
=>
this
.
_cache
.
delete
(
id
)));
result
.
$ident
=
id
;
result
.
id
=
this
.
_delegatingCommandId
;
...
...
@@ -260,7 +259,8 @@ export class CommandsConverter {
// we have a contributed command with arguments. that
// means we don't want to send the arguments around
const
id
=
this
.
_heap
.
keep
(
command
);
const
id
=
++
this
.
_cachIdPool
;
this
.
_cache
.
set
(
id
,
command
);
result
.
$ident
=
id
;
result
.
id
=
this
.
_delegatingCommandId
;
...
...
@@ -274,11 +274,11 @@ export class CommandsConverter {
return
result
;
}
fromInternal
(
command
:
modes
.
Command
):
vscode
.
Command
{
fromInternal
(
command
:
modes
.
Command
):
vscode
.
Command
|
undefined
{
const
id
=
ObjectIdentifier
.
of
(
command
);
if
(
typeof
id
===
'
number
'
)
{
return
this
.
_
heap
.
get
<
vscode
.
Command
>
(
id
);
return
this
.
_
cache
.
get
(
id
);
}
else
{
return
{
...
...
@@ -290,7 +290,10 @@ export class CommandsConverter {
}
private
_executeConvertedCommand
<
R
>
(...
args
:
any
[]):
Promise
<
R
>
{
const
actualCmd
=
this
.
_heap
.
get
<
vscode
.
Command
>
(
args
[
0
]);
const
actualCmd
=
this
.
_cache
.
get
(
args
[
0
]);
if
(
!
actualCmd
)
{
return
Promise
.
reject
(
'
actual command NOT FOUND
'
);
}
return
this
.
_commands
.
executeCommand
(
actualCmd
.
command
,
...(
actualCmd
.
arguments
||
[]));
}
...
...
src/vs/workbench/api/common/extHostHeapService.ts
已删除
100644 → 0
浏览文件 @
8e91c0db
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ExtHostHeapServiceShape
}
from
'
./extHost.protocol
'
;
export
class
ExtHostHeapService
implements
ExtHostHeapServiceShape
{
private
static
_idPool
=
0
;
private
_data
=
new
Map
<
number
,
any
>
();
keep
(
obj
:
any
):
number
{
const
id
=
ExtHostHeapService
.
_idPool
++
;
this
.
_data
.
set
(
id
,
obj
);
return
id
;
}
delete
(
id
:
number
):
boolean
{
return
this
.
_data
.
delete
(
id
);
}
get
<
T
>
(
id
:
number
):
T
{
return
this
.
_data
.
get
(
id
);
}
$onGarbageCollection
(
ids
:
number
[]):
void
{
for
(
const
id
of
ids
)
{
this
.
delete
(
id
);
}
}
}
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
cb865f93
...
...
@@ -33,7 +33,6 @@ import { ExtensionActivatedByAPI } from 'vs/workbench/api/common/extHostExtensio
import
{
ExtHostExtensionService
}
from
'
vs/workbench/api/node/extHostExtensionService
'
;
import
{
ExtHostFileSystem
}
from
'
vs/workbench/api/common/extHostFileSystem
'
;
import
{
ExtHostFileSystemEventService
}
from
'
vs/workbench/api/common/extHostFileSystemEventService
'
;
import
{
ExtHostHeapService
}
from
'
vs/workbench/api/common/extHostHeapService
'
;
import
{
ExtHostLanguageFeatures
}
from
'
vs/workbench/api/common/extHostLanguageFeatures
'
;
import
{
ExtHostLanguages
}
from
'
vs/workbench/api/common/extHostLanguages
'
;
import
{
ExtHostLogService
}
from
'
vs/workbench/api/common/extHostLogService
'
;
...
...
@@ -97,7 +96,6 @@ export function createApiFactory(
// Addressable instances
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostLogService
,
extHostLogService
);
const
extHostHeapService
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostHeapService
,
new
ExtHostHeapService
());
const
extHostDecorations
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDecorations
,
new
ExtHostDecorations
(
rpcProtocol
));
const
extHostWebviews
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWebviews
,
new
ExtHostWebviews
(
rpcProtocol
));
const
extHostUrls
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostUrls
,
new
ExtHostUrls
(
rpcProtocol
));
...
...
@@ -106,7 +104,7 @@ export function createApiFactory(
const
extHostDocumentContentProviders
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDocumentContentProviders
,
new
ExtHostDocumentContentProvider
(
rpcProtocol
,
extHostDocumentsAndEditors
,
extHostLogService
));
const
extHostDocumentSaveParticipant
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDocumentSaveParticipant
,
new
ExtHostDocumentSaveParticipant
(
extHostLogService
,
extHostDocuments
,
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadTextEditors
)));
const
extHostEditors
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostEditors
,
new
ExtHostEditors
(
rpcProtocol
,
extHostDocumentsAndEditors
));
const
extHostCommands
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostCommands
,
new
ExtHostCommands
(
rpcProtocol
,
extHost
HeapService
,
extHost
LogService
));
const
extHostCommands
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostCommands
,
new
ExtHostCommands
(
rpcProtocol
,
extHostLogService
));
const
extHostTreeViews
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostTreeViews
,
new
ExtHostTreeViews
(
rpcProtocol
.
getProxy
(
MainContext
.
MainThreadTreeViews
),
extHostCommands
,
extHostLogService
));
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWorkspace
,
extHostWorkspace
);
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostConfiguration
,
extHostConfiguration
);
...
...
src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts
浏览文件 @
cb865f93
...
...
@@ -18,7 +18,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguage
import
{
MainThreadLanguageFeatures
}
from
'
vs/workbench/api/browser/mainThreadLanguageFeatures
'
;
import
{
ExtHostApiCommands
}
from
'
vs/workbench/api/common/extHostApiCommands
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
ExtHostHeapService
}
from
'
vs/workbench/api/common/extHostHeapService
'
;
import
{
MainThreadCommands
}
from
'
vs/workbench/api/browser/mainThreadCommands
'
;
import
{
ExtHostDocuments
}
from
'
vs/workbench/api/common/extHostDocuments
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
...
...
@@ -107,9 +106,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
const
extHostDocuments
=
new
ExtHostDocuments
(
rpcProtocol
,
extHostDocumentsAndEditors
);
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDocuments
,
extHostDocuments
);
const
heapService
=
new
ExtHostHeapService
();
commands
=
new
ExtHostCommands
(
rpcProtocol
,
heapService
,
new
NullLogService
());
commands
=
new
ExtHostCommands
(
rpcProtocol
,
new
NullLogService
());
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostCommands
,
commands
);
rpcProtocol
.
set
(
MainContext
.
MainThreadCommands
,
inst
.
createInstance
(
MainThreadCommands
,
rpcProtocol
));
ExtHostApiCommands
.
register
(
commands
);
...
...
src/vs/workbench/test/electron-browser/api/extHostCommands.test.ts
浏览文件 @
cb865f93
...
...
@@ -26,7 +26,7 @@ suite('ExtHostCommands', function () {
}
};
const
commands
=
new
ExtHostCommands
(
SingleProxyRPCProtocol
(
shape
),
undefined
!
,
new
NullLogService
());
const
commands
=
new
ExtHostCommands
(
SingleProxyRPCProtocol
(
shape
),
new
NullLogService
());
commands
.
registerCommand
(
true
,
'
foo
'
,
():
any
=>
{
}).
dispose
();
assert
.
equal
(
lastUnregister
!
,
'
foo
'
);
assert
.
equal
(
CommandsRegistry
.
getCommand
(
'
foo
'
),
undefined
);
...
...
@@ -46,7 +46,7 @@ suite('ExtHostCommands', function () {
}
};
const
commands
=
new
ExtHostCommands
(
SingleProxyRPCProtocol
(
shape
),
undefined
!
,
new
NullLogService
());
const
commands
=
new
ExtHostCommands
(
SingleProxyRPCProtocol
(
shape
),
new
NullLogService
());
const
reg
=
commands
.
registerCommand
(
true
,
'
foo
'
,
():
any
=>
{
});
reg
.
dispose
();
reg
.
dispose
();
...
...
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
cb865f93
...
...
@@ -36,7 +36,6 @@ import { getDocumentFormattingEditsUntilResult, getDocumentRangeFormattingEditsU
import
{
getLinks
}
from
'
vs/editor/contrib/links/getLinks
'
;
import
{
MainContext
,
ExtHostContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostDiagnostics
}
from
'
vs/workbench/api/common/extHostDiagnostics
'
;
import
{
ExtHostHeapService
}
from
'
vs/workbench/api/common/extHostHeapService
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
...
...
@@ -100,9 +99,7 @@ suite('ExtHostLanguageFeatures', function () {
const
extHostDocuments
=
new
ExtHostDocuments
(
rpcProtocol
,
extHostDocumentsAndEditors
);
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostDocuments
,
extHostDocuments
);
const
heapService
=
new
ExtHostHeapService
();
const
commands
=
new
ExtHostCommands
(
rpcProtocol
,
heapService
,
new
NullLogService
());
const
commands
=
new
ExtHostCommands
(
rpcProtocol
,
new
NullLogService
());
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostCommands
,
commands
);
rpcProtocol
.
set
(
MainContext
.
MainThreadCommands
,
inst
.
createInstance
(
MainThreadCommands
,
rpcProtocol
));
...
...
src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts
浏览文件 @
cb865f93
...
...
@@ -11,7 +11,6 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import
{
MainThreadTreeViewsShape
,
MainContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
TreeDataProvider
,
TreeItem
}
from
'
vscode
'
;
import
{
TestRPCProtocol
}
from
'
./testRPCProtocol
'
;
import
{
ExtHostHeapService
}
from
'
vs/workbench/api/common/extHostHeapService
'
;
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
MainThreadCommands
}
from
'
vs/workbench/api/browser/mainThreadCommands
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -72,7 +71,7 @@ suite('ExtHostTreeView', function () {
rpcProtocol
.
set
(
MainContext
.
MainThreadCommands
,
inst
.
createInstance
(
MainThreadCommands
,
rpcProtocol
));
target
=
new
RecordingShape
();
testObject
=
new
ExtHostTreeViews
(
target
,
new
ExtHostCommands
(
rpcProtocol
,
new
ExtHostHeapService
(),
new
NullLogService
()),
new
NullLogService
());
testObject
=
new
ExtHostTreeViews
(
target
,
new
ExtHostCommands
(
rpcProtocol
,
new
NullLogService
()),
new
NullLogService
());
onDidChangeTreeNode
=
new
Emitter
<
{
key
:
string
}
>
();
onDidChangeTreeNodeWithId
=
new
Emitter
<
{
key
:
string
}
>
();
testObject
.
createTreeView
(
'
testNodeTreeProvider
'
,
{
treeDataProvider
:
aNodeTreeDataProvider
()
},
{
enableProposedApi
:
true
}
as
IExtensionDescription
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录