Skip to content

Commit

Permalink
Merge pull request #3764 from Rawi01/update-index
Browse files Browse the repository at this point in the history
Update annotation value index
  • Loading branch information
rzwitserloot authored Oct 24, 2024
2 parents c8d6152 + 5caea32 commit 87bc91a
Show file tree
Hide file tree
Showing 40 changed files with 102 additions and 78 deletions.
3 changes: 2 additions & 1 deletion src/core/lombok/core/AnnotationValues.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2022 The Project Lombok Authors.
* Copyright (C) 2009-2024 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -182,6 +182,7 @@ public List<String> getAsStringList(String methodName) {
"I can't make sense of this annotation value. Try using a fully qualified literal.", idx);
}
out.add((String) result);
idx++;
}

return Collections.unmodifiableList(out);
Expand Down
17 changes: 11 additions & 6 deletions test/core/src/lombok/CompilerMessageMatcher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2013 The Project Lombok Authors.
* Copyright (C) 2012-2024 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,6 +36,7 @@
public class CompilerMessageMatcher {
/** Line Number (starting at 1) */
private final List<Integer> lineNumbers = new ArrayList<Integer>();
private final List<Long> positions = new ArrayList<Long>();
private final List<List<String>> messages = new ArrayList<List<String>>();
private boolean optional;

Expand All @@ -48,14 +49,17 @@ public boolean isOptional() {
public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage message) {
CompilerMessageMatcher cmm = new CompilerMessageMatcher();
cmm.lineNumbers.add((int) message.getLine());
cmm.positions.add(message.getPosition());
cmm.messages.add(Arrays.asList(message.getMessage().split("\\s+")));
return cmm;
}

@Override public String toString() {
StringBuilder out = new StringBuilder();
for (int i = 0; i < lineNumbers.size(); i++) {
out.append(lineNumbers.get(i)).append(" ");
out.append(lineNumbers.get(i));
if (positions.get(i) != null) out.append(":").append(positions.get(i));
out.append(" ");
for (String part : messages.get(i)) out.append(part).append(" ");
if (out.length() > 0) out.setLength(out.length() - 1);
out.append(" |||| ");
Expand All @@ -67,8 +71,8 @@ public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage me
public boolean matches(CompilerMessage message) {
outer:
for (int i = 0; i < lineNumbers.size(); i++) {
//Allow an off-by-1 in line numbers; when running tests that sometimes happens for as yet unknown reasons.
if (message.getLine() != lineNumbers.get(i) && message.getLine() -1 != lineNumbers.get(i)) continue;
if (message.getLine() != lineNumbers.get(i)) continue;
if (positions.get(i) != null && !positions.get(i).equals(message.getPosition())) continue;
for (String token : messages.get(i)) {
if (!message.getMessage().contains(token)) continue outer;
}
Expand All @@ -88,7 +92,7 @@ public static List<CompilerMessageMatcher> readAll(InputStream rawIn) throws IOE
return out;
}

private static final Pattern PATTERN = Pattern.compile("^(-?\\d+) (.*)$");
private static final Pattern PATTERN = Pattern.compile("^(-?\\d+)(?::(\\d+))? (.*)$");

private static CompilerMessageMatcher read(String line) {
line = line.trim();
Expand All @@ -108,7 +112,8 @@ private static CompilerMessageMatcher read(String line) {
Matcher m = PATTERN.matcher(part);
if (!m.matches()) throw new IllegalArgumentException("Typo in test file: " + line);
cmm.lineNumbers.add(Integer.parseInt(m.group(1)));
cmm.messages.add(Arrays.asList(m.group(2).split("\\s+")));
cmm.positions.add(m.group(2) != null ? Long.parseLong(m.group(2)) : null);
cmm.messages.add(Arrays.asList(m.group(3).split("\\s+")));
}

return cmm;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// skip-compare-contents
@lombok.EqualsAndHashCode(of={"x", Const.A})
final class EqualsAndHashCodeErrorOf {
int x;
}

@lombok.EqualsAndHashCode(exclude={"x", Const.A})
final class EqualsAndHashCodeErrorExclude {
int x;
}

class Const {
static final String A = "A";
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4 Use of @Delegate is flagged according to lombok configuration.
5 Use of @Delegate is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
6 @Delegate is legal only on instance fields or no-argument instance methods.
10 @Delegate is legal only on instance fields or no-argument instance methods.
7 @Delegate is legal only on instance fields or no-argument instance methods.
11 @Delegate is legal only on instance fields or no-argument instance methods.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter"
5 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2:60 You must use constant literals in lombok annotations; they cannot be references to (static) fields.
7:160 You must use constant literals in lombok annotations; they cannot be references to (static) fields.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1 This field does not exist.
6 This field does not exist, or would have been excluded anyway.
2 This field does not exist.
7 This field does not exist, or would have been excluded anyway.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9 reference to ambiguous is ambiguous both method <T,R>ambiguous(T,java.util.function.Function<T,R>) in ExtensionMethodAmbiguousFunctional.Extensions and method <T>ambiguous(T,java.util.function.Consumer<T>) in ExtensionMethodAmbiguousFunctional.Extensions match
10 reference to ambiguous is ambiguous both method <T,R>ambiguous(T,java.util.function.Function<T,R>) in ExtensionMethodAmbiguousFunctional.Extensions and method <T>ambiguous(T,java.util.function.Consumer<T>) in ExtensionMethodAmbiguousFunctional.Extensions match
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.
2 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5 @Locked is legal only on methods in classes and enums.
6 @Locked is legal only on methods in classes and enums.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22 @NonNull is meaningless on a primitive.
23 @NonNull is meaningless on a primitive.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
9 Use of @Getter(onMethod=...) is flagged according to lombok configuration.
10 Use of @Setter(onMethod=...) is flagged according to lombok configuration.
10 Use of @Setter(onParam=...) is flagged according to lombok configuration.
11 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
12 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
18 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
10 Use of @Getter(onMethod=...) is flagged according to lombok configuration.
11 Use of @Setter(onMethod=...) is flagged according to lombok configuration.
11 Use of @Setter(onParam=...) is flagged according to lombok configuration.
12 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
13 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
19 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5 @Synchronized is legal only on methods in classes and enums.
6 @Synchronized is legal only on methods in classes and enums.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
6 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved
10 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })
7 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved
11 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7 'val' is not allowed in old-style for loops
8 'val' is not allowed in old-style for loops
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6 'var' is not allowed in old-style for loops if there is more than 1 initializer
7 'var' is not allowed in old-style for loops if there is more than 1 initializer
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5 variable initializer is 'null'
6 variable initializer is 'null'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6 Use of var is flagged according to lombok configuration
7 Use of var is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4 Use of @Delegate is flagged according to lombok configuration.
5 Use of @Delegate is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1 The type Delegate is deprecated
6 The type Delegate is deprecated
2 The type Delegate is deprecated
7 The type Delegate is deprecated
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
6 @Delegate is legal only on instance fields or no-argument instance methods.
10 @Delegate is legal only on instance fields or no-argument instance methods.
7 @Delegate is legal only on instance fields or no-argument instance methods.
11 @Delegate is legal only on instance fields or no-argument instance methods.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter"
5 @Delegate does not support recursion (delegating to a type that itself has @Delegate members). Member "inner" is @Delegate in type "DelegateRecursionCenter"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2:60 You must use constant literals in lombok annotations; they cannot be references to (static) fields.
7:160 You must use constant literals in lombok annotations; they cannot be references to (static) fields.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1 This field does not exist.
6 This field does not exist, or would have been excluded anyway.
2 This field does not exist.
7 This field does not exist, or would have been excluded anyway.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.
2 @JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
15 Dead code
22 @NonNull is meaningless on a primitive.
28 Dead code
16 Dead code
23 @NonNull is meaningless on a primitive.
29 Dead code
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7 @NonNull is meaningless on a primitive.
8 @NonNull is meaningless on a primitive.
12 changes: 6 additions & 6 deletions test/transform/resource/messages-ecj/OnXFlagUsage.java.messages
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
9 Use of @Getter(onMethod=...) is flagged according to lombok configuration.
10 Use of @Setter(onMethod=...) is flagged according to lombok configuration.
10 Use of @Setter(onParam=...) is flagged according to lombok configuration.
11 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
12 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
18 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
10 Use of @Getter(onMethod=...) is flagged according to lombok configuration.
11 Use of @Setter(onMethod=...) is flagged according to lombok configuration.
11 Use of @Setter(onParam=...) is flagged according to lombok configuration.
12 Use of @NoArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
13 Use of @AllArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
19 Use of @RequiredArgsConstructor(onConstructor=...) is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17 The serializable class does not declare a static final serialVersionUID field of type long
18 The serializable class does not declare a static final serialVersionUID field of type long
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
5 NonExistingClass cannot be resolved to a type
6 NonExistingClass cannot be resolved to a type
7 The method nonExisitingMethod(Integer) is undefined for the type ValInvalidParameter
8 nonExistingObject cannot be resolved
9 The method nonExistingMethod() is undefined for the type Integer
10 NonExistingClass cannot be resolved to a type
11 The method b2(int, int) in the type ValInvalidParameter is not applicable for the arguments (int)
12 The method a(String) is ambiguous for the type ValInvalidParameter
13 The method a(String) is ambiguous for the type ValInvalidParameter
7 NonExistingClass cannot be resolved to a type
8 The method nonExisitingMethod(Integer) is undefined for the type ValInvalidParameter
9 nonExistingObject cannot be resolved
10 The method nonExistingMethod() is undefined for the type Integer
11 NonExistingClass cannot be resolved to a type
12 The method b2(int, int) in the type ValInvalidParameter is not applicable for the arguments (int)
13 The method a(String) is ambiguous for the type ValInvalidParameter
14 The method a(String) is ambiguous for the type ValInvalidParameter
4 changes: 2 additions & 2 deletions test/transform/resource/messages-ecj/ValLambda.java.messages
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
24 Function is a raw type. References to generic type Function<T,R> should be parameterized
25 Function is a raw type. References to generic type Function<T,R> should be parameterized
25 Function is a raw type. References to generic type Function<T,R> should be parameterized
26 Function is a raw type. References to generic type Function<T,R> should be parameterized
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13 List is a raw type. References to generic type List<E> should be parameterized
14 List is a raw type. References to generic type List<E> should be parameterized
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6 'var' is not allowed in old-style for loops if there is more than 1 initializer
7 'var' is not allowed in old-style for loops if there is more than 1 initializer
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1 The type var is deprecated
7 The type var is deprecated
2 The type var is deprecated
8 The type var is deprecated
9 The type var is deprecated
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5 variable initializer is 'null'
6 variable initializer is 'null'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6 Use of var is flagged according to lombok configuration.
7 Use of var is flagged according to lombok configuration.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
27 cannot find symbol
31 cannot find symbol
28 cannot find symbol method readLock() location: java.util.concurrent.locks.Lock
32 cannot find symbol method readLock() location: java.util.concurrent.locks.Lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
33 @NonNull is meaningless on a primitive.
34 @NonNull is meaningless on a primitive.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
3 cannot find symbol
4 cannot find symbol
5 cannot find symbol
6 cannot find symbol
7 cannot find symbol
8 cannot find symbol
9 method b2 in class ValInvalidParameter cannot be applied to given types;
10 reference to a is ambiguous
11 reference to a is ambiguous
4 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter
5 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter
6 cannot find symbol symbol: method nonExisitingMethod(java.lang.Integer) location: class ValInvalidParameter
7 cannot find symbol symbol: variable nonExistingObject location: class ValInvalidParameter
8 cannot find symbol symbol: method nonExistingMethod() location: class java.lang.Integer
9 cannot find symbol symbol: class NonExistingClass location: class ValInvalidParameter
10 method b2 in class ValInvalidParameter cannot be applied to given types; required: int,int found: int reason: actual and formal argument lists differ in length
11 reference to a is ambiguous both method a(java.lang.String) in ValInvalidParameter and method a(java.lang.Integer) in ValInvalidParameter match
12 reference to a is ambiguous both method a(java.lang.String) in ValInvalidParameter and method a(java.lang.Integer) in ValInvalidParameter match

0 comments on commit 87bc91a

Please sign in to comment.