From d206de25f9c044b9edc4a4f1ad3d09047093cbd9 Mon Sep 17 00:00:00 2001 From: Markus Lottmann Date: Fri, 21 Jul 2023 11:26:38 +0200 Subject: [PATCH] Allow tags to tag other tags. (#1723) --- .../generated/nodes/Tag.scala | 28 +++++++++++++++---- .../schema/TagsAndLocation.scala | 3 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/Tag.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/Tag.scala index 9bd22df3c..f3b29a39d 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/Tag.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/Tag.scala @@ -29,12 +29,12 @@ object Tag { val layoutInformation = new NodeLayoutInformation( Label, PropertyNames.allAsJava, - List().asJava, + List(io.shiftleft.codepropertygraph.generated.edges.TaggedBy.layoutInformation).asJava, List(io.shiftleft.codepropertygraph.generated.edges.TaggedBy.layoutInformation).asJava ) object Edges { - val Out: Array[String] = Array() + val Out: Array[String] = Array("TAGGED_BY") val In: Array[String] = Array("TAGGED_BY") } @@ -69,8 +69,15 @@ class Tag(graph_4762: Graph, id_4762: Long /*cf https://github.com/scala/bug/iss case _ => super.propertyDefaultValue(propertyKey) } - def taggedByIn: Iterator[AstNode] = get().taggedByIn - override def _taggedByIn = get()._taggedByIn + def taggedByOut: Iterator[Tag] = get().taggedByOut + override def _taggedByOut = get()._taggedByOut + + /** Traverse to TAG via TAGGED_BY OUT edge. + */ + def _tagViaTaggedByOut: overflowdb.traversal.Traversal[Tag] = get()._tagViaTaggedByOut + + def taggedByIn: Iterator[StoredNode] = get().taggedByIn + override def _taggedByIn = get()._taggedByIn /** Traverse to BLOCK via TAGGED_BY IN edge. */ @@ -144,6 +151,10 @@ class Tag(graph_4762: Graph, id_4762: Long /*cf https://github.com/scala/bug/iss */ def _returnViaTaggedByIn: overflowdb.traversal.Traversal[Return] = get()._returnViaTaggedByIn + /** Traverse to TAG via TAGGED_BY IN edge. + */ + def _tagViaTaggedByIn: overflowdb.traversal.Traversal[Tag] = get()._tagViaTaggedByIn + /** Traverse to TEMPLATE_DOM via TAGGED_BY IN edge. */ def _templateDomViaTaggedByIn: overflowdb.traversal.Traversal[TemplateDom] = get()._templateDomViaTaggedByIn @@ -218,8 +229,12 @@ class TagDb(ref: NodeRef[NodeDb]) extends NodeDb(ref) with StoredNode with TagBa } import overflowdb.traversal._ - def taggedByIn: Iterator[AstNode] = createAdjacentNodeScalaIteratorByOffSet[AstNode](0) - override def _taggedByIn = createAdjacentNodeScalaIteratorByOffSet[StoredNode](0) + def taggedByOut: Iterator[Tag] = createAdjacentNodeScalaIteratorByOffSet[Tag](0) + override def _taggedByOut = createAdjacentNodeScalaIteratorByOffSet[StoredNode](0) + def _tagViaTaggedByOut: overflowdb.traversal.Traversal[Tag] = taggedByOut.collectAll[Tag] + + def taggedByIn: Iterator[StoredNode] = createAdjacentNodeScalaIteratorByOffSet[StoredNode](1) + override def _taggedByIn = createAdjacentNodeScalaIteratorByOffSet[StoredNode](1) def _blockViaTaggedByIn: overflowdb.traversal.Traversal[Block] = taggedByIn.collectAll[Block] def _callViaTaggedByIn: overflowdb.traversal.Traversal[Call] = taggedByIn.collectAll[Call] def _controlStructureViaTaggedByIn: overflowdb.traversal.Traversal[ControlStructure] = @@ -241,6 +256,7 @@ class TagDb(ref: NodeRef[NodeDb]) extends NodeDb(ref) with StoredNode with TagBa def _methodRefViaTaggedByIn: overflowdb.traversal.Traversal[MethodRef] = taggedByIn.collectAll[MethodRef] def _methodReturnViaTaggedByIn: overflowdb.traversal.Traversal[MethodReturn] = taggedByIn.collectAll[MethodReturn] def _returnViaTaggedByIn: overflowdb.traversal.Traversal[Return] = taggedByIn.collectAll[Return] + def _tagViaTaggedByIn: overflowdb.traversal.Traversal[Tag] = taggedByIn.collectAll[Tag] def _templateDomViaTaggedByIn: overflowdb.traversal.Traversal[TemplateDom] = taggedByIn.collectAll[TemplateDom] def _typeRefViaTaggedByIn: overflowdb.traversal.Traversal[TypeRef] = taggedByIn.collectAll[TypeRef] def _unknownViaTaggedByIn: overflowdb.traversal.Traversal[Unknown] = taggedByIn.collectAll[Unknown] diff --git a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/TagsAndLocation.scala b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/TagsAndLocation.scala index 48897ba90..158eeaa4a 100644 --- a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/TagsAndLocation.scala +++ b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/TagsAndLocation.scala @@ -132,7 +132,8 @@ object TagsAndLocation extends SchemaBase { typeRef, jumpTarget, file, - methodParameterOut + methodParameterOut, + tag ).foreach(_.addOutEdge(edge = taggedBy, inNode = tag)) }