aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-12-22 04:41:56 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-01-18 18:55:52 +0100
commit3797c8320acd903d3a5b6ce5c1ad97917df65f0a (patch)
tree362790d6c3aa4a50d7df2a53f52afd1ad978dc2f /src/core/lombok
parentd680f8c7f48b6a982c2cea0e8758716eee4807bc (diff)
downloadlombok-3797c8320acd903d3a5b6ce5c1ad97917df65f0a.tar.gz
lombok-3797c8320acd903d3a5b6ce5c1ad97917df65f0a.tar.bz2
lombok-3797c8320acd903d3a5b6ce5c1ad97917df65f0a.zip
[configuration] Reduced the range around which all already flagged errors/warnings are removed (javac/delombok only) when using onMethod / onConstructor / onParam. Useful for adding warnings such as lombok configuration 'flag usages'.
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/javac/JavacAST.java2
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java26
2 files changed, 20 insertions, 8 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index 5064f852..4e553063 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -395,7 +395,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
}
}
- private void removeFromDeferredDiagnostics(int startPos, int endPos) {
+ public void removeFromDeferredDiagnostics(int startPos, int endPos) {
JCCompilationUnit self = (JCCompilationUnit) top().get();
new CompilerMessageSuppressor(getContext()).removeAllBetween(self.sourcefile, startPos, endPos);
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index ef2a936a..adfac6e2 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1065,11 +1065,20 @@ public class JavacHandlerUtil {
return problematic.toList();
}
- static List<JCAnnotation> unboxAndRemoveAnnotationParameter(JCAnnotation ast, String parameterName, String errorName, JavacNode errorNode) {
+ static List<JCAnnotation> unboxAndRemoveAnnotationParameter(JCAnnotation ast, String parameterName, String errorName, JavacNode annotationNode) {
ListBuffer<JCExpression> params = new ListBuffer<JCExpression>();
ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
- errorNode.removeDeferredErrors();
+ try {
+ for (JCExpression arg : ast.args) {
+ String argName = "value";
+ if (arg instanceof JCAssign) {
+ JCAssign as = (JCAssign) arg;
+ argName = as.lhs.toString();
+ }
+ if (!argName.equals(parameterName)) continue;
+ }
+ } catch (Exception ignore) {}
outer:
for (JCExpression param : ast.args) {
@@ -1089,11 +1098,14 @@ public class JavacHandlerUtil {
continue outer;
}
+ int endPos = Javac.getEndPosition(param.pos(), (JCCompilationUnit) annotationNode.top().get());
+ annotationNode.getAst().removeFromDeferredDiagnostics(param.pos, endPos);
+
if (valueOfParam instanceof JCAnnotation) {
String dummyAnnotationName = ((JCAnnotation) valueOfParam).annotationType.toString();
dummyAnnotationName = dummyAnnotationName.replace("_", "").replace("$", "").replace("x", "").replace("X", "");
if (dummyAnnotationName.length() > 0) {
- errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
+ annotationNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
continue outer;
}
for (JCExpression expr : ((JCAnnotation) valueOfParam).args) {
@@ -1102,7 +1114,7 @@ public class JavacHandlerUtil {
if ("value".equals(id.name.toString())) {
expr = ((JCAssign) expr).rhs;
} else {
- errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
+ annotationNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
continue outer;
}
}
@@ -1114,12 +1126,12 @@ public class JavacHandlerUtil {
if (expr2 instanceof JCAnnotation) {
result.append((JCAnnotation) expr2);
} else {
- errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
+ annotationNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
continue outer;
}
}
} else {
- errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
+ annotationNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
continue outer;
}
}
@@ -1127,7 +1139,7 @@ public class JavacHandlerUtil {
if (valueOfParam instanceof JCNewArray && ((JCNewArray) valueOfParam).elems.isEmpty()) {
// Then we just remove it and move on (it's onMethod={} for example).
} else {
- errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
+ annotationNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))");
}
}
}