Skip to content

Commit 5c28505

Browse files
committed
Load attributes from db
1 parent 7c714b7 commit 5c28505

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import org.svis.lib.database.Database
4545
import org.svis.lib.database.DBConnector
4646
import org.neo4j.graphdb.Node
4747
import org.neo4j.graphdb.Label
48-
import org.neo4j.graphdb.traversal.Evaluators
4948
import org.neo4j.graphdb.Direction
5049
import org.neo4j.graphdb.traversal.Uniqueness
5150

@@ -114,6 +113,8 @@ class Famix2Famix extends WorkflowComponentWithConfig {
114113
type = "Class"
115114
} else if (label.name == "Method") {
116115
type = "Method"
116+
} else if(label.name == "Field") {
117+
type = "Field"
117118
}
118119
}
119120
switch (type) {
@@ -171,6 +172,22 @@ class Famix2Famix extends WorkflowComponentWithConfig {
171172
method.sourceAnchor = anchorRef
172173
famixDocument.elements += method
173174
}
175+
case "Field": {
176+
val attribute = createAttribute(node)
177+
val parentClass = classes.get(parent.id)
178+
var ref = famixFactory.createIntegerReference
179+
ref.ref = parentClass
180+
attribute.parentType = ref
181+
val fileAnchor = famixFactory.createFAMIXFileAnchor
182+
val anchorRef = famixFactory.createIntegerReference
183+
val attributeRef = famixFactory.createIntegerReference
184+
fileAnchor.filename = parent.getProperty("sourceFileName") as String
185+
anchorRef.ref = attribute
186+
attributeRef.ref = fileAnchor
187+
fileAnchor.element = attributeRef
188+
attribute.sourceAnchor = anchorRef
189+
famixDocument.elements+= attribute
190+
}
174191
}
175192
]
176193
]
@@ -679,7 +696,7 @@ class Famix2Famix extends WorkflowComponentWithConfig {
679696

680697
def createNamespace(Node node) {
681698
val namespace = famixFactory.createFAMIXNamespace
682-
val id = node.getId.toString
699+
val id = node.id.toString
683700
namespace.name = id
684701
namespace.id = id
685702
namespace.value = node.getProperty("name") as String
@@ -689,7 +706,7 @@ class Famix2Famix extends WorkflowComponentWithConfig {
689706

690707
def createClass(Node node) {
691708
val class = famixFactory.createFAMIXClass
692-
class.name = node.getId.toString
709+
class.name = node.id.toString
693710
if(node.hasProperty("name")) {
694711
class.value = node.getProperty("name") as String
695712
}
@@ -712,7 +729,7 @@ class Famix2Famix extends WorkflowComponentWithConfig {
712729

713730
def createMethod(Node node) {
714731
val method = famixFactory.createFAMIXMethod
715-
method.name = node.getId.toString
732+
method.name = node.id.toString
716733
if(node.hasProperty("name")) {
717734
method.value = node.getProperty("name") as String
718735
}
@@ -728,4 +745,16 @@ class Famix2Famix extends WorkflowComponentWithConfig {
728745
method.signature = node.getProperty("signature") as String
729746
return method
730747
}
748+
749+
def createAttribute(Node node) {
750+
val attribute = famixFactory.createFAMIXAttribute
751+
attribute.name = node.id.toString
752+
if(node.hasProperty("name")) {
753+
attribute.value = node.getProperty("name") as String
754+
}
755+
if(node.hasProperty("visibility")) {
756+
attribute.modifiers+= node.getProperty("visibility") as String
757+
}
758+
return attribute
759+
}
731760
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.svis.generator.famix
33
import org.neo4j.graphdb.Path
44
import org.neo4j.graphdb.traversal.Evaluation
55
import org.neo4j.graphdb.traversal.Evaluator
6-
import org.neo4j.graphdb.Direction
76
import org.neo4j.graphdb.Label
87

98
class FamixEvaluator implements Evaluator {
@@ -24,6 +23,11 @@ class FamixEvaluator implements Evaluator {
2423
result = Evaluation.INCLUDE_AND_CONTINUE
2524
}
2625
}
26+
if(label.name == "Field") {
27+
result = Evaluation.INCLUDE_AND_CONTINUE
28+
//To-Do: Attribute entfernen, die nur lokal in Funktionen deklariert werden
29+
}
30+
2731
}
2832
return result
2933
}

0 commit comments

Comments
 (0)