Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
619ef444
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,发现更多精彩内容 >>
提交
619ef444
编写于
4月 18, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move service collection to its own file
上级
f50f5270
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
74 deletion
+83
-74
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+2
-1
src/vs/editor/contrib/referenceSearch/browser/referenceSearchWidget.ts
.../contrib/referenceSearch/browser/referenceSearchWidget.ts
+2
-1
src/vs/platform/instantiation/common/instantiation.ts
src/vs/platform/instantiation/common/instantiation.ts
+2
-60
src/vs/platform/instantiation/common/instantiationService.ts
src/vs/platform/instantiation/common/instantiationService.ts
+7
-6
src/vs/platform/instantiation/common/serviceCollection.ts
src/vs/platform/instantiation/common/serviceCollection.ts
+61
-0
src/vs/platform/instantiation/test/common/instantiationService.test.ts
...rm/instantiation/test/common/instantiationService.test.ts
+3
-3
src/vs/workbench/browser/parts/compositePart.ts
src/vs/workbench/browser/parts/compositePart.ts
+2
-1
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+2
-1
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+2
-1
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
619ef444
...
...
@@ -12,7 +12,8 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
timer
from
'
vs/base/common/timer
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IInstantiationService
,
ServiceCollection
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IKeybindingContextKey
,
IKeybindingScopeLocation
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
CommonEditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearchWidget.ts
浏览文件 @
619ef444
...
...
@@ -25,7 +25,8 @@ import * as tree from 'vs/base/parts/tree/browser/tree';
import
{
DefaultController
,
LegacyRenderer
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
,
ServiceCollection
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
DefaultConfig
}
from
'
vs/editor/common/config/defaultConfig
'
;
...
...
src/vs/platform/instantiation/common/instantiation.ts
浏览文件 @
619ef444
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
ServiceCollection
from
'
./serviceCollection
'
;
import
*
as
descriptors
from
'
./descriptors
'
;
// ----------------------- internal util -----------------------
...
...
@@ -104,12 +104,6 @@ export interface IFunctionSignature8<A1, A2, A3, A4, A5, A6, A7, A8, R> {
(
accessor
:
ServicesAccessor
,
first
:
A1
,
second
:
A2
,
third
:
A3
,
forth
:
A4
,
fifth
:
A5
,
sixth
:
A6
,
seventh
:
A7
,
eigth
:
A8
):
R
;
}
export
interface
IServiceCollection
{
set
<
T
>
(
id
:
ServiceIdentifier
<
T
>
,
instanceOrDescriptor
:
T
|
descriptors
.
SyncDescriptor
<
T
>
):
void
;
forEach
(
callback
:
(
id
:
ServiceIdentifier
<
any
>
,
instanceOrDescriptor
:
any
)
=>
any
):
void
;
has
(
id
:
ServiceIdentifier
<
any
>
):
boolean
;
}
export
var
IInstantiationService
=
createDecorator
<
IInstantiationService
>
(
'
instantiationService
'
);
export
interface
IInstantiationService
{
...
...
@@ -181,7 +175,7 @@ export interface IInstantiationService {
* Creates a child of this service which inherts all current services
* and adds/overwrites the given services
*/
createChild
(
services
:
I
ServiceCollection
):
IInstantiationService
;
createChild
(
services
:
ServiceCollection
):
IInstantiationService
;
/**
* Adds a service or a descriptor to the collection of services and
...
...
@@ -223,55 +217,3 @@ export function createDecorator<T>(serviceId: string): { (...args: any[]): void;
// ret['type'] = undefined;
return
<
any
>
ret
;
}
type
Entry
=
[
ServiceIdentifier
<
any
>
,
any
];
export
class
ServiceCollection
implements
IServiceCollection
{
private
_entries
:
Entry
[]
=
[];
constructor
(...
entries
:[
ServiceIdentifier
<
any
>
,
any
][])
{
for
(
let
entry
of
entries
)
{
this
.
set
(
entry
[
0
],
entry
[
1
]);
}
}
set
<
T
>
(
id
:
ServiceIdentifier
<
T
>
,
instanceOrDescriptor
:
T
|
descriptors
.
SyncDescriptor
<
T
>
):
void
{
const
entry
:
Entry
=
[
id
,
instanceOrDescriptor
];
const
idx
=
~
binarySearch
(
this
.
_entries
,
entry
,
ServiceCollection
.
_entryCompare
);
if
(
idx
<
0
)
{
throw
new
Error
(
`service with that identifier already registered`
);
}
this
.
_entries
.
splice
(
idx
,
0
,
entry
);
}
forEach
(
callback
:
(
id
:
ServiceIdentifier
<
any
>
,
instanceOrDescriptor
:
any
)
=>
any
):
void
{
for
(
let
entry
of
this
.
_entries
)
{
let
[
id
,
instanceOrDescriptor
]
=
entry
;
callback
(
id
,
instanceOrDescriptor
);
}
}
has
(
id
:
ServiceIdentifier
<
any
>
):
boolean
{
return
binarySearch
(
this
.
_entries
,
<
Entry
>
[
id
,],
ServiceCollection
.
_entryCompare
)
>=
0
;
}
get
<
T
>
(
id
:
ServiceIdentifier
<
T
>
):
T
|
descriptors
.
SyncDescriptor
<
T
>
{
const
idx
=
binarySearch
(
this
.
_entries
,
<
Entry
>
[
id
,],
ServiceCollection
.
_entryCompare
);
if
(
idx
>=
0
)
{
return
this
.
_entries
[
idx
][
1
];
}
}
private
static
_entryCompare
(
a
:
Entry
,
b
:
Entry
):
number
{
const
_a
=
_util
.
getServiceId
(
a
[
0
]);
const
_b
=
_util
.
getServiceId
(
b
[
0
]);
if
(
_a
<
_b
)
{
return
-
1
;
}
else
if
(
_a
>
_b
)
{
return
1
;
}
else
{
return
0
;
}
}
}
src/vs/platform/instantiation/common/instantiationService.ts
浏览文件 @
619ef444
...
...
@@ -9,8 +9,9 @@ import {illegalArgument, illegalState, canceled} from 'vs/base/common/errors';
import
{
create
}
from
'
vs/base/common/types
'
;
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
Graph
}
from
'
vs/base/common/graph
'
;
import
*
as
descriptors
from
'
./descriptors
'
;
import
*
as
instantiation
from
'
./instantiation
'
;
import
*
as
descriptors
from
'
vs/platform/instantiation/common/descriptors
'
;
import
*
as
instantiation
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
IInstantiationService
=
instantiation
.
IInstantiationService
;
import
ServiceIdentifier
=
instantiation
.
ServiceIdentifier
;
...
...
@@ -18,13 +19,13 @@ import ServiceIdentifier = instantiation.ServiceIdentifier;
/**
* Creates a new instance of an instantiation service.
*/
export
function
createInstantiationService
(
services
?:
instantiation
.
I
ServiceCollection
|
{
[
legacyId
:
string
]:
any
}):
IInstantiationService
{
export
function
createInstantiationService
(
services
?:
ServiceCollection
|
{
[
legacyId
:
string
]:
any
}):
IInstantiationService
{
let
map
:{
[
legacyId
:
string
]:
any
};
if
(
typeof
services
===
'
undefined
'
)
{
map
=
Object
.
create
(
null
);
}
else
if
(
typeof
(
<
instantiation
.
IServiceCollection
>
services
).
forEach
===
'
function
'
)
{
}
else
if
(
services
instanceof
ServiceCollection
)
{
map
=
Object
.
create
(
null
);
(
<
instantiation
.
IServiceCollection
>
services
)
.
forEach
((
id
,
service
)
=>
{
services
.
forEach
((
id
,
service
)
=>
{
map
[
instantiation
.
_util
.
getServiceId
(
id
)]
=
service
;
});
}
else
if
(
typeof
services
===
'
object
'
)
{
...
...
@@ -239,7 +240,7 @@ class InstantiationService implements IInstantiationService {
this
.
_servicesMap
=
new
ServicesMap
(
services
,
lock
);
}
createChild
(
services
:
instantiation
.
ServiceCollection
):
IInstantiationService
{
createChild
(
services
:
ServiceCollection
):
IInstantiationService
{
const
result
=
new
InstantiationService
(
Object
.
create
(
null
),
this
.
_servicesMap
.
lock
);
...
...
src/vs/platform/instantiation/common/serviceCollection.ts
0 → 100644
浏览文件 @
619ef444
/*---------------------------------------------------------------------------------------------
* 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
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
{
ServiceIdentifier
,
_util
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
SyncDescriptor
}
from
'
./descriptors
'
;
type
Entry
=
[
ServiceIdentifier
<
any
>
,
any
];
export
default
class
ServiceCollection
{
private
_entries
:
Entry
[]
=
[];
constructor
(...
entries
:[
ServiceIdentifier
<
any
>
,
any
][])
{
for
(
let
entry
of
entries
)
{
this
.
set
(
entry
[
0
],
entry
[
1
]);
}
}
set
<
T
>
(
id
:
ServiceIdentifier
<
T
>
,
instanceOrDescriptor
:
T
|
SyncDescriptor
<
T
>
):
void
{
const
entry
:
Entry
=
[
id
,
instanceOrDescriptor
];
const
idx
=
~
binarySearch
(
this
.
_entries
,
entry
,
ServiceCollection
.
_entryCompare
);
if
(
idx
<
0
)
{
throw
new
Error
(
`service with that identifier already registered`
);
}
this
.
_entries
.
splice
(
idx
,
0
,
entry
);
}
forEach
(
callback
:
(
id
:
ServiceIdentifier
<
any
>
,
instanceOrDescriptor
:
any
)
=>
any
):
void
{
for
(
let
entry
of
this
.
_entries
)
{
let
[
id
,
instanceOrDescriptor
]
=
entry
;
callback
(
id
,
instanceOrDescriptor
);
}
}
has
(
id
:
ServiceIdentifier
<
any
>
):
boolean
{
return
binarySearch
(
this
.
_entries
,
<
Entry
>
[
id
,],
ServiceCollection
.
_entryCompare
)
>=
0
;
}
get
<
T
>
(
id
:
ServiceIdentifier
<
T
>
):
T
|
SyncDescriptor
<
T
>
{
const
idx
=
binarySearch
(
this
.
_entries
,
<
Entry
>
[
id
,],
ServiceCollection
.
_entryCompare
);
if
(
idx
>=
0
)
{
return
this
.
_entries
[
idx
][
1
];
}
}
private
static
_entryCompare
(
a
:
Entry
,
b
:
Entry
):
number
{
const
_a
=
_util
.
getServiceId
(
a
[
0
]);
const
_b
=
_util
.
getServiceId
(
b
[
0
]);
if
(
_a
<
_b
)
{
return
-
1
;
}
else
if
(
_a
>
_b
)
{
return
1
;
}
else
{
return
0
;
}
}
}
src/vs/platform/instantiation/test/common/instantiationService.test.ts
浏览文件 @
619ef444
...
...
@@ -8,7 +8,7 @@
import
assert
=
require
(
'
assert
'
);
import
instantiation
=
require
(
'
vs/platform/instantiation/common/instantiation
'
);
import
instantiationService
=
require
(
'
vs/platform/instantiation/common/instantiationService
'
);
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
let
IService1
=
instantiation
.
createDecorator
<
IService1
>
(
'
service1
'
);
...
...
@@ -125,13 +125,13 @@ class ServiceLoop2 implements IService2 {
suite
(
'
Instantiation Service
'
,
()
=>
{
test
(
'
service collection, cannot overwrite
'
,
function
()
{
let
collection
=
new
instantiation
.
ServiceCollection
();
let
collection
=
new
ServiceCollection
();
collection
.
set
(
IService1
,
null
);
assert
.
throws
(()
=>
collection
.
set
(
IService1
,
null
));
});
test
(
'
service collection, add/has
'
,
function
()
{
let
collection
=
new
instantiation
.
ServiceCollection
();
let
collection
=
new
ServiceCollection
();
collection
.
set
(
IService1
,
null
);
assert
.
ok
(
collection
.
has
(
IService1
));
...
...
src/vs/workbench/browser/parts/compositePart.ts
浏览文件 @
619ef444
...
...
@@ -30,7 +30,8 @@ import {IPartService} from 'vs/workbench/services/part/common/partService';
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
,
ServiceCollection
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
619ef444
...
...
@@ -35,7 +35,8 @@ import {IPartService} from 'vs/workbench/services/part/common/partService';
import
{
Position
,
POSITIONS
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
,
ServiceCollection
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IMessageService
,
IMessageWithAction
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
...
...
src/vs/workbench/browser/parts/editor/textDiffEditor.ts
浏览文件 @
619ef444
...
...
@@ -31,7 +31,8 @@ import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/c
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
,
ServiceCollection
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
ServiceCollection
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录