Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object Annotation extends SchemaBase {
|itself and not the ANNOTATION node.
|""".stripMargin
)
.protoId(5)
.protoId(ProtoIds.Annotation)
.addProperties(name, fullName)
.extendz(expression)

Expand All @@ -56,23 +56,23 @@ object Annotation extends SchemaBase {
name = "ANNOTATION_PARAMETER_ASSIGN",
comment = "Assignment of annotation argument to annotation parameter"
)
.protoId(6)
.protoId(ProtoIds.AnnotationParameterAssign)
.extendz(astNode)

val annotationParameter: NodeType = builder
.addNodeType(name = "ANNOTATION_PARAMETER", comment = "Formal annotation parameter")
.protoId(7)
.protoId(ProtoIds.AnnotationParameter)
.extendz(astNode)

val annotationLiteral: NodeType = builder
.addNodeType(name = "ANNOTATION_LITERAL", comment = "A literal value assigned to an ANNOTATION_PARAMETER")
.protoId(49)
.protoId(ProtoIds.AnnotationLiteral)
.addProperties(name)
.extendz(expression)

val arrayInitializer: NodeType = builder
.addNodeType(name = "ARRAY_INITIALIZER", comment = "Initialization construct for arrays")
.protoId(14)
.protoId(ProtoIds.ArrayInitializer)
.extendz(astNode)

arrayInitializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object Ast extends SchemaBase {
|""".stripMargin
)
.mandatory(-1)
.protoId(4)
.protoId(ProtoIds.Order)

val astNode = builder
.addNodeBaseType(
Expand Down Expand Up @@ -116,7 +116,7 @@ object Ast extends SchemaBase {
|"block expression") to describe what in the CPG we call "Block".
|""".stripMargin
)
.protoId(31)
.protoId(ProtoIds.Block)
.addProperties(typeFullName)

val literal: NodeType = builder
Expand All @@ -128,7 +128,7 @@ object Ast extends SchemaBase {
|e.g., `java.lang.Integer`.
|""".stripMargin
)
.protoId(8)
.protoId(ProtoIds.Literal)
.addProperties(typeFullName)
.primaryKey(code)

Expand All @@ -141,7 +141,7 @@ object Ast extends SchemaBase {
|`int x = 10;`, it contains `int x`.
|""".stripMargin
)
.protoId(23)
.protoId(ProtoIds.Local)
.addProperties(typeFullName)
.extendz(declaration, astNode)
.primaryKey(name)
Expand All @@ -154,7 +154,7 @@ object Ast extends SchemaBase {
|name in `TYPE_FULL_NAME`.
|""".stripMargin
)
.protoId(27)
.protoId(ProtoIds.Identifier)
.addProperties(typeFullName, name)
.primaryKey(name)

Expand All @@ -172,7 +172,7 @@ object Ast extends SchemaBase {
|""".stripMargin
)
.mandatory(PropertyDefaults.String)
.protoId(2001092)
.protoId(ProtoIds.CanonicalName)

val fieldIdentifier: NodeType = builder
.addNodeType(
Expand All @@ -189,7 +189,7 @@ object Ast extends SchemaBase {
|it.
|""".stripMargin
)
.protoId(2001081)
.protoId(ProtoIds.FieldIdentifier)
.addProperties(canonicalName)

val modifierType = builder
Expand All @@ -201,55 +201,55 @@ object Ast extends SchemaBase {
|""".stripMargin
)
.mandatory(PropertyDefaults.String)
.protoId(26)
.protoId(ProtoIds.ModifierType)

val modifierTypes = builder.addConstants(
category = "ModifierTypes",
Constant(name = "STATIC", value = "STATIC", valueType = ValueType.String, comment = "The static modifier")
.protoId(1),
.protoId(ProtoIds.Static),
Constant(name = "PUBLIC", value = "PUBLIC", valueType = ValueType.String, comment = "The public modifier")
.protoId(2),
.protoId(ProtoIds.Public),
Constant(
name = "PROTECTED",
value = "PROTECTED",
valueType = ValueType.String,
comment = "The protected modifier"
).protoId(3),
).protoId(ProtoIds.Protected),
Constant(name = "PRIVATE", value = "PRIVATE", valueType = ValueType.String, comment = "The private modifier")
.protoId(4),
.protoId(ProtoIds.Private),
Constant(name = "ABSTRACT", value = "ABSTRACT", valueType = ValueType.String, comment = "The abstract modifier")
.protoId(5),
.protoId(ProtoIds.Abstract),
Constant(name = "NATIVE", value = "NATIVE", valueType = ValueType.String, comment = "The native modifier")
.protoId(6),
.protoId(ProtoIds.Native),
Constant(
name = "CONSTRUCTOR",
value = "CONSTRUCTOR",
valueType = ValueType.String,
comment = "The constructor modifier"
).protoId(7),
).protoId(ProtoIds.Constructor),
Constant(name = "VIRTUAL", value = "VIRTUAL", valueType = ValueType.String, comment = "The virtual modifier")
.protoId(8),
.protoId(ProtoIds.Virtual),
Constant(name = "INTERNAL", value = "INTERNAL", valueType = ValueType.String, comment = "The internal modifier")
.protoId(9),
.protoId(ProtoIds.Internal),
Constant(name = "FINAL", value = "FINAL", valueType = ValueType.String, comment = "The final modifier")
.protoId(10),
.protoId(ProtoIds.Final),
Constant(name = "READONLY", value = "READONLY", valueType = ValueType.String, comment = "The readonly modifier")
.protoId(11),
.protoId(ProtoIds.ReadOnly),
Constant(
name = "MODULE",
value = "MODULE",
valueType = ValueType.String,
comment =
"Indicate that a method defines a module in the sense e.g. a python module does with the creation of a module object"
)
.protoId(12),
.protoId(ProtoIds.Module),
Constant(
name = "LAMBDA",
value = "LAMBDA",
valueType = ValueType.String,
comment = "Indicate that a method is an anonymous function, lambda, or closure"
)
.protoId(13)
.protoId(ProtoIds.Lambda)
)

val modifier: NodeType = builder
Expand All @@ -260,7 +260,7 @@ object Ast extends SchemaBase {
|cannot be evaluated and cannot be passed as an argument in function calls.
|""".stripMargin
)
.protoId(300)
.protoId(ProtoIds.Modifier)
.addProperties(modifierType)
.extendz(astNode)

Expand All @@ -273,7 +273,7 @@ object Ast extends SchemaBase {
|that this jump target is created from, e.g., "Label".
|""".stripMargin
)
.protoId(340)
.protoId(ProtoIds.JumpTarget)
.addProperties(name, parserTypeName)
.extendz(astNode)

Expand All @@ -286,7 +286,7 @@ object Ast extends SchemaBase {
|label is created from, e.g., "Label".
|""".stripMargin
)
.protoId(341)
.protoId(ProtoIds.JumpLabel)
.addProperties(name, parserTypeName)
.extendz(astNode)

Expand All @@ -299,12 +299,12 @@ object Ast extends SchemaBase {
|`TYPE_FULL_NAME` holds its fully-qualified type name.
|""".stripMargin
)
.protoId(333)
.protoId(ProtoIds.MethodRef)
.addProperties(typeFullName)

val typeRef: NodeType = builder
.addNodeType(name = "TYPE_REF", comment = "Reference to a type/class")
.protoId(335)
.protoId(ProtoIds.TypeRef)
.addProperties(typeFullName)

val ret: NodeType = builder
Expand All @@ -315,7 +315,7 @@ object Ast extends SchemaBase {
|represented via `METHOD_RETURN` nodes.
|""".stripMargin
)
.protoId(30)
.protoId(ProtoIds.Return)
.starterName("ret")
.primaryKey(code)

Expand All @@ -329,7 +329,7 @@ object Ast extends SchemaBase {
|""".stripMargin
)
.mandatory(PropertyDefaults.String)
.protoId(27)
.protoId(ProtoIds.ControlStructureType)

val controlStructureTypes = builder.addConstants(
category = "ControlStructureTypes",
Expand All @@ -339,49 +339,49 @@ object Ast extends SchemaBase {
valueType = ValueType.String,
comment = """Represents a break statement. Labeled breaks are expected to have a JUMP_LABEL
|node AST child with ORDER 1""".stripMargin
).protoId(1),
).protoId(ProtoIds.Break),
Constant(
name = "CONTINUE",
value = "CONTINUE",
valueType = ValueType.String,
comment = """Represents a continue statement. Labeled continues are expected to have a JUMP_LABEL
|node AST child with ORDER 1""".stripMargin
).protoId(2),
).protoId(ProtoIds.Continue),
Constant(name = "WHILE", value = "WHILE", valueType = ValueType.String, comment = "Represents a while statement")
.protoId(3),
.protoId(ProtoIds.While),
Constant(name = "DO", value = "DO", valueType = ValueType.String, comment = "Represents a do statement")
.protoId(4),
.protoId(ProtoIds.Do),
Constant(name = "FOR", value = "FOR", valueType = ValueType.String, comment = "Represents a for statement")
.protoId(5),
.protoId(ProtoIds.For),
Constant(name = "GOTO", value = "GOTO", valueType = ValueType.String, comment = "Represents a goto statement")
.protoId(6),
.protoId(ProtoIds.Goto),
Constant(name = "IF", value = "IF", valueType = ValueType.String, comment = "Represents an if statement")
.protoId(7),
.protoId(ProtoIds.If),
Constant(name = "ELSE", value = "ELSE", valueType = ValueType.String, comment = "Represents an else statement")
.protoId(8),
.protoId(ProtoIds.Else),
Constant(
name = "SWITCH",
value = "SWITCH",
valueType = ValueType.String,
comment = "Represents a switch statement"
).protoId(9),
).protoId(ProtoIds.Switch),
Constant(name = "TRY", value = "TRY", valueType = ValueType.String, comment = "Represents a try statement")
.protoId(10),
.protoId(ProtoIds.Try),
Constant(name = "THROW", value = "THROW", valueType = ValueType.String, comment = "Represents a throw statement")
.protoId(11),
.protoId(ProtoIds.Throw),
Constant(name = "MATCH", value = "MATCH", valueType = ValueType.String, comment = "Represents a match expression")
.protoId(12),
.protoId(ProtoIds.Match),
Constant(name = "YIELD", value = "YIELD", valueType = ValueType.String, comment = "Represents a yield expression")
.protoId(13),
.protoId(ProtoIds.Yield),
Constant(name = "CATCH", value = "CATCH", valueType = ValueType.String, comment = "Represents a catch clause")
.protoId(14),
.protoId(ProtoIds.Catch),
Constant(
name = "FINALLY",
value = "FINALLY",
valueType = ValueType.String,
comment = "Represents a finally clause"
)
.protoId(15)
.protoId(ProtoIds.Finally)
)

val controlStructure: NodeType = builder
Expand All @@ -399,7 +399,7 @@ object Ast extends SchemaBase {
|for construction of the control flow layer.
|""".stripMargin
)
.protoId(339)
.protoId(ProtoIds.ControlStructure)
.addProperties(parserTypeName, controlStructureType)

val unknown: NodeType = builder
Expand All @@ -410,21 +410,21 @@ object Ast extends SchemaBase {
|included using a node of type `UNKNOWN`.
|""".stripMargin
)
.protoId(44)
.protoId(ProtoIds.Unknown)
.addProperties(parserTypeName, typeFullName)

// Edge types

val ast = builder
.addEdgeType(name = "AST", comment = "This edge connects a parent node to its child in the syntax tree.")
.protoId(3)
.protoId(ProtoIds.Ast)

val condition = builder
.addEdgeType(
name = "CONDITION",
comment = "The edge connects control structure nodes to the expressions that holds their conditions."
)
.protoId(56)
.protoId(ProtoIds.Condition)

file.addOutEdge(edge = ast, inNode = namespaceBlock, cardinalityIn = Cardinality.ZeroOrOne)

Expand Down Expand Up @@ -578,7 +578,7 @@ object Ast extends SchemaBase {
|any information we may have about the types of arguments and return value.
|""".stripMargin
)
.protoId(15)
.protoId(ProtoIds.CallNode)
.extendz(callRepr)
.addProperties(typeFullName)
.primaryKey(name)
Expand Down
Loading