mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Java: Fix toString on field declarations with single field
This commit is contained in:
@@ -587,7 +587,7 @@ class FieldDeclaration extends ExprParent, @fielddecl, Annotatable {
|
||||
int getNumField() { result = max(int idx | fieldDeclaredIn(_, this, idx) | idx) + 1 }
|
||||
|
||||
override string toString() {
|
||||
if this.getNumField() = 0
|
||||
if this.getNumField() = 1
|
||||
then result = this.getTypeAccess() + " " + this.getField(0) + ";"
|
||||
else result = this.getTypeAccess() + " " + this.getField(0) + ", ...;"
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ jdk/A.java:
|
||||
jdk/SystemGetPropertyCall.java:
|
||||
# 0| [CompilationUnit] SystemGetPropertyCall
|
||||
# 3| 1: [Class] SystemGetPropertyCall
|
||||
# 4| 3: [FieldDeclaration] String USER_DIR_PROPERTY, ...;
|
||||
# 4| 3: [FieldDeclaration] String USER_DIR_PROPERTY;
|
||||
# 4| -1: [TypeAccess] String
|
||||
# 4| 0: [StringLiteral] "user.dir"
|
||||
# 6| 4: [Method] a
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
arrays/A.java:
|
||||
# 0| [CompilationUnit] A
|
||||
# 3| 1: [Class] A
|
||||
# 4| 2: [FieldDeclaration] ...[] a, ...;
|
||||
# 4| 2: [FieldDeclaration] ...[] a;
|
||||
# 4| -1: [ArrayTypeAccess] ...[]
|
||||
# 4| 0: [TypeAccess] String
|
||||
# 5| 3: [FieldDeclaration] ...[] b, ...;
|
||||
# 5| 3: [FieldDeclaration] ...[] b;
|
||||
# 5| -1: [ArrayTypeAccess] ...[]
|
||||
# 5| 0: [ArrayTypeAccess] ...[]
|
||||
# 5| 0: [TypeAccess] String
|
||||
|
||||
@@ -3,7 +3,7 @@ collections/Test.java:
|
||||
#-----| -1: (Imports)
|
||||
# 3| 1: [ImportOnDemandFromPackage] import java.util.*
|
||||
# 5| 1: [Class] Test
|
||||
# 6| 3: [FieldDeclaration] Map<String,Integer> m, ...;
|
||||
# 6| 3: [FieldDeclaration] Map<String,Integer> m;
|
||||
# 6| -1: [TypeAccess] Map<String,Integer>
|
||||
# 6| 0: [TypeAccess] String
|
||||
# 6| 1: [TypeAccess] Integer
|
||||
|
||||
@@ -70,13 +70,13 @@ constants/Constants.java:
|
||||
constants/Initializers.java:
|
||||
# 0| [CompilationUnit] Initializers
|
||||
# 3| 1: [Class] Initializers
|
||||
# 4| 3: [FieldDeclaration] int SFIELD, ...;
|
||||
# 4| 3: [FieldDeclaration] int SFIELD;
|
||||
# 4| -1: [TypeAccess] int
|
||||
# 4| 0: [IntegerLiteral] 12
|
||||
# 6| 4: [FieldDeclaration] int IFIELD, ...;
|
||||
# 6| 4: [FieldDeclaration] int IFIELD;
|
||||
# 6| -1: [TypeAccess] int
|
||||
# 6| 0: [IntegerLiteral] 20
|
||||
# 8| 5: [FieldDeclaration] int IFIELD2, ...;
|
||||
# 8| 5: [FieldDeclaration] int IFIELD2;
|
||||
# 8| -1: [TypeAccess] int
|
||||
# 10| 6: [Constructor] Initializers
|
||||
# 10| 5: [BlockStmt] { ... }
|
||||
@@ -98,17 +98,17 @@ constants/Initializers.java:
|
||||
# 18| 0: [AssignExpr] ...=...
|
||||
# 18| 0: [VarAccess] y
|
||||
# 18| 1: [IntegerLiteral] 400
|
||||
# 21| 8: [FieldDeclaration] Object SFIELD_OBJECT, ...;
|
||||
# 21| 8: [FieldDeclaration] Object SFIELD_OBJECT;
|
||||
# 21| -1: [TypeAccess] Object
|
||||
# 21| 0: [StringLiteral] "a string"
|
||||
# 23| 9: [FieldDeclaration] int fsf, ...;
|
||||
# 23| 9: [FieldDeclaration] int fsf;
|
||||
# 23| -1: [TypeAccess] int
|
||||
# 24| 10: [FieldDeclaration] int sf, ...;
|
||||
# 24| 10: [FieldDeclaration] int sf;
|
||||
# 24| -1: [TypeAccess] int
|
||||
# 24| 0: [IntegerLiteral] 3
|
||||
# 25| 11: [FieldDeclaration] int ff, ...;
|
||||
# 25| 11: [FieldDeclaration] int ff;
|
||||
# 25| -1: [TypeAccess] int
|
||||
# 26| 12: [FieldDeclaration] int f, ...;
|
||||
# 26| 12: [FieldDeclaration] int f;
|
||||
# 26| -1: [TypeAccess] int
|
||||
# 26| 0: [IntegerLiteral] 4
|
||||
# 28| 13: [BlockStmt] { ... }
|
||||
@@ -135,7 +135,7 @@ constants/Values.java:
|
||||
#-----| -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| 3: [FieldDeclaration] int final_field;
|
||||
# 6| -1: [TypeAccess] int
|
||||
# 6| 0: [IntegerLiteral] 42
|
||||
# 8| 4: [Method] values
|
||||
|
||||
@@ -20,10 +20,10 @@ constructors/A.java:
|
||||
# 11| 0: [ExprStmt] <Expr>;
|
||||
# 11| 0: [ClassInstanceExpr] new A(...)
|
||||
# 11| -3: [TypeAccess] A
|
||||
# 14| 6: [FieldDeclaration] String STATIC, ...;
|
||||
# 14| 6: [FieldDeclaration] String STATIC;
|
||||
# 14| -1: [TypeAccess] String
|
||||
# 14| 0: [StringLiteral] "static string"
|
||||
# 15| 7: [FieldDeclaration] String INSTANCE, ...;
|
||||
# 15| 7: [FieldDeclaration] String INSTANCE;
|
||||
# 15| -1: [TypeAccess] String
|
||||
# 15| 0: [StringLiteral] "instance string"
|
||||
# 17| 8: [BlockStmt] { ... }
|
||||
|
||||
@@ -5,10 +5,10 @@ dependency/A.java:
|
||||
# 3| 0: [TypeVariable] T
|
||||
# 6| 2: [Class] B
|
||||
# 9| 3: [Class] C
|
||||
# 10| 2: [FieldDeclaration] A<B> b, ...;
|
||||
# 10| 2: [FieldDeclaration] A<B> b;
|
||||
# 10| -1: [TypeAccess] A<B>
|
||||
# 10| 0: [TypeAccess] B
|
||||
# 11| 3: [FieldDeclaration] ...[] c, ...;
|
||||
# 11| 3: [FieldDeclaration] ...[] c;
|
||||
# 11| -1: [ArrayTypeAccess] ...[]
|
||||
# 11| 0: [TypeAccess] C
|
||||
# 14| 4: [Class] D
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
| fields/FieldTest.java:5:9:5:39 | Object obj, ...; | 1/2 | fields/FieldTest.java:5:35:5:38 | obj2 |
|
||||
| fields/FieldTest.java:6:9:6:58 | List<> l, ...; | 0/2 | fields/FieldTest.java:6:54:6:54 | l |
|
||||
| fields/FieldTest.java:6:9:6:58 | List<> l, ...; | 1/2 | fields/FieldTest.java:6:57:6:57 | m |
|
||||
| fields/FieldTest.java:7:9:7:18 | int x, ...; | 0/1 | fields/FieldTest.java:7:13:7:13 | x |
|
||||
| fields/FieldTest.java:8:9:8:22 | int y, ...; | 0/1 | fields/FieldTest.java:8:13:8:13 | y |
|
||||
| fields/FieldTest.java:12:9:12:25 | int z, ...; | 0/1 | fields/FieldTest.java:12:20:12:20 | z |
|
||||
| fields/FieldTest.java:13:9:13:29 | int w, ...; | 0/1 | fields/FieldTest.java:13:20:13:20 | w |
|
||||
| fields/FieldTest.java:7:9:7:18 | int x; | 0/1 | fields/FieldTest.java:7:13:7:13 | x |
|
||||
| fields/FieldTest.java:8:9:8:22 | int y; | 0/1 | fields/FieldTest.java:8:13:8:13 | y |
|
||||
| fields/FieldTest.java:12:9:12:25 | int z; | 0/1 | fields/FieldTest.java:12:20:12:20 | z |
|
||||
| fields/FieldTest.java:13:9:13:29 | int w; | 0/1 | fields/FieldTest.java:13:20:13:20 | w |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
| List<> l, ...; | 6 | 9 | 6 | 58 |
|
||||
| Object obj, ...; | 5 | 9 | 5 | 39 |
|
||||
| float ff, ...; | 4 | 9 | 4 | 32 |
|
||||
| int w, ...; | 13 | 9 | 13 | 29 |
|
||||
| int x, ...; | 7 | 9 | 7 | 18 |
|
||||
| int y, ...; | 8 | 9 | 8 | 22 |
|
||||
| int z, ...; | 12 | 9 | 12 | 25 |
|
||||
| int w; | 13 | 9 | 13 | 29 |
|
||||
| int x; | 7 | 9 | 7 | 18 |
|
||||
| int y; | 8 | 9 | 8 | 22 |
|
||||
| int z; | 12 | 9 | 12 | 25 |
|
||||
|
||||
@@ -12,10 +12,10 @@ fields/FieldTest.java:
|
||||
# 6| 1: [Annotation] SuppressWarnings
|
||||
# 6| 1: [StringLiteral] "rawtypes"
|
||||
# 6| -1: [TypeAccess] List<>
|
||||
# 7| 7: [FieldDeclaration] int x, ...;
|
||||
# 7| 7: [FieldDeclaration] int x;
|
||||
# 7| -1: [TypeAccess] int
|
||||
# 7| 0: [IntegerLiteral] 0
|
||||
# 8| 8: [FieldDeclaration] int y, ...;
|
||||
# 8| 8: [FieldDeclaration] int y;
|
||||
# 8| -1: [TypeAccess] int
|
||||
# 8| 0: [AssignExpr] ...=...
|
||||
# 8| 0: [VarAccess] x
|
||||
@@ -25,10 +25,10 @@ fields/FieldTest.java:
|
||||
# 10| 0: [AssignExpr] ...=...
|
||||
# 10| 0: [VarAccess] x
|
||||
# 10| 1: [IntegerLiteral] 2
|
||||
# 12| 10: [FieldDeclaration] int z, ...;
|
||||
# 12| 10: [FieldDeclaration] int z;
|
||||
# 12| -1: [TypeAccess] int
|
||||
# 12| 0: [IntegerLiteral] 0
|
||||
# 13| 11: [FieldDeclaration] int w, ...;
|
||||
# 13| 11: [FieldDeclaration] int w;
|
||||
# 13| -1: [TypeAccess] int
|
||||
# 13| 0: [AssignExpr] ...=...
|
||||
# 13| 0: [VarAccess] z
|
||||
|
||||
@@ -8,14 +8,14 @@ generics/A.java:
|
||||
# 6| 0: [TypeVariable] T
|
||||
# 7| 2: [Class] B
|
||||
# 10| 2: [Class] C
|
||||
# 11| 3: [FieldDeclaration] A<String> f, ...;
|
||||
# 11| 3: [FieldDeclaration] A<String> f;
|
||||
# 11| -1: [TypeAccess] A<String>
|
||||
# 11| 0: [TypeAccess] String
|
||||
# 12| 4: [FieldDeclaration] A<String>.B<> b, ...;
|
||||
# 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| 5: [FieldDeclaration] Map<String,Object> m;
|
||||
# 13| -1: [TypeAccess] Map<String,Object>
|
||||
# 13| 0: [TypeAccess] String
|
||||
# 13| 1: [TypeAccess] Object
|
||||
@@ -27,18 +27,18 @@ generics/A.java:
|
||||
#-----| -2: (Generic Parameters)
|
||||
# 16| 0: [TypeVariable] V
|
||||
# 16| 0: [TypeAccess] Number
|
||||
# 17| 3: [FieldDeclaration] D<?> d1, ...;
|
||||
# 17| 3: [FieldDeclaration] D<?> d1;
|
||||
# 17| -1: [TypeAccess] D<?>
|
||||
# 17| 0: [WildcardTypeAccess] ? ...
|
||||
# 18| 4: [FieldDeclaration] D<? extends Object> d2, ...;
|
||||
# 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| 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| 6: [FieldDeclaration] D<? super Double> d4;
|
||||
# 20| -1: [TypeAccess] D<? super Double>
|
||||
# 20| 0: [WildcardTypeAccess] ? ...
|
||||
# 20| 1: [TypeAccess] Double
|
||||
|
||||
@@ -6,13 +6,13 @@ Diamond.java:
|
||||
# 5| 3: [ImportType] import List
|
||||
# 6| 4: [ImportType] import Map
|
||||
# 8| 1: [Class] Diamond
|
||||
# 10| 3: [FieldDeclaration] List<Integer> list, ...;
|
||||
# 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| 4: [FieldDeclaration] Map<String,Object> map;
|
||||
# 11| -1: [TypeAccess] Map<String,Object>
|
||||
# 11| 0: [TypeAccess] String
|
||||
# 11| 1: [TypeAccess] Object
|
||||
@@ -20,22 +20,22 @@ Diamond.java:
|
||||
# 11| -3: [TypeAccess] HashMap<String,Object>
|
||||
# 11| 0: [TypeAccess] String
|
||||
# 11| 1: [TypeAccess] Object
|
||||
# 14| 5: [FieldDeclaration] List<Integer> diamond_list, ...;
|
||||
# 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| 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| 7: [FieldDeclaration] List<> l;
|
||||
# 18| -1: [TypeAccess] List<>
|
||||
# 18| 0: [ClassInstanceExpr] new ArrayList<>(...)
|
||||
# 18| -3: [TypeAccess] ArrayList<>
|
||||
# 19| 8: [FieldDeclaration] Error e, ...;
|
||||
# 19| 8: [FieldDeclaration] Error e;
|
||||
# 19| -1: [TypeAccess] Error
|
||||
# 19| 0: [ClassInstanceExpr] new Error(...)
|
||||
# 19| -3: [TypeAccess] Error
|
||||
|
||||
@@ -17,9 +17,9 @@ javadoc/Test.java:
|
||||
# 9| 0: [JavadocText] Another javadoc comment
|
||||
# 11| 3: [TypeAccess] void
|
||||
# 11| 5: [BlockStmt] { ... }
|
||||
# 14| 4: [FieldDeclaration] int x, ...;
|
||||
# 14| 4: [FieldDeclaration] int x;
|
||||
# 14| -1: [TypeAccess] int
|
||||
# 15| 5: [FieldDeclaration] int y, ...;
|
||||
# 15| 5: [FieldDeclaration] int y;
|
||||
# 15| -1: [TypeAccess] int
|
||||
# 18| 6: [Method] h
|
||||
#-----| 0: (Javadoc)
|
||||
|
||||
@@ -2,20 +2,20 @@ Test.java:
|
||||
# 0| [CompilationUnit] Test
|
||||
# 1| 1: [Class] Test
|
||||
# 2| 2: [Class] FinalEnum
|
||||
# 2| 3: [FieldDeclaration] FinalEnum RED, ...;
|
||||
# 2| 3: [FieldDeclaration] FinalEnum RED;
|
||||
# 2| -1: [TypeAccess] FinalEnum
|
||||
# 2| 0: [ClassInstanceExpr] new FinalEnum(...)
|
||||
# 2| -3: [TypeAccess] FinalEnum
|
||||
# 2| 4: [FieldDeclaration] FinalEnum GREEN, ...;
|
||||
# 2| 4: [FieldDeclaration] FinalEnum GREEN;
|
||||
# 2| -1: [TypeAccess] FinalEnum
|
||||
# 2| 0: [ClassInstanceExpr] new FinalEnum(...)
|
||||
# 2| -3: [TypeAccess] FinalEnum
|
||||
# 2| 5: [FieldDeclaration] FinalEnum BLUE, ...;
|
||||
# 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| 3: [FieldDeclaration] NonFinalEnum RED;
|
||||
# 4| -1: [TypeAccess] NonFinalEnum
|
||||
# 4| 0: [ClassInstanceExpr] new (...)
|
||||
# 4| -4: [AnonymousClass] new NonFinalEnum(...) { ... }
|
||||
@@ -27,11 +27,11 @@ Test.java:
|
||||
# 4| 0: [ReturnStmt] return ...
|
||||
# 4| 0: [StringLiteral] "red"
|
||||
# 4| -3: [TypeAccess] NonFinalEnum
|
||||
# 5| 4: [FieldDeclaration] NonFinalEnum GREEN, ...;
|
||||
# 5| 4: [FieldDeclaration] NonFinalEnum GREEN;
|
||||
# 5| -1: [TypeAccess] NonFinalEnum
|
||||
# 5| 0: [ClassInstanceExpr] new NonFinalEnum(...)
|
||||
# 5| -3: [TypeAccess] NonFinalEnum
|
||||
# 6| 5: [FieldDeclaration] NonFinalEnum BLUE, ...;
|
||||
# 6| 5: [FieldDeclaration] NonFinalEnum BLUE;
|
||||
# 6| -1: [TypeAccess] NonFinalEnum
|
||||
# 6| 0: [ClassInstanceExpr] new NonFinalEnum(...)
|
||||
# 6| -3: [TypeAccess] NonFinalEnum
|
||||
|
||||
@@ -66,7 +66,7 @@ A.java:
|
||||
# 25| 0: [VarAccess] m
|
||||
# 27| 3: [ReturnStmt] return ...
|
||||
# 27| 0: [IntegerLiteral] 0
|
||||
# 30| 6: [FieldDeclaration] int counter, ...;
|
||||
# 30| 6: [FieldDeclaration] int counter;
|
||||
# 30| -1: [TypeAccess] int
|
||||
# 30| 0: [IntegerLiteral] 1
|
||||
# 32| 7: [BlockStmt] { ... }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
typeaccesses/Arrays.java:
|
||||
# 0| [CompilationUnit] Arrays
|
||||
# 3| 1: [Class] Arrays
|
||||
# 4| 2: [FieldDeclaration] ...[] ss, ...;
|
||||
# 4| 2: [FieldDeclaration] ...[] ss;
|
||||
# 4| -1: [ArrayTypeAccess] ...[]
|
||||
# 4| 0: [TypeAccess] String
|
||||
# 5| 3: [FieldDeclaration] ...[] sls, ...;
|
||||
# 5| 3: [FieldDeclaration] ...[] sls;
|
||||
# 5| -1: [ArrayTypeAccess] ...[]
|
||||
# 5| 0: [TypeAccess] List<String>
|
||||
# 5| 0: [TypeAccess] String
|
||||
@@ -32,7 +32,7 @@ typeaccesses/TA.java:
|
||||
#-----| -1: (Base Types)
|
||||
# 5| -1: [TypeAccess] ArrayList<TA>
|
||||
# 5| 0: [TypeAccess] TA
|
||||
# 6| 2: [FieldDeclaration] ArrayList<TA> field, ...;
|
||||
# 6| 2: [FieldDeclaration] ArrayList<TA> field;
|
||||
# 6| -1: [TypeAccess] ArrayList<TA>
|
||||
# 6| 0: [TypeAccess] TA
|
||||
# 7| 3: [Method] method1
|
||||
|
||||
Reference in New Issue
Block a user