Skip to content

Commit 444f169

Browse files
committed
Fix problem of no existing references to some attributes and methods
Ignore relationships between methods and attributes, which weren't added to FAMIX model
1 parent c612b16 commit 444f169

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

generator/org.svis.generator/src/org/svis/generator/famix/Famix2Famix.xtend

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,30 @@ class Famix2Famix extends WorkflowComponentWithConfig {
160160
]
161161
graph.execute("MATCH p=()-[r:INVOKES]->() RETURN r").forEach [ row |
162162
val rel = row.get("r") as Relationship
163-
val invocation = famixFactory.createFAMIXInvocation
164-
val senderRef = famixFactory.createIntegerReference
165-
val receiverRef = famixFactory.createIntegerReference
166-
senderRef.ref = methods.get(rel.startNode.id)
167-
receiverRef.ref = methods.get(rel.endNode.id)
168-
invocation.sender = senderRef
169-
invocation.candidates = receiverRef
170-
famixDocument.elements += invocation
163+
if (methods.containsKey(rel.startNode.id) && methods.containsKey(rel.endNode.id)) {
164+
val invocation = famixFactory.createFAMIXInvocation
165+
val senderRef = famixFactory.createIntegerReference
166+
val receiverRef = famixFactory.createIntegerReference
167+
senderRef.ref = methods.get(rel.startNode.id)
168+
receiverRef.ref = methods.get(rel.endNode.id)
169+
invocation.sender = senderRef
170+
invocation.candidates = receiverRef
171+
famixDocument.elements += invocation
172+
}
171173
]
172174
graph.execute("MATCH p=()-[r:READS|WRITES]->() RETURN r").forEach [ row |
173175
val rel = row.get("r") as Relationship
174-
val access = famixFactory.createFAMIXAccess
175-
val attributeRef = famixFactory.createIntegerReference
176-
val accessorRef = famixFactory.createIntegerReference
177-
attributeRef.ref = attributes.get(rel.endNode.id)
178-
accessorRef.ref = methods.get(rel.startNode.id)
179-
access.variable = attributeRef
180-
access.accessor = accessorRef
181-
famixDocument.elements += access
176+
if (methods.containsKey(rel.startNode.id) && attributes.containsKey(rel.endNode.id)) {
177+
val access = famixFactory.createFAMIXAccess
178+
val attributeRef = famixFactory.createIntegerReference
179+
val accessorRef = famixFactory.createIntegerReference
180+
attributeRef.ref = attributes.get(rel.endNode.id)
181+
accessorRef.ref = methods.get(rel.startNode.id)
182+
access.variable = attributeRef
183+
access.accessor = accessorRef
184+
famixDocument.elements += access
185+
}
186+
182187
]
183188
println("finish")
184189
tx.success
@@ -731,6 +736,7 @@ class Famix2Famix extends WorkflowComponentWithConfig {
731736
def createMethod(Node node, FAMIXClass parent, FAMIXFileAnchor fileAnchor) {
732737
val method = famixFactory.createFAMIXMethod
733738
method.name = node.id.toString
739+
method.id = node.id.toString
734740
if (node.hasProperty("name")) {
735741
method.value = node.getProperty("name") as String
736742
}
@@ -767,6 +773,7 @@ class Famix2Famix extends WorkflowComponentWithConfig {
767773
def createAttribute(Node node, FAMIXClass parent, FAMIXFileAnchor fileAnchor) {
768774
val attribute = famixFactory.createFAMIXAttribute
769775
attribute.name = node.id.toString
776+
attribute.id = node.id.toString
770777
if (node.hasProperty("name")) {
771778
attribute.value = node.getProperty("name") as String
772779
}

0 commit comments

Comments
 (0)