@@ -32,6 +32,33 @@ object Ast {
3232 ast.conditionEdges.foreach { edge =>
3333 diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .CONDITION )
3434 }
35+ ast.trueBodyEdges.foreach { edge =>
36+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .TRUE_BODY )
37+ }
38+ ast.falseBodyEdges.foreach { edge =>
39+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .FALSE_BODY )
40+ }
41+ ast.doBodyEdges.foreach { edge =>
42+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .DO_BODY )
43+ }
44+ ast.tryBodyEdges.foreach { edge =>
45+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .TRY_BODY )
46+ }
47+ ast.catchBodyEdges.foreach { edge =>
48+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .CATCH_BODY )
49+ }
50+ ast.finallyBodyEdges.foreach { edge =>
51+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .FINALLY_BODY )
52+ }
53+ ast.forInitEdges.foreach { edge =>
54+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .FOR_INIT )
55+ }
56+ ast.forUpdateEdges.foreach { edge =>
57+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .FOR_UPDATE )
58+ }
59+ ast.forBodyEdges.foreach { edge =>
60+ diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .FOR_BODY )
61+ }
3562 ast.receiverEdges.foreach { edge =>
3663 diffGraph.addEdge(edge.src, edge.dst, EdgeTypes .RECEIVER )
3764 }
@@ -90,6 +117,15 @@ case class Ast(
90117 ], // technically this should be a Seq[AstNewNode], but we also use it for non-ast nodes like Binding...
91118 edges : collection.Seq [AstEdge ] = Vector .empty,
92119 conditionEdges : collection.Seq [AstEdge ] = Vector .empty,
120+ trueBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
121+ falseBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
122+ doBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
123+ tryBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
124+ catchBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
125+ finallyBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
126+ forInitEdges : collection.Seq [AstEdge ] = Vector .empty,
127+ forUpdateEdges : collection.Seq [AstEdge ] = Vector .empty,
128+ forBodyEdges : collection.Seq [AstEdge ] = Vector .empty,
93129 refEdges : collection.Seq [AstEdge ] = Vector .empty,
94130 bindsEdges : collection.Seq [AstEdge ] = Vector .empty,
95131 receiverEdges : collection.Seq [AstEdge ] = Vector .empty,
@@ -113,6 +149,15 @@ case class Ast(
113149 }
114150 ),
115151 conditionEdges = conditionEdges ++ other.conditionEdges,
152+ trueBodyEdges = trueBodyEdges ++ other.trueBodyEdges,
153+ falseBodyEdges = falseBodyEdges ++ other.falseBodyEdges,
154+ doBodyEdges = doBodyEdges ++ other.doBodyEdges,
155+ tryBodyEdges = tryBodyEdges ++ other.tryBodyEdges,
156+ catchBodyEdges = catchBodyEdges ++ other.catchBodyEdges,
157+ finallyBodyEdges = finallyBodyEdges ++ other.finallyBodyEdges,
158+ forInitEdges = forInitEdges ++ other.forInitEdges,
159+ forUpdateEdges = forUpdateEdges ++ other.forUpdateEdges,
160+ forBodyEdges = forBodyEdges ++ other.forBodyEdges,
116161 argEdges = argEdges ++ other.argEdges,
117162 receiverEdges = receiverEdges ++ other.receiverEdges,
118163 refEdges = refEdges ++ other.refEdges,
@@ -126,6 +171,15 @@ case class Ast(
126171 nodes ++ other.nodes,
127172 edges = edges ++ other.edges,
128173 conditionEdges = conditionEdges ++ other.conditionEdges,
174+ trueBodyEdges = trueBodyEdges ++ other.trueBodyEdges,
175+ falseBodyEdges = falseBodyEdges ++ other.falseBodyEdges,
176+ doBodyEdges = doBodyEdges ++ other.doBodyEdges,
177+ tryBodyEdges = tryBodyEdges ++ other.tryBodyEdges,
178+ catchBodyEdges = catchBodyEdges ++ other.catchBodyEdges,
179+ finallyBodyEdges = finallyBodyEdges ++ other.finallyBodyEdges,
180+ forInitEdges = forInitEdges ++ other.forInitEdges,
181+ forUpdateEdges = forUpdateEdges ++ other.forUpdateEdges,
182+ forBodyEdges = forBodyEdges ++ other.forBodyEdges,
129183 argEdges = argEdges ++ other.argEdges,
130184 receiverEdges = receiverEdges ++ other.receiverEdges,
131185 refEdges = refEdges ++ other.refEdges,
@@ -154,6 +208,56 @@ case class Ast(
154208 this .copy(conditionEdges = conditionEdges ++ List (AstEdge (src, dst)))
155209 }
156210
211+ def withTrueBodyEdge (src : NewNode , dst : NewNode ): Ast = {
212+ Ast .neighbourValidation(src, dst, EdgeTypes .TRUE_BODY )
213+ this .copy(trueBodyEdges = trueBodyEdges ++ List (AstEdge (src, dst)))
214+ }
215+
216+ def withFalseBodyEdge (src : NewNode , dst : NewNode ): Ast = {
217+ Ast .neighbourValidation(src, dst, EdgeTypes .FALSE_BODY )
218+ this .copy(falseBodyEdges = falseBodyEdges ++ List (AstEdge (src, dst)))
219+ }
220+
221+ def withDoBodyEdge (src : NewNode , dst : NewNode ): Ast = {
222+ Ast .neighbourValidation(src, dst, EdgeTypes .DO_BODY )
223+ this .copy(doBodyEdges = doBodyEdges ++ List (AstEdge (src, dst)))
224+ }
225+
226+ def withTryBodyEdge (src : NewNode , dst : NewNode ): Ast = {
227+ Ast .neighbourValidation(src, dst, EdgeTypes .TRY_BODY )
228+ this .copy(tryBodyEdges = tryBodyEdges ++ List (AstEdge (src, dst)))
229+ }
230+
231+ def withCatchBodyEdge (src : NewNode , dst : NewNode ): Ast = {
232+ Ast .neighbourValidation(src, dst, EdgeTypes .CATCH_BODY )
233+ this .copy(catchBodyEdges = catchBodyEdges ++ List (AstEdge (src, dst)))
234+ }
235+
236+ def withCatchBodyEdges (src : NewNode , dsts : List [NewNode ]): Ast = {
237+ dsts.foreach(dst => Ast .neighbourValidation(src, dst, EdgeTypes .CATCH_BODY ))
238+ this .copy(catchBodyEdges = catchBodyEdges ++ dsts.map(AstEdge (src, _)))
239+ }
240+
241+ def withFinallyBodyEdge (src : NewNode , dst : NewNode ): Ast = {
242+ Ast .neighbourValidation(src, dst, EdgeTypes .FINALLY_BODY )
243+ this .copy(finallyBodyEdges = finallyBodyEdges ++ List (AstEdge (src, dst)))
244+ }
245+
246+ def withForInitEdge (src : NewNode , dst : NewNode ): Ast = {
247+ Ast .neighbourValidation(src, dst, EdgeTypes .FOR_INIT )
248+ this .copy(forInitEdges = forInitEdges ++ List (AstEdge (src, dst)))
249+ }
250+
251+ def withForUpdateEdge (src : NewNode , dst : NewNode ): Ast = {
252+ Ast .neighbourValidation(src, dst, EdgeTypes .FOR_UPDATE )
253+ this .copy(forUpdateEdges = forUpdateEdges ++ List (AstEdge (src, dst)))
254+ }
255+
256+ def withForBodyEdge (src : NewNode , dst : NewNode ): Ast = {
257+ Ast .neighbourValidation(src, dst, EdgeTypes .FOR_BODY )
258+ this .copy(forBodyEdges = forBodyEdges ++ List (AstEdge (src, dst)))
259+ }
260+
157261 def withRefEdge (src : NewNode , dst : NewNode ): Ast = {
158262 Ast .neighbourValidation(src, dst, EdgeTypes .REF )
159263 this .copy(refEdges = refEdges ++ List (AstEdge (src, dst)))
@@ -259,6 +363,15 @@ case class Ast(
259363
260364 val newArgEdges = argEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
261365 val newConditionEdges = conditionEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
366+ val newTrueBodyEdges = trueBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
367+ val newFalseBodyEdges = falseBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
368+ val newDoBodyEdges = doBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
369+ val newTryBodyEdges = tryBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
370+ val newCatchBodyEdges = catchBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
371+ val newFinallyEdges = finallyBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
372+ val newForInitEdges = forInitEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
373+ val newForUpdateEdges = forUpdateEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
374+ val newForBodyEdges = forBodyEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
262375 val newRefEdges = refEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
263376 val newBindsEdges = bindsEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
264377 val newReceiverEdges = receiverEdges.filter(_.src == node).map(x => AstEdge (newNode, newIfExists(x.dst)))
@@ -268,6 +381,15 @@ case class Ast(
268381 .copy(
269382 argEdges = newArgEdges,
270383 conditionEdges = newConditionEdges,
384+ trueBodyEdges = newTrueBodyEdges,
385+ falseBodyEdges = newFalseBodyEdges,
386+ doBodyEdges = newDoBodyEdges,
387+ tryBodyEdges = newTryBodyEdges,
388+ catchBodyEdges = newCatchBodyEdges,
389+ finallyBodyEdges = newFinallyEdges,
390+ forInitEdges = newForInitEdges,
391+ forUpdateEdges = newForUpdateEdges,
392+ forBodyEdges = newForBodyEdges,
271393 refEdges = newRefEdges,
272394 bindsEdges = newBindsEdges,
273395 receiverEdges = newReceiverEdges,
0 commit comments