Java: PrintAst: Add tests

This commit is contained in:
Joe
2020-09-11 16:42:51 +01:00
parent b73e7d8390
commit e38b583ec4
40 changed files with 1270 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/**
* @name Print AST
* @description Outputs a representation of the Abstract Syntax Tree.
* @id csharp/print-ast
* @kind graph
*/
import java
import PrintAst
/**
* Temporarily tweak this class or make a copy to control which functions are
* printed.
*/
class PrintAstConfigurationOverride extends PrintAstConfiguration {
/**
* TWEAK THIS PREDICATE AS NEEDED.
*/
override predicate shouldPrint(Element e, Location l) { super.shouldPrint(e, l) }
}

View File

@@ -0,0 +1,62 @@
jdk/A.java:
# 0| [CompilationUnit] A
# 3| 1: [Class] A
# 4| 2: [Method] main
# 4| 3: [TypeAccess] void
# 4| 4: (Parameters)
# 4| 0: [Parameter] args
# 4| 0: [ArrayTypeAccess] ...[]
# 4| 0: [TypeAccess] String
# 4| 5: [BlockStmt] stmt
# 7| 2: [Class] B
# 8| 2: [Method] main
# 8| 3: [TypeAccess] void
# 8| 4: (Parameters)
# 8| 0: [Parameter] args
# 8| 0: [ArrayTypeAccess] ...[]
# 8| 0: [TypeAccess] String
# 8| 5: [BlockStmt] stmt
# 11| 3: [Class] C
# 12| 2: [Method] main
# 12| 3: [TypeAccess] void
# 12| 4: (Parameters)
# 12| 0: [Parameter] args
# 12| 0: [ArrayTypeAccess] ...[]
# 12| 0: [TypeAccess] String
# 12| 5: [BlockStmt] stmt
# 15| 4: [Class] D
# 16| 2: [Method] main
# 16| 3: [TypeAccess] int
# 16| 4: (Parameters)
# 16| 0: [Parameter] args
# 16| 0: [ArrayTypeAccess] ...[]
# 16| 0: [TypeAccess] String
# 16| 5: [BlockStmt] stmt
# 16| 0: [ReturnStmt] stmt
# 16| 0: [IntegerLiteral] 0
# 19| 5: [Class] E
# 20| 2: [Method] main
# 20| 3: [TypeAccess] void
# 20| 4: (Parameters)
# 20| 0: [Parameter] argc
# 20| 0: [TypeAccess] int
# 20| 1: [Parameter] args
# 20| 0: [ArrayTypeAccess] ...[]
# 20| 0: [TypeAccess] String
# 20| 5: [BlockStmt] stmt
# 23| 6: [Class] F
# 24| 2: [Method] main
# 24| 3: [TypeAccess] void
# 24| 4: (Parameters)
# 24| 0: [Parameter] arg
# 24| 0: [TypeAccess] String
# 24| 5: [BlockStmt] stmt
# 27| 7: [Class] G
# 28| 2: [Method] main
# 28| 3: [TypeAccess] void
# 28| 4: (Parameters)
# 28| 0: [Parameter] args
# 28| 0: [ArrayTypeAccess] ...[]
# 28| 0: [ArrayTypeAccess] ...[]
# 28| 0: [TypeAccess] String
# 28| 5: [BlockStmt] stmt

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,52 @@
arrays/A.java:
# 0| [CompilationUnit] A
# 3| 1: [Class] A
# 4| 2: [FieldDeclaration] ...[] a, ...;
# 4| -1: [ArrayTypeAccess] ...[]
# 4| 0: [TypeAccess] String
# 5| 3: [FieldDeclaration] ...[] b, ...;
# 5| -1: [ArrayTypeAccess] ...[]
# 5| 0: [ArrayTypeAccess] ...[]
# 5| 0: [TypeAccess] String
arrays/B.java:
# 0| [CompilationUnit] B
# 3| 1: [Class] B
# 4| 2: [Method] m
# 4| 3: [TypeAccess] void
# 4| 4: (Parameters)
# 4| 0: [Parameter] a
# 4| 0: [TypeAccess] A
# 4| 5: [BlockStmt] stmt
# 5| 0: [LocalVariableDeclStmt] stmt
# 5| 0: [ArrayTypeAccess] ...[]
# 5| 0: [TypeAccess] A
# 5| 1: [LocalVariableDeclExpr] aa
# 5| 0: [ArrayCreationExpr] new A[]
# 5| -2: [ArrayInit] {...}
# 5| 0: [VarAccess] a
# 5| -1: [TypeAccess] A
# 6| 1: [LocalVariableDeclStmt] stmt
# 6| 0: [ArrayTypeAccess] ...[]
# 6| 0: [ArrayTypeAccess] ...[]
# 6| 0: [TypeAccess] A
# 6| 1: [LocalVariableDeclExpr] aaa
# 6| 0: [ArrayCreationExpr] new A[][]
# 6| -2: [ArrayInit] {...}
# 6| 0: [ArrayInit] {...}
# 6| 0: [VarAccess] a
# 6| -1: [ArrayTypeAccess] ...[]
# 6| 0: [TypeAccess] A
# 7| 2: [LocalVariableDeclStmt] stmt
# 7| 0: [ArrayTypeAccess] ...[]
# 7| 0: [ArrayTypeAccess] ...[]
# 7| 0: [ArrayTypeAccess] ...[]
# 7| 0: [TypeAccess] A
# 7| 1: [LocalVariableDeclExpr] aaaa
# 7| 0: [ArrayCreationExpr] new A[][][]
# 7| -2: [ArrayInit] {...}
# 7| 0: [ArrayInit] {...}
# 7| 0: [ArrayInit] {...}
# 7| 0: [VarAccess] a
# 7| -1: [ArrayTypeAccess] ...[]
# 7| 0: [ArrayTypeAccess] ...[]
# 7| 0: [TypeAccess] A

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,18 @@
collections/Test.java:
# 0| [CompilationUnit] Test
# 3| 1: [ImportOnDemandFromPackage] import java.util.*
# 5| 2: [Class] Test
# 6| 3: [FieldDeclaration] Map<String,Integer> m, ...;
# 6| -1: [TypeAccess] Map<String,Integer>
# 6| 0: [TypeAccess] String
# 6| 1: [TypeAccess] Integer
# 6| 0: [ClassInstanceExpr] new LinkedHashMap<String,Integer>(...)
# 6| -3: [TypeAccess] LinkedHashMap<String,Integer>
# 6| 0: [TypeAccess] String
# 6| 1: [TypeAccess] Integer
# 8| 4: [BlockStmt] stmt
# 9| 0: [ExprStmt] stmt
# 9| 0: [MethodAccess] put(...)
# 9| -1: [VarAccess] m
# 9| 0: [StringLiteral] "key"
# 9| 1: [IntegerLiteral] 23

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,28 @@
Test.java:
# 0| [CompilationUnit] Test
# 5| 1: [Class] Test
# 1| -4: [Javadoc] /** A JavaDoc comment ... */
# 2| 0: [JavadocText] A JavaDoc comment
# 3| 1: [JavadocText] with multiple lines.
# 7| 2: [Method] m
# 6| 0: [Javadoc] /** A JavaDoc comment with a single line. */
# 6| 0: [JavadocText] A JavaDoc comment with a single line.
# 7| 3: [TypeAccess] void
# 7| 5: [BlockStmt] stmt
# 21| 3: [Method] test
# 21| 3: [TypeAccess] void
# 21| 5: [BlockStmt] stmt
TestWindows.java:
# 0| [CompilationUnit] TestWindows
# 5| 1: [Class] TestWindows
# 1| -4: [Javadoc] /** A JavaDoc comment ... */
# 2| 0: [JavadocText] A JavaDoc comment
# 3| 1: [JavadocText] with multiple lines.
# 7| 2: [Method] m
# 6| 0: [Javadoc] /** A JavaDoc comment with a single line. */
# 6| 0: [JavadocText] A JavaDoc comment with a single line.
# 7| 3: [TypeAccess] void
# 7| 5: [BlockStmt] stmt
# 21| 3: [Method] test
# 21| 3: [TypeAccess] void
# 21| 5: [BlockStmt] stmt

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,516 @@
constants/Constants.java:
# 0| [CompilationUnit] Constants
# 3| 1: [Class] Constants
# 4| 2: [Method] constants
# 4| 3: [TypeAccess] void
# 4| 4: (Parameters)
# 4| 0: [Parameter] notConstant
# 4| 0: [TypeAccess] int
# 4| 5: [BlockStmt] stmt
# 5| 0: [LocalVariableDeclStmt] stmt
# 5| 0: [TypeAccess] int
# 5| 1: [LocalVariableDeclExpr] sfield
# 5| 0: [VarAccess] Initializers.SFIELD
# 5| -1: [TypeAccess] Initializers
# 6| 1: [LocalVariableDeclStmt] stmt
# 6| 0: [TypeAccess] int
# 6| 1: [LocalVariableDeclExpr] ifield
# 6| 0: [VarAccess] new Initializers(...).IFIELD
# 6| -1: [ClassInstanceExpr] new Initializers(...)
# 6| -3: [TypeAccess] Initializers
# 9| 2: [LocalVariableDeclStmt] stmt
# 9| 0: [TypeAccess] Object
# 9| 1: [LocalVariableDeclExpr] staticObjectField
# 9| 0: [VarAccess] Initializers.SFIELD_OBJECT
# 9| -1: [TypeAccess] Initializers
# 11| 3: [LocalVariableDeclStmt] stmt
# 11| 0: [TypeAccess] int
# 11| 1: [LocalVariableDeclExpr] x
# 11| 0: [IntegerLiteral] 3
# 12| 4: [LocalVariableDeclStmt] stmt
# 12| 0: [TypeAccess] int
# 12| 1: [LocalVariableDeclExpr] y
# 12| 0: [VarAccess] x
# 13| 5: [LocalVariableDeclStmt] stmt
# 13| 0: [TypeAccess] int
# 13| 1: [LocalVariableDeclExpr] z
# 13| 0: [VarAccess] y
# 15| 6: [LocalVariableDeclStmt] stmt
# 15| 0: [TypeAccess] int
# 15| 1: [LocalVariableDeclExpr] binop
# 15| 0: [AddExpr] ... + ...
# 15| 0: [VarAccess] Initializers.SFIELD
# 15| -1: [TypeAccess] Initializers
# 15| 1: [IntegerLiteral] 1
# 16| 7: [LocalVariableDeclStmt] stmt
# 16| 0: [TypeAccess] int
# 16| 1: [LocalVariableDeclExpr] binopNonConst
# 16| 0: [AddExpr] ... + ...
# 16| 0: [VarAccess] Initializers.SFIELD
# 16| -1: [TypeAccess] Initializers
# 16| 1: [VarAccess] notConstant
# 18| 8: [LocalVariableDeclStmt] stmt
# 18| 0: [TypeAccess] int
# 18| 1: [LocalVariableDeclExpr] paren
# 18| 0: [IntegerLiteral] 12
# 19| 9: [LocalVariableDeclStmt] stmt
# 19| 0: [TypeAccess] String
# 19| 1: [LocalVariableDeclExpr] string
# 19| 0: [StringLiteral] "a string"
# 20| 10: [LocalVariableDeclStmt] stmt
# 20| 0: [TypeAccess] int
# 20| 1: [LocalVariableDeclExpr] ternary
# 20| 0: [ConditionalExpr] ...?...:...
# 20| 0: [LTExpr] ... < ...
# 20| 0: [IntegerLiteral] 3
# 20| 1: [IntegerLiteral] 5
# 20| 1: [IntegerLiteral] 1
# 20| 2: [IntegerLiteral] 2
# 22| 11: [ReturnStmt] stmt
constants/Initializers.java:
# 0| [CompilationUnit] Initializers
# 3| 1: [Class] Initializers
# 4| 3: [FieldDeclaration] int SFIELD, ...;
# 4| -1: [TypeAccess] int
# 4| 0: [IntegerLiteral] 12
# 6| 4: [FieldDeclaration] int IFIELD, ...;
# 6| -1: [TypeAccess] int
# 6| 0: [IntegerLiteral] 20
# 8| 5: [FieldDeclaration] int IFIELD2, ...;
# 8| -1: [TypeAccess] int
# 10| 6: [Constructor] Initializers
# 10| 5: [BlockStmt] stmt
# 10| 0: [SuperConstructorInvocationStmt] super(...)
# 10| 1: [ExprStmt] stmt
# 10| 0: [MethodAccess] <obinit>(...)
# 12| 2: [ExprStmt] stmt
# 12| 0: [AssignExpr] ...=...
# 12| 0: [VarAccess] IFIELD2
# 12| 1: [IntegerLiteral] 22
# 15| 7: [Method] stuff
# 15| 3: [TypeAccess] void
# 15| 5: [BlockStmt] stmt
# 16| 0: [LocalVariableDeclStmt] stmt
# 16| 0: [TypeAccess] int
# 16| 1: [LocalVariableDeclExpr] x
# 16| 0: [IntegerLiteral] 300
# 17| 1: [LocalVariableDeclStmt] stmt
# 17| 0: [TypeAccess] int
# 17| 1: [LocalVariableDeclExpr] y
# 18| 2: [ExprStmt] stmt
# 18| 0: [AssignExpr] ...=...
# 18| 0: [VarAccess] y
# 18| 1: [IntegerLiteral] 400
# 21| 8: [FieldDeclaration] Object SFIELD_OBJECT, ...;
# 21| -1: [TypeAccess] Object
# 21| 0: [StringLiteral] "a string"
# 23| 9: [FieldDeclaration] int fsf, ...;
# 23| -1: [TypeAccess] int
# 24| 10: [FieldDeclaration] int sf, ...;
# 24| -1: [TypeAccess] int
# 24| 0: [IntegerLiteral] 3
# 25| 11: [FieldDeclaration] int ff, ...;
# 25| -1: [TypeAccess] int
# 26| 12: [FieldDeclaration] int f, ...;
# 26| -1: [TypeAccess] int
# 26| 0: [IntegerLiteral] 4
# 28| 13: [BlockStmt] stmt
# 30| 0: [ExprStmt] stmt
# 30| 0: [AssignExpr] ...=...
# 30| 0: [VarAccess] fsf
# 30| 1: [IntegerLiteral] 42
# 31| 1: [ExprStmt] stmt
# 31| 0: [AssignExpr] ...=...
# 31| 0: [VarAccess] sf
# 31| 1: [IntegerLiteral] 42
# 34| 14: [BlockStmt] stmt
# 36| 0: [ExprStmt] stmt
# 36| 0: [AssignExpr] ...=...
# 36| 0: [VarAccess] ff
# 36| 1: [IntegerLiteral] 42
# 37| 1: [ExprStmt] stmt
# 37| 0: [AssignExpr] ...=...
# 37| 0: [VarAccess] f
# 37| 1: [IntegerLiteral] 42
constants/Values.java:
# 0| [CompilationUnit] Values
# 4| 1: [Class] Values
# 3| -4: [Javadoc] /** Tests of the getIntValue() predicate */
# 3| 0: [JavadocText] Tests of the getIntValue() predicate
# 6| 3: [FieldDeclaration] int final_field, ...;
# 6| -1: [TypeAccess] int
# 6| 0: [IntegerLiteral] 42
# 8| 4: [Method] values
# 8| 3: [TypeAccess] void
# 8| 4: (Parameters)
# 8| 0: [Parameter] notConstant
# 8| 0: [TypeAccess] int
# 8| 5: [BlockStmt] stmt
# 9| 0: [LocalVariableDeclStmt] stmt
# 9| 0: [TypeAccess] int
# 9| 1: [LocalVariableDeclExpr] int_literal
# 9| 0: [IntegerLiteral] 42
# 10| 1: [LocalVariableDeclStmt] stmt
# 10| 0: [TypeAccess] int
# 10| 1: [LocalVariableDeclExpr] negative_int_literal
# 10| 0: [IntegerLiteral] -2147483648
# 11| 2: [LocalVariableDeclStmt] stmt
# 11| 0: [TypeAccess] int
# 11| 1: [LocalVariableDeclExpr] octal_literal
# 11| 0: [IntegerLiteral] 052
# 12| 3: [LocalVariableDeclStmt] stmt
# 12| 0: [TypeAccess] int
# 12| 1: [LocalVariableDeclExpr] negative_octal_literal
# 12| 0: [MinusExpr] -...
# 12| 0: [IntegerLiteral] 052
# 13| 4: [LocalVariableDeclStmt] stmt
# 13| 0: [TypeAccess] int
# 13| 1: [LocalVariableDeclExpr] hex_literal
# 13| 0: [IntegerLiteral] 0x2A
# 14| 5: [LocalVariableDeclStmt] stmt
# 14| 0: [TypeAccess] int
# 14| 1: [LocalVariableDeclExpr] negative_hex_literal
# 14| 0: [MinusExpr] -...
# 14| 0: [IntegerLiteral] 0x2A
# 15| 6: [LocalVariableDeclStmt] stmt
# 15| 0: [TypeAccess] int
# 15| 1: [LocalVariableDeclExpr] hex_literal_underscores
# 15| 0: [IntegerLiteral] 0x2_A
# 16| 7: [LocalVariableDeclStmt] stmt
# 16| 0: [TypeAccess] int
# 16| 1: [LocalVariableDeclExpr] binary_literal
# 16| 0: [IntegerLiteral] 0b101010
# 17| 8: [LocalVariableDeclStmt] stmt
# 17| 0: [TypeAccess] int
# 17| 1: [LocalVariableDeclExpr] negative_binary_literal
# 17| 0: [MinusExpr] -...
# 17| 0: [IntegerLiteral] 0b101010
# 18| 9: [LocalVariableDeclStmt] stmt
# 18| 0: [TypeAccess] int
# 18| 1: [LocalVariableDeclExpr] binary_literal_underscores
# 18| 0: [IntegerLiteral] 0b1_0101_0
# 19| 10: [LocalVariableDeclStmt] stmt
# 19| 0: [TypeAccess] char
# 19| 1: [LocalVariableDeclExpr] char_literal
# 19| 0: [CharacterLiteral] '*'
# 20| 11: [LocalVariableDeclStmt] stmt
# 20| 0: [TypeAccess] long
# 20| 1: [LocalVariableDeclExpr] long_literal
# 20| 0: [LongLiteral] 42L
# 21| 12: [LocalVariableDeclStmt] stmt
# 21| 0: [TypeAccess] boolean
# 21| 1: [LocalVariableDeclExpr] boolean_literal
# 21| 0: [BooleanLiteral] true
# 22| 13: [LocalVariableDeclStmt] stmt
# 22| 0: [TypeAccess] Integer
# 22| 1: [LocalVariableDeclExpr] boxed_int
# 22| 0: [ClassInstanceExpr] new Integer(...)
# 22| -3: [TypeAccess] Integer
# 22| 0: [IntegerLiteral] 42
# 23| 14: [LocalVariableDeclStmt] stmt
# 23| 0: [TypeAccess] int
# 23| 1: [LocalVariableDeclExpr] parameter
# 23| 0: [VarAccess] notConstant
# 25| 15: [LocalVariableDeclStmt] stmt
# 25| 0: [TypeAccess] int
# 25| 1: [LocalVariableDeclExpr] cast
# 25| 0: [CastExpr] (...)...
# 25| 0: [TypeAccess] int
# 25| 1: [IntegerLiteral] 42
# 26| 16: [LocalVariableDeclStmt] stmt
# 26| 0: [TypeAccess] char
# 26| 1: [LocalVariableDeclExpr] downcast
# 26| 0: [CastExpr] (...)...
# 26| 0: [TypeAccess] char
# 26| 1: [IntegerLiteral] 42
# 27| 17: [LocalVariableDeclStmt] stmt
# 27| 0: [TypeAccess] byte
# 27| 1: [LocalVariableDeclExpr] downcast_byte_1
# 27| 0: [CastExpr] (...)...
# 27| 0: [TypeAccess] byte
# 27| 1: [MinusExpr] -...
# 27| 0: [IntegerLiteral] 42
# 28| 18: [LocalVariableDeclStmt] stmt
# 28| 0: [TypeAccess] byte
# 28| 1: [LocalVariableDeclExpr] downcast_byte_2
# 28| 0: [CastExpr] (...)...
# 28| 0: [TypeAccess] byte
# 28| 1: [IntegerLiteral] 42
# 29| 19: [LocalVariableDeclStmt] stmt
# 29| 0: [TypeAccess] byte
# 29| 1: [LocalVariableDeclExpr] downcast_byte_3
# 29| 0: [CastExpr] (...)...
# 29| 0: [TypeAccess] byte
# 29| 1: [IntegerLiteral] 298
# 30| 20: [LocalVariableDeclStmt] stmt
# 30| 0: [TypeAccess] byte
# 30| 1: [LocalVariableDeclExpr] downcast_byte_4
# 30| 0: [CastExpr] (...)...
# 30| 0: [TypeAccess] byte
# 30| 1: [IntegerLiteral] 214
# 31| 21: [LocalVariableDeclStmt] stmt
# 31| 0: [TypeAccess] byte
# 31| 1: [LocalVariableDeclExpr] downcast_byte_5
# 31| 0: [CastExpr] (...)...
# 31| 0: [TypeAccess] byte
# 31| 1: [MinusExpr] -...
# 31| 0: [IntegerLiteral] 214
# 32| 22: [LocalVariableDeclStmt] stmt
# 32| 0: [TypeAccess] short
# 32| 1: [LocalVariableDeclExpr] downcast_short
# 32| 0: [CastExpr] (...)...
# 32| 0: [TypeAccess] short
# 32| 1: [IntegerLiteral] 32768
# 33| 23: [LocalVariableDeclStmt] stmt
# 33| 0: [TypeAccess] int
# 33| 1: [LocalVariableDeclExpr] cast_of_non_constant
# 33| 0: [CastExpr] (...)...
# 33| 0: [TypeAccess] int
# 33| 1: [CharacterLiteral] '*'
# 34| 24: [LocalVariableDeclStmt] stmt
# 34| 0: [TypeAccess] long
# 34| 1: [LocalVariableDeclExpr] cast_to_long
# 34| 0: [CastExpr] (...)...
# 34| 0: [TypeAccess] long
# 34| 1: [IntegerLiteral] 42
# 36| 25: [LocalVariableDeclStmt] stmt
# 36| 0: [TypeAccess] int
# 36| 1: [LocalVariableDeclExpr] unary_plus
# 36| 0: [PlusExpr] +...
# 36| 0: [IntegerLiteral] 42
# 37| 26: [LocalVariableDeclStmt] stmt
# 37| 0: [TypeAccess] int
# 37| 1: [LocalVariableDeclExpr] parameter_plus
# 37| 0: [PlusExpr] +...
# 37| 0: [VarAccess] notConstant
# 39| 27: [LocalVariableDeclStmt] stmt
# 39| 0: [TypeAccess] int
# 39| 1: [LocalVariableDeclExpr] unary_minus
# 39| 0: [MinusExpr] -...
# 39| 0: [IntegerLiteral] 42
# 40| 28: [LocalVariableDeclStmt] stmt
# 40| 0: [TypeAccess] int
# 40| 1: [LocalVariableDeclExpr] parameter_minus
# 40| 0: [MinusExpr] -...
# 40| 0: [VarAccess] notConstant
# 42| 29: [LocalVariableDeclStmt] stmt
# 42| 0: [TypeAccess] boolean
# 42| 1: [LocalVariableDeclExpr] not
# 42| 0: [LogNotExpr] !...
# 42| 0: [BooleanLiteral] true
# 43| 30: [LocalVariableDeclStmt] stmt
# 43| 0: [TypeAccess] int
# 43| 1: [LocalVariableDeclExpr] bitwise_not
# 43| 0: [BitNotExpr] ~...
# 43| 0: [IntegerLiteral] 0
# 45| 31: [LocalVariableDeclStmt] stmt
# 45| 0: [TypeAccess] int
# 45| 1: [LocalVariableDeclExpr] mul
# 45| 0: [MulExpr] ... * ...
# 45| 0: [IntegerLiteral] 7
# 45| 1: [IntegerLiteral] 9
# 46| 32: [LocalVariableDeclStmt] stmt
# 46| 0: [TypeAccess] int
# 46| 1: [LocalVariableDeclExpr] mul_parameter
# 46| 0: [MulExpr] ... * ...
# 46| 0: [VarAccess] notConstant
# 46| 1: [VarAccess] notConstant
# 48| 33: [LocalVariableDeclStmt] stmt
# 48| 0: [TypeAccess] int
# 48| 1: [LocalVariableDeclExpr] div
# 48| 0: [DivExpr] ... / ...
# 48| 0: [IntegerLiteral] 168
# 48| 1: [IntegerLiteral] 4
# 49| 34: [LocalVariableDeclStmt] stmt
# 49| 0: [TypeAccess] int
# 49| 1: [LocalVariableDeclExpr] div_by_zero
# 49| 0: [DivExpr] ... / ...
# 49| 0: [IntegerLiteral] 42
# 49| 1: [IntegerLiteral] 0
# 50| 35: [LocalVariableDeclStmt] stmt
# 50| 0: [TypeAccess] int
# 50| 1: [LocalVariableDeclExpr] div_parameter
# 50| 0: [DivExpr] ... / ...
# 50| 0: [VarAccess] notConstant
# 50| 1: [VarAccess] notConstant
# 52| 36: [LocalVariableDeclStmt] stmt
# 52| 0: [TypeAccess] int
# 52| 1: [LocalVariableDeclExpr] rem
# 52| 0: [RemExpr] ... % ...
# 52| 0: [IntegerLiteral] 168
# 52| 1: [IntegerLiteral] 63
# 53| 37: [LocalVariableDeclStmt] stmt
# 53| 0: [TypeAccess] int
# 53| 1: [LocalVariableDeclExpr] rem_by_zero
# 53| 0: [RemExpr] ... % ...
# 53| 0: [IntegerLiteral] 42
# 53| 1: [IntegerLiteral] 0
# 54| 38: [LocalVariableDeclStmt] stmt
# 54| 0: [TypeAccess] int
# 54| 1: [LocalVariableDeclExpr] rem_parameter
# 54| 0: [RemExpr] ... % ...
# 54| 0: [VarAccess] notConstant
# 54| 1: [VarAccess] notConstant
# 56| 39: [LocalVariableDeclStmt] stmt
# 56| 0: [TypeAccess] int
# 56| 1: [LocalVariableDeclExpr] plus
# 56| 0: [AddExpr] ... + ...
# 56| 0: [IntegerLiteral] 10
# 56| 1: [IntegerLiteral] 32
# 57| 40: [LocalVariableDeclStmt] stmt
# 57| 0: [TypeAccess] int
# 57| 1: [LocalVariableDeclExpr] plus_parameter
# 57| 0: [AddExpr] ... + ...
# 57| 0: [VarAccess] notConstant
# 57| 1: [VarAccess] notConstant
# 59| 41: [LocalVariableDeclStmt] stmt
# 59| 0: [TypeAccess] int
# 59| 1: [LocalVariableDeclExpr] minus
# 59| 0: [SubExpr] ... - ...
# 59| 0: [IntegerLiteral] 168
# 59| 1: [IntegerLiteral] 126
# 60| 42: [LocalVariableDeclStmt] stmt
# 60| 0: [TypeAccess] int
# 60| 1: [LocalVariableDeclExpr] minus_parameter
# 60| 0: [SubExpr] ... - ...
# 60| 0: [VarAccess] notConstant
# 60| 1: [VarAccess] notConstant
# 62| 43: [LocalVariableDeclStmt] stmt
# 62| 0: [TypeAccess] int
# 62| 1: [LocalVariableDeclExpr] lshift
# 62| 0: [LShiftExpr] ... << ...
# 62| 0: [IntegerLiteral] 21
# 62| 1: [IntegerLiteral] 2
# 63| 44: [LocalVariableDeclStmt] stmt
# 63| 0: [TypeAccess] int
# 63| 1: [LocalVariableDeclExpr] lshift_parameter
# 63| 0: [LShiftExpr] ... << ...
# 63| 0: [VarAccess] notConstant
# 63| 1: [VarAccess] notConstant
# 65| 45: [LocalVariableDeclStmt] stmt
# 65| 0: [TypeAccess] int
# 65| 1: [LocalVariableDeclExpr] rshift
# 65| 0: [RShiftExpr] ... >> ...
# 65| 0: [MinusExpr] -...
# 65| 0: [IntegerLiteral] 1
# 65| 1: [IntegerLiteral] 2
# 66| 46: [LocalVariableDeclStmt] stmt
# 66| 0: [TypeAccess] int
# 66| 1: [LocalVariableDeclExpr] urshift
# 66| 0: [URShiftExpr] ... >>> ...
# 66| 0: [MinusExpr] -...
# 66| 0: [IntegerLiteral] 1
# 66| 1: [IntegerLiteral] 1
# 67| 47: [LocalVariableDeclStmt] stmt
# 67| 0: [TypeAccess] int
# 67| 1: [LocalVariableDeclExpr] bitwise_and
# 67| 0: [AndBitwiseExpr] ... & ...
# 67| 0: [IntegerLiteral] 63
# 67| 1: [IntegerLiteral] 42
# 68| 48: [LocalVariableDeclStmt] stmt
# 68| 0: [TypeAccess] int
# 68| 1: [LocalVariableDeclExpr] bitwise_or
# 68| 0: [OrBitwiseExpr] ... | ...
# 68| 0: [IntegerLiteral] 32
# 68| 1: [IntegerLiteral] 42
# 69| 49: [LocalVariableDeclStmt] stmt
# 69| 0: [TypeAccess] int
# 69| 1: [LocalVariableDeclExpr] bitwise_xor
# 69| 0: [XorBitwiseExpr] ... ^ ...
# 69| 0: [IntegerLiteral] 48
# 69| 1: [IntegerLiteral] 26
# 70| 50: [LocalVariableDeclStmt] stmt
# 70| 0: [TypeAccess] boolean
# 70| 1: [LocalVariableDeclExpr] and
# 70| 0: [AndLogicalExpr] ... && ...
# 70| 0: [BooleanLiteral] true
# 70| 1: [BooleanLiteral] false
# 71| 51: [LocalVariableDeclStmt] stmt
# 71| 0: [TypeAccess] boolean
# 71| 1: [LocalVariableDeclExpr] or
# 71| 0: [OrLogicalExpr] ... || ...
# 71| 0: [BooleanLiteral] true
# 71| 1: [BooleanLiteral] false
# 72| 52: [LocalVariableDeclStmt] stmt
# 72| 0: [TypeAccess] boolean
# 72| 1: [LocalVariableDeclExpr] lt
# 72| 0: [LTExpr] ... < ...
# 72| 0: [IntegerLiteral] 42
# 72| 1: [IntegerLiteral] 42
# 73| 53: [LocalVariableDeclStmt] stmt
# 73| 0: [TypeAccess] boolean
# 73| 1: [LocalVariableDeclExpr] le
# 73| 0: [LEExpr] ... <= ...
# 73| 0: [IntegerLiteral] 42
# 73| 1: [IntegerLiteral] 42
# 74| 54: [LocalVariableDeclStmt] stmt
# 74| 0: [TypeAccess] boolean
# 74| 1: [LocalVariableDeclExpr] gt
# 74| 0: [GTExpr] ... > ...
# 74| 0: [IntegerLiteral] 42
# 74| 1: [IntegerLiteral] 42
# 75| 55: [LocalVariableDeclStmt] stmt
# 75| 0: [TypeAccess] boolean
# 75| 1: [LocalVariableDeclExpr] gle
# 75| 0: [GEExpr] ... >= ...
# 75| 0: [IntegerLiteral] 42
# 75| 1: [IntegerLiteral] 42
# 76| 56: [LocalVariableDeclStmt] stmt
# 76| 0: [TypeAccess] boolean
# 76| 1: [LocalVariableDeclExpr] eq
# 76| 0: [EQExpr] ... == ...
# 76| 0: [IntegerLiteral] 42
# 76| 1: [IntegerLiteral] 42
# 77| 57: [LocalVariableDeclStmt] stmt
# 77| 0: [TypeAccess] boolean
# 77| 1: [LocalVariableDeclExpr] ne
# 77| 0: [NEExpr] ... != ...
# 77| 0: [IntegerLiteral] 42
# 77| 1: [IntegerLiteral] 42
# 78| 58: [LocalVariableDeclStmt] stmt
# 78| 0: [TypeAccess] boolean
# 78| 1: [LocalVariableDeclExpr] ter
# 78| 0: [ConditionalExpr] ...?...:...
# 78| 0: [BooleanLiteral] true
# 78| 1: [BooleanLiteral] false
# 78| 2: [BooleanLiteral] true
# 80| 59: [LocalVariableDeclStmt] stmt
# 80| 0: [TypeAccess] boolean
# 80| 1: [LocalVariableDeclExpr] seq
# 80| 0: [EQExpr] ... == ...
# 80| 0: [StringLiteral] "foo"
# 80| 1: [StringLiteral] "foo"
# 81| 60: [LocalVariableDeclStmt] stmt
# 81| 0: [TypeAccess] boolean
# 81| 1: [LocalVariableDeclExpr] sneq
# 81| 0: [NEExpr] ... != ...
# 81| 0: [StringLiteral] "foo"
# 81| 1: [StringLiteral] "foo"
# 83| 61: [LocalVariableDeclStmt] stmt
# 83| 0: [TypeAccess] int
# 83| 1: [LocalVariableDeclExpr] par
# 83| 0: [IntegerLiteral] 42
# 84| 62: [LocalVariableDeclStmt] stmt
# 84| 0: [TypeAccess] int
# 84| 1: [LocalVariableDeclExpr] par_not_constant
# 84| 0: [VarAccess] notConstant
# 86| 63: [LocalVariableDeclStmt] stmt
# 86| 0: [TypeAccess] int
# 86| 1: [LocalVariableDeclExpr] var_field
# 86| 0: [VarAccess] final_field
# 87| 64: [LocalVariableDeclStmt] stmt
# 87| 0: [TypeAccess] int
# 87| 1: [LocalVariableDeclExpr] final_local
# 87| 0: [IntegerLiteral] 42
# 88| 65: [LocalVariableDeclStmt] stmt
# 88| 0: [TypeAccess] int
# 88| 1: [LocalVariableDeclExpr] var_local
# 88| 0: [VarAccess] final_local
# 89| 66: [LocalVariableDeclStmt] stmt
# 89| 0: [TypeAccess] int
# 89| 1: [LocalVariableDeclExpr] var_param
# 89| 0: [VarAccess] notConstant
# 90| 67: [LocalVariableDeclStmt] stmt
# 90| 0: [TypeAccess] int
# 90| 1: [LocalVariableDeclExpr] var_nonfinald_local
# 90| 0: [VarAccess] var_field

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,15 @@
Example.java:
# 0| [CompilationUnit] Example
# 1| 1: [ImportType] import Set
# 2| 2: [ImportType] import List
# 4| 3: [Interface] Example
#-----| -2: (Generic Parameters)
# 4| 0: [TypeVariable] A
#-----| -1: (Base Types)
# 4| 0: [TypeAccess] Set<List<A>>
# 4| 0: [TypeAccess] List<A>
# 4| 0: [TypeAccess] A
# 5| 1: [Interface] InnerExample
#-----| -1: (Base Types)
# 5| 0: [TypeAccess] Example<Set<>>
# 5| 0: [TypeAccess] Set<>

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,51 @@
dependency/A.java:
# 0| [CompilationUnit] A
# 3| 1: [Class] A
#-----| -2: (Generic Parameters)
# 3| 0: [TypeVariable] T
# 6| 2: [Class] B
# 9| 3: [Class] C
# 10| 2: [FieldDeclaration] A<B> b, ...;
# 10| -1: [TypeAccess] A<B>
# 10| 0: [TypeAccess] B
# 11| 3: [FieldDeclaration] ...[] c, ...;
# 11| -1: [ArrayTypeAccess] ...[]
# 11| 0: [TypeAccess] C
# 14| 4: [Class] D
#-----| -1: (Base Types)
# 14| -1: [TypeAccess] A<B>
# 14| 0: [TypeAccess] B
# 15| 2: [Class] E
# 16| 2: [Method] m
# 16| 3: [TypeAccess] C
# 16| 4: (Parameters)
# 16| 0: [Parameter] f
# 16| 0: [TypeAccess] A<F>
# 16| 0: [TypeAccess] F
# 16| 5: [BlockStmt] stmt
# 17| 0: [ReturnStmt] stmt
# 17| 0: [NullLiteral] null
# 22| 5: [Class] F
# 24| 6: [Class] G
#-----| -1: (Base Types)
# 24| -1: [TypeAccess] Throwable
# 26| 7: [Class] H
# 27| 2: [Method] test
#-----| 2: (Generic Parameters)
# 27| 0: [TypeVariable] T
# 27| 0: [TypeAccess] String
# 27| 3: [TypeAccess] T
# 27| 4: (Parameters)
# 27| 0: [Parameter] t
# 27| 0: [TypeAccess] T
# 27| 5: [BlockStmt] stmt
# 27| 0: [ReturnStmt] stmt
# 27| 0: [VarAccess] t
# 28| 3: [Method] test2
# 28| 3: [TypeAccess] void
# 28| 4: (Parameters)
# 28| 0: [Parameter] t
# 28| 0: [TypeAccess] Collection<? extends Number>
# 28| 0: [WildcardTypeAccess] ? ...
# 28| 0: [TypeAccess] Number
# 28| 5: [BlockStmt] stmt

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,47 @@
generics/A.java:
# 0| [CompilationUnit] A
# 3| 1: [ImportType] import HashMap
# 4| 2: [ImportType] import Map
# 6| 3: [Class] A
#-----| -2: (Generic Parameters)
# 6| 0: [TypeVariable] T
# 7| 2: [Class] B
# 10| 4: [Class] C
# 11| 3: [FieldDeclaration] A<String> f, ...;
# 11| -1: [TypeAccess] A<String>
# 11| 0: [TypeAccess] String
# 12| 4: [FieldDeclaration] A<String>.B<> b, ...;
# 12| -1: [TypeAccess] A<String>.B<>
# 12| -1: [TypeAccess] A<String>
# 12| 0: [TypeAccess] String
# 13| 5: [FieldDeclaration] Map<String,Object> m, ...;
# 13| -1: [TypeAccess] Map<String,Object>
# 13| 0: [TypeAccess] String
# 13| 1: [TypeAccess] Object
# 13| 0: [ClassInstanceExpr] new HashMap<String,Object>(...)
# 13| -3: [TypeAccess] HashMap<String,Object>
# 13| 0: [TypeAccess] String
# 13| 1: [TypeAccess] Object
# 16| 5: [Class] D
#-----| -2: (Generic Parameters)
# 16| 0: [TypeVariable] V
# 16| 0: [TypeAccess] Number
# 17| 3: [FieldDeclaration] D<?> d1, ...;
# 17| -1: [TypeAccess] D<?>
# 17| 0: [WildcardTypeAccess] ? ...
# 18| 4: [FieldDeclaration] D<? extends Object> d2, ...;
# 18| -1: [TypeAccess] D<? extends Object>
# 18| 0: [WildcardTypeAccess] ? ...
# 18| 0: [TypeAccess] Object
# 19| 5: [FieldDeclaration] D<? extends Float> d3, ...;
# 19| -1: [TypeAccess] D<? extends Float>
# 19| 0: [WildcardTypeAccess] ? ...
# 19| 0: [TypeAccess] Float
# 20| 6: [FieldDeclaration] D<? super Double> d4, ...;
# 20| -1: [TypeAccess] D<? super Double>
# 20| 0: [WildcardTypeAccess] ? ...
# 20| 1: [TypeAccess] Double
# 21| 7: [BlockStmt] stmt
# 21| 0: [ExprStmt] stmt
# 21| 0: [MethodAccess] asList(...)
# 21| -1: [TypeAccess] Arrays

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,23 @@
Test.java:
# 0| [CompilationUnit] Test
# 1| 1: [Class] Test
# 2| 2: [Method] foo
# 2| 3: [TypeAccess] void
# 2| 4: (Parameters)
# 2| 0: [Parameter] s
# 2| 0: [TypeAccess] String
# 2| 5: [BlockStmt] stmt
# 3| 0: [LocalVariableDeclStmt] stmt
# 3| 0: [TypeAccess] int
# 3| 1: [LocalVariableDeclExpr] x
# 3| 0: [SwitchExpr] switch (...)
# 3| -1: [VarAccess] s
# 4| 0: [ConstCase] stmt
# 4| -1: [IntegerLiteral] 1
# 4| 0: [StringLiteral] "a"
# 4| 1: [StringLiteral] "b"
# 5| 1: [ConstCase] stmt
# 5| -1: [IntegerLiteral] 2
# 5| 0: [StringLiteral] "c"
# 6| 2: [DefaultCase] stmt
# 6| -1: [IntegerLiteral] 3

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,40 @@
Diamond.java:
# 0| [CompilationUnit] Diamond
# 3| 1: [ImportType] import ArrayList
# 4| 2: [ImportType] import HashMap
# 5| 3: [ImportType] import List
# 6| 4: [ImportType] import Map
# 8| 5: [Class] Diamond
# 10| 3: [FieldDeclaration] List<Integer> list, ...;
# 10| -1: [TypeAccess] List<Integer>
# 10| 0: [TypeAccess] Integer
# 10| 0: [ClassInstanceExpr] new ArrayList<Integer>(...)
# 10| -3: [TypeAccess] ArrayList<Integer>
# 10| 0: [TypeAccess] Integer
# 11| 4: [FieldDeclaration] Map<String,Object> map, ...;
# 11| -1: [TypeAccess] Map<String,Object>
# 11| 0: [TypeAccess] String
# 11| 1: [TypeAccess] Object
# 11| 0: [ClassInstanceExpr] new HashMap<String,Object>(...)
# 11| -3: [TypeAccess] HashMap<String,Object>
# 11| 0: [TypeAccess] String
# 11| 1: [TypeAccess] Object
# 14| 5: [FieldDeclaration] List<Integer> diamond_list, ...;
# 14| -1: [TypeAccess] List<Integer>
# 14| 0: [TypeAccess] Integer
# 14| 0: [ClassInstanceExpr] new ArrayList<Integer>(...)
# 14| -3: [TypeAccess] ArrayList<Integer>
# 15| 6: [FieldDeclaration] Map<String,Object> diamond_map, ...;
# 15| -1: [TypeAccess] Map<String,Object>
# 15| 0: [TypeAccess] String
# 15| 1: [TypeAccess] Object
# 15| 0: [ClassInstanceExpr] new HashMap<String,Object>(...)
# 15| -3: [TypeAccess] HashMap<String,Object>
# 18| 7: [FieldDeclaration] List<> l, ...;
# 18| -1: [TypeAccess] List<>
# 18| 0: [ClassInstanceExpr] new ArrayList<>(...)
# 18| -3: [TypeAccess] ArrayList<>
# 19| 8: [FieldDeclaration] Error e, ...;
# 19| -1: [TypeAccess] Error
# 19| 0: [ClassInstanceExpr] new Error(...)
# 19| -3: [TypeAccess] Error

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,73 @@
MultiCatch.java:
# 0| [CompilationUnit] MultiCatch
# 3| 1: [ImportType] import IOException
# 4| 2: [ImportType] import SQLException
# 6| 3: [Class] MultiCatch
# 7| 2: [Method] multiCatch
# 7| 3: [TypeAccess] void
# 7| 4: (Parameters)
# 7| 0: [Parameter] b
# 7| 0: [TypeAccess] boolean
# 8| 5: [BlockStmt] stmt
# 9| 0: [TryStmt] stmt
# 10| -1: [BlockStmt] stmt
# 11| 0: [IfStmt] stmt
# 11| 0: [VarAccess] b
# 12| 1: [ThrowStmt] stmt
# 12| 0: [ClassInstanceExpr] new IOException(...)
# 12| -3: [TypeAccess] IOException
# 14| 2: [ThrowStmt] stmt
# 14| 0: [ClassInstanceExpr] new SQLException(...)
# 14| -3: [TypeAccess] SQLException
# 15| 0: [CatchClause] stmt
# 15| -1: [UnionTypeAccess] ...|...
# 15| 0: [TypeAccess] IOException
# 15| 1: [TypeAccess] SQLException
# 15| 0: [LocalVariableDeclExpr] e
# 16| 1: [BlockStmt] stmt
# 17| 0: [ExprStmt] stmt
# 17| 0: [MethodAccess] printStackTrace(...)
# 17| -1: [VarAccess] e
# 18| 1: [ThrowStmt] stmt
# 18| 0: [VarAccess] e
# 22| 3: [Method] multiCatch2
# 22| 3: [TypeAccess] void
# 22| 4: (Parameters)
# 22| 0: [Parameter] b
# 22| 0: [TypeAccess] boolean
# 22| 1: [Parameter] c
# 22| 0: [TypeAccess] boolean
# 23| 5: [BlockStmt] stmt
# 24| 0: [TryStmt] stmt
# 25| -1: [BlockStmt] stmt
# 26| 0: [IfStmt] stmt
# 26| 0: [VarAccess] b
# 27| 1: [ThrowStmt] stmt
# 27| 0: [ClassInstanceExpr] new IOException(...)
# 27| -3: [TypeAccess] IOException
# 28| 2: [IfStmt] stmt
# 28| 0: [VarAccess] c
# 29| 1: [ThrowStmt] stmt
# 29| 0: [ClassInstanceExpr] new SQLException(...)
# 29| -3: [TypeAccess] SQLException
# 30| 1: [ThrowStmt] stmt
# 30| 0: [ClassInstanceExpr] new Exception(...)
# 30| -3: [TypeAccess] Exception
# 31| 0: [CatchClause] stmt
# 31| -1: [UnionTypeAccess] ...|...
# 31| 0: [TypeAccess] IOException
# 31| 1: [TypeAccess] SQLException
# 31| 0: [LocalVariableDeclExpr] e
# 32| 1: [BlockStmt] stmt
# 35| 4: [Method] ordinaryCatch
# 35| 3: [TypeAccess] void
# 36| 5: [BlockStmt] stmt
# 37| 0: [TryStmt] stmt
# 38| -1: [BlockStmt] stmt
# 39| 0: [ThrowStmt] stmt
# 39| 0: [ClassInstanceExpr] new IOException(...)
# 39| -3: [TypeAccess] IOException
# 40| 0: [CatchClause] stmt
# 40| -1: [TypeAccess] Exception
# 40| 0: [LocalVariableDeclExpr] e
# 41| 1: [BlockStmt] stmt

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,25 @@
javadoc/Test.java:
# 0| [CompilationUnit] Test
# 4| 1: [Class] Test
# 3| -4: [Javadoc] /** A test class. */
# 3| 0: [JavadocText] A test class.
# 7| 2: [Method] f
# 5| 0: [Javadoc] /** A javadoc ... */
# 5| 0: [JavadocText] A javadoc
# 6| 1: [JavadocText] comment
# 7| 3: [TypeAccess] void
# 7| 5: [BlockStmt] stmt
# 11| 3: [Method] g
# 9| 0: [Javadoc] /** Another javadoc comment */
# 9| 0: [JavadocText] Another javadoc comment
# 11| 3: [TypeAccess] void
# 11| 5: [BlockStmt] stmt
# 14| 4: [FieldDeclaration] int x, ...;
# 14| -1: [TypeAccess] int
# 15| 5: [FieldDeclaration] int y, ...;
# 15| -1: [TypeAccess] int
# 18| 6: [Method] h
# 17| 0: [Javadoc] /** @deprecated */
# 17| 0: [Javadoc] @deprecated
# 18| 3: [TypeAccess] void
# 18| 5: [BlockStmt] stmt

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,37 @@
Test.java:
# 0| [CompilationUnit] Test
# 1| 1: [Class] Test
# 2| 2: [Class] FinalEnum
# 2| 3: [FieldDeclaration] FinalEnum RED, ...;
# 2| -1: [TypeAccess] FinalEnum
# 2| 0: [ClassInstanceExpr] new FinalEnum(...)
# 2| -3: [TypeAccess] FinalEnum
# 2| 4: [FieldDeclaration] FinalEnum GREEN, ...;
# 2| -1: [TypeAccess] FinalEnum
# 2| 0: [ClassInstanceExpr] new FinalEnum(...)
# 2| -3: [TypeAccess] FinalEnum
# 2| 5: [FieldDeclaration] FinalEnum BLUE, ...;
# 2| -1: [TypeAccess] FinalEnum
# 2| 0: [ClassInstanceExpr] new FinalEnum(...)
# 2| -3: [TypeAccess] FinalEnum
# 3| 3: [Class] NonFinalEnum
# 4| 3: [FieldDeclaration] NonFinalEnum RED, ...;
# 4| -1: [TypeAccess] NonFinalEnum
# 4| 0: [ClassInstanceExpr] new (...)
# 4| -4: [AnonymousClass] new NonFinalEnum(...) { ... }
# 4| 2: [Method] toString
# 4| 1: (Annotations)
# 4| 1: [Annotation] Override
# 4| 3: [TypeAccess] String
# 4| 5: [BlockStmt] stmt
# 4| 0: [ReturnStmt] stmt
# 4| 0: [StringLiteral] "red"
# 4| -3: [TypeAccess] NonFinalEnum
# 5| 4: [FieldDeclaration] NonFinalEnum GREEN, ...;
# 5| -1: [TypeAccess] NonFinalEnum
# 5| 0: [ClassInstanceExpr] new NonFinalEnum(...)
# 5| -3: [TypeAccess] NonFinalEnum
# 6| 5: [FieldDeclaration] NonFinalEnum BLUE, ...;
# 6| -1: [TypeAccess] NonFinalEnum
# 6| 0: [ClassInstanceExpr] new NonFinalEnum(...)
# 6| -3: [TypeAccess] NonFinalEnum

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,37 @@
/** Another javadoc */
/**
* A class
*
* @author someone
*/
class A {
public @interface Ann1 {
String value() default "b";
Ann2[] nest() default {};
}
public @interface Ann2 {
int value() default 3;
}
/** Does something */
@Deprecated
static int doSomething(@SuppressWarnings("all") String text) {
return 0;
}
int counter = 1;
{
counter = doSomething("hi");
}
@Ann1(
value="a",
nest={
@Ann2(2),
@Ann2(7)
})
String doSomethingElse() { return "c"; }
}

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,48 @@
reflection/ReflectiveAccess.java:
# 0| [CompilationUnit] ReflectiveAccess
# 3| 1: [ImportType] import Annotation
# 5| 2: [Class] ReflectiveAccess
# 6| 2: [Interface] TestAnnotation
# 10| 3: [Class] TestClass
# 10| -3: (Annotations)
# 9| 1: [Annotation] TestAnnotation
# 13| 4: [Method] getAnnotation
#-----| 2: (Generic Parameters)
# 13| 0: [TypeVariable] A
# 13| 0: [TypeAccess] Annotation
# 13| 3: [TypeAccess] A
# 13| 4: (Parameters)
# 13| 0: [Parameter] classContainingAnnotation
# 13| 0: [TypeAccess] Class<?>
# 13| 0: [WildcardTypeAccess] ? ...
# 13| 1: [Parameter] annotationClass
# 13| 0: [TypeAccess] Class<A>
# 13| 0: [TypeAccess] A
# 13| 5: [BlockStmt] stmt
# 14| 0: [ReturnStmt] stmt
# 14| 0: [MethodAccess] getAnnotation(...)
# 14| -1: [VarAccess] classContainingAnnotation
# 14| 0: [VarAccess] annotationClass
# 17| 5: [Method] main
# 17| 3: [TypeAccess] void
# 17| 4: (Parameters)
# 17| 0: [Parameter] args
# 17| 0: [ArrayTypeAccess] ...[]
# 17| 0: [TypeAccess] String
# 17| 5: [BlockStmt] stmt
# 18| 0: [LocalVariableDeclStmt] stmt
# 18| 0: [TypeAccess] Class<?>
# 18| 0: [WildcardTypeAccess] ? ...
# 18| 1: [LocalVariableDeclExpr] testClass
# 18| 0: [MethodAccess] forName(...)
# 18| -1: [TypeAccess] Class<>
# 18| 0: [StringLiteral] "reflection.ReflectiveAccess$TestClass"
# 20| 1: [ExprStmt] stmt
# 20| 0: [MethodAccess] newInstance(...)
# 20| -1: [VarAccess] testClass
# 22| 2: [ExprStmt] stmt
# 22| 0: [MethodAccess] getAnnotation(...)
# 22| 0: [TypeLiteral] TestClass.class
# 22| 0: [TypeAccess] TestClass
# 22| 1: [TypeLiteral] TestAnnotation.class
# 22| 0: [TypeAccess] TestAnnotation

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,103 @@
typeaccesses/Arrays.java:
# 0| [CompilationUnit] Arrays
# 3| 1: [Class] Arrays
# 4| 2: [FieldDeclaration] ...[] ss, ...;
# 4| -1: [ArrayTypeAccess] ...[]
# 4| 0: [TypeAccess] String
# 5| 3: [FieldDeclaration] ...[] sls, ...;
# 5| -1: [ArrayTypeAccess] ...[]
# 5| 0: [TypeAccess] List<String>
# 5| 0: [TypeAccess] String
typeaccesses/Outer.java:
# 0| [CompilationUnit] Outer
# 3| 1: [Class] Outer
# 4| 3: [Class] Inner
# 5| 4: [BlockStmt] stmt
# 6| 0: [LocalVariableDeclStmt] stmt
# 6| 0: [TypeAccess] Object
# 6| 1: [LocalVariableDeclExpr] o
# 6| 0: [ArrayCreationExpr] new Outer[]
# 6| -1: [TypeAccess] Outer
# 6| 0: [IntegerLiteral] 1
# 7| 2: [LocalVariableDeclExpr] i
# 7| 0: [ArrayCreationExpr] new Inner[]
# 7| -1: [TypeAccess] Outer.Inner
# 7| -1: [TypeAccess] Outer
# 7| 0: [IntegerLiteral] 1
typeaccesses/TA.java:
# 0| [CompilationUnit] TA
# 3| 1: [ImportType] import ArrayList
# 5| 2: [Class] TA
#-----| -1: (Base Types)
# 5| -1: [TypeAccess] ArrayList<TA>
# 5| 0: [TypeAccess] TA
# 6| 2: [FieldDeclaration] ArrayList<TA> field, ...;
# 6| -1: [TypeAccess] ArrayList<TA>
# 6| 0: [TypeAccess] TA
# 7| 3: [Method] method1
# 7| 3: [TypeAccess] ArrayList<TA>
# 7| 0: [TypeAccess] TA
# 7| 5: [BlockStmt] stmt
# 7| 0: [ReturnStmt] stmt
# 7| 0: [NullLiteral] null
# 8| 4: [Method] method2
# 8| 3: [TypeAccess] void
# 8| 4: (Parameters)
# 8| 0: [Parameter] param
# 8| 0: [TypeAccess] ArrayList<TA>
# 8| 0: [TypeAccess] TA
# 8| 5: [BlockStmt] stmt
# 9| 5: [Method] method3
# 9| 3: [TypeAccess] void
# 9| 5: [BlockStmt] stmt
# 9| 0: [LocalVariableDeclStmt] stmt
# 9| 0: [TypeAccess] ArrayList<TA>
# 9| 0: [TypeAccess] TA
# 9| 1: [LocalVariableDeclExpr] local
# 10| 6: [Method] method4
#-----| 2: (Generic Parameters)
# 10| 0: [TypeVariable] T
# 10| 0: [TypeAccess] ArrayList<TA>
# 10| 0: [TypeAccess] TA
# 10| 3: [TypeAccess] void
# 10| 5: [BlockStmt] stmt
# 11| 7: [Method] method5
# 11| 3: [TypeAccess] void
# 11| 5: [BlockStmt] stmt
# 11| 0: [ExprStmt] stmt
# 11| 0: [MethodAccess] toString(...)
# 11| -1: [CastExpr] (...)...
# 11| 0: [TypeAccess] ArrayList<TA>
# 11| 0: [TypeAccess] TA
# 11| 1: [NullLiteral] null
# 12| 8: [Method] method6
# 12| 3: [TypeAccess] void
# 12| 5: [BlockStmt] stmt
# 12| 0: [ExprStmt] stmt
# 12| 0: [ClassInstanceExpr] new ArrayList<TA>(...)
# 12| -3: [TypeAccess] ArrayList<TA>
# 12| 0: [TypeAccess] TA
# 13| 9: [Method] method7
# 13| 3: [TypeAccess] void
# 13| 5: [BlockStmt] stmt
# 13| 0: [ExprStmt] stmt
# 13| 0: [MethodAccess] method3(...)
# 13| -1: [TypeAccess] TA
# 14| 10: [Class] Inner
#-----| -2: (Generic Parameters)
# 14| 0: [TypeVariable] T
# 14| 0: [TypeAccess] ArrayList<TA>
# 14| 0: [TypeAccess] TA
# 15| 11: [Method] method8
# 15| 3: [TypeAccess] TA.Inner<?>
# 15| -1: [TypeAccess] TA
# 15| 0: [WildcardTypeAccess] ? ...
# 15| 5: [BlockStmt] stmt
# 15| 0: [ReturnStmt] stmt
# 15| 0: [NullLiteral] null
# 16| 12: [Method] method9
# 16| 3: [TypeAccess] List<TA>
# 16| 0: [TypeAccess] TA
# 16| 5: [BlockStmt] stmt
# 16| 0: [ReturnStmt] stmt
# 16| 0: [NullLiteral] null

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,56 @@
varargs/Test.java:
# 0| [CompilationUnit] Test
# 3| 1: [Class] Test
# 4| 3: [Method] f
# 4| 3: [TypeAccess] void
# 4| 4: (Parameters)
# 4| 0: [Parameter] is
# 4| 0: [ArrayTypeAccess] ...[]
# 4| 0: [TypeAccess] int
# 4| 5: [BlockStmt] stmt
# 5| 4: [Method] g
# 5| 3: [TypeAccess] void
# 5| 4: (Parameters)
# 5| 0: [Parameter] os
# 5| 0: [ArrayTypeAccess] ...[]
# 5| 0: [TypeAccess] Object
# 5| 5: [BlockStmt] stmt
# 6| 5: [Method] h
# 6| 3: [TypeAccess] void
# 6| 4: (Parameters)
# 6| 0: [Parameter] s
# 6| 0: [TypeAccess] String
# 6| 1: [Parameter] ss
# 6| 0: [ArrayTypeAccess] ...[]
# 6| 0: [TypeAccess] String
# 6| 5: [BlockStmt] stmt
# 8| 6: [Method] ff
# 8| 3: [TypeAccess] void
# 8| 4: (Parameters)
# 8| 0: [Parameter] is
# 8| 0: [ArrayTypeAccess] ...[]
# 8| 0: [TypeAccess] int
# 8| 5: [BlockStmt] stmt
# 9| 7: [Method] gg
# 9| 3: [TypeAccess] void
# 9| 4: (Parameters)
# 9| 0: [Parameter] os
# 9| 0: [ArrayTypeAccess] ...[]
# 9| 0: [TypeAccess] Object
# 9| 5: [BlockStmt] stmt
# 10| 8: [Method] hh
# 10| 3: [TypeAccess] void
# 10| 4: (Parameters)
# 10| 0: [Parameter] s
# 10| 0: [TypeAccess] String
# 10| 1: [Parameter] ss
# 10| 0: [ArrayTypeAccess] ...[]
# 10| 0: [TypeAccess] String
# 10| 5: [BlockStmt] stmt
# 11| 9: [BlockStmt] stmt
# 12| 0: [ExprStmt] stmt
# 12| 0: [MethodAccess] asList(...)
# 12| -1: [TypeAccess] Arrays
# 12| 0: [IntegerLiteral] 1
# 12| 1: [IntegerLiteral] 2
# 12| 2: [IntegerLiteral] 3

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql