diff --git a/java/ql/src/semmle/code/java/PrintAst.qll b/java/ql/src/semmle/code/java/PrintAst.qll index fba755bf638..845e038ae44 100644 --- a/java/ql/src/semmle/code/java/PrintAst.qll +++ b/java/ql/src/semmle/code/java/PrintAst.qll @@ -46,7 +46,7 @@ private class ExprOrStmt extends Element { } } -/** Holds if the given element does not need to be rendered in the AST, due to being compiler-generated. */ +/** Holds if the given element does not need to be rendered in the AST, due to being compiler-generated. */ private predicate isNotNeeded(Element el) { exists(InitializerMethod im | el = im @@ -58,17 +58,33 @@ private predicate isNotNeeded(Element el) { ) ) or - exists(Constructor c | c.isDefaultConstructor() | + exists(Constructor c | c.isDefaultConstructor() | el = c or el.(ExprOrStmt).getEnclosingCallable() = c ) or + exists(Constructor c, int sline, int eline, int scol, int ecol | + el.(ExprOrStmt).getEnclosingCallable() = c + | + el.getLocation().hasLocationInfo(_, sline, eline, scol, ecol) and + c.getLocation().hasLocationInfo(_, sline, eline, scol, ecol) + // simply comparing their getLocation() doesn't work as they have distinct but equivalent locations + ) + or isNotNeeded(el.(Expr).getParent*().(Annotation).getAnnotatedElement()) or isNotNeeded(el.(Parameter).getCallable()) } +/** Holds if the given field would have the same javadoc and annotations as another field declared in the same declaration */ +private predicate duplicateMetadata(Field f) { + exists(FieldDeclaration fd | + f = fd.getAField() and + not f = fd.getField(0) + ) +} + /** * Retrieves the canonical QL class(es) for entity `el` */ @@ -97,14 +113,18 @@ private predicate locationSortKeys(Element ast, string file, int line, int colum */ private newtype TPrintAstNode = TElementNode(Element el) { shouldPrint(el, _) } or - TAnnotationsNode(Annotatable ann) { shouldPrint(ann, _) and ann.hasAnnotation() and not partOfAnnotation(ann)} or + TAnnotationsNode(Annotatable ann) { + shouldPrint(ann, _) and ann.hasAnnotation() and not partOfAnnotation(ann) + } or TParametersNode(Callable c) { shouldPrint(c, _) and not c.hasNoParameters() } or TBaseTypesNode(ClassOrInterface ty) { shouldPrint(ty, _) } or - TGenericTypeNode(GenericType ty) { shouldPrint(ty, _) } or + TGenericTypeNode(GenericType ty) { shouldPrint(ty, _) } or TGenericCallableNode(GenericCallable c) { shouldPrint(c, _) } or TDocumentableNode(Documentable d) { shouldPrint(d, _) and exists(d.getJavadoc()) } or TJavadocNode(Javadoc jd) { exists(Documentable d | d.getJavadoc() = jd | shouldPrint(d, _)) } or - TJavadocElementNode(JavadocElement jd) { exists(Documentable d | d.getJavadoc() = jd.getParent*() | shouldPrint(d, _)) } + TJavadocElementNode(JavadocElement jd) { + exists(Documentable d | d.getJavadoc() = jd.getParent*() | shouldPrint(d, _)) + } /** * A node in the output tree. @@ -201,7 +221,7 @@ abstract class ElementNode extends PrintAstNode, TElementNode { private predicate partOfAnnotation(Expr e) { e instanceof Annotation or - e instanceof ArrayInit and + e instanceof ArrayInit and partOfAnnotation(e.getParent()) } @@ -236,11 +256,12 @@ final class ExprStmtNode extends ElementNode { el = element.(LocalClassDeclStmt).getLocalClass() or partOfAnnotation(element) and - el = rank[childIndex](Element ch, string file, int line, int column | - ch = getAnAnnotationChild(element) and locationSortKeys(ch, file, line, column) - | - ch order by file, line, column - ) + el = + rank[childIndex](Element ch, string file, int line, int column | + ch = getAnAnnotationChild(element) and locationSortKeys(ch, file, line, column) + | + ch order by file, line, column + ) ) or exists(Element el | result.(AnnotationsNode).getAnnotated() = el | @@ -292,7 +313,7 @@ final class ParameterNode extends ElementNode { result.(AnnotationsNode).getAnnotated() = p or childIndex = 0 and - result.(ElementNode).getElement().(Expr).getParent() = p + result.(ElementNode).getElement().(Expr).isNthChildOf(p, -1) // type } } @@ -353,10 +374,10 @@ final class FieldDeclNode extends ElementNode { override PrintAstNode getChild(int childIndex) { childIndex = -3 and - result.(DocumentableNode).getDocumentable() = decl.getAField() + result.(DocumentableNode).getDocumentable() = decl.getField(0) or childIndex = -2 and - result.(AnnotationsNode).getAnnotated() = decl.getAField() + result.(AnnotationsNode).getAnnotated() = decl.getField(0) or childIndex = -1 and result.(ElementNode).getElement() = decl.getTypeAccess() @@ -398,7 +419,7 @@ final class ImportNode extends ElementNode { ImportNode() { element instanceof Import } } -/** +/** * A node representing a `TypeVariable`. */ final class TypeVariableNode extends ElementNode { @@ -416,7 +437,9 @@ final class TypeVariableNode extends ElementNode { final class AnnotationsNode extends PrintAstNode, TAnnotationsNode { Annotatable ann; - AnnotationsNode() { this = TAnnotationsNode(ann) and not isNotNeeded(ann) } + AnnotationsNode() { + this = TAnnotationsNode(ann) and not isNotNeeded(ann) and not duplicateMetadata(ann) + } override string toString() { result = "(Annotations)" } @@ -526,13 +549,13 @@ final class GenericCallableNode extends PrintAstNode, TGenericCallableNode { } /** - * A node representing the documentation of a `Documentable`. + * A node representing the documentation of a `Documentable`. * Only rendered if there is at least one `Javadoc` attatched to it. */ final class DocumentableNode extends PrintAstNode, TDocumentableNode { Documentable d; - DocumentableNode() { this = TDocumentableNode(d) } + DocumentableNode() { this = TDocumentableNode(d) and not duplicateMetadata(d) } override string toString() { result = "(Javadoc)" } @@ -542,7 +565,7 @@ final class DocumentableNode extends PrintAstNode, TDocumentableNode { result.getJavadoc() = rank[childIndex](Javadoc jd, string file, int line, int column | jd.getCommentedElement() = d and jd.getLocation().hasLocationInfo(file, line, column, _, _) - | + | jd order by file, line, column ) } @@ -554,7 +577,7 @@ final class DocumentableNode extends PrintAstNode, TDocumentableNode { } /** - * A node representing a `Javadoc`. + * A node representing a `Javadoc`. * Only rendered if it is the javadoc of some `Documentable`. */ final class JavadocNode extends PrintAstNode, TJavadocNode { @@ -576,7 +599,8 @@ final class JavadocNode extends PrintAstNode, TJavadocNode { Javadoc getJavadoc() { result = jd } } -/** A node representing a `JavadocElement`. +/** + * A node representing a `JavadocElement`. * Only rendered if it is part of the javadoc of some `Documentable`. */ final class JavadocElementNode extends PrintAstNode, TJavadocElementNode { diff --git a/java/ql/test/library-tests/JDK/PrintAst.expected b/java/ql/test/library-tests/JDK/PrintAst.expected index 8e76b35a838..ff260ac6c38 100644 --- a/java/ql/test/library-tests/JDK/PrintAst.expected +++ b/java/ql/test/library-tests/JDK/PrintAst.expected @@ -3,7 +3,7 @@ jdk/A.java: # 3| 1: [Class] A # 4| 2: [Method] main # 4| 3: [TypeAccess] void -# 4| 4: (Parameters) +#-----| 4: (Parameters) # 4| 0: [Parameter] args # 4| 0: [ArrayTypeAccess] ...[] # 4| 0: [TypeAccess] String @@ -11,7 +11,7 @@ jdk/A.java: # 7| 2: [Class] B # 8| 2: [Method] main # 8| 3: [TypeAccess] void -# 8| 4: (Parameters) +#-----| 4: (Parameters) # 8| 0: [Parameter] args # 8| 0: [ArrayTypeAccess] ...[] # 8| 0: [TypeAccess] String @@ -19,7 +19,7 @@ jdk/A.java: # 11| 3: [Class] C # 12| 2: [Method] main # 12| 3: [TypeAccess] void -# 12| 4: (Parameters) +#-----| 4: (Parameters) # 12| 0: [Parameter] args # 12| 0: [ArrayTypeAccess] ...[] # 12| 0: [TypeAccess] String @@ -27,7 +27,7 @@ jdk/A.java: # 15| 4: [Class] D # 16| 2: [Method] main # 16| 3: [TypeAccess] int -# 16| 4: (Parameters) +#-----| 4: (Parameters) # 16| 0: [Parameter] args # 16| 0: [ArrayTypeAccess] ...[] # 16| 0: [TypeAccess] String @@ -37,7 +37,7 @@ jdk/A.java: # 19| 5: [Class] E # 20| 2: [Method] main # 20| 3: [TypeAccess] void -# 20| 4: (Parameters) +#-----| 4: (Parameters) # 20| 0: [Parameter] argc # 20| 0: [TypeAccess] int # 20| 1: [Parameter] args @@ -47,14 +47,14 @@ jdk/A.java: # 23| 6: [Class] F # 24| 2: [Method] main # 24| 3: [TypeAccess] void -# 24| 4: (Parameters) +#-----| 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) +#-----| 4: (Parameters) # 28| 0: [Parameter] args # 28| 0: [ArrayTypeAccess] ...[] # 28| 0: [ArrayTypeAccess] ...[] diff --git a/java/ql/test/library-tests/arrays/PrintAst.expected b/java/ql/test/library-tests/arrays/PrintAst.expected index 843b5930711..2fd1eb3d7d8 100644 --- a/java/ql/test/library-tests/arrays/PrintAst.expected +++ b/java/ql/test/library-tests/arrays/PrintAst.expected @@ -13,7 +13,7 @@ arrays/B.java: # 3| 1: [Class] B # 4| 2: [Method] m # 4| 3: [TypeAccess] void -# 4| 4: (Parameters) +#-----| 4: (Parameters) # 4| 0: [Parameter] a # 4| 0: [TypeAccess] A # 4| 5: [BlockStmt] stmt diff --git a/java/ql/test/library-tests/comments/PrintAst.expected b/java/ql/test/library-tests/comments/PrintAst.expected index 266a960a687..dce19c722e7 100644 --- a/java/ql/test/library-tests/comments/PrintAst.expected +++ b/java/ql/test/library-tests/comments/PrintAst.expected @@ -1,12 +1,14 @@ 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. +#-----| -4: (Javadoc) +# 1| 1: [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. +#-----| 0: (Javadoc) +# 6| 1: [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 @@ -15,12 +17,14 @@ Test.java: 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. +#-----| -4: (Javadoc) +# 1| 1: [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. +#-----| 0: (Javadoc) +# 6| 1: [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 diff --git a/java/ql/test/library-tests/constants/PrintAst.expected b/java/ql/test/library-tests/constants/PrintAst.expected index 98b112d5ecd..d2420e71ada 100644 --- a/java/ql/test/library-tests/constants/PrintAst.expected +++ b/java/ql/test/library-tests/constants/PrintAst.expected @@ -3,7 +3,7 @@ constants/Constants.java: # 3| 1: [Class] Constants # 4| 2: [Method] constants # 4| 3: [TypeAccess] void -# 4| 4: (Parameters) +#-----| 4: (Parameters) # 4| 0: [Parameter] notConstant # 4| 0: [TypeAccess] int # 4| 5: [BlockStmt] stmt @@ -80,9 +80,6 @@ constants/Initializers.java: # 8| -1: [TypeAccess] int # 10| 6: [Constructor] Initializers # 10| 5: [BlockStmt] stmt -# 10| 0: [SuperConstructorInvocationStmt] super(...) -# 10| 1: [ExprStmt] stmt -# 10| 0: [MethodAccess] (...) # 12| 2: [ExprStmt] stmt # 12| 0: [AssignExpr] ...=... # 12| 0: [VarAccess] IFIELD2 @@ -135,14 +132,15 @@ constants/Initializers.java: 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 +#-----| -4: (Javadoc) +# 3| 1: [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) +#-----| 4: (Parameters) # 8| 0: [Parameter] notConstant # 8| 0: [TypeAccess] int # 8| 5: [BlockStmt] stmt diff --git a/java/ql/test/library-tests/constructors/PrintAst.expected b/java/ql/test/library-tests/constructors/PrintAst.expected index e69de29bb2d..6dc34314b0b 100644 --- a/java/ql/test/library-tests/constructors/PrintAst.expected +++ b/java/ql/test/library-tests/constructors/PrintAst.expected @@ -0,0 +1,40 @@ +constructors/A.java: +# 0| [CompilationUnit] A +# 3| 1: [Class] A +# 4| 3: [Constructor] A +# 4| 5: [BlockStmt] stmt +# 5| 0: [ThisConstructorInvocationStmt] this(...) +# 5| 0: [IntegerLiteral] 42 +# 8| 4: [Constructor] A +#-----| 4: (Parameters) +# 8| 0: [Parameter] i +# 8| 0: [TypeAccess] int +# 8| 5: [BlockStmt] stmt +# 10| 5: [Method] main +# 10| 3: [TypeAccess] void +#-----| 4: (Parameters) +# 10| 0: [Parameter] args +# 10| 0: [ArrayTypeAccess] ...[] +# 10| 0: [TypeAccess] String +# 10| 5: [BlockStmt] stmt +# 11| 0: [ExprStmt] stmt +# 11| 0: [ClassInstanceExpr] new A(...) +# 11| -3: [TypeAccess] A +# 14| 6: [FieldDeclaration] String STATIC, ...; +# 14| -1: [TypeAccess] String +# 14| 0: [StringLiteral] "static string" +# 15| 7: [FieldDeclaration] String INSTANCE, ...; +# 15| -1: [TypeAccess] String +# 15| 0: [StringLiteral] "instance string" +# 17| 8: [BlockStmt] stmt +# 18| 0: [ExprStmt] stmt +# 18| 0: [MethodAccess] println(...) +# 18| -1: [VarAccess] System.out +# 18| -1: [TypeAccess] System +# 18| 0: [StringLiteral] "" +# 21| 9: [BlockStmt] stmt +# 22| 0: [ExprStmt] stmt +# 22| 0: [MethodAccess] println(...) +# 22| -1: [VarAccess] System.out +# 22| -1: [TypeAccess] System +# 22| 0: [StringLiteral] "" diff --git a/java/ql/test/library-tests/dependency/PrintAst.expected b/java/ql/test/library-tests/dependency/PrintAst.expected index 588528623d4..e9eeb6f75b4 100644 --- a/java/ql/test/library-tests/dependency/PrintAst.expected +++ b/java/ql/test/library-tests/dependency/PrintAst.expected @@ -18,7 +18,7 @@ dependency/A.java: # 15| 2: [Class] E # 16| 2: [Method] m # 16| 3: [TypeAccess] C -# 16| 4: (Parameters) +#-----| 4: (Parameters) # 16| 0: [Parameter] f # 16| 0: [TypeAccess] A # 16| 0: [TypeAccess] F @@ -35,7 +35,7 @@ dependency/A.java: # 27| 0: [TypeVariable] T # 27| 0: [TypeAccess] String # 27| 3: [TypeAccess] T -# 27| 4: (Parameters) +#-----| 4: (Parameters) # 27| 0: [Parameter] t # 27| 0: [TypeAccess] T # 27| 5: [BlockStmt] stmt @@ -43,7 +43,7 @@ dependency/A.java: # 27| 0: [VarAccess] t # 28| 3: [Method] test2 # 28| 3: [TypeAccess] void -# 28| 4: (Parameters) +#-----| 4: (Parameters) # 28| 0: [Parameter] t # 28| 0: [TypeAccess] Collection # 28| 0: [WildcardTypeAccess] ? ... diff --git a/java/ql/test/library-tests/fields/PrintAst.expected b/java/ql/test/library-tests/fields/PrintAst.expected index e69de29bb2d..60f8a7fee45 100644 --- a/java/ql/test/library-tests/fields/PrintAst.expected +++ b/java/ql/test/library-tests/fields/PrintAst.expected @@ -0,0 +1,14 @@ +fields/FieldTest.java: +# 0| [CompilationUnit] FieldTest +# 3| 1: [Class] FieldTest +# 4| 4: [FieldDeclaration] float ff, ...; +# 4| -1: [TypeAccess] float +# 4| 1: [FloatingPointLiteral] 2.3f +# 5| 5: [FieldDeclaration] Object obj, ...; +# 5| -1: [TypeAccess] Object +# 5| 0: [NullLiteral] null +# 6| 6: [FieldDeclaration] List<> l, ...; +#-----| -2: (Annotations) +# 6| 1: [Annotation] SuppressWarnings +# 6| 1: [StringLiteral] "rawtypes" +# 6| -1: [TypeAccess] List<> diff --git a/java/ql/test/library-tests/guards12/PrintAst.expected b/java/ql/test/library-tests/guards12/PrintAst.expected index 98b5d58d144..5ef51e2fd7e 100644 --- a/java/ql/test/library-tests/guards12/PrintAst.expected +++ b/java/ql/test/library-tests/guards12/PrintAst.expected @@ -3,7 +3,7 @@ Test.java: # 1| 1: [Class] Test # 2| 2: [Method] foo # 2| 3: [TypeAccess] void -# 2| 4: (Parameters) +#-----| 4: (Parameters) # 2| 0: [Parameter] s # 2| 0: [TypeAccess] String # 2| 5: [BlockStmt] stmt diff --git a/java/ql/test/library-tests/java7/MultiCatch/PrintAst.expected b/java/ql/test/library-tests/java7/MultiCatch/PrintAst.expected index b12a0ed64f7..fa567fe95a3 100644 --- a/java/ql/test/library-tests/java7/MultiCatch/PrintAst.expected +++ b/java/ql/test/library-tests/java7/MultiCatch/PrintAst.expected @@ -5,7 +5,7 @@ MultiCatch.java: # 6| 3: [Class] MultiCatch # 7| 2: [Method] multiCatch # 7| 3: [TypeAccess] void -# 7| 4: (Parameters) +#-----| 4: (Parameters) # 7| 0: [Parameter] b # 7| 0: [TypeAccess] boolean # 8| 5: [BlockStmt] stmt @@ -32,7 +32,7 @@ MultiCatch.java: # 18| 0: [VarAccess] e # 22| 3: [Method] multiCatch2 # 22| 3: [TypeAccess] void -# 22| 4: (Parameters) +#-----| 4: (Parameters) # 22| 0: [Parameter] b # 22| 0: [TypeAccess] boolean # 22| 1: [Parameter] c diff --git a/java/ql/test/library-tests/javadoc/PrintAst.expected b/java/ql/test/library-tests/javadoc/PrintAst.expected index f8a9cc22385..901ebd4d4bd 100644 --- a/java/ql/test/library-tests/javadoc/PrintAst.expected +++ b/java/ql/test/library-tests/javadoc/PrintAst.expected @@ -1,17 +1,20 @@ javadoc/Test.java: # 0| [CompilationUnit] Test # 4| 1: [Class] Test -# 3| -4: [Javadoc] /** A test class. */ -# 3| 0: [JavadocText] A test class. +#-----| -4: (Javadoc) +# 3| 1: [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 +#-----| 0: (Javadoc) +# 5| 1: [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 +#-----| 0: (Javadoc) +# 9| 1: [Javadoc] /** Another javadoc comment */ +# 9| 0: [JavadocText] Another javadoc comment # 11| 3: [TypeAccess] void # 11| 5: [BlockStmt] stmt # 14| 4: [FieldDeclaration] int x, ...; @@ -19,7 +22,8 @@ javadoc/Test.java: # 15| 5: [FieldDeclaration] int y, ...; # 15| -1: [TypeAccess] int # 18| 6: [Method] h -# 17| 0: [Javadoc] /** @deprecated */ -# 17| 0: [Javadoc] @deprecated +#-----| 0: (Javadoc) +# 17| 1: [Javadoc] /** @deprecated */ +# 17| 0: [Javadoc] @deprecated # 18| 3: [TypeAccess] void # 18| 5: [BlockStmt] stmt diff --git a/java/ql/test/library-tests/modifiers/PrintAst.expected b/java/ql/test/library-tests/modifiers/PrintAst.expected index 08b11eea4f9..6bf393864a0 100644 --- a/java/ql/test/library-tests/modifiers/PrintAst.expected +++ b/java/ql/test/library-tests/modifiers/PrintAst.expected @@ -20,7 +20,7 @@ Test.java: # 4| 0: [ClassInstanceExpr] new (...) # 4| -4: [AnonymousClass] new NonFinalEnum(...) { ... } # 4| 2: [Method] toString -# 4| 1: (Annotations) +#-----| 1: (Annotations) # 4| 1: [Annotation] Override # 4| 3: [TypeAccess] String # 4| 5: [BlockStmt] stmt diff --git a/java/ql/test/library-tests/printAst/A.java b/java/ql/test/library-tests/printAst/A.java index 3dd249289b9..b0eeb9276a1 100644 --- a/java/ql/test/library-tests/printAst/A.java +++ b/java/ql/test/library-tests/printAst/A.java @@ -30,7 +30,7 @@ class A { @Ann1( value="a", nest={ - @Ann2(2), + @Ann2, @Ann2(7) }) String doSomethingElse() { return "c"; } diff --git a/java/ql/test/library-tests/printAst/PrintAst.expected b/java/ql/test/library-tests/printAst/PrintAst.expected index e69de29bb2d..9f0280c529a 100644 --- a/java/ql/test/library-tests/printAst/PrintAst.expected +++ b/java/ql/test/library-tests/printAst/PrintAst.expected @@ -0,0 +1,56 @@ +A.java: +# 0| [CompilationUnit] A +# 8| 1: [Class] A +#-----| -4: (Javadoc) +# 1| 1: [Javadoc] /** Another javadoc */ +# 1| 0: [JavadocText] Another javadoc +# 3| 2: [Javadoc] /** A class ... */ +# 4| 0: [JavadocText] A class +# 6| 1: [Javadoc] @author +# 6| 0: [JavadocText] someone +# 9| 3: [Interface] Ann1 +# 10| 1: [Method] value +# 10| 3: [TypeAccess] String +# 11| 2: [Method] nest +# 11| 3: [ArrayTypeAccess] ...[] +# 11| 0: [TypeAccess] Ann2 +# 14| 4: [Interface] Ann2 +# 15| 1: [Method] value +# 15| 3: [TypeAccess] int +# 20| 5: [Method] doSomething +#-----| 0: (Javadoc) +# 18| 1: [Javadoc] /** Does something */ +# 18| 0: [JavadocText] Does something +#-----| 1: (Annotations) +# 19| 1: [Annotation] Deprecated +# 20| 3: [TypeAccess] int +#-----| 4: (Parameters) +# 20| 0: [Parameter] text +#-----| -1: (Annotations) +# 20| 1: [Annotation] SuppressWarnings +# 20| 1: [StringLiteral] "all" +# 20| 0: [TypeAccess] String +# 20| 5: [BlockStmt] stmt +# 21| 0: [ReturnStmt] stmt +# 21| 0: [IntegerLiteral] 0 +# 24| 6: [FieldDeclaration] int counter, ...; +# 24| -1: [TypeAccess] int +# 24| 0: [IntegerLiteral] 1 +# 26| 7: [BlockStmt] stmt +# 27| 0: [ExprStmt] stmt +# 27| 0: [AssignExpr] ...=... +# 27| 0: [VarAccess] counter +# 27| 1: [MethodAccess] doSomething(...) +# 27| 0: [StringLiteral] "hi" +# 36| 8: [Method] doSomethingElse +#-----| 1: (Annotations) +# 30| 1: [Annotation] Ann1 +# 31| 1: [StringLiteral] "a" +# 32| 2: [ArrayInit] {...} +# 33| 1: [Annotation] Ann2 +# 34| 2: [Annotation] Ann2 +# 34| 1: [IntegerLiteral] 7 +# 36| 3: [TypeAccess] String +# 36| 5: [BlockStmt] stmt +# 36| 0: [ReturnStmt] stmt +# 36| 0: [StringLiteral] "c" diff --git a/java/ql/test/library-tests/reflection/PrintAst.expected b/java/ql/test/library-tests/reflection/PrintAst.expected index b39631bed76..b891272e84d 100644 --- a/java/ql/test/library-tests/reflection/PrintAst.expected +++ b/java/ql/test/library-tests/reflection/PrintAst.expected @@ -4,14 +4,14 @@ reflection/ReflectiveAccess.java: # 5| 2: [Class] ReflectiveAccess # 6| 2: [Interface] TestAnnotation # 10| 3: [Class] TestClass -# 10| -3: (Annotations) +#-----| -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) +#-----| 4: (Parameters) # 13| 0: [Parameter] classContainingAnnotation # 13| 0: [TypeAccess] Class # 13| 0: [WildcardTypeAccess] ? ... @@ -25,7 +25,7 @@ reflection/ReflectiveAccess.java: # 14| 0: [VarAccess] annotationClass # 17| 5: [Method] main # 17| 3: [TypeAccess] void -# 17| 4: (Parameters) +#-----| 4: (Parameters) # 17| 0: [Parameter] args # 17| 0: [ArrayTypeAccess] ...[] # 17| 0: [TypeAccess] String diff --git a/java/ql/test/library-tests/typeaccesses/PrintAst.expected b/java/ql/test/library-tests/typeaccesses/PrintAst.expected index d4cfc1ce56d..4d925b49ac4 100644 --- a/java/ql/test/library-tests/typeaccesses/PrintAst.expected +++ b/java/ql/test/library-tests/typeaccesses/PrintAst.expected @@ -42,7 +42,7 @@ typeaccesses/TA.java: # 7| 0: [NullLiteral] null # 8| 4: [Method] method2 # 8| 3: [TypeAccess] void -# 8| 4: (Parameters) +#-----| 4: (Parameters) # 8| 0: [Parameter] param # 8| 0: [TypeAccess] ArrayList # 8| 0: [TypeAccess] TA diff --git a/java/ql/test/library-tests/varargs/PrintAst.expected b/java/ql/test/library-tests/varargs/PrintAst.expected index 02aa31b997d..285ef6fc051 100644 --- a/java/ql/test/library-tests/varargs/PrintAst.expected +++ b/java/ql/test/library-tests/varargs/PrintAst.expected @@ -3,21 +3,21 @@ varargs/Test.java: # 3| 1: [Class] Test # 4| 3: [Method] f # 4| 3: [TypeAccess] void -# 4| 4: (Parameters) +#-----| 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) +#-----| 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) +#-----| 4: (Parameters) # 6| 0: [Parameter] s # 6| 0: [TypeAccess] String # 6| 1: [Parameter] ss @@ -26,21 +26,21 @@ varargs/Test.java: # 6| 5: [BlockStmt] stmt # 8| 6: [Method] ff # 8| 3: [TypeAccess] void -# 8| 4: (Parameters) +#-----| 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) +#-----| 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) +#-----| 4: (Parameters) # 10| 0: [Parameter] s # 10| 0: [TypeAccess] String # 10| 1: [Parameter] ss