mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 12:15:00 +00:00
Added code to NOT add @SuppressWarnings to things if a @SuppressWarnings is already there. Lombok itself can't ever do that anyway (we don't add @SW except to things we just generated fresh), but some lombok extension builders do, and this helps them.
This commit is contained in:
1 parent
7bbe19f1b8
commit
685ddfd52e
2 files changed
+21
No files matched your search
@@ -1388,6 +1388,19 @@ public class EclipseHandlerUtil {
|
||||
private static final char[] ALL = "all".toCharArray();
|
||||
|
||||
public static Annotation[] createSuppressWarningsAll(ASTNode source, Annotation[] originalAnnotationArray) {
|
||||
if (originalAnnotationArray != null) for (Annotation ann : originalAnnotationArray) {
|
||||
char[] lastToken = null;
|
||||
|
||||
if (ann.type instanceof QualifiedTypeReference) {
|
||||
char[][] t = ((QualifiedTypeReference) ann.type).tokens;
|
||||
lastToken = t[t.length - 1];
|
||||
} else if (ann.type instanceof SingleTypeReference) {
|
||||
lastToken = ((SingleTypeReference) ann.type).token;
|
||||
}
|
||||
|
||||
if (lastToken != null && new String(lastToken).equals("SuppressWarnings")) return originalAnnotationArray;
|
||||
}
|
||||
|
||||
int pS = source.sourceStart, pE = source.sourceEnd;
|
||||
long p = (long)pS << 32 | pE;
|
||||
long[] poss = new long[3];
|
||||
|
||||
@@ -918,6 +918,14 @@ public class JavacHandlerUtil {
|
||||
|
||||
private static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
|
||||
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return;
|
||||
for (JCAnnotation ann : mods.annotations) {
|
||||
JCTree annType = ann.getAnnotationType();
|
||||
Name lastPart = null;
|
||||
if (annType instanceof JCIdent) lastPart = ((JCIdent) annType).name;
|
||||
else if (annType instanceof JCFieldAccess) lastPart = ((JCFieldAccess) annType).name;
|
||||
|
||||
if (lastPart != null && lastPart.contentEquals("SuppressWarnings")) return;
|
||||
}
|
||||
JavacTreeMaker maker = node.getTreeMaker();
|
||||
JCExpression suppressWarningsType = genJavaLangTypeRef(node, "SuppressWarnings");
|
||||
JCLiteral allLiteral = maker.Literal("all");
|
||||
|
||||
Reference in new issue
Block a user