Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e5a93f37
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,发现更多精彩内容 >>
提交
e5a93f37
编写于
11月 28, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AsyncDataTree
上级
9b6928ca
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
77 addition
and
77 deletion
+77
-77
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+2
-2
src/vs/base/browser/ui/tree/asyncDataTree.ts
src/vs/base/browser/ui/tree/asyncDataTree.ts
+47
-47
src/vs/editor/contrib/referenceSearch/referencesTree.ts
src/vs/editor/contrib/referenceSearch/referencesTree.ts
+1
-1
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
+4
-4
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+4
-4
src/vs/workbench/electron-browser/commands.ts
src/vs/workbench/electron-browser/commands.ts
+15
-15
test/tree/public/index.html
test/tree/public/index.html
+4
-4
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
e5a93f37
...
...
@@ -58,7 +58,7 @@
"./vs/base/browser/ui/splitview/panelview.ts"
,
"./vs/base/browser/ui/splitview/splitview.ts"
,
"./vs/base/browser/ui/tree/abstractTree.ts"
,
"./vs/base/browser/ui/tree/
d
ataTree.ts"
,
"./vs/base/browser/ui/tree/
asyncD
ataTree.ts"
,
"./vs/base/browser/ui/tree/indexTree.ts"
,
"./vs/base/browser/ui/tree/indexTreeModel.ts"
,
"./vs/base/browser/ui/tree/objectTree.ts"
,
...
...
@@ -725,4 +725,4 @@
"exclude"
:
[
"./typings/require-monaco.d.ts"
]
}
}
\ No newline at end of file
src/vs/base/browser/ui/tree/
d
ataTree.ts
→
src/vs/base/browser/ui/tree/
asyncD
ataTree.ts
浏览文件 @
e5a93f37
...
...
@@ -19,46 +19,46 @@ export interface IDataSource<T extends NonNullable<any>> {
getChildren
(
element
:
T
|
null
):
Thenable
<
T
[]
>
;
}
enum
DataTreeNodeState
{
enum
Async
DataTreeNodeState
{
Uninitialized
,
Loaded
,
Loading
,
Slow
}
interface
IDataTreeNode
<
T
extends
NonNullable
<
any
>>
{
interface
I
Async
DataTreeNode
<
T
extends
NonNullable
<
any
>>
{
readonly
element
:
T
|
null
;
readonly
parent
:
IDataTreeNode
<
T
>
|
null
;
state
:
DataTreeNodeState
;
readonly
parent
:
I
Async
DataTreeNode
<
T
>
|
null
;
state
:
Async
DataTreeNodeState
;
}
interface
IDataTreeListTemplateData
<
T
>
{
templateData
:
T
;
}
class
DataTreeNodeWrapper
<
T
,
TFilterData
>
implements
ITreeNode
<
T
,
TFilterData
>
{
class
Async
DataTreeNodeWrapper
<
T
,
TFilterData
>
implements
ITreeNode
<
T
,
TFilterData
>
{
get
element
():
T
{
return
this
.
node
.
element
!
.
element
!
;
}
get
parent
():
ITreeNode
<
T
,
TFilterData
>
|
undefined
{
return
this
.
node
.
parent
&&
new
DataTreeNodeWrapper
(
this
.
node
.
parent
);
}
get
children
():
ITreeNode
<
T
,
TFilterData
>
[]
{
return
this
.
node
.
children
.
map
(
node
=>
new
DataTreeNodeWrapper
(
node
));
}
get
parent
():
ITreeNode
<
T
,
TFilterData
>
|
undefined
{
return
this
.
node
.
parent
&&
new
Async
DataTreeNodeWrapper
(
this
.
node
.
parent
);
}
get
children
():
ITreeNode
<
T
,
TFilterData
>
[]
{
return
this
.
node
.
children
.
map
(
node
=>
new
Async
DataTreeNodeWrapper
(
node
));
}
get
depth
():
number
{
return
this
.
node
.
depth
;
}
get
collapsible
():
boolean
{
return
this
.
node
.
collapsible
;
}
get
collapsed
():
boolean
{
return
this
.
node
.
collapsed
;
}
get
visible
():
boolean
{
return
this
.
node
.
visible
;
}
get
filterData
():
TFilterData
|
undefined
{
return
this
.
node
.
filterData
;
}
constructor
(
private
node
:
ITreeNode
<
IDataTreeNode
<
T
>
|
null
,
TFilterData
>
)
{
}
constructor
(
private
node
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
|
null
,
TFilterData
>
)
{
}
}
class
DataTreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
implements
ITreeRenderer
<
IDataTreeNode
<
T
>
,
TFilterData
,
IDataTreeListTemplateData
<
TTemplateData
>>
{
class
DataTreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
implements
ITreeRenderer
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
,
IDataTreeListTemplateData
<
TTemplateData
>>
{
readonly
templateId
:
string
;
private
renderedNodes
=
new
Map
<
IDataTreeNode
<
T
>
,
IDataTreeListTemplateData
<
TTemplateData
>>
();
private
renderedNodes
=
new
Map
<
I
Async
DataTreeNode
<
T
>
,
IDataTreeListTemplateData
<
TTemplateData
>>
();
private
disposables
:
IDisposable
[]
=
[];
constructor
(
private
renderer
:
ITreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
,
readonly
onDidChangeTwistieState
:
Event
<
IDataTreeNode
<
T
>>
readonly
onDidChangeTwistieState
:
Event
<
I
Async
DataTreeNode
<
T
>>
)
{
this
.
templateId
=
renderer
.
templateId
;
}
...
...
@@ -68,17 +68,17 @@ class DataTreeRenderer<T, TFilterData, TTemplateData> implements ITreeRenderer<I
return
{
templateData
};
}
renderElement
(
node
:
ITreeNode
<
IDataTreeNode
<
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
):
void
{
this
.
renderer
.
renderElement
(
new
DataTreeNodeWrapper
(
node
),
index
,
templateData
.
templateData
);
renderElement
(
node
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
):
void
{
this
.
renderer
.
renderElement
(
new
Async
DataTreeNodeWrapper
(
node
),
index
,
templateData
.
templateData
);
}
renderTwistie
(
element
:
IDataTreeNode
<
T
>
,
twistieElement
:
HTMLElement
):
boolean
{
toggleClass
(
twistieElement
,
'
loading
'
,
element
.
state
===
DataTreeNodeState
.
Slow
);
renderTwistie
(
element
:
I
Async
DataTreeNode
<
T
>
,
twistieElement
:
HTMLElement
):
boolean
{
toggleClass
(
twistieElement
,
'
loading
'
,
element
.
state
===
Async
DataTreeNodeState
.
Slow
);
return
false
;
}
disposeElement
(
node
:
ITreeNode
<
IDataTreeNode
<
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
):
void
{
this
.
renderer
.
disposeElement
(
new
DataTreeNodeWrapper
(
node
),
index
,
templateData
.
templateData
);
disposeElement
(
node
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
):
void
{
this
.
renderer
.
disposeElement
(
new
Async
DataTreeNodeWrapper
(
node
),
index
,
templateData
.
templateData
);
}
disposeTemplate
(
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
):
void
{
...
...
@@ -91,21 +91,21 @@ class DataTreeRenderer<T, TFilterData, TTemplateData> implements ITreeRenderer<I
}
}
function
asTreeEvent
<
T
>
(
e
:
ITreeEvent
<
IDataTreeNode
<
T
>>
):
ITreeEvent
<
T
>
{
function
asTreeEvent
<
T
>
(
e
:
ITreeEvent
<
I
Async
DataTreeNode
<
T
>>
):
ITreeEvent
<
T
>
{
return
{
browserEvent
:
e
.
browserEvent
,
elements
:
e
.
elements
.
map
(
e
=>
e
.
element
!
)
};
}
function
asTreeMouseEvent
<
T
>
(
e
:
ITreeMouseEvent
<
IDataTreeNode
<
T
>>
):
ITreeMouseEvent
<
T
>
{
function
asTreeMouseEvent
<
T
>
(
e
:
ITreeMouseEvent
<
I
Async
DataTreeNode
<
T
>>
):
ITreeMouseEvent
<
T
>
{
return
{
browserEvent
:
e
.
browserEvent
,
element
:
e
.
element
&&
e
.
element
.
element
!
};
}
function
asTreeContextMenuEvent
<
T
>
(
e
:
ITreeContextMenuEvent
<
IDataTreeNode
<
T
>>
):
ITreeContextMenuEvent
<
T
>
{
function
asTreeContextMenuEvent
<
T
>
(
e
:
ITreeContextMenuEvent
<
I
Async
DataTreeNode
<
T
>>
):
ITreeContextMenuEvent
<
T
>
{
return
{
browserEvent
:
e
.
browserEvent
,
element
:
e
.
element
&&
e
.
element
.
element
!
,
...
...
@@ -123,14 +123,14 @@ export interface IChildrenResolutionEvent<T> {
readonly
reason
:
ChildrenResolutionReason
;
}
export
class
DataTree
<
T
extends
NonNullable
<
any
>
,
TFilterData
=
void
>
implements
IDisposable
{
export
class
Async
DataTree
<
T
extends
NonNullable
<
any
>
,
TFilterData
=
void
>
implements
IDisposable
{
private
tree
:
ObjectTree
<
IDataTreeNode
<
T
>
,
TFilterData
>
;
private
root
:
IDataTreeNode
<
T
>
;
private
nodes
=
new
Map
<
T
|
null
,
IDataTreeNode
<
T
>>
();
private
refreshPromises
=
new
Map
<
IDataTreeNode
<
T
>
,
Thenable
<
void
>>
();
private
tree
:
ObjectTree
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
>
;
private
root
:
I
Async
DataTreeNode
<
T
>
;
private
nodes
=
new
Map
<
T
|
null
,
I
Async
DataTreeNode
<
T
>>
();
private
refreshPromises
=
new
Map
<
I
Async
DataTreeNode
<
T
>
,
Thenable
<
void
>>
();
private
_onDidChangeNodeState
=
new
Emitter
<
IDataTreeNode
<
T
>>
();
private
_onDidChangeNodeState
=
new
Emitter
<
I
Async
DataTreeNode
<
T
>>
();
protected
disposables
:
IDisposable
[]
=
[];
...
...
@@ -156,15 +156,15 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
private
dataSource
:
IDataSource
<
T
>
,
options
?:
ITreeOptions
<
T
,
TFilterData
>
)
{
const
objectTreeDelegate
=
new
ComposedTreeDelegate
<
T
|
null
,
IDataTreeNode
<
T
>>
(
delegate
);
const
objectTreeDelegate
=
new
ComposedTreeDelegate
<
T
|
null
,
I
Async
DataTreeNode
<
T
>>
(
delegate
);
const
objectTreeRenderers
=
renderers
.
map
(
r
=>
new
DataTreeRenderer
(
r
,
this
.
_onDidChangeNodeState
.
event
));
const
objectTreeOptions
=
createComposedTreeListOptions
<
T
|
null
,
IDataTreeNode
<
T
>>
(
options
);
const
objectTreeOptions
=
createComposedTreeListOptions
<
T
|
null
,
I
Async
DataTreeNode
<
T
>>
(
options
);
this
.
tree
=
new
ObjectTree
(
container
,
objectTreeDelegate
,
objectTreeRenderers
,
objectTreeOptions
);
this
.
root
=
{
element
:
null
,
parent
:
null
,
state
:
DataTreeNodeState
.
Uninitialized
,
state
:
Async
DataTreeNodeState
.
Uninitialized
,
};
this
.
nodes
.
set
(
null
,
this
.
root
);
...
...
@@ -213,7 +213,7 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
getNode
(
element
:
T
|
null
):
ITreeNode
<
T
|
null
,
TFilterData
>
{
const
dataNode
=
this
.
getDataNode
(
element
);
const
node
=
this
.
tree
.
getNode
(
dataNode
===
this
.
root
?
null
:
dataNode
);
return
new
DataTreeNodeWrapper
<
T
|
null
,
TFilterData
>
(
node
);
return
new
Async
DataTreeNodeWrapper
<
T
|
null
,
TFilterData
>
(
node
);
}
collapse
(
element
:
T
):
boolean
{
...
...
@@ -227,7 +227,7 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
return
Promise
.
resolve
(
false
);
}
if
(
node
.
element
!
.
state
===
DataTreeNodeState
.
Uninitialized
)
{
if
(
node
.
element
!
.
state
===
Async
DataTreeNodeState
.
Uninitialized
)
{
const
result
=
this
.
refreshNode
(
node
,
ChildrenResolutionReason
.
Expand
);
this
.
tree
.
expand
(
node
);
return
result
.
then
(()
=>
true
);
...
...
@@ -341,8 +341,8 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
// Implementation
private
getDataNode
(
element
:
T
|
null
):
IDataTreeNode
<
T
>
{
const
node
:
IDataTreeNode
<
T
>
=
this
.
nodes
.
get
(
element
);
private
getDataNode
(
element
:
T
|
null
):
I
Async
DataTreeNode
<
T
>
{
const
node
:
I
Async
DataTreeNode
<
T
>
=
this
.
nodes
.
get
(
element
);
if
(
typeof
node
===
'
undefined
'
)
{
throw
new
Error
(
`Data tree node not found:
${
element
}
`
);
...
...
@@ -351,7 +351,7 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
return
node
;
}
private
refreshNode
(
node
:
IDataTreeNode
<
T
>
,
reason
:
ChildrenResolutionReason
):
Thenable
<
void
>
{
private
refreshNode
(
node
:
I
Async
DataTreeNode
<
T
>
,
reason
:
ChildrenResolutionReason
):
Thenable
<
void
>
{
let
result
=
this
.
refreshPromises
.
get
(
node
);
if
(
result
)
{
...
...
@@ -363,36 +363,36 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
return
always
(
result
,
()
=>
this
.
refreshPromises
.
delete
(
node
));
}
private
doRefresh
(
node
:
IDataTreeNode
<
T
>
,
reason
:
ChildrenResolutionReason
):
Thenable
<
void
>
{
private
doRefresh
(
node
:
I
Async
DataTreeNode
<
T
>
,
reason
:
ChildrenResolutionReason
):
Thenable
<
void
>
{
const
hasChildren
=
this
.
dataSource
.
hasChildren
(
node
.
element
);
if
(
!
hasChildren
)
{
this
.
setChildren
(
node
===
this
.
root
?
null
:
node
);
return
Promise
.
resolve
();
}
else
{
node
.
state
=
DataTreeNodeState
.
Loading
;
node
.
state
=
Async
DataTreeNodeState
.
Loading
;
this
.
_onDidChangeNodeState
.
fire
(
node
);
const
slowTimeout
=
timeout
(
800
);
slowTimeout
.
then
(()
=>
{
node
.
state
=
DataTreeNodeState
.
Slow
;
node
.
state
=
Async
DataTreeNodeState
.
Slow
;
this
.
_onDidChangeNodeState
.
fire
(
node
);
},
_
=>
null
);
return
this
.
dataSource
.
getChildren
(
node
.
element
)
.
then
(
children
=>
{
slowTimeout
.
cancel
();
node
.
state
=
DataTreeNodeState
.
Loaded
;
node
.
state
=
Async
DataTreeNodeState
.
Loaded
;
this
.
_onDidChangeNodeState
.
fire
(
node
);
const
createTreeElement
=
(
element
:
T
):
ITreeElement
<
IDataTreeNode
<
T
>>
=>
{
const
createTreeElement
=
(
element
:
T
):
ITreeElement
<
I
Async
DataTreeNode
<
T
>>
=>
{
const
collapsible
=
this
.
dataSource
.
hasChildren
(
element
);
return
{
element
:
{
element
:
element
,
state
:
DataTreeNodeState
.
Uninitialized
,
state
:
Async
DataTreeNodeState
.
Uninitialized
,
parent
:
node
},
collapsible
,
...
...
@@ -400,12 +400,12 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
};
};
const
nodeChildren
=
children
.
map
<
ITreeElement
<
IDataTreeNode
<
T
>>>
(
createTreeElement
);
const
nodeChildren
=
children
.
map
<
ITreeElement
<
I
Async
DataTreeNode
<
T
>>>
(
createTreeElement
);
this
.
setChildren
(
node
===
this
.
root
?
null
:
node
,
nodeChildren
);
this
.
_onDidResolveChildren
.
fire
({
element
:
node
.
element
,
reason
});
},
err
=>
{
slowTimeout
.
cancel
();
node
.
state
=
DataTreeNodeState
.
Uninitialized
;
node
.
state
=
Async
DataTreeNodeState
.
Uninitialized
;
this
.
_onDidChangeNodeState
.
fire
(
node
);
if
(
node
!==
this
.
root
)
{
...
...
@@ -417,23 +417,23 @@ export class DataTree<T extends NonNullable<any>, TFilterData = void> implements
}
}
private
_onDidChangeCollapseState
(
treeNode
:
ITreeNode
<
IDataTreeNode
<
T
>
,
any
>
):
void
{
if
(
!
treeNode
.
collapsed
&&
treeNode
.
element
.
state
===
DataTreeNodeState
.
Uninitialized
)
{
private
_onDidChangeCollapseState
(
treeNode
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
,
any
>
):
void
{
if
(
!
treeNode
.
collapsed
&&
treeNode
.
element
.
state
===
Async
DataTreeNodeState
.
Uninitialized
)
{
this
.
refreshNode
(
treeNode
.
element
,
ChildrenResolutionReason
.
Expand
);
}
}
private
setChildren
(
element
:
I
DataTreeNode
<
T
>
|
null
,
children
?:
ISequence
<
ITreeElement
<
I
DataTreeNode
<
T
>>>
):
void
{
private
setChildren
(
element
:
I
AsyncDataTreeNode
<
T
>
|
null
,
children
?:
ISequence
<
ITreeElement
<
IAsync
DataTreeNode
<
T
>>>
):
void
{
const
insertedElements
=
new
Set
<
T
>
();
const
onDidCreateNode
=
(
node
:
ITreeNode
<
IDataTreeNode
<
T
>
,
TFilterData
>
)
=>
{
const
onDidCreateNode
=
(
node
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
>
)
=>
{
if
(
node
.
element
.
element
)
{
insertedElements
.
add
(
node
.
element
.
element
);
this
.
nodes
.
set
(
node
.
element
.
element
,
node
.
element
);
}
};
const
onDidDeleteNode
=
(
node
:
ITreeNode
<
IDataTreeNode
<
T
>
,
TFilterData
>
)
=>
{
const
onDidDeleteNode
=
(
node
:
ITreeNode
<
I
Async
DataTreeNode
<
T
>
,
TFilterData
>
)
=>
{
if
(
node
.
element
.
element
)
{
if
(
!
insertedElements
.
has
(
node
.
element
.
element
))
{
this
.
nodes
.
delete
(
node
.
element
.
element
);
...
...
src/vs/editor/contrib/referenceSearch/referencesTree.ts
浏览文件 @
e5a93f37
...
...
@@ -5,7 +5,7 @@
import
{
ReferencesModel
,
FileReferences
,
OneReference
}
from
'
./referencesModel
'
;
import
{
IDataSource
}
from
'
vs/base/browser/ui/tree/
d
ataTree
'
;
import
{
IDataSource
}
from
'
vs/base/browser/ui/tree/
asyncD
ataTree
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ITreeRenderer
,
ITreeNode
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
IconLabel
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
...
...
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
浏览文件 @
e5a93f37
...
...
@@ -26,7 +26,7 @@ import * as nls from 'vs/nls';
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
WorkbenchDataTree
}
from
'
vs/platform/list/browser/listService
'
;
import
{
Workbench
Async
DataTree
}
from
'
vs/platform/list/browser/listService
'
;
import
{
activeContrastBorder
,
contrastBorder
,
registerColor
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
ITheme
,
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
PeekViewWidget
}
from
'
./peekViewWidget
'
;
...
...
@@ -236,7 +236,7 @@ export class ReferenceWidget extends PeekViewWidget {
private
_onDidSelectReference
=
new
Emitter
<
SelectionEvent
>
();
private
_treeDataSource
:
DataSource
;
private
_tree
:
WorkbenchDataTree
<
TreeElement
>
;
private
_tree
:
Workbench
Async
DataTree
<
TreeElement
>
;
private
_treeContainer
:
HTMLElement
;
private
_sash
:
VSash
;
private
_preview
:
ICodeEditor
;
...
...
@@ -358,11 +358,11 @@ export class ReferenceWidget extends PeekViewWidget {
this
.
_treeDataSource
=
this
.
_instantiationService
.
createInstance
(
DataSource
);
this
.
_tree
=
this
.
_instantiationService
.
createInstance
(
WorkbenchDataTree
,
this
.
_treeContainer
,
new
Delegate
(),
Workbench
Async
DataTree
,
this
.
_treeContainer
,
new
Delegate
(),
renderer
as
any
,
this
.
_treeDataSource
,
treeOptions
)
as
any
as
WorkbenchDataTree
<
TreeElement
>
;
)
as
any
as
Workbench
Async
DataTree
<
TreeElement
>
;
ctxReferenceWidgetSearchTreeFocused
.
bindTo
(
this
.
_tree
.
contextKeyService
);
...
...
src/vs/platform/list/browser/listService.ts
浏览文件 @
e5a93f37
...
...
@@ -35,9 +35,9 @@ import { InputFocusedContextKey } from 'vs/platform/workbench/common/contextkeys
import
{
ObjectTree
}
from
'
vs/base/browser/ui/tree/objectTree
'
;
import
{
ITreeOptions
as
ITreeOptions2
,
ITreeEvent
}
from
'
vs/base/browser/ui/tree/abstractTree
'
;
import
{
ITreeRenderer
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
DataTree
,
IDataSource
}
from
'
vs/base/browser/ui/tree/d
ataTree
'
;
import
{
AsyncDataTree
,
IDataSource
}
from
'
vs/base/browser/ui/tree/asyncD
ataTree
'
;
export
type
ListWidget
=
List
<
any
>
|
PagedList
<
any
>
|
ITree
|
ObjectTree
<
any
,
any
>
|
DataTree
<
any
,
any
>
;
export
type
ListWidget
=
List
<
any
>
|
PagedList
<
any
>
|
ITree
|
ObjectTree
<
any
,
any
>
|
Async
DataTree
<
any
,
any
>
;
export
const
IListService
=
createDecorator
<
IListService
>
(
'
listService
'
);
...
...
@@ -581,7 +581,7 @@ export class TreeResourceNavigator2<T, TFilterData> extends Disposable {
private
readonly
_openResource
:
Emitter
<
IOpenEvent
<
T
>>
=
new
Emitter
<
IOpenEvent
<
T
>>
();
readonly
openResource
:
Event
<
IOpenEvent
<
T
>>
=
this
.
_openResource
.
event
;
constructor
(
private
tree
:
WorkbenchObjectTree
<
T
,
TFilterData
>
|
WorkbenchDataTree
<
T
,
TFilterData
>
,
private
options
?:
IResourceResultsNavigationOptions
)
{
constructor
(
private
tree
:
WorkbenchObjectTree
<
T
,
TFilterData
>
|
Workbench
Async
DataTree
<
T
,
TFilterData
>
,
private
options
?:
IResourceResultsNavigationOptions
)
{
super
();
this
.
registerListeners
();
...
...
@@ -932,7 +932,7 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, TFilterData = void>
}
}
export
class
Workbench
DataTree
<
T
extends
NonNullable
<
any
>
,
TFilterData
=
void
>
extends
DataTree
<
T
,
TFilterData
>
{
export
class
Workbench
AsyncDataTree
<
T
extends
NonNullable
<
any
>
,
TFilterData
=
void
>
extends
Async
DataTree
<
T
,
TFilterData
>
{
readonly
contextKeyService
:
IContextKeyService
;
...
...
src/vs/workbench/electron-browser/commands.ts
浏览文件 @
e5a93f37
...
...
@@ -23,7 +23,7 @@ import { URI } from 'vs/base/common/uri';
import
{
IDownloadService
}
from
'
vs/platform/download/common/download
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
ObjectTree
}
from
'
vs/base/browser/ui/tree/objectTree
'
;
import
{
DataTree
}
from
'
vs/base/browser/ui/tree/d
ataTree
'
;
import
{
AsyncDataTree
}
from
'
vs/base/browser/ui/tree/asyncD
ataTree
'
;
// --- List Commands
...
...
@@ -59,7 +59,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
...
...
@@ -92,7 +92,7 @@ export function registerCommands(): void {
handler
:
(
accessor
,
arg2
)
=>
focusDown
(
accessor
,
arg2
)
});
function
expandMultiSelection
(
focused
:
List
<
any
>
|
PagedList
<
any
>
|
ITree
|
ObjectTree
<
any
,
any
>
|
DataTree
<
any
,
any
>
,
previousFocus
:
any
):
void
{
function
expandMultiSelection
(
focused
:
List
<
any
>
|
PagedList
<
any
>
|
ITree
|
ObjectTree
<
any
,
any
>
|
Async
DataTree
<
any
,
any
>
,
previousFocus
:
any
):
void
{
// List
if
(
focused
instanceof
List
||
focused
instanceof
PagedList
)
{
...
...
@@ -108,7 +108,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
focus
=
list
.
getFocus
()
?
list
.
getFocus
()[
0
]
:
void
0
;
...
...
@@ -145,7 +145,7 @@ export function registerCommands(): void {
const
focused
=
accessor
.
get
(
IListService
).
lastFocusedList
;
// List
if
(
focused
instanceof
List
||
focused
instanceof
PagedList
||
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
if
(
focused
instanceof
List
||
focused
instanceof
PagedList
||
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
// Focus down first
...
...
@@ -189,7 +189,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
...
...
@@ -270,7 +270,7 @@ export function registerCommands(): void {
// Tree only
if
(
focused
&&
!
(
focused
instanceof
List
||
focused
instanceof
PagedList
))
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
tree
=
focused
;
const
focusedElements
=
tree
.
getFocus
();
...
...
@@ -317,7 +317,7 @@ export function registerCommands(): void {
// Tree only
if
(
focused
&&
!
(
focused
instanceof
List
||
focused
instanceof
PagedList
))
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
tree
=
focused
;
const
focusedElements
=
tree
.
getFocus
();
...
...
@@ -374,7 +374,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
...
...
@@ -412,7 +412,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
...
...
@@ -461,7 +461,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
first
=
list
.
getFirstElementChild
(
null
);
...
...
@@ -514,7 +514,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
last
=
list
.
getLastElementAncestor
();
...
...
@@ -556,7 +556,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
setSelection
(
list
.
getFocus
(),
fakeKeyboardEvent
);
...
...
@@ -601,7 +601,7 @@ export function registerCommands(): void {
// Tree only
if
(
focused
&&
!
(
focused
instanceof
List
||
focused
instanceof
PagedList
))
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
tree
=
focused
;
const
focus
=
tree
.
getFocus
();
...
...
@@ -642,7 +642,7 @@ export function registerCommands(): void {
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
DataTree
)
{
else
if
(
focused
instanceof
ObjectTree
||
focused
instanceof
Async
DataTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
...
...
test/tree/public/index.html
浏览文件 @
e5a93f37
...
...
@@ -42,7 +42,7 @@
require
.
config
({
baseUrl
:
'
/static
'
});
require
([
'
vs/base/browser/ui/tree/indexTree
'
,
'
vs/base/browser/ui/tree/
dataTree
'
,
'
vs/base/browser/ui/tree/tree
'
,
'
vs/base/common/iterator
'
],
({
IndexTree
},
{
DataTree
},
{
TreeVisibility
},
{
iter
})
=>
{
require
([
'
vs/base/browser/ui/tree/indexTree
'
,
'
vs/base/browser/ui/tree/
asyncDataTree
'
,
'
vs/base/browser/ui/tree/tree
'
,
'
vs/base/common/iterator
'
],
({
IndexTree
},
{
Async
DataTree
},
{
TreeVisibility
},
{
iter
})
=>
{
function
createIndexTree
(
opts
)
{
opts
=
opts
||
{};
...
...
@@ -98,7 +98,7 @@
return
{
tree
,
treeFilter
};
}
function
createDataTree
()
{
function
create
Async
DataTree
()
{
const
delegate
=
{
getHeight
()
{
return
22
;
},
getTemplateId
()
{
return
'
template
'
;
}
...
...
@@ -163,7 +163,7 @@
}
}
const
tree
=
new
DataTree
(
container
,
delegate
,
[
renderer
],
dataSource
,
{
filter
:
treeFilter
});
const
tree
=
new
Async
DataTree
(
container
,
delegate
,
[
renderer
],
dataSource
,
{
filter
:
treeFilter
});
return
{
tree
,
treeFilter
};
}
...
...
@@ -190,7 +190,7 @@
break
;
}
case
'
?data
'
:
{
const
{
tree
,
treeFilter
}
=
createDataTree
();
const
{
tree
,
treeFilter
}
=
create
Async
DataTree
();
collapseall
.
onclick
=
()
=>
perf
(
'
collapse all
'
,
()
=>
tree
.
collapseAll
());
renderwidth
.
onclick
=
()
=>
perf
(
'
renderwidth
'
,
()
=>
tree
.
layoutWidth
(
Math
.
random
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录