Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
bd4e85d8
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,发现更多精彩内容 >>
提交
bd4e85d8
编写于
7月 07, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move CommandRegistry out of KeybindingsRegistry
上级
739acb2b
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
185 addition
and
76 deletion
+185
-76
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+3
-2
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
+2
-1
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+2
-1
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+2
-1
src/vs/platform/commands/common/commands.ts
src/vs/platform/commands/common/commands.ts
+128
-0
src/vs/platform/commands/test/commands.test.ts
src/vs/platform/commands/test/commands.test.ts
+22
-0
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
+5
-4
src/vs/platform/keybinding/common/keybinding.ts
src/vs/platform/keybinding/common/keybinding.ts
+1
-17
src/vs/platform/keybinding/common/keybindingsRegistry.ts
src/vs/platform/keybinding/common/keybindingsRegistry.ts
+4
-36
src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts
...atform/keybinding/test/common/keybindingsRegistry.test.ts
+5
-5
src/vs/workbench/api/node/extHostApiCommands.ts
src/vs/workbench/api/node/extHostApiCommands.ts
+1
-1
src/vs/workbench/api/node/extHostCommands.ts
src/vs/workbench/api/node/extHostCommands.ts
+1
-1
src/vs/workbench/api/node/extHostProtocol.ts
src/vs/workbench/api/node/extHostProtocol.ts
+1
-1
src/vs/workbench/api/node/mainThreadCommands.ts
src/vs/workbench/api/node/mainThreadCommands.ts
+5
-3
src/vs/workbench/common/actionRegistry.ts
src/vs/workbench/common/actionRegistry.ts
+1
-1
src/vs/workbench/test/node/api/extHostApiCommands.test.ts
src/vs/workbench/test/node/api/extHostApiCommands.test.ts
+2
-2
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
bd4e85d8
...
...
@@ -15,9 +15,10 @@ import {ConfigurationService, IContent, IStat} from 'vs/platform/configuration/c
import
{
IEditor
,
IEditorInput
,
IEditorOptions
,
IEditorService
,
IResourceInput
,
ITextEditorModel
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
AbstractExtensionService
,
ActivatedExtension
}
from
'
vs/platform/extensions/common/abstractExtensionService
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingService
}
from
'
vs/platform/keybinding/browser/keybindingServiceImpl
'
;
import
{
IOSupport
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
I
CommandHandler
,
ICommandsMap
,
I
KeybindingItem
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingItem
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IConfirmation
,
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -202,7 +203,7 @@ export class StandaloneKeybindingService extends KeybindingService {
private
static
LAST_GENERATED_ID
=
0
;
private
_dynamicKeybindings
:
IKeybindingItem
[];
private
_dynamicCommands
:
ICommandsMap
;
private
_dynamicCommands
:
{
[
id
:
string
]:
ICommandHandler
}
;
constructor
(
configurationService
:
IConfigurationService
,
messageService
:
IMessageService
,
domNode
:
HTMLElement
)
{
super
(
configurationService
,
messageService
);
...
...
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
浏览文件 @
bd4e85d8
...
...
@@ -9,7 +9,8 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
AbstractKeybindingService
}
from
'
vs/platform/keybinding/browser/keybindingServiceImpl
'
;
import
{
ICommandHandler
,
IKeybindingContextKey
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingContextKey
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IActionDescriptor
,
ICodeEditorWidgetCreationOptions
,
IDiffEditorOptions
,
IModel
,
IModelChangedEvent
,
EventType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
bd4e85d8
...
...
@@ -9,7 +9,8 @@ import URI from 'vs/base/common/uri';
import
{
SyncDescriptor1
,
createSyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICommandHandler
,
IKeybindings
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindings
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandDescriptor
,
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
bd4e85d8
...
...
@@ -10,7 +10,8 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICommandHandler
,
IKeybindingService
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IKeybindingService
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
src/vs/platform/commands/common/commands.ts
0 → 100644
浏览文件 @
bd4e85d8
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TypeConstraint
,
validateConstraints
}
from
'
vs/base/common/types
'
;
import
{
IInstantiationService
,
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
export
const
ICommandService
=
createDecorator
(
'
commandService
'
);
export
interface
ICommandService
{
executeCommand
<
T
>
(
commandId
:
string
,
...
args
:
any
[]):
TPromise
<
T
>
;
executeCommand
(
commandId
:
string
,
...
args
:
any
[]):
TPromise
<
any
>
;
}
export
interface
ICommandsMap
{
[
id
:
string
]:
ICommand
;
}
export
interface
ICommandHandler
{
(
accessor
:
ServicesAccessor
,
...
args
:
any
[]):
void
;
}
export
interface
ICommand
{
handler
:
ICommandHandler
;
description
?:
ICommandHandlerDescription
;
}
export
interface
ICommandHandlerDescription
{
description
:
string
;
args
:
{
name
:
string
;
description
?:
string
;
constraint
?:
TypeConstraint
;
}[];
returns
?:
string
;
}
export
interface
ICommandRegistry
{
registerCommand
(
id
:
string
,
command
:
ICommandHandler
):
void
;
registerCommand
(
id
:
string
,
command
:
ICommand
):
void
;
getCommand
(
id
:
string
):
ICommand
;
getCommands
():
ICommandsMap
;
}
function
isCommand
(
thing
:
any
):
thing
is
ICommand
{
return
typeof
thing
===
'
object
'
&&
typeof
(
<
ICommand
>
thing
).
handler
===
'
function
'
&&
(
!
(
<
ICommand
>
thing
).
description
||
typeof
(
<
ICommand
>
thing
).
description
===
'
object
'
);
}
export
const
CommandsRegistry
:
ICommandRegistry
=
new
class
implements
ICommandRegistry
{
private
_commands
:
{
[
id
:
string
]:
ICommand
}
=
Object
.
create
(
null
);
registerCommand
(
id
:
string
,
commandOrDesc
:
ICommandHandler
|
ICommand
):
void
{
// if (this._commands[id] !== void 0) {
// throw new Error(`command already exists: '${id}'`);
// }
if
(
!
commandOrDesc
)
{
throw
new
Error
(
`invalid command`
);
}
if
(
!
isCommand
(
commandOrDesc
))
{
// simple handler
this
.
_commands
[
id
]
=
{
handler
:
commandOrDesc
};
}
else
{
const
{
handler
,
description
}
=
commandOrDesc
;
if
(
description
)
{
// add argument validation if rich command metadata is provided
const
constraints
:
TypeConstraint
[]
=
[];
for
(
let
arg
of
description
.
args
)
{
constraints
.
push
(
arg
.
constraint
);
}
this
.
_commands
[
id
]
=
{
description
,
handler
(
accessor
,
...
args
:
any
[])
{
validateConstraints
(
args
,
constraints
);
return
handler
(
accessor
,
...
args
);
}
};
}
else
{
// add as simple handler
this
.
_commands
[
id
]
=
{
handler
};
}
}
}
getCommand
(
id
:
string
):
ICommand
{
return
this
.
_commands
[
id
];
}
getCommands
():
ICommandsMap
{
return
this
.
_commands
;
}
};
class
DefaultCommandService
implements
ICommandService
{
serviceId
:
any
;
constructor
(
@
IInstantiationService
private
_instantiationService
:
IInstantiationService
,
@
IExtensionService
private
_extensionService
:
IExtensionService
)
{
//
}
executeCommand
<
T
>
(
id
:
string
,
...
args
:
any
[]):
TPromise
<
T
>
{
const
command
=
CommandsRegistry
.
getCommand
(
id
);
if
(
!
command
)
{
return
TPromise
.
wrapError
(
new
Error
(
`command '
${
id
}
' not found`
));
}
this
.
_extensionService
.
activateByEvent
(
`onCommand:
${
id
}
`
).
then
(
_
=>
{
try
{
const
result
=
this
.
_instantiationService
.
invokeFunction
.
apply
(
this
.
_instantiationService
,
[
command
].
concat
(
args
));
return
TPromise
.
as
(
result
);
}
catch
(
err
)
{
return
TPromise
.
wrapError
(
err
);
}
});
}
}
registerSingleton
(
ICommandService
,
DefaultCommandService
);
src/vs/platform/commands/test/commands.test.ts
0 → 100644
浏览文件 @
bd4e85d8
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
suite
(
'
Command Tests
'
,
function
()
{
test
(
'
register command - no handler
'
,
function
()
{
assert
.
throws
(()
=>
CommandsRegistry
.
registerCommand
(
'
foo
'
,
null
));
});
// test('register command - dupe', function () {
// CommandsRegistry.registerCommand('foo', () => { });
// assert.throws(() => CommandsRegistry.registerCommand('foo', () => { }));
// });
});
\ No newline at end of file
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
浏览文件 @
bd4e85d8
...
...
@@ -15,8 +15,9 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IKeyboardEvent
,
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
CommandsRegistry
,
ICommandHandler
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingResolver
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
I
CommandHandler
,
ICommandHandlerDescription
,
I
KeybindingContextKey
,
IKeybindingItem
,
IKeybindingScopeLocation
,
IKeybindingService
,
SET_CONTEXT_COMMAND_ID
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingContextKey
,
IKeybindingItem
,
IKeybindingScopeLocation
,
IKeybindingService
,
SET_CONTEXT_COMMAND_ID
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IStatusbarService
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -207,7 +208,7 @@ export abstract class AbstractKeybindingService {
}
public
hasCommand
(
commandId
:
string
):
boolean
{
return
!!
Keybinding
sRegistry
.
getCommands
()[
commandId
];
return
!!
Command
sRegistry
.
getCommands
()[
commandId
];
}
public
abstract
executeCommand
(
commandId
:
string
,
args
:
any
):
TPromise
<
any
>
;
...
...
@@ -312,7 +313,7 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
}
private
_getAllCommandsAsComment
():
string
{
const
commands
=
Keybinding
sRegistry
.
getCommands
();
const
commands
=
Command
sRegistry
.
getCommands
();
const
unboundCommands
:
string
[]
=
[];
const
boundCommands
=
this
.
_getResolver
().
getDefaultBoundCommands
();
...
...
@@ -336,7 +337,7 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
}
protected
_getCommandHandler
(
commandId
:
string
):
ICommandHandler
{
return
KeybindingsRegistry
.
getCommands
()[
commandId
]
;
return
CommandsRegistry
.
getCommand
(
commandId
).
handler
;
}
private
_dispatch
(
e
:
IKeyboardEvent
):
void
{
...
...
src/vs/platform/keybinding/common/keybinding.ts
浏览文件 @
bd4e85d8
...
...
@@ -6,9 +6,8 @@
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
TypeConstraint
}
from
'
vs/base/common/types
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServiceIdentifier
,
ServicesAccessor
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
Event
from
'
vs/base/common/event
'
;
export
interface
IUserFriendlyKeybinding
{
...
...
@@ -436,21 +435,6 @@ export interface IKeybindingItem {
weight2
:
number
;
}
export
interface
ICommandHandler
{
(
accessor
:
ServicesAccessor
,
...
args
:
any
[]):
void
;
description
?:
string
|
ICommandHandlerDescription
;
}
export
interface
ICommandHandlerDescription
{
description
:
string
;
args
:
{
name
:
string
;
description
?:
string
;
constraint
?:
TypeConstraint
;
}[];
returns
?:
string
;
}
export
interface
ICommandsMap
{
[
id
:
string
]:
ICommandHandler
;
}
export
interface
IKeybindingContextKey
<
T
>
{
set
(
value
:
T
):
void
;
reset
():
void
;
...
...
src/vs/platform/keybinding/common/keybindingsRegistry.ts
浏览文件 @
bd4e85d8
...
...
@@ -6,8 +6,8 @@
import
{
BinaryKeybindings
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
TypeConstraint
,
validateConstraints
}
from
'
vs/base/common/types
'
;
import
{
ICommandHandler
,
ICommandHandlerDescription
,
ICommandsMap
,
IKeybindingItem
,
IKeybindings
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingItem
,
IKeybindings
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
CommandsRegistry
,
ICommandHandler
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
export
interface
ICommandRule
extends
IKeybindings
{
...
...
@@ -18,13 +18,12 @@ export interface ICommandRule extends IKeybindings {
export
interface
ICommandDescriptor
extends
ICommandRule
{
handler
:
ICommandHandler
;
description
?:
string
|
ICommandHandlerDescription
;
description
?:
ICommandHandlerDescription
;
}
export
interface
IKeybindingsRegistry
{
registerCommandRule
(
rule
:
ICommandRule
);
registerCommandDesc
(
desc
:
ICommandDescriptor
):
void
;
getCommands
():
ICommandsMap
;
getDefaultKeybindings
():
IKeybindingItem
[];
WEIGHT
:
{
...
...
@@ -39,7 +38,6 @@ export interface IKeybindingsRegistry {
class
KeybindingsRegistryImpl
implements
IKeybindingsRegistry
{
private
_keybindings
:
IKeybindingItem
[];
private
_commands
:
ICommandsMap
;
public
WEIGHT
=
{
editorCore
:
(
importance
:
number
=
0
):
number
=>
{
...
...
@@ -61,7 +59,6 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
constructor
()
{
this
.
_keybindings
=
[];
this
.
_commands
=
Object
.
create
(
null
);
}
/**
...
...
@@ -101,36 +98,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
public
registerCommandDesc
(
desc
:
ICommandDescriptor
):
void
{
this
.
registerCommandRule
(
desc
);
// if (_commands[desc.id]) {
// console.warn('Duplicate handler for command: ' + desc.id);
// }
// this._commands[desc.id] = desc.handler;
let
handler
=
desc
.
handler
;
let
description
=
desc
.
description
||
handler
.
description
;
// add argument validation if rich command metadata is provided
if
(
typeof
description
===
'
object
'
)
{
let
constraints
:
TypeConstraint
[]
=
[];
for
(
let
arg
of
description
.
args
)
{
constraints
.
push
(
arg
.
constraint
);
}
handler
=
function
(
accesor
,
...
args
:
any
[])
{
validateConstraints
(
args
,
constraints
);
return
desc
.
handler
(
accesor
,
...
args
);
};
}
// make sure description is there
handler
.
description
=
description
;
// register handler
this
.
_commands
[
desc
.
id
]
=
handler
;
}
public
getCommands
():
ICommandsMap
{
return
this
.
_commands
;
CommandsRegistry
.
registerCommand
(
desc
.
id
,
desc
);
}
private
registerDefaultKeybinding
(
keybinding
:
number
,
commandId
:
string
,
weight1
:
number
,
weight2
:
number
,
when
:
KbExpr
):
void
{
...
...
src/vs/platform/keybinding/test/common/keybindingsRegistry.test.ts
浏览文件 @
bd4e85d8
...
...
@@ -6,6 +6,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
suite
(
'
Keybinding Registry
'
,
()
=>
{
...
...
@@ -23,7 +24,6 @@ suite('Keybinding Registry', () => {
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
test2
'
,
description
:
'
test
'
,
when
:
undefined
,
primary
:
undefined
,
weight
:
0
,
...
...
@@ -46,10 +46,10 @@ suite('Keybinding Registry', () => {
}
});
KeybindingsRegistry
.
getCommands
()[
'
test
'
]
.
apply
(
undefined
,
[
undefined
,
'
string
'
]);
KeybindingsRegistry
.
getCommands
()[
'
test2
'
]
.
apply
(
undefined
,
[
undefined
,
'
string
'
]);
assert
.
throws
(()
=>
KeybindingsRegistry
.
getCommands
()[
'
test3
'
]
.
apply
(
undefined
,
[
undefined
,
'
string
'
]));
assert
.
equal
(
KeybindingsRegistry
.
getCommands
()[
'
test3
'
]
.
apply
(
undefined
,
[
undefined
,
1
]),
true
);
CommandsRegistry
.
getCommands
()[
'
test
'
].
handler
.
apply
(
undefined
,
[
undefined
,
'
string
'
]);
CommandsRegistry
.
getCommands
()[
'
test2
'
].
handler
.
apply
(
undefined
,
[
undefined
,
'
string
'
]);
assert
.
throws
(()
=>
CommandsRegistry
.
getCommands
()[
'
test3
'
].
handler
.
apply
(
undefined
,
[
undefined
,
'
string
'
]));
assert
.
equal
(
CommandsRegistry
.
getCommands
()[
'
test3
'
].
handler
.
apply
(
undefined
,
[
undefined
,
1
]),
true
);
});
});
src/vs/workbench/api/node/extHostApiCommands.ts
浏览文件 @
bd4e85d8
...
...
@@ -12,7 +12,7 @@ import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters';
import
*
as
types
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
ISingleEditOperation
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
keybinding/common/keybinding
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
commands/common/commands
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
IQuickFix2
}
from
'
vs/editor/contrib/quickFix/common/quickFix
'
;
import
{
IOutline
}
from
'
vs/editor/contrib/quickOpen/common/quickOpen
'
;
...
...
src/vs/workbench/api/node/extHostCommands.ts
浏览文件 @
bd4e85d8
...
...
@@ -6,7 +6,7 @@
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
validateConstraint
}
from
'
vs/base/common/types
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
keybinding/common/keybinding
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
commands/common/commands
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtHostEditors
}
from
'
vs/workbench/api/node/extHostEditors
'
;
import
*
as
extHostTypes
from
'
vs/workbench/api/node/extHostTypes
'
;
...
...
src/vs/workbench/api/node/extHostProtocol.ts
浏览文件 @
bd4e85d8
...
...
@@ -21,7 +21,7 @@ import {Position as EditorPosition} from 'vs/platform/editor/common/editor';
import
{
IMessage
,
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
StatusbarAlignment
as
MainThreadStatusBarAlignment
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
ITelemetryInfo
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
keybinding/common/keybinding
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/
commands/common/commands
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
...
...
src/vs/workbench/api/node/mainThreadCommands.ts
浏览文件 @
bd4e85d8
...
...
@@ -6,7 +6,9 @@
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IKeybindingService
,
ICommandHandlerDescription
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
CommandsRegistry
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ExtHostContext
,
ExtHostCommandsShape
}
from
'
./extHostProtocol
'
;
...
...
@@ -49,7 +51,7 @@ export class MainThreadCommands {
}
$getCommands
():
Thenable
<
string
[]
>
{
return
TPromise
.
as
(
Object
.
keys
(
Keybinding
sRegistry
.
getCommands
()));
return
TPromise
.
as
(
Object
.
keys
(
Command
sRegistry
.
getCommands
()));
}
}
...
...
@@ -61,7 +63,7 @@ KeybindingsRegistry.registerCommandDesc({
return
accessor
.
get
(
IThreadService
).
get
(
ExtHostContext
.
ExtHostCommands
).
$getContributedCommandHandlerDescriptions
().
then
(
result
=>
{
// add local commands
const
commands
=
Keybinding
sRegistry
.
getCommands
();
const
commands
=
Command
sRegistry
.
getCommands
();
for
(
let
id
in
commands
)
{
let
{
description
}
=
commands
[
id
];
if
(
description
)
{
...
...
src/vs/workbench/common/actionRegistry.ts
浏览文件 @
bd4e85d8
...
...
@@ -10,7 +10,7 @@ import {Registry} from 'vs/platform/platform';
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
KeybindingsRegistry
,
ICommandDescriptor
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
ICommandHandler
}
from
'
vs/platform/
keybinding/common/keybinding
'
;
import
{
ICommandHandler
}
from
'
vs/platform/
commands/common/commands
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
src/vs/workbench/test/node/api/extHostApiCommands.test.ts
浏览文件 @
bd4e85d8
...
...
@@ -19,7 +19,7 @@ import {MarkerService} from 'vs/platform/markers/common/markerService';
import
{
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ExtHostLanguageFeatures
}
from
'
vs/workbench/api/node/extHostLanguageFeatures
'
;
import
{
MainThreadLanguageFeatures
}
from
'
vs/workbench/api/node/mainThreadLanguageFeatures
'
;
...
...
@@ -62,7 +62,7 @@ suite('ExtHostLanguageFeatureCommands', function() {
services
.
set
(
IKeybindingService
,
<
IKeybindingService
>
{
executeCommand
(
id
,
args
):
any
{
let
handler
=
Keybinding
sRegistry
.
getCommands
()[
id
];
let
{
handler
}
=
Command
sRegistry
.
getCommands
()[
id
];
return
TPromise
.
as
(
instantiationService
.
invokeFunction
(
handler
,
args
));
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录