Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
db47ba52
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,发现更多精彩内容 >>
提交
db47ba52
编写于
9月 21, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#58469 Move view descriptor collection to view service
上级
8e89438a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
23 deletion
+76
-23
src/vs/workbench/browser/parts/views/views.ts
src/vs/workbench/browser/parts/views/views.ts
+16
-7
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+7
-0
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+1
-1
src/vs/workbench/test/browser/parts/views/views.test.ts
src/vs/workbench/test/browser/parts/views/views.test.ts
+20
-15
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+32
-0
未找到文件。
src/vs/workbench/browser/parts/views/views.ts
浏览文件 @
db47ba52
...
@@ -7,7 +7,7 @@ import 'vs/css!./media/views';
...
@@ -7,7 +7,7 @@ import 'vs/css!./media/views';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IViewsService
,
ViewsRegistry
,
IViewsViewlet
,
ViewContainer
,
IViewDescriptor
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
TEST_VIEW_CONTAINER_ID
,
IView
}
from
'
vs/workbench/common/views
'
;
import
{
IViewsService
,
ViewsRegistry
,
IViewsViewlet
,
ViewContainer
,
IViewDescriptor
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
TEST_VIEW_CONTAINER_ID
,
IView
,
IViewDescriptorCollection
}
from
'
vs/workbench/common/views
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ViewletRegistry
,
Extensions
as
ViewletExtensions
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
ViewletRegistry
,
Extensions
as
ViewletExtensions
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
...
@@ -63,7 +63,7 @@ interface IViewItem {
...
@@ -63,7 +63,7 @@ interface IViewItem {
active
:
boolean
;
active
:
boolean
;
}
}
class
ViewDescriptorCollection
extends
Disposable
{
class
ViewDescriptorCollection
extends
Disposable
implements
IViewDescriptorCollection
{
private
contextKeys
=
new
CounterSet
<
string
>
();
private
contextKeys
=
new
CounterSet
<
string
>
();
private
items
:
IViewItem
[]
=
[];
private
items
:
IViewItem
[]
=
[];
...
@@ -208,11 +208,11 @@ export class ContributableViewsModel extends Disposable {
...
@@ -208,11 +208,11 @@ export class ContributableViewsModel extends Disposable {
constructor
(
constructor
(
container
:
ViewContainer
,
container
:
ViewContainer
,
contextKeyService
:
IContextKey
Service
,
viewsService
:
IViews
Service
,
protected
viewStates
=
new
Map
<
string
,
IViewState
>
(),
protected
viewStates
=
new
Map
<
string
,
IViewState
>
(),
)
{
)
{
super
();
super
();
const
viewDescriptorCollection
=
this
.
_register
(
new
ViewDescriptorCollection
(
container
,
contextKeyService
)
);
const
viewDescriptorCollection
=
viewsService
.
getViewDescriptors
(
container
);
this
.
_register
(
viewDescriptorCollection
.
onDidChange
(()
=>
this
.
onDidChangeViewDescriptors
(
viewDescriptorCollection
.
viewDescriptors
)));
this
.
_register
(
viewDescriptorCollection
.
onDidChange
(()
=>
this
.
onDidChangeViewDescriptors
(
viewDescriptorCollection
.
viewDescriptors
)));
this
.
onDidChangeViewDescriptors
(
viewDescriptorCollection
.
viewDescriptors
);
this
.
onDidChangeViewDescriptors
(
viewDescriptorCollection
.
viewDescriptors
);
...
@@ -407,14 +407,14 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
...
@@ -407,14 +407,14 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
constructor
(
constructor
(
container
:
ViewContainer
,
container
:
ViewContainer
,
viewletStateStorageId
:
string
,
viewletStateStorageId
:
string
,
@
I
ContextKeyService
contextKeyService
:
IContextKey
Service
,
@
I
ViewsService
viewsService
:
IViews
Service
,
@
IStorageService
storageService
:
IStorageService
,
@
IStorageService
storageService
:
IStorageService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
)
{
const
hiddenViewsStorageId
=
`
${
viewletStateStorageId
}
.hidden`
;
const
hiddenViewsStorageId
=
`
${
viewletStateStorageId
}
.hidden`
;
const
viewStates
=
PersistentContributableViewsModel
.
loadViewsStates
(
viewletStateStorageId
,
hiddenViewsStorageId
,
storageService
,
contextService
);
const
viewStates
=
PersistentContributableViewsModel
.
loadViewsStates
(
viewletStateStorageId
,
hiddenViewsStorageId
,
storageService
,
contextService
);
super
(
container
,
contextKey
Service
,
viewStates
);
super
(
container
,
views
Service
,
viewStates
);
this
.
viewletStateStorageId
=
viewletStateStorageId
;
this
.
viewletStateStorageId
=
viewletStateStorageId
;
this
.
hiddenViewsStorageId
=
hiddenViewsStorageId
;
this
.
hiddenViewsStorageId
=
hiddenViewsStorageId
;
...
@@ -485,21 +485,29 @@ export class ViewsService extends Disposable implements IViewsService {
...
@@ -485,21 +485,29 @@ export class ViewsService extends Disposable implements IViewsService {
_serviceBrand
:
any
;
_serviceBrand
:
any
;
private
readonly
viewDescriptorCollections
:
Map
<
ViewContainer
,
IViewDescriptorCollection
>
;
constructor
(
constructor
(
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IViewletService
private
viewletService
:
IViewletService
,
@
IViewletService
private
viewletService
:
IViewletService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
@
IWorkspaceContextService
private
workspaceContextService
:
IWorkspaceContextService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
)
{
)
{
super
();
super
();
this
.
viewDescriptorCollections
=
new
Map
<
ViewContainer
,
IViewDescriptorCollection
>
();
const
viewContainersRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
const
viewContainersRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
viewContainersRegistry
.
all
.
forEach
(
viewContainer
=>
this
.
onDidRegisterViewContainer
(
viewContainer
));
viewContainersRegistry
.
all
.
forEach
(
viewContainer
=>
this
.
onDidRegisterViewContainer
(
viewContainer
));
this
.
_register
(
viewContainersRegistry
.
onDidRegister
(
viewContainer
=>
this
.
onDidRegisterViewContainer
(
viewContainer
)));
this
.
_register
(
viewContainersRegistry
.
onDidRegister
(
viewContainer
=>
this
.
onDidRegisterViewContainer
(
viewContainer
)));
this
.
_register
(
Registry
.
as
<
ViewletRegistry
>
(
ViewletExtensions
.
Viewlets
).
onDidRegister
(
viewlet
=>
this
.
viewletService
.
setViewletEnablement
(
viewlet
.
id
,
this
.
storageService
.
getBoolean
(
`viewservice.
${
viewlet
.
id
}
.enablement`
,
this
.
getStorageScope
(),
viewlet
.
id
!==
TEST_VIEW_CONTAINER_ID
))));
this
.
_register
(
Registry
.
as
<
ViewletRegistry
>
(
ViewletExtensions
.
Viewlets
).
onDidRegister
(
viewlet
=>
this
.
viewletService
.
setViewletEnablement
(
viewlet
.
id
,
this
.
storageService
.
getBoolean
(
`viewservice.
${
viewlet
.
id
}
.enablement`
,
this
.
getStorageScope
(),
viewlet
.
id
!==
TEST_VIEW_CONTAINER_ID
))));
}
}
getViewDescriptors
(
container
:
ViewContainer
):
IViewDescriptorCollection
{
return
this
.
viewDescriptorCollections
.
get
(
container
);
}
openView
(
id
:
string
,
focus
:
boolean
):
TPromise
<
IView
>
{
openView
(
id
:
string
,
focus
:
boolean
):
TPromise
<
IView
>
{
const
viewDescriptor
=
ViewsRegistry
.
getView
(
id
);
const
viewDescriptor
=
ViewsRegistry
.
getView
(
id
);
if
(
viewDescriptor
)
{
if
(
viewDescriptor
)
{
...
@@ -518,6 +526,7 @@ export class ViewsService extends Disposable implements IViewsService {
...
@@ -518,6 +526,7 @@ export class ViewsService extends Disposable implements IViewsService {
}
}
private
onDidRegisterViewContainer
(
viewContainer
:
ViewContainer
):
void
{
private
onDidRegisterViewContainer
(
viewContainer
:
ViewContainer
):
void
{
this
.
viewDescriptorCollections
.
set
(
viewContainer
,
this
.
_register
(
new
ViewDescriptorCollection
(
viewContainer
,
this
.
contextKeyService
)));
// TODO: @Joao Remove this after moving SCM Viewlet to ViewContainerViewlet - https://github.com/Microsoft/vscode/issues/49054
// TODO: @Joao Remove this after moving SCM Viewlet to ViewContainerViewlet - https://github.com/Microsoft/vscode/issues/49054
if
(
viewContainer
.
id
!==
SCM_VIEWLET_ID
)
{
if
(
viewContainer
.
id
!==
SCM_VIEWLET_ID
)
{
const
viewDescriptorCollection
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ViewDescriptorCollection
,
viewContainer
));
const
viewDescriptorCollection
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
ViewDescriptorCollection
,
viewContainer
));
...
...
src/vs/workbench/common/views.ts
浏览文件 @
db47ba52
...
@@ -113,6 +113,11 @@ export interface IViewDescriptor {
...
@@ -113,6 +113,11 @@ export interface IViewDescriptor {
readonly
hideByDefault
?:
boolean
;
readonly
hideByDefault
?:
boolean
;
}
}
export
interface
IViewDescriptorCollection
{
readonly
onDidChange
:
Event
<
void
>
;
readonly
viewDescriptors
:
IViewDescriptor
[];
}
export
interface
IViewsRegistry
{
export
interface
IViewsRegistry
{
readonly
onViewsRegistered
:
Event
<
IViewDescriptor
[]
>
;
readonly
onViewsRegistered
:
Event
<
IViewDescriptor
[]
>
;
...
@@ -213,6 +218,8 @@ export interface IViewsService {
...
@@ -213,6 +218,8 @@ export interface IViewsService {
_serviceBrand
:
any
;
_serviceBrand
:
any
;
openView
(
id
:
string
,
focus
?:
boolean
):
TPromise
<
IView
>
;
openView
(
id
:
string
,
focus
?:
boolean
):
TPromise
<
IView
>
;
getViewDescriptors
(
container
:
ViewContainer
):
IViewDescriptorCollection
;
}
}
// Custom views
// Custom views
...
...
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
db47ba52
...
@@ -1065,7 +1065,7 @@ export class SCMViewlet extends PanelViewlet implements IViewModel, IViewsViewle
...
@@ -1065,7 +1065,7 @@ export class SCMViewlet extends PanelViewlet implements IViewModel, IViewsViewle
this
.
menus
=
instantiationService
.
createInstance
(
SCMMenus
,
undefined
);
this
.
menus
=
instantiationService
.
createInstance
(
SCMMenus
,
undefined
);
this
.
menus
.
onDidChangeTitle
(
this
.
updateTitleArea
,
this
,
this
.
disposables
);
this
.
menus
.
onDidChangeTitle
(
this
.
updateTitleArea
,
this
,
this
.
disposables
);
this
.
contributedViews
=
new
PersistentContributableViewsModel
(
VIEW_CONTAINER
,
'
scm.views
'
,
contextKeyService
,
storageService
,
contextService
);
this
.
contributedViews
=
instantiationService
.
createInstance
(
PersistentContributableViewsModel
,
VIEW_CONTAINER
,
'
scm.views
'
);
this
.
disposables
.
push
(
this
.
contributedViews
);
this
.
disposables
.
push
(
this
.
contributedViews
);
}
}
...
...
src/vs/workbench/test/browser/parts/views/views.test.ts
浏览文件 @
db47ba52
...
@@ -4,14 +4,15 @@
...
@@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
ContributableViewsModel
}
from
'
vs/workbench/browser/parts/views/views
'
;
import
{
ContributableViewsModel
,
ViewsService
}
from
'
vs/workbench/browser/parts/views/views
'
;
import
{
ViewsRegistry
,
IViewDescriptor
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
}
from
'
vs/workbench/common/views
'
;
import
{
ViewsRegistry
,
IViewDescriptor
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
move
}
from
'
vs/base/common/arrays
'
;
import
{
move
}
from
'
vs/base/common/arrays
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
TestInstantiationService
}
from
'
vs/platform/instantiation/test/common/instantiationServiceMock
'
;
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
const
container
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
).
registerViewContainer
(
'
test
'
);
const
container
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
).
registerViewContainer
(
'
test
'
);
...
@@ -33,24 +34,28 @@ class ViewDescriptorSequence {
...
@@ -33,24 +34,28 @@ class ViewDescriptorSequence {
}
}
suite
(
'
ContributableViewsModel
'
,
()
=>
{
suite
(
'
ContributableViewsModel
'
,
()
=>
{
let
viewsService
:
IViewsService
;
let
contextKeyService
:
IContextKeyService
;
let
contextKeyService
:
IContextKeyService
;
setup
(()
=>
{
setup
(()
=>
{
const
configurationService
=
new
TestConfigurationService
();
const
instantiationService
:
TestInstantiationService
=
<
TestInstantiationService
>
workbenchInstantiationService
();
contextKeyService
=
new
ContextKeyService
(
configurationService
);
contextKeyService
=
instantiationService
.
createInstance
(
ContextKeyService
);
instantiationService
.
stub
(
IContextKeyService
,
contextKeyService
);
viewsService
=
instantiationService
.
createInstance
(
ViewsService
);
});
});
teardown
(()
=>
{
teardown
(()
=>
{
contextKeyService
.
dispose
(
);
ViewsRegistry
.
deregisterViews
(
ViewsRegistry
.
getViews
(
container
).
map
(({
id
})
=>
id
),
container
);
});
});
test
(
'
empty model
'
,
function
()
{
test
(
'
empty model
'
,
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
});
});
test
(
'
register/unregister
'
,
function
()
{
test
(
'
register/unregister
'
,
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
...
@@ -77,7 +82,7 @@ suite('ContributableViewsModel', () => {
...
@@ -77,7 +82,7 @@ suite('ContributableViewsModel', () => {
});
});
test
(
'
when contexts
'
,
async
function
()
{
test
(
'
when contexts
'
,
async
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
assert
.
equal
(
model
.
visibleViewDescriptors
.
length
,
0
);
...
@@ -122,7 +127,7 @@ suite('ContributableViewsModel', () => {
...
@@ -122,7 +127,7 @@ suite('ContributableViewsModel', () => {
});
});
test
(
'
when contexts - multiple
'
,
async
function
()
{
test
(
'
when contexts - multiple
'
,
async
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
};
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
};
...
@@ -145,7 +150,7 @@ suite('ContributableViewsModel', () => {
...
@@ -145,7 +150,7 @@ suite('ContributableViewsModel', () => {
});
});
test
(
'
when contexts - multiple 2
'
,
async
function
()
{
test
(
'
when contexts - multiple 2
'
,
async
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
,
when
:
ContextKeyExpr
.
equals
(
'
showview1
'
,
true
)
};
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
,
when
:
ContextKeyExpr
.
equals
(
'
showview1
'
,
true
)
};
...
@@ -168,7 +173,7 @@ suite('ContributableViewsModel', () => {
...
@@ -168,7 +173,7 @@ suite('ContributableViewsModel', () => {
});
});
test
(
'
setVisible
'
,
function
()
{
test
(
'
setVisible
'
,
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
,
canToggleVisibility
:
true
};
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
,
canToggleVisibility
:
true
};
...
@@ -213,7 +218,7 @@ suite('ContributableViewsModel', () => {
...
@@ -213,7 +218,7 @@ suite('ContributableViewsModel', () => {
});
});
test
(
'
move
'
,
function
()
{
test
(
'
move
'
,
function
()
{
const
model
=
new
ContributableViewsModel
(
container
,
contextKey
Service
);
const
model
=
new
ContributableViewsModel
(
container
,
views
Service
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
seq
=
new
ViewDescriptorSequence
(
model
);
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
};
const
view1
:
IViewDescriptor
=
{
id
:
'
view1
'
,
ctor
:
null
,
container
,
name
:
'
Test View 1
'
};
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
db47ba52
...
@@ -77,6 +77,10 @@ import { Dimension } from 'vs/base/browser/dom';
...
@@ -77,6 +77,10 @@ import { Dimension } from 'vs/base/browser/dom';
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
,
LogLevel
}
from
'
vs/platform/log/common/log
'
;
import
{
ILabelService
,
LabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
ILabelService
,
LabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
ViewletDescriptor
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IViewlet
}
from
'
vs/workbench/common/viewlet
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
export
function
createFileInput
(
instantiationService
:
IInstantiationService
,
resource
:
URI
):
FileEditorInput
{
export
function
createFileInput
(
instantiationService
:
IInstantiationService
,
resource
:
URI
):
FileEditorInput
{
return
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
return
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
...
@@ -276,6 +280,7 @@ export function workbenchInstantiationService(): IInstantiationService {
...
@@ -276,6 +280,7 @@ export function workbenchInstantiationService(): IInstantiationService {
const
editorService
=
new
TestEditorService
();
const
editorService
=
new
TestEditorService
();
instantiationService
.
stub
(
IEditorService
,
editorService
);
instantiationService
.
stub
(
IEditorService
,
editorService
);
instantiationService
.
stub
(
ICodeEditorService
,
new
TestCodeEditorService
());
instantiationService
.
stub
(
ICodeEditorService
,
new
TestCodeEditorService
());
instantiationService
.
stub
(
IViewletService
,
new
TestViewletService
());
return
instantiationService
;
return
instantiationService
;
}
}
...
@@ -1384,6 +1389,33 @@ export class TestHashService implements IHashService {
...
@@ -1384,6 +1389,33 @@ export class TestHashService implements IHashService {
}
}
}
}
export
class
TestViewletService
implements
IViewletService
{
_serviceBrand
:
ServiceIdentifier
<
any
>
;
readonly
onDidViewletRegister
:
Event
<
ViewletDescriptor
>
=
new
Emitter
<
ViewletDescriptor
>
().
event
;
onDidViewletOpen
:
Event
<
IViewlet
>
=
new
Emitter
<
IViewlet
>
().
event
;
onDidViewletClose
:
Event
<
IViewlet
>
=
new
Emitter
<
IViewlet
>
().
event
;
onDidViewletEnablementChange
:
Event
<
{
id
:
string
,
enabled
:
boolean
}
>
=
new
Emitter
<
{
id
:
string
,
enabled
:
boolean
}
>
().
event
;
openViewlet
(
id
:
string
,
focus
?:
boolean
):
TPromise
<
IViewlet
>
{
return
null
;
}
getActiveViewlet
():
IViewlet
{
return
null
;
}
getDefaultViewletId
():
string
{
return
null
;
}
getViewlet
(
id
:
string
):
ViewletDescriptor
{
return
null
;
}
getAllViewlets
():
ViewletDescriptor
[]
{
return
null
;
}
getViewlets
():
ViewletDescriptor
[]
{
return
null
;
}
setViewletEnablement
(
id
:
string
,
enabled
:
boolean
):
void
{
}
getProgressIndicator
(
id
:
string
):
IProgressService
{
return
null
;
}
}
export
function
getRandomTestPath
(
tmpdir
:
string
,
...
segments
:
string
[]):
string
{
export
function
getRandomTestPath
(
tmpdir
:
string
,
...
segments
:
string
[]):
string
{
return
paths
.
join
(
tmpdir
,
...
segments
,
generateUuid
());
return
paths
.
join
(
tmpdir
,
...
segments
,
generateUuid
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录