@@ -134,7 +134,6 @@ public boolean visit(MethodDeclaration md) {
134134 graph .addVertex (pn );
135135 defPool .put (para_qname , pn );
136136 GraphUtil .addNode (pn );
137- graph .addEdge (node , pn , new Edge (GraphUtil .eid (), EdgeType .PARAMETER ));
138137
139138 if (currentTemplate != "" && !javaURIS .containsKey (currentTemplate )) {
140139 javaURIS .put (currentTemplate , new ArrayList <>());
@@ -162,7 +161,6 @@ public boolean visit(MethodDeclaration md) {
162161 JdtService .getIdentifier (p ));
163162
164163 node .setRange (computeRange (p ));
165- graph .addEdge (node , pn , new Edge (GraphUtil .eid (), EdgeType .PARAMETER ));
166164
167165 ITypeBinding paraBinding = p .getType ().resolveBinding ();
168166 if (paraBinding != null ) {
@@ -177,10 +175,7 @@ public boolean visit(MethodDeclaration md) {
177175 // TODO: process body here or else where?
178176 if (md .getBody () != null ) {
179177 if (!md .getBody ().statements ().isEmpty ()) {
180- parseBodyBlock (md .getBody (), md .getName ().toString (), qname )
181- .ifPresent (
182- blockNode ->
183- graph .addEdge (node , blockNode , new Edge (GraphUtil .eid (), EdgeType .BODY )));
178+ parseBodyBlock (md .getBody (), md .getName ().toString (), qname );
184179 }
185180 }
186181
@@ -280,6 +275,23 @@ private void parseStatementForLayout(Statement stmt) {
280275 }
281276 break ;
282277 }
278+ case ASTNode .EXPRESSION_STATEMENT :
279+ {
280+ Expression exp = ((ExpressionStatement ) stmt ).getExpression ();
281+ if (exp instanceof MethodInvocation ) {
282+ MethodInvocation mi = (MethodInvocation ) exp ;
283+
284+ // accessor
285+ Expression expr = mi .getExpression ();
286+ if (expr != null ) {
287+ if (exp .toString ().contains ("setViewName(" )) {
288+ String arg = mi .arguments ().get (0 ).toString ();
289+ currentTemplate = arg .substring (1 , arg .length () - 1 );
290+ }
291+ }
292+ }
293+ break ;
294+ }
283295 // control
284296 case ASTNode .IF_STATEMENT :
285297 {
@@ -407,7 +419,6 @@ protected void parseAnnotations(List modifiers, ElementNode annotatedNode) {
407419 node .setUri (createIdentifier (identifier ));
408420
409421 graph .addVertex (node );
410- graph .addEdge (annotatedNode , node , new Edge (GraphUtil .eid (), EdgeType .ANNOTATION ));
411422
412423 // check annotation type and possible refs
413424 // add possible refs into use pool
@@ -576,7 +587,6 @@ protected RelationNode parseExpression(Expression exp) {
576587 JdtService .getIdentifier (fragment ));
577588
578589 n .setRange (computeRange (fragment ));
579- graph .addEdge (root , n , new Edge (GraphUtil .eid (), EdgeType .CHILD ));
580590
581591 if (binding != null ) {
582592 usePool .add (Triple .of (n , EdgeType .DATA_TYPE , binding .getType ().getQualifiedName ()));
@@ -669,7 +679,7 @@ protected RelationNode parseExpression(Expression exp) {
669679 Expression expr = mi .getExpression ();
670680 if (expr != null ) {
671681 Edge edge = new Edge (GraphUtil .eid (), EdgeType .ACCESSOR );
672- graph . addEdge ( root , parseExpression (expr ), edge );
682+ parseExpression (expr );
673683 String source = expr .toString ();
674684 if (source .matches ("^\\ w+(\\ .\\ w+)*$" )) {
675685 identifier = expr .toString () + "." + mi .getName ().getIdentifier ();
@@ -706,6 +716,13 @@ protected RelationNode parseExpression(Expression exp) {
706716 if (!javaURIS .get (currentTemplate ).contains (uri ))
707717 javaURIS .get (currentTemplate ).add (uri );
708718 }
719+ } else if (exp .toString ().contains ("setViewName(" )) {
720+ String identifier = root .getUri ().getIdentifier ();
721+ String arg = mi .arguments ().get (0 ).toString ();
722+ URI uri = new URI (false , uriFilePath );
723+ uri .addLayer (identifier , Language .JAVA );
724+ uri .addLayer (arg .substring (1 , arg .length () - 1 ), Language .ANY );
725+ addViewPathReturn (uri );
709726 }
710727
711728 IMethodBinding mdBinding = mi .resolveMethodBinding ();
@@ -731,14 +748,8 @@ protected RelationNode parseExpression(Expression exp) {
731748 root .setSymbol (asg .getOperator ().toString ());
732749 root .setArity (2 );
733750
734- graph .addEdge (
735- root ,
736- parseExpression (asg .getLeftHandSide ()),
737- new Edge (GraphUtil .eid (), EdgeType .LEFT ));
738- graph .addEdge (
739- root ,
740- parseExpression (asg .getRightHandSide ()),
741- new Edge (GraphUtil .eid (), EdgeType .RIGHT ));
751+ parseExpression (asg .getLeftHandSide ());
752+ parseExpression (asg .getRightHandSide ());
742753 break ;
743754 }
744755 case ASTNode .CAST_EXPRESSION :
@@ -754,10 +765,7 @@ protected RelationNode parseExpression(Expression exp) {
754765 usePool .add (Triple .of (root , EdgeType .TARGET_TYPE , typeBinding .getQualifiedName ()));
755766 }
756767
757- graph .addEdge (
758- root ,
759- parseExpression (castExpression .getExpression ()),
760- new Edge (GraphUtil .eid (), EdgeType .CASTED_OBJECT ));
768+ parseExpression (castExpression .getExpression ());
761769
762770 break ;
763771 }
@@ -768,14 +776,8 @@ protected RelationNode parseExpression(Expression exp) {
768776 root .setSymbol (iex .getOperator ().toString ());
769777 root .setArity (2 );
770778
771- graph .addEdge (
772- root ,
773- parseExpression (iex .getLeftOperand ()),
774- new Edge (GraphUtil .eid (), EdgeType .LEFT ));
775- graph .addEdge (
776- root ,
777- parseExpression (iex .getRightOperand ()),
778- new Edge (GraphUtil .eid (), EdgeType .RIGHT ));
779+ parseExpression (iex .getLeftOperand ());
780+ parseExpression (iex .getRightOperand ());
779781 break ;
780782 }
781783 case ASTNode .PREFIX_EXPRESSION :
@@ -785,8 +787,7 @@ protected RelationNode parseExpression(Expression exp) {
785787 root .setSymbol (pex .getOperator ().toString ());
786788 root .setArity (1 );
787789
788- graph .addEdge (
789- root , parseExpression (pex .getOperand ()), new Edge (GraphUtil .eid (), EdgeType .LEFT ));
790+ parseExpression (pex .getOperand ());
790791 break ;
791792 }
792793 case ASTNode .POSTFIX_EXPRESSION :
@@ -796,8 +797,7 @@ protected RelationNode parseExpression(Expression exp) {
796797 root .setSymbol (pex .getOperator ().toString ());
797798 root .setArity (1 );
798799
799- graph .addEdge (
800- root , parseExpression (pex .getOperand ()), new Edge (GraphUtil .eid (), EdgeType .RIGHT ));
800+ parseExpression (pex .getOperand ());
801801 }
802802 }
803803
@@ -819,10 +819,7 @@ protected Optional<Node> parseStatement(Statement stmt) {
819819 graph .addVertex (node );
820820
821821 for (Object st : block .statements ()) {
822- parseStatement ((Statement ) st )
823- .ifPresent (
824- child ->
825- graph .addEdge (node , child , new Edge (GraphUtil .eid (), EdgeType .CHILD )));
822+ parseStatement ((Statement ) st );
826823 }
827824 return Optional .of (node );
828825 }
@@ -916,10 +913,7 @@ protected Optional<Node> parseStatement(Statement stmt) {
916913 Triple .of (node , EdgeType .DATA_TYPE , binding .getType ().getQualifiedName ()));
917914
918915 if (fragment .getInitializer () != null ) {
919- graph .addEdge (
920- node ,
921- parseExpression (fragment .getInitializer ()),
922- new Edge (GraphUtil .eid (), EdgeType .INITIALIZER ));
916+ parseExpression (fragment .getInitializer ());
923917 }
924918
925919 return Optional .of (node );
@@ -951,17 +945,12 @@ protected Optional<Node> parseStatement(Statement stmt) {
951945
952946 if (ifStatement .getExpression () != null ) {
953947 RelationNode cond = parseExpression (ifStatement .getExpression ());
954- graph .addEdge (node , cond , new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
955948 }
956949 if (ifStatement .getThenStatement () != null ) {
957- parseStatement (ifStatement .getThenStatement ())
958- .ifPresent (
959- then -> graph .addEdge (node , then , new Edge (GraphUtil .eid (), EdgeType .THEN )));
950+ parseStatement (ifStatement .getThenStatement ());
960951 }
961952 if (ifStatement .getElseStatement () != null ) {
962- parseStatement (ifStatement .getElseStatement ())
963- .ifPresent (
964- els -> graph .addEdge (node , els , new Edge (GraphUtil .eid (), EdgeType .ELSE )));
953+ parseStatement (ifStatement .getElseStatement ());
965954 }
966955 return Optional .of (node );
967956 }
@@ -975,32 +964,13 @@ protected Optional<Node> parseStatement(Statement stmt) {
975964
976965 graph .addVertex (node );
977966
978- forStatement
979- .initializers ()
980- .forEach (
981- init ->
982- graph .addEdge (
983- node ,
984- parseExpression ((Expression ) init ),
985- new Edge (GraphUtil .eid (), EdgeType .INITIALIZER )));
986- forStatement
987- .updaters ()
988- .forEach (
989- upd ->
990- graph .addEdge (
991- node ,
992- parseExpression ((Expression ) upd ),
993- new Edge (GraphUtil .eid (), EdgeType .UPDATER )));
967+ forStatement .initializers ().forEach (init -> parseExpression ((Expression ) init ));
968+ forStatement .updaters ().forEach (upd -> parseExpression ((Expression ) upd ));
994969
995970 if (forStatement .getExpression () != null ) {
996- graph .addEdge (
997- node ,
998- parseExpression (forStatement .getExpression ()),
999- new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
971+ parseExpression (forStatement .getExpression ());
1000972 }
1001- parseStatement (forStatement .getBody ())
1002- .ifPresent (
1003- body -> graph .addEdge (node , body , new Edge (GraphUtil .eid (), EdgeType .BODY )));
973+ parseStatement (forStatement .getBody ());
1004974
1005975 return Optional .of (node );
1006976 }
@@ -1036,20 +1006,14 @@ protected Optional<Node> parseStatement(Statement stmt) {
10361006 JdtService .getIdentifier (p ));
10371007
10381008 pn .setRange (computeRange (p ));
1039- graph .addEdge (node , pn , new Edge (GraphUtil .eid (), EdgeType .ELEMENT ));
10401009
10411010 ITypeBinding paraBinding = p .getType ().resolveBinding ();
10421011 if (paraBinding != null ) {
10431012 usePool .add (Triple .of (pn , EdgeType .DATA_TYPE , paraBinding .getQualifiedName ()));
10441013 }
10451014
1046- graph .addEdge (
1047- node ,
1048- parseExpression (eForStatement .getExpression ()),
1049- new Edge (GraphUtil .eid (), EdgeType .VALUES ));
1050- parseStatement (eForStatement .getBody ())
1051- .ifPresent (
1052- body -> graph .addEdge (node , body , new Edge (GraphUtil .eid (), EdgeType .BODY )));
1015+ parseExpression (eForStatement .getExpression ());
1016+ parseStatement (eForStatement .getBody ());
10531017
10541018 return Optional .of (node );
10551019 }
@@ -1066,14 +1030,11 @@ protected Optional<Node> parseStatement(Statement stmt) {
10661030 Expression expression = doStatement .getExpression ();
10671031 if (expression != null ) {
10681032 RelationNode cond = parseExpression (expression );
1069- graph .addEdge (node , cond , new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
10701033 }
10711034
10721035 Statement doBody = doStatement .getBody ();
10731036 if (doBody != null ) {
1074- parseStatement (doBody )
1075- .ifPresent (
1076- body -> graph .addEdge (node , body , new Edge (GraphUtil .eid (), EdgeType .BODY )));
1037+ parseStatement (doBody );
10771038 }
10781039 return Optional .of (node );
10791040 }
@@ -1093,14 +1054,11 @@ protected Optional<Node> parseStatement(Statement stmt) {
10931054 Expression expression = whileStatement .getExpression ();
10941055 if (expression != null ) {
10951056 RelationNode cond = parseExpression (expression );
1096- graph .addEdge (node , cond , new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
10971057 }
10981058
10991059 Statement whileBody = whileStatement .getBody ();
11001060 if (whileBody != null ) {
1101- parseStatement (whileBody )
1102- .ifPresent (
1103- body -> graph .addEdge (node , body , new Edge (GraphUtil .eid (), EdgeType .BODY )));
1061+ parseStatement (whileBody );
11041062 }
11051063 return Optional .of (node );
11061064 }
@@ -1116,9 +1074,7 @@ protected Optional<Node> parseStatement(Statement stmt) {
11161074
11171075 Statement tryBody = tryStatement .getBody ();
11181076 if (tryBody != null ) {
1119- parseStatement (tryBody )
1120- .ifPresent (
1121- body -> graph .addEdge (node , body , new Edge (GraphUtil .eid (), EdgeType .BODY )));
1077+ parseStatement (tryBody );
11221078
11231079 List <CatchClause > catchClauses = tryStatement .catchClauses ();
11241080 if (catchClauses != null && !catchClauses .isEmpty ()) {
@@ -1133,25 +1089,17 @@ protected Optional<Node> parseStatement(Statement stmt) {
11331089 catchNode .setRange (computeRange (catchClause ));
11341090
11351091 graph .addVertex (catchNode );
1136- graph .addEdge (node , catchNode , new Edge (GraphUtil .eid (), EdgeType .CATCH ));
11371092
11381093 if (binding != null ) {
11391094 usePool .add (Triple .of (node , EdgeType .TARGET_TYPE , binding .getQualifiedName ()));
11401095 }
11411096 if (catchClause .getBody () != null ) {
1142- parseBodyBlock (catchClause .getBody ())
1143- .ifPresent (
1144- block ->
1145- graph .addEdge (
1146- catchNode , block , new Edge (GraphUtil .eid (), EdgeType .CHILD )));
1097+ parseBodyBlock (catchClause .getBody ());
11471098 }
11481099 }
11491100 }
11501101 if (tryStatement .getFinally () != null ) {
1151- parseBodyBlock (tryStatement .getFinally ())
1152- .ifPresent (
1153- block ->
1154- graph .addEdge (node , block , new Edge (GraphUtil .eid (), EdgeType .FINALLY )));
1102+ parseBodyBlock (tryStatement .getFinally ());
11551103 }
11561104 }
11571105 return Optional .of (node );
@@ -1171,7 +1119,6 @@ protected Optional<Node> parseStatement(Statement stmt) {
11711119
11721120 if (throwStatement .getExpression () != null ) {
11731121 RelationNode thr = parseExpression (throwStatement .getExpression ());
1174- graph .addEdge (node , thr , new Edge (GraphUtil .eid (), EdgeType .THROW ));
11751122 }
11761123
11771124 return Optional .of (node );
@@ -1192,7 +1139,6 @@ protected Optional<Node> parseStatement(Statement stmt) {
11921139 Expression expression = switchStatement .getExpression ();
11931140 if (expression != null ) {
11941141 RelationNode cond = parseExpression (expression );
1195- graph .addEdge (node , cond , new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
11961142 }
11971143 // treat case as an implicit block of statements
11981144 for (int i = 0 ; i < switchStatement .statements ().size (); ++i ) {
@@ -1212,10 +1158,8 @@ protected Optional<Node> parseStatement(Statement stmt) {
12121158 if (exx instanceof Expression ) {
12131159 RelationNode condition = parseExpression ((Expression ) exx );
12141160 graph .addVertex (condition );
1215- graph .addEdge (caseNode , condition , new Edge (GraphUtil .eid (), EdgeType .CONDITION ));
12161161 }
12171162 }
1218- graph .addEdge (node , caseNode , new Edge (GraphUtil .eid (), EdgeType .CHILD ));
12191163
12201164 while (i + 1 < switchStatement .statements ().size ()) {
12211165 Object nxxt = switchStatement .statements ().get (++i );
@@ -1225,11 +1169,7 @@ protected Optional<Node> parseStatement(Statement stmt) {
12251169 i -= 1 ;
12261170 break ;
12271171 } else if (nxxt instanceof Statement ) {
1228- parseStatement ((Statement ) nxxt )
1229- .ifPresent (
1230- then ->
1231- graph .addEdge (
1232- caseNode , then , new Edge (GraphUtil .eid (), EdgeType .THEN )));
1172+ parseStatement ((Statement ) nxxt );
12331173 }
12341174 }
12351175 }
0 commit comments