3
3
using System . Linq ;
4
4
using GitHub . Unity ;
5
5
6
- static internal class TreeBuilder
6
+ static class TreeBuilder
7
7
{
8
- internal static void BuildTree ( FileTreeNode parent , FileTreeNode node , List < string > foldedTreeEntries1 , Action < FileTreeNode > stateChangeCallback1 )
8
+ internal static void BuildChildNode ( FileTreeNode parent , FileTreeNode node , List < string > foldedTreeEntries1 , Action < FileTreeNode > stateChangeCallback1 )
9
9
{
10
10
if ( String . IsNullOrEmpty ( node . Label ) )
11
11
{
@@ -32,7 +32,7 @@ internal static void BuildTree(FileTreeNode parent, FileTreeNode node, List<stri
32
32
if ( child . Label . Equals ( root ) )
33
33
{
34
34
found = true ;
35
- BuildTree ( child , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
35
+ BuildChildNode ( child , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
36
36
break ;
37
37
}
38
38
}
@@ -41,7 +41,7 @@ internal static void BuildTree(FileTreeNode parent, FileTreeNode node, List<stri
41
41
if ( ! found )
42
42
{
43
43
var p = parent . RepositoryPath . ToNPath ( ) . Combine ( root ) ;
44
- BuildTree ( parent . Add ( new FileTreeNode ( root , stateChangeCallback1 ) { RepositoryPath = p } ) , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
44
+ BuildChildNode ( parent . Add ( new FileTreeNode ( root , stateChangeCallback1 ) { RepositoryPath = p } ) , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
45
45
}
46
46
}
47
47
else if ( nodePath . ExtensionWithDot == ".meta" )
@@ -54,7 +54,7 @@ internal static void BuildTree(FileTreeNode parent, FileTreeNode node, List<stri
54
54
if ( child . Label . Equals ( nodePath . Parent . Combine ( nodePath . FileNameWithoutExtension ) ) )
55
55
{
56
56
found = true ;
57
- BuildTree ( child , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
57
+ BuildChildNode ( child , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
58
58
break ;
59
59
}
60
60
}
@@ -70,35 +70,10 @@ internal static void BuildTree(FileTreeNode parent, FileTreeNode node, List<stri
70
70
}
71
71
}
72
72
73
- internal static FileTreeNode BuildTree3 ( List < GitStatusEntry > gitStatusEntries , Action < FileTreeNode > stateChangeCallback1 , List < GitCommitTarget > entryCommitTargets , List < string > foldedTreeEntries1 )
73
+ internal static FileTreeNode BuildTreeRoot ( IList < GitStatusEntry > newEntries , List < GitStatusEntry > gitStatusEntries , List < GitCommitTarget > gitCommitTargets , List < string > foldedTreeEntries , Action < FileTreeNode > stateChangeCallback )
74
74
{
75
- // TODO: Filter .meta files - consider adding them as children of the asset or folder they're supporting
76
- // TODO: In stead of completely rebuilding the tree structure, figure out a way to migrate open/closed states from the old tree to the new
77
- // Build tree structure
78
-
79
- var tree = new FileTreeNode ( FileSystemHelpers . FindCommonPath ( gitStatusEntries . Select ( e => e . Path ) ) , stateChangeCallback1 ) ;
80
- tree . RepositoryPath = tree . Path ;
81
-
82
- for ( var index = 0 ; index < gitStatusEntries . Count ; index ++ )
83
- {
84
- GitStatusEntry gitStatusEntry = gitStatusEntries [ index ] ;
85
- var entryPath = gitStatusEntry . Path . ToNPath ( ) ;
86
- if ( entryPath . IsChildOf ( tree . Path ) ) entryPath = entryPath . RelativeTo ( tree . Path . ToNPath ( ) ) ;
87
-
88
- var node = new FileTreeNode ( entryPath , stateChangeCallback1 ) { Target = entryCommitTargets [ index ] } ;
89
- if ( ! String . IsNullOrEmpty ( gitStatusEntry . ProjectPath ) )
90
- {
91
- //node.Icon = AssetDatabase.GetCachedIcon(gitStatusEntry.ProjectPath);
92
- }
93
-
94
- TreeBuilder . BuildTree ( tree , node , foldedTreeEntries1 , stateChangeCallback1 ) ;
95
- }
96
-
97
- return tree ;
98
- }
75
+ Guard . ArgumentNotNullOrEmpty ( newEntries , "newEntries" ) ;
99
76
100
- internal static FileTreeNode BuildTree4 ( IList < GitStatusEntry > newEntries , List < GitStatusEntry > gitStatusEntries , List < GitCommitTarget > gitCommitTargets , List < string > foldedTreeEntries1 , Action < FileTreeNode > stateChangeCallback1 )
101
- {
102
77
// Remove what got nuked
103
78
for ( var index = 0 ; index < gitStatusEntries . Count ; )
104
79
{
@@ -114,11 +89,11 @@ internal static FileTreeNode BuildTree4(IList<GitStatusEntry> newEntries, List<G
114
89
}
115
90
116
91
// Remove folding state of nuked items
117
- for ( var index = 0 ; index < foldedTreeEntries1 . Count ; )
92
+ for ( var index = 0 ; index < foldedTreeEntries . Count ; )
118
93
{
119
- if ( ! newEntries . Any ( e => e . Path . IndexOf ( foldedTreeEntries1 [ index ] ) == 0 ) )
94
+ if ( ! newEntries . Any ( e => e . Path . IndexOf ( foldedTreeEntries [ index ] ) == 0 ) )
120
95
{
121
- foldedTreeEntries1 . RemoveAt ( index ) ;
96
+ foldedTreeEntries . RemoveAt ( index ) ;
122
97
}
123
98
else
124
99
{
@@ -137,6 +112,28 @@ internal static FileTreeNode BuildTree4(IList<GitStatusEntry> newEntries, List<G
137
112
}
138
113
}
139
114
140
- return TreeBuilder . BuildTree3 ( gitStatusEntries , stateChangeCallback1 , gitCommitTargets , foldedTreeEntries1 ) ;
115
+ // TODO: Filter .meta files - consider adding them as children of the asset or folder they're supporting
116
+ // TODO: In stead of completely rebuilding the tree structure, figure out a way to migrate open/closed states from the old tree to the new
117
+ // Build tree structure
118
+
119
+ var tree = new FileTreeNode ( FileSystemHelpers . FindCommonPath ( gitStatusEntries . Select ( e => e . Path ) ) , stateChangeCallback ) ;
120
+ tree . RepositoryPath = tree . Path ;
121
+
122
+ for ( var index1 = 0 ; index1 < gitStatusEntries . Count ; index1 ++ )
123
+ {
124
+ GitStatusEntry gitStatusEntry = gitStatusEntries [ index1 ] ;
125
+ var entryPath = gitStatusEntry . Path . ToNPath ( ) ;
126
+ if ( entryPath . IsChildOf ( tree . Path ) ) entryPath = entryPath . RelativeTo ( tree . Path . ToNPath ( ) ) ;
127
+
128
+ var node = new FileTreeNode ( entryPath , stateChangeCallback ) { Target = gitCommitTargets [ index1 ] } ;
129
+ if ( ! String . IsNullOrEmpty ( gitStatusEntry . ProjectPath ) )
130
+ {
131
+ //node.Icon = AssetDatabase.GetCachedIcon(gitStatusEntry.ProjectPath);
132
+ }
133
+
134
+ TreeBuilder . BuildChildNode ( tree , node , foldedTreeEntries , stateChangeCallback ) ;
135
+ }
136
+
137
+ return tree ;
141
138
}
142
139
}
0 commit comments