Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
31b011f8
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,发现更多精彩内容 >>
提交
31b011f8
编写于
9月 10, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "async data tree: use proxies instead"
This reverts commit
492def26
.
上级
7d4a2539
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
33 deletion
+18
-33
src/vs/base/browser/ui/tree/asyncDataTree.ts
src/vs/base/browser/ui/tree/asyncDataTree.ts
+18
-33
未找到文件。
src/vs/base/browser/ui/tree/asyncDataTree.ts
浏览文件 @
31b011f8
...
...
@@ -66,32 +66,20 @@ interface IDataTreeListTemplateData<T> {
templateData
:
T
;
}
class
NodeMapper
<
TInput
,
T
,
TFilterData
>
{
private
map
=
new
WeakMap
<
ITreeNode
<
IAsyncDataTreeNode
<
TInput
,
T
>
|
null
,
TFilterData
>
,
ITreeNode
<
TInput
|
T
,
TFilterData
>>
();
mapNode
(
node
:
ITreeNode
<
IAsyncDataTreeNode
<
TInput
,
T
>
|
null
,
TFilterData
>
):
ITreeNode
<
TInput
|
T
,
TFilterData
>
{
const
that
=
this
;
let
result
=
this
.
map
.
get
(
node
);
if
(
!
result
)
{
result
=
new
Proxy
(
node
,
{
get
(
obj
,
prop
)
{
if
(
prop
===
'
element
'
)
{
return
node
.
element
!
.
element
;
}
else
if
(
prop
===
'
children
'
)
{
return
node
.
children
.
map
(
child
=>
that
.
mapNode
(
child
));
}
return
(
obj
as
any
)[
prop
];
}
})
as
unknown
as
ITreeNode
<
TInput
|
T
,
TFilterData
>
;
this
.
map
.
set
(
node
,
result
);
}
return
result
;
}
class
AsyncDataTreeNodeWrapper
<
TInput
,
T
,
TFilterData
>
implements
ITreeNode
<
TInput
|
T
,
TFilterData
>
{
get
element
():
T
{
return
this
.
node
.
element
!
.
element
as
T
;
}
get
parent
():
ITreeNode
<
T
,
TFilterData
>
|
undefined
{
return
this
.
node
.
parent
&&
new
AsyncDataTreeNodeWrapper
(
this
.
node
.
parent
);
}
get
children
():
ITreeNode
<
T
,
TFilterData
>
[]
{
return
this
.
node
.
children
.
map
(
node
=>
new
AsyncDataTreeNodeWrapper
(
node
));
}
get
depth
():
number
{
return
this
.
node
.
depth
;
}
get
visibleChildrenCount
():
number
{
return
this
.
node
.
visibleChildrenCount
;
}
get
visibleChildIndex
():
number
{
return
this
.
node
.
visibleChildIndex
;
}
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
<
IAsyncDataTreeNode
<
TInput
,
T
>
|
null
,
TFilterData
>
)
{
}
}
class
DataTreeRenderer
<
TInput
,
T
,
TFilterData
,
TTemplateData
>
implements
ITreeRenderer
<
IAsyncDataTreeNode
<
TInput
,
T
>
,
TFilterData
,
IDataTreeListTemplateData
<
TTemplateData
>>
{
...
...
@@ -102,7 +90,6 @@ class DataTreeRenderer<TInput, T, TFilterData, TTemplateData> implements ITreeRe
constructor
(
private
renderer
:
ITreeRenderer
<
T
,
TFilterData
,
TTemplateData
>
,
private
nodeMapper
:
NodeMapper
<
TInput
,
T
,
TFilterData
>
,
readonly
onDidChangeTwistieState
:
Event
<
IAsyncDataTreeNode
<
TInput
,
T
>>
)
{
this
.
templateId
=
renderer
.
templateId
;
...
...
@@ -114,7 +101,7 @@ class DataTreeRenderer<TInput, T, TFilterData, TTemplateData> implements ITreeRe
}
renderElement
(
node
:
ITreeNode
<
IAsyncDataTreeNode
<
TInput
,
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
,
height
:
number
|
undefined
):
void
{
this
.
renderer
.
renderElement
(
this
.
nodeMapper
.
mapNode
(
node
)
as
ITreeNode
<
T
,
TFilterData
>
,
index
,
templateData
.
templateData
,
height
);
this
.
renderer
.
renderElement
(
new
AsyncDataTreeNodeWrapper
(
node
)
,
index
,
templateData
.
templateData
,
height
);
}
renderTwistie
(
element
:
IAsyncDataTreeNode
<
TInput
,
T
>
,
twistieElement
:
HTMLElement
):
boolean
{
...
...
@@ -124,7 +111,7 @@ class DataTreeRenderer<TInput, T, TFilterData, TTemplateData> implements ITreeRe
disposeElement
(
node
:
ITreeNode
<
IAsyncDataTreeNode
<
TInput
,
T
>
,
TFilterData
>
,
index
:
number
,
templateData
:
IDataTreeListTemplateData
<
TTemplateData
>
,
height
:
number
|
undefined
):
void
{
if
(
this
.
renderer
.
disposeElement
)
{
this
.
renderer
.
disposeElement
(
this
.
nodeMapper
.
mapNode
(
node
)
as
ITreeNode
<
T
,
TFilterData
>
,
index
,
templateData
.
templateData
,
height
);
this
.
renderer
.
disposeElement
(
new
AsyncDataTreeNodeWrapper
(
node
)
,
index
,
templateData
.
templateData
,
height
);
}
}
...
...
@@ -319,8 +306,6 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
private
readonly
_onDidRender
=
new
Emitter
<
void
>
();
private
readonly
_onDidChangeNodeSlowState
=
new
Emitter
<
IAsyncDataTreeNode
<
TInput
,
T
>>
();
private
readonly
nodeMapper
=
new
NodeMapper
<
TInput
,
T
,
TFilterData
>
();
protected
readonly
disposables
:
IDisposable
[]
=
[];
get
onDidScroll
():
Event
<
ScrollEvent
>
{
return
this
.
tree
.
onDidScroll
;
}
...
...
@@ -367,7 +352,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this
.
collapseByDefault
=
options
.
collapseByDefault
;
const
objectTreeDelegate
=
new
ComposedTreeDelegate
<
TInput
|
T
,
IAsyncDataTreeNode
<
TInput
,
T
>>
(
delegate
);
const
objectTreeRenderers
=
renderers
.
map
(
r
=>
new
DataTreeRenderer
(
r
,
this
.
nodeMapper
,
this
.
_onDidChangeNodeSlowState
.
event
));
const
objectTreeRenderers
=
renderers
.
map
(
r
=>
new
DataTreeRenderer
(
r
,
this
.
_onDidChangeNodeSlowState
.
event
));
const
objectTreeOptions
=
asObjectTreeOptions
<
TInput
,
T
,
TFilterData
>
(
options
)
||
{};
this
.
tree
=
new
ObjectTree
(
user
,
container
,
objectTreeDelegate
,
objectTreeRenderers
,
objectTreeOptions
);
...
...
@@ -525,7 +510,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
getNode
(
element
:
TInput
|
T
=
this
.
root
.
element
):
ITreeNode
<
TInput
|
T
,
TFilterData
>
{
const
dataNode
=
this
.
getDataNode
(
element
);
const
node
=
this
.
tree
.
getNode
(
dataNode
===
this
.
root
?
null
:
dataNode
);
return
this
.
nodeMapper
.
mapNode
(
node
);
return
new
AsyncDataTreeNodeWrapper
<
TInput
,
T
,
TFilterData
>
(
node
);
}
collapse
(
element
:
T
,
recursive
:
boolean
=
false
):
boolean
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录