Skip to content

Commit 0c7f719

Browse files
Add the offset and offsetEnd property to all AST nodes (#1810)
* Add the offset and offsetEnd fields to all nodes * Generate code
1 parent 16241ee commit 0c7f719

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4297
-885
lines changed

Diff for: domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Cpg.scala

+13-20
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,6 @@ which language frontend was used to generate the CPG and the list property
374374
* `LINE_NUMBER_END`, and `COLUMN_NUMBER_END` and the name of the source file is specified in `FILENAME`. An optional
375375
* hash value MAY be calculated over the function contents and included in the `HASH` field.
376376
*
377-
* The optional `OFFSET` and `OFFSET_END` specify the start and exclusive end position of the code belonging to a
378-
* method within the corresponding `FILE` nodes `CONTENT` property.
379-
*
380377
* Finally, the fully qualified name of the program constructs that the method is immediately contained in is stored
381378
* in the `AST_PARENT_FULL_NAME` field and its type is indicated in the `AST_PARENT_TYPE` field to be one of
382379
* `METHOD`, `TYPE_DECL` or `NAMESPACE_BLOCK`.
@@ -399,10 +396,6 @@ Line and column number information is specified in the optional fields
399396
the name of the source file is specified in `FILENAME`. An optional hash value
400397
MAY be calculated over the function contents and included in the `HASH` field.
401398
402-
The optional `OFFSET` and `OFFSET_END` specify the start
403-
and exclusive end position of the code belonging to a method within the corresponding
404-
`FILE` nodes `CONTENT` property.
405-
406399
Finally, the fully qualified name of the program constructs that the method
407400
is immediately contained in is stored in the `AST_PARENT_FULL_NAME` field
408401
and its type is indicated in the `AST_PARENT_TYPE` field to be one of
@@ -576,9 +569,6 @@ to interpret the type argument. It MUST however store its code in the
576569
* fully-qualified name of a base type. If the type is known to be an alias of another type (as for example
577570
* introduced via the C `typedef` statement), the name of the alias is stored in `ALIAS_TYPE_FULL_NAME`.
578571
*
579-
* The optional `OFFSET` and `OFFSET_END` specify the start and exclusive end position of the code belonging to a
580-
* `TYPE_DECL` within the corresponding `FILE` nodes `CONTENT` property.
581-
*
582572
* Finally, the fully qualified name of the program constructs that the type declaration is immediately contained in
583573
* is stored in the `AST_PARENT_FULL_NAME` field and its type is indicated in the `AST_PARENT_TYPE` field to be one
584574
* of `METHOD`, `TYPE_DECL` or `NAMESPACE_BLOCK`.
@@ -604,10 +594,6 @@ each entry contains the fully-qualified name of a base type. If the type is
604594
known to be an alias of another type (as for example introduced via the C
605595
`typedef` statement), the name of the alias is stored in `ALIAS_TYPE_FULL_NAME`.
606596
607-
The optional `OFFSET` and `OFFSET_END` specify the start
608-
and exclusive end position of the code belonging to a `TYPE_DECL` within the corresponding
609-
`FILE` nodes `CONTENT` property.
610-
611597
Finally, the fully qualified name of the program constructs that the type declaration
612598
is immediately contained in is stored in the `AST_PARENT_FULL_NAME` field
613599
and its type is indicated in the `AST_PARENT_TYPE` field to be one of
@@ -649,11 +635,14 @@ included using a node of type `UNKNOWN`.""")
649635
* AST nodes contain optional `LINE_NUMBER` and `COLUMN_NUMBER` fields. For source-based frontends, these fields
650636
* contain the start line number and start column number of the code represented by the node. For machine-code-based
651637
* and bytecode-based frontends, `LINE_NUMBER` contains the address at which the code starts while `COLUMN_NUMBER` is
652-
* undefined. subtypes: ANNOTATION, ANNOTATION_LITERAL, ANNOTATION_PARAMETER, ANNOTATION_PARAMETER_ASSIGN,
653-
* ARRAY_INITIALIZER, BLOCK, CALL, COMMENT, CONTROL_STRUCTURE, FIELD_IDENTIFIER, FILE, IDENTIFIER, IMPORT,
654-
* JUMP_LABEL, JUMP_TARGET, LITERAL, LOCAL, MEMBER, METHOD, METHOD_PARAMETER_IN, METHOD_PARAMETER_OUT, METHOD_REF,
655-
* METHOD_RETURN, MODIFIER, NAMESPACE, NAMESPACE_BLOCK, RETURN, TEMPLATE_DOM, TYPE_ARGUMENT, TYPE_DECL,
656-
* TYPE_PARAMETER, TYPE_REF, UNKNOWN
638+
* undefined.
639+
*
640+
* The optional `OFFSET` and `OFFSET_END` specify the start and exclusive end position of the code belonging to a
641+
* node within the corresponding `FILE` nodes `CONTENT` property. subtypes: ANNOTATION, ANNOTATION_LITERAL,
642+
* ANNOTATION_PARAMETER, ANNOTATION_PARAMETER_ASSIGN, ARRAY_INITIALIZER, BLOCK, CALL, COMMENT, CONTROL_STRUCTURE,
643+
* FIELD_IDENTIFIER, FILE, IDENTIFIER, IMPORT, JUMP_LABEL, JUMP_TARGET, LITERAL, LOCAL, MEMBER, METHOD,
644+
* METHOD_PARAMETER_IN, METHOD_PARAMETER_OUT, METHOD_REF, METHOD_RETURN, MODIFIER, NAMESPACE, NAMESPACE_BLOCK,
645+
* RETURN, TEMPLATE_DOM, TYPE_ARGUMENT, TYPE_DECL, TYPE_PARAMETER, TYPE_REF, UNKNOWN
657646
*/
658647
@flatgraph.help.Doc(
659648
info = """This is the base type for all nodes of the abstract syntax tree (AST). An AST
@@ -666,7 +655,11 @@ AST nodes contain optional `LINE_NUMBER` and `COLUMN_NUMBER` fields. For
666655
source-based frontends, these fields contain the start line number and
667656
start column number of the code represented by the node.
668657
For machine-code-based and bytecode-based frontends, `LINE_NUMBER` contains
669-
the address at which the code starts while `COLUMN_NUMBER` is undefined.""",
658+
the address at which the code starts while `COLUMN_NUMBER` is undefined.
659+
660+
The optional `OFFSET` and `OFFSET_END` specify the start
661+
and exclusive end position of the code belonging to a node within the corresponding
662+
`FILE` nodes `CONTENT` property.""",
670663
longInfo =
671664
"""subtypes: ANNOTATION, ANNOTATION_LITERAL, ANNOTATION_PARAMETER, ANNOTATION_PARAMETER_ASSIGN, ARRAY_INITIALIZER, BLOCK, CALL, COMMENT, CONTROL_STRUCTURE, FIELD_IDENTIFIER, FILE, IDENTIFIER, IMPORT, JUMP_LABEL, JUMP_TARGET, LITERAL, LOCAL, MEMBER, METHOD, METHOD_PARAMETER_IN, METHOD_PARAMETER_OUT, METHOD_REF, METHOD_RETURN, MODIFIER, NAMESPACE, NAMESPACE_BLOCK, RETURN, TEMPLATE_DOM, TYPE_ARGUMENT, TYPE_DECL, TYPE_PARAMETER, TYPE_REF, UNKNOWN"""
672665
)

0 commit comments

Comments
 (0)