Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
815b26e0
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,发现更多精彩内容 >>
提交
815b26e0
编写于
1月 13, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify StandaloneCommandService
上级
97570d91
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
17 deletion
+22
-17
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+19
-12
src/vs/editor/browser/standalone/standaloneServices.ts
src/vs/editor/browser/standalone/standaloneServices.ts
+1
-1
src/vs/editor/test/browser/standalone/simpleServices.test.ts
src/vs/editor/test/browser/standalone/simpleServices.test.ts
+2
-4
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
815b26e0
...
...
@@ -11,8 +11,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
IConfigurationValue
,
getConfigurationValue
,
IConfigurationKeys
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditor
,
IEditorInput
,
IEditorOptions
,
IEditorService
,
IResourceInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
AbstractExtensionService
,
ActivatedExtension
}
from
'
vs/platform/extensions/common/abstractExtensionService
'
;
import
{
IExtensionDescription
,
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ICommandService
,
ICommand
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ICommandService
,
ICommand
,
ICommandHandler
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
AbstractKeybindingService
}
from
'
vs/platform/keybinding/common/abstractKeybindingService
'
;
import
{
KeybindingResolver
,
IOSupport
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
IKeybindingEvent
,
IKeybindingItem
,
KeybindingSource
}
from
'
vs/platform/keybinding/common/keybinding
'
;
...
...
@@ -23,7 +23,6 @@ import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
getDefaultValues
as
getDefaultConfiguration
}
from
'
vs/platform/configuration/common/model
'
;
import
{
CommandService
}
from
'
vs/platform/commands/common/commandService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProgressService
,
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ITextModelResolverService
,
ITextModelContentProvider
,
ITextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
...
...
@@ -263,16 +262,14 @@ export class SimpleMessageService implements IMessageService {
}
}
export
class
StandaloneCommandService
extends
CommandService
{
export
class
StandaloneCommandService
implements
ICommandService
{
_serviceBrand
:
any
;
private
readonly
_instantiationService
:
IInstantiationService
;
private
_dynamicCommands
:
{
[
id
:
string
]:
ICommand
;
};
constructor
(
instantiationService
:
IInstantiationService
,
extensionService
:
IExtensionService
)
{
super
(
instantiationService
,
extensionService
);
constructor
(
instantiationService
:
IInstantiationService
)
{
this
.
_instantiationService
=
instantiationService
;
this
.
_dynamicCommands
=
Object
.
create
(
null
);
}
...
...
@@ -280,8 +277,18 @@ export class StandaloneCommandService extends CommandService {
this
.
_dynamicCommands
[
id
]
=
command
;
}
protected
_getCommand
(
id
:
string
):
ICommand
{
return
super
.
_getCommand
(
id
)
||
this
.
_dynamicCommands
[
id
];
public
executeCommand
<
T
>
(
id
:
string
,
...
args
:
any
[]):
TPromise
<
T
>
{
const
command
=
(
CommandsRegistry
.
getCommand
(
id
)
||
this
.
_dynamicCommands
[
id
]);
if
(
!
command
)
{
return
TPromise
.
wrapError
(
new
Error
(
`command '
${
id
}
' not found`
));
}
try
{
const
result
=
this
.
_instantiationService
.
invokeFunction
.
apply
(
this
.
_instantiationService
,
[
command
.
handler
].
concat
(
args
));
return
TPromise
.
as
(
result
);
}
catch
(
err
)
{
return
TPromise
.
wrapError
(
err
);
}
}
}
...
...
src/vs/editor/browser/standalone/standaloneServices.ts
浏览文件 @
815b26e0
...
...
@@ -175,7 +175,7 @@ export class DynamicStandaloneServices extends Disposable {
let
contextKeyService
=
ensure
(
IContextKeyService
,
()
=>
this
.
_register
(
new
ContextKeyService
(
configurationService
)));
let
commandService
=
ensure
(
ICommandService
,
()
=>
new
StandaloneCommandService
(
this
.
_instantiationService
,
extensionService
));
let
commandService
=
ensure
(
ICommandService
,
()
=>
new
StandaloneCommandService
(
this
.
_instantiationService
));
ensure
(
IKeybindingService
,
()
=>
this
.
_register
(
new
StandaloneKeybindingService
(
contextKeyService
,
commandService
,
messageService
,
domElement
)));
...
...
src/vs/editor/test/browser/standalone/simpleServices.test.ts
浏览文件 @
815b26e0
...
...
@@ -6,7 +6,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
import
{
SimpleConfigurationService
,
SimpleMessageService
,
S
impleExtensionService
,
S
tandaloneKeybindingService
,
StandaloneCommandService
}
from
'
vs/editor/browser/standalone/simpleServices
'
;
import
{
SimpleConfigurationService
,
SimpleMessageService
,
StandaloneKeybindingService
,
StandaloneCommandService
}
from
'
vs/editor/browser/standalone/simpleServices
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
Keybinding
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -32,9 +32,7 @@ suite('StandaloneKeybindingService', () => {
let
contextKeyService
=
new
ContextKeyService
(
configurationService
);
let
extensionService
=
new
SimpleExtensionService
();
let
commandService
=
new
StandaloneCommandService
(
instantiationService
,
extensionService
);
let
commandService
=
new
StandaloneCommandService
(
instantiationService
);
let
messageService
=
new
SimpleMessageService
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录