@@ -19,15 +19,23 @@ export class ModuleManager {
1919 project . components . set ( file . name , file ) ;
2020 }
2121 else if ( file instanceof Pipe ) {
22- project . pipes . set ( file . name , new NamedEntity ( file . name , filename ) ) ;
22+ project . pipes . set ( file . name , file ) ;
2323 }
2424 else if ( file instanceof Directive ) {
25- project . directives . set ( file . name , new NamedEntity ( file . name , filename ) ) ;
25+ project . directives . set ( file . name , file ) ;
2626 }
2727 else if ( file instanceof Injectable ) {
28- project . directives . set ( file . name , new NamedEntity ( file . name , filename ) ) ;
28+ project . injectables . set ( file . name , file ) ;
2929 }
3030 } ) ;
31+ project . components . forEach ( component => {
32+ component . dependencyInjections . forEach ( injectable => {
33+ const filename = project . injectables . get ( injectable . name ) ?. filename ;
34+ if ( filename !== undefined ) {
35+ injectable . filename = filename ;
36+ }
37+ } ) ;
38+ } ) ;
3139 return project ;
3240 }
3341
@@ -59,39 +67,38 @@ export class ModuleManager {
5967 regex = / @ C o m p o n e n t \s * \( \s * ( \{ .+ ?\} ) \s * \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + ( .* ) / ims;
6068 match = regex . exec ( fileContents . toString ( ) ) ;
6169 if ( match !== null ) {
62- const componentBody = match [ 1 ] ;
6370 const className = match [ 2 ] ;
6471 const component = new Component ( className , filename ) ;
6572 const classBody = match [ 3 ] ;
66- this . enrichComponent ( component , classBody , componentBody ) ;
73+ this . enrichComponent ( component , classBody ) ;
6774 return component ;
6875 }
69- regex = / @ D i r e c t i v e \s * \( \s * ( \{ . + ? \} ) \s * \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
76+ regex = / @ D i r e c t i v e \s * \( . * ? \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
7077 match = regex . exec ( fileContents . toString ( ) ) ;
7178 if ( match !== null ) {
72- return new Directive ( match [ 2 ] , filename ) ;
79+ return new Directive ( match [ 1 ] , filename ) ;
7380 }
74- regex = / @ P i p e \s * \( \s * ( \{ . + ? \} ) \s * \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
81+ regex = / @ P i p e \s * \( . * ? \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
7582 match = regex . exec ( fileContents . toString ( ) ) ;
7683 if ( match !== null ) {
77- return new Pipe ( match [ 2 ] , filename ) ;
84+ return new Pipe ( match [ 1 ] , filename ) ;
7885 }
79- regex = / @ I n j e c t a b l e \s * \( \s * ( \{ . + ? \} ) \s * \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
86+ regex = / @ I n j e c t a b l e \s * \( . * ? \) \s * e x p o r t \s + c l a s s \s + ( \w + ) \s + / ims;
8087 match = regex . exec ( fileContents . toString ( ) ) ;
8188 if ( match !== null ) {
82- return new Injectable ( match [ 2 ] , filename ) ;
89+ return new Injectable ( match [ 1 ] , filename ) ;
8390 }
8491 }
8592
86- private static enrichComponent ( component : Component , classBody : string , componentBody : string ) : void {
93+ private static enrichComponent ( component : Component , classBody : string ) : void {
8794 let regex = / c o n s t r u c t o r \s * \( ( .* ?) \) / ims;
8895 let match = regex . exec ( classBody ) ;
8996 if ( match !== null ) {
9097 const constructorParameters = match [ 1 ] ;
9198 regex = / \s * \w + \s + \w + \s * : \s * ( \w + ) [ , ] * / gims;
9299 match = regex . exec ( constructorParameters ) ;
93100 while ( match ) {
94- component . dependencyInjections . push ( new NamedEntity ( match [ 1 ] , component . filename ) ) ;
101+ component . dependencyInjections . push ( new NamedEntity ( match [ 1 ] , '' ) ) ;
95102 match = regex . exec ( constructorParameters ) ;
96103 }
97104 }
0 commit comments