Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fa406d2d
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa406d2d
编写于
5月 16, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tiny tweaks
上级
ab769475
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
24 deletion
+27
-24
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+11
-5
src/vs/workbench/api/browser/mainThreadCommands.ts
src/vs/workbench/api/browser/mainThreadCommands.ts
+9
-8
src/vs/workbench/api/common/extHostCommands.ts
src/vs/workbench/api/common/extHostCommands.ts
+7
-11
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
fa406d2d
...
@@ -555,16 +555,22 @@ declare module 'vscode' {
...
@@ -555,16 +555,22 @@ declare module 'vscode' {
* @return Disposable which unregisters this command on disposal.
* @return Disposable which unregisters this command on disposal.
*/
*/
export
function
registerDiffInformationCommand
(
command
:
string
,
callback
:
(
diff
:
LineChange
[],
...
args
:
any
[])
=>
any
,
thisArg
?:
any
):
Disposable
;
export
function
registerDiffInformationCommand
(
command
:
string
,
callback
:
(
diff
:
LineChange
[],
...
args
:
any
[])
=>
any
,
thisArg
?:
any
):
Disposable
;
}
//#endregion
export
interface
ICommandEvent
{
//#region Joh: onDidExecuteCommand
commandId
:
string
;
args
:
any
[];
}
export
interface
CommandExecutionEvent
{
command
:
string
;
arguments
:
any
[];
}
export
namespace
commands
{
/**
/**
* An event that is emitted when a [command](#Command) is executed.
* An event that is emitted when a [command](#Command) is executed.
*/
*/
export
const
onDidExecuteCommand
:
Event
<
ICommand
Event
>
;
export
const
onDidExecuteCommand
:
Event
<
CommandExecution
Event
>
;
}
}
//#endregion
//#endregion
...
...
src/vs/workbench/api/browser/mainThreadCommands.ts
浏览文件 @
fa406d2d
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
ICommandService
,
CommandsRegistry
,
ICommandHandlerDescription
,
ICommandEvent
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandService
,
CommandsRegistry
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ExtHostContext
,
MainThreadCommandsShape
,
ExtHostCommandsShape
,
MainContext
,
IExtHostContext
}
from
'
../common/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadCommandsShape
,
ExtHostCommandsShape
,
MainContext
,
IExtHostContext
}
from
'
../common/extHost.protocol
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/common/extHostCustomers
'
;
...
@@ -15,7 +15,7 @@ export class MainThreadCommands implements MainThreadCommandsShape {
...
@@ -15,7 +15,7 @@ export class MainThreadCommands implements MainThreadCommandsShape {
private
readonly
_disposables
=
new
Map
<
string
,
IDisposable
>
();
private
readonly
_disposables
=
new
Map
<
string
,
IDisposable
>
();
private
readonly
_generateCommandsDocumentationRegistration
:
IDisposable
;
private
readonly
_generateCommandsDocumentationRegistration
:
IDisposable
;
private
readonly
_proxy
:
ExtHostCommandsShape
;
private
readonly
_proxy
:
ExtHostCommandsShape
;
private
_onDidExecuteCommandListener
:
IDisposable
;
private
_onDidExecuteCommandListener
?
:
IDisposable
;
constructor
(
constructor
(
extHostContext
:
IExtHostContext
,
extHostContext
:
IExtHostContext
,
...
@@ -80,20 +80,21 @@ export class MainThreadCommands implements MainThreadCommandsShape {
...
@@ -80,20 +80,21 @@ export class MainThreadCommands implements MainThreadCommandsShape {
}
}
$registerCommandListener
()
{
$registerCommandListener
()
{
this
.
_onDidExecuteCommandListener
=
this
.
_commandService
.
onDidExecuteCommand
((
command
)
=>
this
.
handleExecuteCommand
(
command
));
if
(
!
this
.
_onDidExecuteCommandListener
)
{
this
.
_onDidExecuteCommandListener
=
this
.
_commandService
.
onDidExecuteCommand
(
command
=>
this
.
_proxy
.
$handleDidExecuteCommand
(
command
));
}
}
}
$unregisterCommandListener
()
{
$unregisterCommandListener
()
{
return
this
.
_onDidExecuteCommandListener
.
dispose
();
if
(
this
.
_onDidExecuteCommandListener
)
{
this
.
_onDidExecuteCommandListener
.
dispose
();
this
.
_onDidExecuteCommandListener
=
undefined
;
}
}
}
$getCommands
():
Promise
<
string
[]
>
{
$getCommands
():
Promise
<
string
[]
>
{
return
Promise
.
resolve
(
Object
.
keys
(
CommandsRegistry
.
getCommands
()));
return
Promise
.
resolve
(
Object
.
keys
(
CommandsRegistry
.
getCommands
()));
}
}
handleExecuteCommand
(
command
:
ICommandEvent
)
{
this
.
_proxy
.
$handleDidExecuteCommand
(
command
);
}
}
}
// --- command doc
// --- command doc
...
...
src/vs/workbench/api/common/extHostCommands.ts
浏览文件 @
fa406d2d
...
@@ -19,7 +19,6 @@ import { Range } from 'vs/editor/common/core/range';
...
@@ -19,7 +19,6 @@ import { Range } from 'vs/editor/common/core/range';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
interface
CommandHandler
{
interface
CommandHandler
{
callback
:
Function
;
callback
:
Function
;
...
@@ -32,8 +31,9 @@ export interface ArgumentProcessor {
...
@@ -32,8 +31,9 @@ export interface ArgumentProcessor {
}
}
export
class
ExtHostCommands
implements
ExtHostCommandsShape
{
export
class
ExtHostCommands
implements
ExtHostCommandsShape
{
private
readonly
_onDidExecuteCommand
:
Emitter
<
ICommandEvent
>
;
readonly
onDidExecuteCommandEmitter
:
Event
<
ICommandEvent
>
;
private
readonly
_onDidExecuteCommand
:
Emitter
<
vscode
.
CommandExecutionEvent
>
;
readonly
onDidExecuteCommand
:
Event
<
vscode
.
CommandExecutionEvent
>
;
private
readonly
_commands
=
new
Map
<
string
,
CommandHandler
>
();
private
readonly
_commands
=
new
Map
<
string
,
CommandHandler
>
();
private
readonly
_proxy
:
MainThreadCommandsShape
;
private
readonly
_proxy
:
MainThreadCommandsShape
;
...
@@ -47,11 +47,11 @@ export class ExtHostCommands implements ExtHostCommandsShape {
...
@@ -47,11 +47,11 @@ export class ExtHostCommands implements ExtHostCommandsShape {
logService
:
ILogService
logService
:
ILogService
)
{
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadCommands
);
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadCommands
);
this
.
_onDidExecuteCommand
=
new
Emitter
<
ICommand
Event
>
({
this
.
_onDidExecuteCommand
=
new
Emitter
<
vscode
.
CommandExecution
Event
>
({
onFirstListenerDidAdd
:
()
=>
this
.
_proxy
.
$registerCommandListener
(),
onFirstListenerDidAdd
:
()
=>
this
.
_proxy
.
$registerCommandListener
(),
onLastListenerRemove
:
()
=>
this
.
_proxy
.
$unregisterCommandListener
(),
onLastListenerRemove
:
()
=>
this
.
_proxy
.
$unregisterCommandListener
(),
});
});
this
.
onDidExecuteCommand
Emitter
=
this
.
_onDidExecuteCommand
.
event
;
this
.
onDidExecuteCommand
=
this
.
_onDidExecuteCommand
.
event
;
this
.
_logService
=
logService
;
this
.
_logService
=
logService
;
this
.
_converter
=
new
CommandsConverter
(
this
,
heapService
);
this
.
_converter
=
new
CommandsConverter
(
this
,
heapService
);
this
.
_argumentProcessors
=
[
this
.
_argumentProcessors
=
[
...
@@ -116,12 +116,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
...
@@ -116,12 +116,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
});
});
}
}
onDidExecuteCommand
(
listener
:
(
command
:
ICommandEvent
)
=>
any
,
thisArgs
?:
any
,
disposables
?:
IDisposable
[])
{
return
this
.
onDidExecuteCommandEmitter
(
listener
,
thisArgs
,
disposables
);
}
$handleDidExecuteCommand
(
command
:
ICommandEvent
):
void
{
$handleDidExecuteCommand
(
command
:
ICommandEvent
):
void
{
this
.
_onDidExecuteCommand
.
fire
(
command
);
this
.
_onDidExecuteCommand
.
fire
(
{
command
:
command
.
commandId
,
arguments
:
command
.
args
}
);
}
}
executeCommand
<
T
>
(
id
:
string
,
...
args
:
any
[]):
Promise
<
T
>
{
executeCommand
<
T
>
(
id
:
string
,
...
args
:
any
[]):
Promise
<
T
>
{
...
@@ -172,7 +168,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
...
@@ -172,7 +168,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
try
{
try
{
const
result
=
callback
.
apply
(
thisArg
,
args
);
const
result
=
callback
.
apply
(
thisArg
,
args
);
this
.
_onDidExecuteCommand
.
fire
({
command
Id
:
id
,
args
});
this
.
_onDidExecuteCommand
.
fire
({
command
:
id
,
arguments
:
args
});
return
Promise
.
resolve
(
result
);
return
Promise
.
resolve
(
result
);
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
_logService
.
error
(
err
,
id
);
this
.
_logService
.
error
(
err
,
id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录