Skip to content

Commit b0faab4

Browse files
authored
Add a new MODULE modifier. (#1745)
* Add a new MODULE modifier. This new MODULE modifier is to be used for methods which define a module in sense of Python or Javascript where a module method creates a module object. * Rebase and generate domain classes again.
1 parent a07c942 commit b0faab4

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/ModifierTypes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class ModifierTypes {
4141
/** The readonly modifier */
4242
public static final String READONLY = "READONLY";
4343

44+
/** Indicate that a method defines a module in the sense e.g. a python module does with the creation of a module object */
45+
public static final String MODULE = "MODULE";
46+
4447

4548
public static Set<String> ALL = new HashSet<String>() {{
4649
add(STATIC);
@@ -54,6 +57,7 @@ public class ModifierTypes {
5457
add(INTERNAL);
5558
add(FINAL);
5659
add(READONLY);
60+
add(MODULE);
5761
}};
5862

5963
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ClosureBinding.scala

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ class ClosureBinding(graph_4762: Graph, id_4762: Long /*cf https://github.com/sc
7979

8080
/** Traverse to LOCAL via REF OUT edge.
8181
*/
82-
def _localViaRefOut: Local = get()._localViaRefOut
82+
def _localViaRefOut: Option[Local] = get()._localViaRefOut
8383

8484
/** Traverse to METHOD_PARAMETER_IN via REF OUT edge.
8585
*/
86-
def _methodParameterInViaRefOut: overflowdb.traversal.Traversal[MethodParameterIn] = get()._methodParameterInViaRefOut
86+
def _methodParameterInViaRefOut: Option[MethodParameterIn] = get()._methodParameterInViaRefOut
8787

8888
def captureIn: Iterator[Expression] = get().captureIn
8989
override def _captureIn = get()._captureIn
@@ -176,18 +176,10 @@ class ClosureBindingDb(ref: NodeRef[NodeDb]) extends NodeDb(ref) with StoredNode
176176
}
177177

178178
import overflowdb.traversal._
179-
def refOut: Iterator[AstNode] = createAdjacentNodeScalaIteratorByOffSet[AstNode](0)
180-
override def _refOut = createAdjacentNodeScalaIteratorByOffSet[StoredNode](0)
181-
def _localViaRefOut: Local = try { refOut.collectAll[Local].next() }
182-
catch {
183-
case e: java.util.NoSuchElementException =>
184-
throw new overflowdb.SchemaViolationException(
185-
"OUT edge with label REF to an adjacent LOCAL is mandatory, but not defined for this CLOSURE_BINDING node with id=" + id,
186-
e
187-
)
188-
}
189-
def _methodParameterInViaRefOut: overflowdb.traversal.Traversal[MethodParameterIn] =
190-
refOut.collectAll[MethodParameterIn]
179+
def refOut: Iterator[AstNode] = createAdjacentNodeScalaIteratorByOffSet[AstNode](0)
180+
override def _refOut = createAdjacentNodeScalaIteratorByOffSet[StoredNode](0)
181+
def _localViaRefOut: Option[Local] = refOut.collectAll[Local].nextOption()
182+
def _methodParameterInViaRefOut: Option[MethodParameterIn] = refOut.collectAll[MethodParameterIn].nextOption()
191183

192184
def captureIn: Iterator[Expression] = createAdjacentNodeScalaIteratorByOffSet[Expression](1)
193185
override def _captureIn = createAdjacentNodeScalaIteratorByOffSet[StoredNode](1)

schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Ast.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,15 @@ object Ast extends SchemaBase {
231231
Constant(name = "FINAL", value = "FINAL", valueType = ValueType.String, comment = "The final modifier")
232232
.protoId(10),
233233
Constant(name = "READONLY", value = "READONLY", valueType = ValueType.String, comment = "The readonly modifier")
234-
.protoId(11)
234+
.protoId(11),
235+
Constant(
236+
name = "MODULE",
237+
value = "MODULE",
238+
valueType = ValueType.String,
239+
comment =
240+
"Indicate that a method defines a module in the sense e.g. a python module does with the creation of a module object"
241+
)
242+
.protoId(12)
235243
)
236244

237245
val modifier: NodeType = builder

0 commit comments

Comments
 (0)