aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleToString.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-07-18 00:24:56 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-07-18 00:34:22 +0200
commit8869e9759478403d362f919fde6b79075e7950d6 (patch)
treeacb6d06a9f46f5a0dc054137ba63f13240fb2727 /src/core/lombok/javac/handlers/HandleToString.java
parent51b031c732a86cb28b35c9b6c9b31916d3846c88 (diff)
downloadlombok-8869e9759478403d362f919fde6b79075e7950d6.tar.gz
lombok-8869e9759478403d362f919fde6b79075e7950d6.tar.bz2
lombok-8869e9759478403d362f919fde6b79075e7950d6.zip
All field accesses done by generated lombok methods are now qualified with 'this.'
Addresses issue #48
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleToString.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java
index dd3df620..cdba7558 100644
--- a/src/core/lombok/javac/handlers/HandleToString.java
+++ b/src/core/lombok/javac/handlers/HandleToString.java
@@ -40,6 +40,7 @@ import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCModifiers;
@@ -202,14 +203,16 @@ public class HandleToString implements JavacAnnotationHandler<ToString> {
JCVariableDecl field = (JCVariableDecl) fieldNode.get();
JCExpression expr;
+ JCFieldAccess thisX = maker.Select(maker.Ident(fieldNode.toName("this")), field.name);
+
if (field.vartype instanceof JCArrayTypeTree) {
boolean multiDim = ((JCArrayTypeTree)field.vartype).elemtype instanceof JCArrayTypeTree;
boolean primitiveArray = ((JCArrayTypeTree)field.vartype).elemtype instanceof JCPrimitiveTypeTree;
boolean useDeepTS = multiDim || !primitiveArray;
JCExpression hcMethod = chainDots(maker, typeNode, "java", "util", "Arrays", useDeepTS ? "deepToString" : "toString");
- expr = maker.Apply(List.<JCExpression>nil(), hcMethod, List.<JCExpression>of(maker.Ident(field.name)));
- } else expr = maker.Ident(field.name);
+ expr = maker.Apply(List.<JCExpression>nil(), hcMethod, List.<JCExpression>of(thisX));
+ } else expr = thisX;
if (first) {
current = maker.Binary(JCTree.PLUS, current, expr);