Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22421911
ArcanistDiffVectorTree.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
ArcanistDiffVectorTree.php
View Options
<?php
final
class
ArcanistDiffVectorTree
extends
Phobject
{
private
$vectors
=
array
();
public
function
addVector
(
array
$vector
)
{
$this
->
vectors
[]
=
$vector
;
return
$this
;
}
public
function
newDisplayList
()
{
$root
=
new
ArcanistDiffVectorNode
();
foreach
(
$this
->
vectors
as
$vector
)
{
$root
->
addChild
(
$vector
,
count
(
$vector
),
0
);
}
foreach
(
$root
->
getChildren
()
as
$child
)
{
$this
->
compressTree
(
$child
);
}
$root
->
setDisplayDepth
(-
1
);
foreach
(
$root
->
getChildren
()
as
$child
)
{
$this
->
updateDisplayDepth
(
$child
);
}
return
$this
->
getDisplayList
(
$root
);
}
private
function
compressTree
(
ArcanistDiffVectorNode
$node
)
{
$display_node
=
$node
;
$children
=
$node
->
getChildren
();
if
(
$children
)
{
$parent
=
$node
->
getParentNode
();
if
(
$parent
)
{
$siblings
=
$parent
->
getChildren
();
if
(
count
(
$siblings
)
===
1
)
{
if
(!
$parent
->
getValueNode
())
{
$parent_display
=
$parent
->
getDisplayNode
();
if
(
$parent_display
)
{
$display_node
=
$parent_display
;
if
(
$node
->
getValueNode
())
{
$parent
->
setValueNode
(
$node
->
getValueNode
());
}
}
}
}
}
}
$node
->
setDisplayNode
(
$display_node
);
$display_element
=
last
(
$node
->
getVector
());
$display_node
->
appendDisplayElement
(
$display_element
);
foreach
(
$children
as
$child
)
{
$this
->
compressTree
(
$child
);
}
}
private
function
updateDisplayDepth
(
ArcanistDiffVectorNode
$node
)
{
$parent_depth
=
$node
->
getParentNode
()->
getDisplayDepth
();
if
(
$node
->
getDisplayVector
()
===
null
)
{
$display_depth
=
$parent_depth
;
}
else
{
$display_depth
=
$parent_depth
+
1
;
}
$node
->
setDisplayDepth
(
$display_depth
);
foreach
(
$node
->
getChildren
()
as
$child
)
{
$this
->
updateDisplayDepth
(
$child
);
}
}
private
function
getDisplayList
(
ArcanistDiffVectorNode
$node
)
{
$result
=
array
();
foreach
(
$node
->
getChildren
()
as
$child
)
{
if
(
$child
->
getDisplayVector
()
!==
null
)
{
$result
[]
=
$child
;
}
foreach
(
$this
->
getDisplayList
(
$child
)
as
$item
)
{
$result
[]
=
$item
;
}
}
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 28, 03:15 (3 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1220650
Default Alt Text
ArcanistDiffVectorTree.php (2 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline