@@ -18,56 +18,6 @@ class IndexGenerator
1818{
1919 const BEFORE_GENERATION = 'index.before_generation ' ;
2020 const AFTER_GENERATION = 'index.after_generation ' ;
21- /**
22- * Array of plugin classes
23- * @var array
24- */
25- public $ plugins ;
26-
27- /**
28- * Verbosity
29- *
30- * @var bool
31- */
32- private $ verbose ;
33-
34- /**
35- *
36- *
37- * @var PathResolver
38- */
39- protected $ path ;
40-
41- /**
42- * Object with Composer-specific functions
43- *
44- * @var Utils\ComposerUtils
45- */
46- protected $ composer ;
47-
48- /**
49- * Object for work with class-information
50- *
51- * @var Utils\ClassUtils
52- */
53- protected $ class ;
54-
55-
56- /**
57- *
58- * @var LoggerInterface
59- */
60- protected $ logger ;
61-
62-
63- /**
64- *
65- * @var IndexProcessor
66- */
67- protected $ processor ;
68-
69- /** @var EventDispatcher */
70- protected $ dispatcher ;
7121
7222 public function __construct (
7323 PathResolver $ path ,
@@ -76,6 +26,7 @@ public function __construct(
7626 LoggerInterface $ logger ,
7727 IndexProcessor $ processor ,
7828 EventDispatcher $ dispatcher ,
29+ FilesFinder $ filesFinder ,
7930 $ verbose = false
8031 ) {
8132 $ this ->path = $ path ;
@@ -86,18 +37,7 @@ public function __construct(
8637 $ this ->verbose = $ verbose ;
8738 $ this ->processor = $ processor ;
8839 $ this ->dispatcher = $ dispatcher ;
89- }
90-
91- public function getComposerUtils (){
92- return $ this ->composer ;
93- }
94-
95- public function getClassUtils (){
96- return $ this ->classUtils ;
97- }
98-
99- public function getNamespaceUtils (){
100- return $ this ->namespaceUtils ;
40+ $ this ->filesFinder = $ filesFinder ;
10141 }
10242
10343 public function generateIndex (Project $ project )
@@ -108,22 +48,24 @@ public function generateIndex(Project $project)
10848 $ index = $ project ->getIndex ();
10949 $ this ->populateClassMapIndex ($ project );
11050
111- $ this ->generateProjectIndex ($ index );
51+ $ this ->generateProjectIndex ($ project );
11252
11353 $ this ->dispatcher ->dispatch (self ::AFTER_GENERATION , $ event );
11454
11555 return $ index ;
11656 }
11757
118- public function generateProjectIndex (Index $ index ){
58+ public function generateProjectIndex (Project $ project )
59+ {
11960 // You know what this mean
12061 gc_disable ();
121- $ classMap = $ index -> getClassMap ();
62+ $ index = $ project -> getIndex ();
12263 $ globalTime = 0 ;
12364 $ process = 0 ;
12465 $ done = 0 ;
125- $ all = count ($ classMap );
126- foreach ($ index ->getClassMap () as $ fqcn => $ file ) {
66+ $ files = $ this ->filesFinder ->getProjectFiles ($ project );
67+ $ all = count ($ files );
68+ foreach ($ files as $ file ) {
12769 $ start = microtime (1 );
12870 $ this ->processFile ($ index , $ file , false , false );
12971 $ end = microtime (1 ) - $ start ;
@@ -139,12 +81,15 @@ public function generateProjectIndex(Index $index){
13981 gc_enable ();
14082 }
14183
142- public function processFile (Index $ index , $ file ,
143- $ rewrite =false , $ createCache =true
144- ){
84+ public function processFile (
85+ Index $ index ,
86+ $ file ,
87+ $ rewrite = false ,
88+ $ createCache = true
89+ ) {
14590 $ this ->getLogger ()
14691 ->addInfo ("processing $ file " );
147- if ($ index ->isParsed ($ file ) && !$ rewrite ){
92+ if ($ index ->isParsed ($ file ) && !$ rewrite ) {
14893 return ;
14994 }
15095 $ startParser = microtime (1 );
@@ -160,30 +105,92 @@ public function processFile(Index $index, $file,
160105 $ this ->processFileNodes ($ index , $ nodes );
161106 $ index ->addParsedFile ($ file );
162107 }
163- public function processFileNodes (Index $ index , $ nodes ){
108+ public function processFileNodes (Index $ index , $ nodes )
109+ {
164110 $ this ->getLogger ()->addDebug ('Processing nodes ' . count ($ nodes ));
165- foreach ($ nodes as $ node ){
166- if ($ node instanceof ClassData){
111+ foreach ($ nodes as $ node ) {
112+ if ($ node instanceof ClassData) {
167113 $ this ->getLogger ()->addDebug ('Processing node ' . $ node ->fqcn ->toString ());
168114 $ index ->addFQCN ($ node ->fqcn );
169115 $ index ->addClass ($ node );
170- }
171- elseif ($ node instanceof InterfaceData){
116+ } elseif ($ node instanceof InterfaceData) {
172117 $ this ->getLogger ()->addDebug ('Processing node ' . $ node ->fqcn ->toString ());
173118 $ index ->addFQCN ($ node ->fqcn );
174119 $ index ->addInterface ($ node );
175120 }
176121 }
177122 }
178123
179- public function getLogger (){
124+ public function getLogger ()
125+ {
180126 return $ this ->logger ;
181127 }
182128
183- protected function populateClassMapIndex (Project $ project ){
129+ protected function populateClassMapIndex (Project $ project )
130+ {
184131 $ classMap = $ this ->getComposerUtils ()->getCanonicalClassMap ($ project ->getRootDir ());
185132 $ index = $ project ->getIndex ();
186133 $ index ->setClassMap ($ classMap );
187134 }
188- }
189135
136+ public function getComposerUtils ()
137+ {
138+ return $ this ->composer ;
139+ }
140+
141+ public function getClassUtils ()
142+ {
143+ return $ this ->classUtils ;
144+ }
145+
146+ public function getNamespaceUtils ()
147+ {
148+ return $ this ->namespaceUtils ;
149+ }
150+
151+ /**
152+ * Verbosity
153+ *
154+ * @var bool
155+ */
156+ private $ verbose ;
157+
158+ /**
159+ *
160+ *
161+ * @var PathResolver
162+ */
163+ protected $ path ;
164+
165+ /**
166+ * Object with Composer-specific functions
167+ *
168+ * @var Utils\ComposerUtils
169+ */
170+ protected $ composer ;
171+
172+ /**
173+ * Object for work with class-information
174+ *
175+ * @var Utils\ClassUtils
176+ */
177+ protected $ class ;
178+
179+ /**
180+ *
181+ * @var LoggerInterface
182+ */
183+ protected $ logger ;
184+
185+ /**
186+ *
187+ * @var IndexProcessor
188+ */
189+ protected $ processor ;
190+
191+ /** @var EventDispatcher */
192+ protected $ dispatcher ;
193+
194+ /** @var FilesFinder */
195+ protected $ filesFinder ;
196+ }
0 commit comments