mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 22:16:11 +00:00
[fixes #3761] Update annotation value index
This commit is contained in:
1 parent
4aa58fb211
commit
5caea32510
5 files changed
+29
-4
No files matched your search
@@ -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
|
||||
@@ -182,6 +182,7 @@ public class AnnotationValues<A extends Annotation> {
|
||||
"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);
|
||||
|
||||
@@ -36,6 +36,7 @@ import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
|
||||
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;
|
||||
|
||||
@@ -48,6 +49,7 @@ public class CompilerMessageMatcher {
|
||||
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;
|
||||
}
|
||||
@@ -55,7 +57,9 @@ public class CompilerMessageMatcher {
|
||||
@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(" |||| ");
|
||||
@@ -68,6 +72,7 @@ public class CompilerMessageMatcher {
|
||||
outer:
|
||||
for (int i = 0; i < lineNumbers.size(); i++) {
|
||||
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;
|
||||
}
|
||||
@@ -87,7 +92,7 @@ public class CompilerMessageMatcher {
|
||||
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();
|
||||
@@ -107,7 +112,8 @@ public class CompilerMessageMatcher {
|
||||
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;
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
+2
@@ -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.
|
||||
@@ -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.
|
||||
Reference in new issue
Block a user