2727import org .jqassistant .contrib .plugin .javascript .api .model .ObjectDescriptor ;
2828import org .jqassistant .contrib .plugin .javascript .api .model .UndefinedDescriptor ;
2929import org .jqassistant .contrib .plugin .javascript .api .model .VariableDescriptor ;
30- import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ArrayDeclaresManipulator ;
3130import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ArrayStoreManipulator ;
3231import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ClassStoreManipulator ;
3332import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .FunctionStoreManipulator ;
33+ import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .InvokesManipulator ;
3434import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .LiteralStoreManipulator ;
35- import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ObjectDeclaresManipulator ;
3635import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ObjectStoreManipulator ;
3736import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .ParameterStoreManipulator ;
38- import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .StoreRelationManipulator ;
3937import org .jqassistant .contrib .plugin .javascript .scanner .visitor .manipulators .VariableStoreManipulator ;
40- import org .jruby .ext .ffi .FFIService ;
4138
4239import com .buschmais .jqassistant .core .store .api .Store ;
4340
@@ -52,19 +49,13 @@ public class JavascriptVisitor extends JavaScriptParserBaseVisitor<Void> {
5249 private String fqnBase ;
5350 private FqnCreator fqnCreator ;
5451 private CodeArtifact rootComp ;
55- private Optional <StoreRelationManipulator <?>> relationCreator ;
5652
5753 public JavascriptVisitor (Store store , String fqnBase , CodeArtifact basicComp ) {
58- this (store , fqnBase , basicComp , null );
59- }
60-
61- public JavascriptVisitor (Store store , String fqnBase , CodeArtifact basicComp , StoreRelationManipulator <?> relationCreator ) {
6254 super ();
6355 System .out .println ("FQN: " + fqnBase );
6456 this .store = store ;
6557 this .fqnBase = fqnBase ;
6658 this .rootComp = basicComp ;
67- this .relationCreator = Optional .ofNullable (relationCreator );
6859 this .fqnCreator = new FqnCreator (fqnBase );
6960 }
7061
@@ -93,7 +84,6 @@ String createFqn(String varName) {
9384 public Void visitFunctionExpression (FunctionExpressionContext ctx ) {
9485 FunctionDescriptor ecmaFunc = new FunctionStoreManipulator ().createNodeIn (store , ctx , fqnCreator );
9586 rootComp .getFunctions ().add (ecmaFunc );
96- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaFunc ));
9787 JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , createFqn (ecmaFunc .getName ()), ecmaFunc );
9888 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
9989 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
@@ -103,7 +93,6 @@ public Void visitFunctionExpression(FunctionExpressionContext ctx) {
10393 public Void visitArrowFunctionExpression (ArrowFunctionExpressionContext ctx ) {
10494 FunctionDescriptor ecmaFunc = new FunctionStoreManipulator ().createNodeIn (store , ctx , fqnCreator );
10595 rootComp .getFunctions ().add (ecmaFunc );
106- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaFunc ));
10796 JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , createFqn (ecmaFunc .getName ()), ecmaFunc );
10897 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
10998 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
@@ -115,7 +104,6 @@ public Void visitFunctionDeclaration(FunctionDeclarationContext ctx) {
115104 FunctionDescriptor ecmaFunc = new FunctionStoreManipulator (funcName ).createNodeIn (store , ctx , fqnCreator );
116105 rootComp .getFunctions ().add (ecmaFunc );
117106 JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , createFqn (funcName ), ecmaFunc );
118- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaFunc ));
119107 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
120108 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
121109 }
@@ -127,7 +115,6 @@ public Void visitMethodDefinition(MethodDefinitionContext ctx) {
127115 FunctionDescriptor ecmaFunc = new FunctionStoreManipulator (funcName ).createNodeIn (store , ctx , fqnCreator );
128116 rootComp .getFunctions ().add (ecmaFunc );
129117 JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , createFqn (funcName ), ecmaFunc );
130- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaFunc ));
131118 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
132119 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
133120 }
@@ -154,8 +141,7 @@ public Void visitLiteral(LiteralContext ctx) {
154141 rootComp .getLiterals ().add (d );
155142 d .setLine (ctx .getStart ().getLine ());
156143 d .setFullQualifiedName (createFqn (Integer .toString (d .hashCode ())));
157- // set relation
158- return relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , d ));
144+ return d ;
159145 });
160146
161147 return super .visitLiteral (ctx );
@@ -164,19 +150,17 @@ public Void visitLiteral(LiteralContext ctx) {
164150 @ Override
165151 public Void visitObjectLiteral (ObjectLiteralContext ctx ) {
166152 ObjectDescriptor ecmaObj = new ObjectStoreManipulator ().createNodeIn (store , ctx , fqnCreator );
167- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaObj ));
168- JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , fqnCreator .createFqn (ObjectDescriptor .OBJECT ), ecmaObj , new ObjectDeclaresManipulator (store ));
153+ JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , fqnCreator .createFqn (ObjectDescriptor .OBJECT ), ecmaObj );
169154 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
170155 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
171156 }
172157
173158 @ Override
174159 public Void visitArrayLiteralExpression (ArrayLiteralExpressionContext ctx ) {
175160 ArrayDescriptor ecmaArray = new ArrayStoreManipulator ().createNodeIn (store , ctx , fqnCreator );
176- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaArray ));
177161 rootComp .getObjects ().add (ecmaArray );
178162
179- JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , fqnCreator .createFqn (ArrayDescriptor .ARRAY ), ecmaArray , new ArrayDeclaresManipulator ( store ) );
163+ JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , fqnCreator .createFqn (ArrayDescriptor .ARRAY ), ecmaArray );
180164 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
181165 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
182166 }
@@ -186,7 +170,6 @@ public Void visitClassDeclaration(ClassDeclarationContext ctx) {
186170 ClassDescriptor ecmaClass = new ClassStoreManipulator ().createNodeIn (store , ctx , fqnCreator );
187171 rootComp .getClasses ().add (ecmaClass );
188172 JavascriptVisitor subTreeVistor = new JavascriptVisitor (store , fqnCreator .createFqn (ecmaClass .getName ()), ecmaClass );
189- relationCreator .map ((a ) -> a .createRelation (ctx , rootComp , ecmaClass ));
190173 ctx .children .forEach ((c ) -> c .accept (subTreeVistor ));
191174 return VISITOR_DOES_NOT_GO_DEEPER_INTO_AST ;
192175 }
@@ -228,8 +211,7 @@ public Void visitArgumentsExpression(ArgumentsExpressionContext ctx) {
228211 fd .setName (funcName );
229212 return fd ;
230213 });
231- rootComp .getInvokes ().add (func );
232- System .out .println (funcName );
214+ new InvokesManipulator (store ).createRelation (ctx , rootComp , func );
233215 }
234216 }
235217
@@ -244,8 +226,6 @@ public Optional<FunctionDescriptor> findFunctioninStore(String funcName) {
244226 .map ((String s ) -> Optional .ofNullable (store .find (FunctionDescriptor .class , s )))
245227 .filter ((Optional <FunctionDescriptor > curFd ) -> curFd .isPresent ())
246228 .findFirst ().orElse (Optional .empty ());
247-
248-
249229 }
250230
251231
0 commit comments