aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-09-03 02:25:51 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-09-03 02:25:51 +0200
commit0b30a5695022649c0e9288b167fe15893e06887b (patch)
tree0fdbf015db81cd86d2e01cd1c739a092cf07f74b
parentcfa9bef58d15bea474b83b3ce80c06f5af814711 (diff)
downloadlombok-0b30a5695022649c0e9288b167fe15893e06887b.tar.gz
lombok-0b30a5695022649c0e9288b167fe15893e06887b.tar.bz2
lombok-0b30a5695022649c0e9288b167fe15893e06887b.zip
Fixed a problem in AnnotationValues where 'isExplicit' always returned true.
-rw-r--r--src/lombok/core/AnnotationValues.java14
-rw-r--r--src/lombok/eclipse/Eclipse.java8
-rw-r--r--src/lombok/eclipse/handlers/HandleToString.java7
-rw-r--r--src/lombok/javac/Javac.java4
-rw-r--r--src/lombok/javac/handlers/HandleEqualsAndHashCode.java5
-rw-r--r--src/lombok/javac/handlers/HandleToString.java5
6 files changed, 35 insertions, 8 deletions
diff --git a/src/lombok/core/AnnotationValues.java b/src/lombok/core/AnnotationValues.java
index 15b4f3b7..663fb86b 100644
--- a/src/lombok/core/AnnotationValues.java
+++ b/src/lombok/core/AnnotationValues.java
@@ -50,6 +50,7 @@ public class AnnotationValues<A extends Annotation> {
* likely be right. If not, it'll be wrong. */
public final List<Object> valueGuesses;
private final AST<?>.Node node;
+ private final boolean isExplicit;
/**
* 'raw' should be the exact expression, for example '5+7', 'AccessLevel.PUBLIC', or 'int.class'.
@@ -58,19 +59,21 @@ public class AnnotationValues<A extends Annotation> {
* For classes, supply the class name (qualified or not) as a string.<br />
* For enums, supply the simple name part (everything after the last dot) as a string.<br />
*/
- public AnnotationValue(AST<?>.Node node, String raw, Object valueGuess) {
+ public AnnotationValue(AST<?>.Node node, String raw, Object valueGuess, boolean isExplicit) {
this.node = node;
this.raws = Collections.singletonList(raw);
this.valueGuesses = Collections.singletonList(valueGuess);
+ this.isExplicit = isExplicit;
}
/**
* Like the other constructor, but used for when the annotation method is initialized with an array value.
*/
- public AnnotationValue(AST<?>.Node node, List<String> raws, List<Object> valueGuesses) {
+ public AnnotationValue(AST<?>.Node node, List<String> raws, List<Object> valueGuesses, boolean isExplicit) {
this.node = node;
this.raws = raws;
this.valueGuesses = valueGuesses;
+ this.isExplicit = isExplicit;
}
/**
@@ -101,6 +104,10 @@ public class AnnotationValues<A extends Annotation> {
@Override public String toString() {
return "raws: " + raws + " valueGuesses: " + valueGuesses;
}
+
+ public boolean isExplicit() {
+ return isExplicit;
+ }
}
/**
@@ -299,7 +306,8 @@ public class AnnotationValues<A extends Annotation> {
}
public boolean isExplicit(String annotationMethodName) {
- return values.get(annotationMethodName) != null;
+ AnnotationValue annotationValue = values.get(annotationMethodName);
+ return annotationValue != null && annotationValue.isExplicit();
}
/**
diff --git a/src/lombok/eclipse/Eclipse.java b/src/lombok/eclipse/Eclipse.java
index 5a69fca9..c37d1e33 100644
--- a/src/lombok/eclipse/Eclipse.java
+++ b/src/lombok/eclipse/Eclipse.java
@@ -346,11 +346,13 @@ public class Eclipse {
if ( mName.equals(name) ) fullExpression = pair.value;
}
- if ( fullExpression != null ) {
+ boolean isExplicit = fullExpression != null;
+
+ if ( isExplicit ) {
if ( fullExpression instanceof ArrayInitializer ) {
expressions = ((ArrayInitializer)fullExpression).expressions;
} else expressions = new Expression[] { fullExpression };
- for ( Expression ex : expressions ) {
+ if ( expressions != null ) for ( Expression ex : expressions ) {
StringBuffer sb = new StringBuffer();
ex.print(0, sb);
raws.add(sb.toString());
@@ -361,7 +363,7 @@ public class Eclipse {
final Expression fullExpr = fullExpression;
final Expression[] exprs = expressions;
- values.put(name, new AnnotationValue(annotationNode, raws, guesses) {
+ values.put(name, new AnnotationValue(annotationNode, raws, guesses, isExplicit) {
@Override public void setError(String message, int valueIdx) {
Expression ex;
if ( valueIdx == -1 ) ex = fullExpr;
diff --git a/src/lombok/eclipse/handlers/HandleToString.java b/src/lombok/eclipse/handlers/HandleToString.java
index d639e3fd..5b88b568 100644
--- a/src/lombok/eclipse/handlers/HandleToString.java
+++ b/src/lombok/eclipse/handlers/HandleToString.java
@@ -108,6 +108,11 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
if ( !annotation.isExplicit("exclude") ) excludes = null;
if ( !annotation.isExplicit("of") ) includes = null;
+ if ( excludes != null && includes != null ) {
+ excludes = null;
+ annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
+ }
+
checkForBogusFieldNames(typeNode, annotation);
return generateToString(typeNode, annotationNode, excludes, includes, ann.includeFieldNames(), callSuper, true);
@@ -147,7 +152,7 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
//Skip static fields.
if ( (fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0 ) continue;
//Skip excluded fields.
- if ( excludes.contains(new String(fieldDecl.name)) ) continue;
+ if ( excludes != null && excludes.contains(new String(fieldDecl.name)) ) continue;
//Skip fields that start with $
if ( fieldDecl.name.length > 0 && fieldDecl.name[0] == '$' ) continue;
nodesForToString.add(child);
diff --git a/src/lombok/javac/Javac.java b/src/lombok/javac/Javac.java
index 0987d31a..60c86099 100644
--- a/src/lombok/javac/Javac.java
+++ b/src/lombok/javac/Javac.java
@@ -92,6 +92,7 @@ public class Javac {
List<String> raws = new ArrayList<String>();
List<Object> guesses = new ArrayList<Object>();
final List<DiagnosticPosition> positions = new ArrayList<DiagnosticPosition>();
+ boolean isExplicit = false;
for ( JCExpression arg : arguments ) {
String mName;
@@ -107,6 +108,7 @@ public class Javac {
}
if ( !mName.equals(name) ) continue;
+ isExplicit = true;
if ( rhs instanceof JCNewArray ) {
List<JCExpression> elems = ((JCNewArray)rhs).elems;
for ( JCExpression inner : elems ) {
@@ -121,7 +123,7 @@ public class Javac {
}
}
- values.put(name, new AnnotationValue(node, raws, guesses) {
+ values.put(name, new AnnotationValue(node, raws, guesses, isExplicit) {
@Override public void setError(String message, int valueIdx) {
node.addError(message, positions.get(valueIdx));
}
diff --git a/src/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/lombok/javac/handlers/HandleEqualsAndHashCode.java
index 16a04da7..21966be2 100644
--- a/src/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -84,6 +84,11 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
if ( !annotation.isExplicit("exclude") ) excludes = null;
if ( !annotation.isExplicit("of") ) includes = null;
+ if ( excludes != null && includes != null ) {
+ excludes = null;
+ annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
+ }
+
return generateMethods(typeNode, annotationNode, excludes, includes, callSuper, true);
}
diff --git a/src/lombok/javac/handlers/HandleToString.java b/src/lombok/javac/handlers/HandleToString.java
index 7cdbb6e1..eb2013c7 100644
--- a/src/lombok/javac/handlers/HandleToString.java
+++ b/src/lombok/javac/handlers/HandleToString.java
@@ -81,6 +81,11 @@ public class HandleToString implements JavacAnnotationHandler<ToString> {
if ( !annotation.isExplicit("exclude") ) excludes = null;
if ( !annotation.isExplicit("of") ) includes = null;
+ if ( excludes != null && includes != null ) {
+ excludes = null;
+ annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
+ }
+
return generateToString(typeNode, annotationNode, excludes, includes, ann.includeFieldNames(), callSuper, true);
}