From f1bd9efc0aae953341250798ac1cba238777a1e9 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Tue, 17 Dec 2024 15:15:44 +0100 Subject: [PATCH] Reorganisation --- .../fraunhofer/aisec/cpg/graph/OverlayNode.kt | 3 ++- .../aisec/cpg/graph/concepts/Concept.kt | 23 ---------------- .../aisec/cpg/graph/edges/overlay/Overlay.kt | 26 +++++++++++++++++++ .../aisec/cpg_vis_neo4j/Neo4JTest.kt | 1 + 4 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt index 968d32a2cb..378c2e334a 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/OverlayNode.kt @@ -25,7 +25,7 @@ */ package de.fraunhofer.aisec.cpg.graph -import de.fraunhofer.aisec.cpg.graph.concepts.OverlaySingleEdge +import de.fraunhofer.aisec.cpg.graph.edges.overlay.OverlaySingleEdge import de.fraunhofer.aisec.cpg.graph.edges.unwrapping import org.neo4j.ogm.annotation.Relationship @@ -45,3 +45,4 @@ abstract class OverlayNode() : Node() { ) var underlyingNode by unwrapping(OverlayNode::underlyingNodeEdge) } + diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt index 8653331f4e..a28fea3171 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/concepts/Concept.kt @@ -25,12 +25,7 @@ */ package de.fraunhofer.aisec.cpg.graph.concepts -import de.fraunhofer.aisec.cpg.graph.Node import de.fraunhofer.aisec.cpg.graph.OverlayNode -import de.fraunhofer.aisec.cpg.graph.edges.Edge -import de.fraunhofer.aisec.cpg.graph.edges.collections.EdgeSingletonList -import de.fraunhofer.aisec.cpg.graph.edges.collections.MirroredEdgeCollection -import kotlin.reflect.KProperty /** * Represents a new concept added to the CPG. This is intended for modelling "concepts" like @@ -41,21 +36,3 @@ abstract class Concept() : OverlayNode() { /** All [Operation]s belonging to this concept. */ val ops: Set = setOf() } - -class OverlayEdge(start: Node, end: Node) : Edge(start, end) { - override var labels: Set = setOf("OVERLAY") -} - -class OverlaySingleEdge( - thisRef: Node, - of: Node?, - override var mirrorProperty: KProperty>, - outgoing: Boolean = true, -) : - EdgeSingletonList( - thisRef = thisRef, - init = ::OverlayEdge, - outgoing = outgoing, - of = of, - ), - MirroredEdgeCollection diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt new file mode 100644 index 0000000000..afe906da1c --- /dev/null +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edges/overlay/Overlay.kt @@ -0,0 +1,26 @@ +package de.fraunhofer.aisec.cpg.graph.edges.overlay + +import de.fraunhofer.aisec.cpg.graph.Node +import de.fraunhofer.aisec.cpg.graph.edges.Edge +import de.fraunhofer.aisec.cpg.graph.edges.collections.EdgeSingletonList +import de.fraunhofer.aisec.cpg.graph.edges.collections.MirroredEdgeCollection +import kotlin.reflect.KProperty + + +class OverlayEdge(start: Node, end: Node) : Edge(start, end) { + override var labels: Set = setOf("OVERLAY") +} + +class OverlaySingleEdge( + thisRef: Node, + of: Node?, + override var mirrorProperty: KProperty>, + outgoing: Boolean = true, +) : + EdgeSingletonList( + thisRef = thisRef, + init = ::OverlayEdge, + outgoing = outgoing, + of = of, + ), + MirroredEdgeCollection diff --git a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt index 27de1d802c..f6c6fc4b5d 100644 --- a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt +++ b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt @@ -77,6 +77,7 @@ class Neo4JTest { val connect = Connect(concept = nw) connect.underlyingNode = connectCall + connect.name = Name("connect") assertEquals(connect, connectCall?.overlayNode)