diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-07-22 01:59:58 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-07-22 01:59:58 +0200 |
commit | 0a9d754fa5a659d34b422d07520937b355188df0 (patch) | |
tree | 89ea318bffc0f686314e39869aa0ac4a6d272435 /src/core | |
parent | 3e2392fb302ee2aafe93814a6b7aef4121a4fbbc (diff) | |
download | lombok-0a9d754fa5a659d34b422d07520937b355188df0.tar.gz lombok-0a9d754fa5a659d34b422d07520937b355188df0.tar.bz2 lombok-0a9d754fa5a659d34b422d07520937b355188df0.zip |
eclipse toString() now uses .getX() instead of .x.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleToString.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java index f409b5c4..37c73bc8 100644 --- a/src/core/lombok/eclipse/handlers/HandleToString.java +++ b/src/core/lombok/eclipse/handlers/HandleToString.java @@ -45,7 +45,6 @@ import org.eclipse.jdt.internal.compiler.ast.BinaryExpression; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; -import org.eclipse.jdt.internal.compiler.ast.FieldReference; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NameReference; @@ -57,8 +56,8 @@ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.eclipse.jdt.internal.compiler.ast.Statement; import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.ast.SuperReference; -import org.eclipse.jdt.internal.compiler.ast.ThisReference; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.mangosdk.spi.ProviderFor; @@ -217,29 +216,24 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> { } for (EclipseNode field : fields) { - FieldDeclaration f = (FieldDeclaration)field.get(); - if (f.name == null || f.type == null) continue; - - FieldReference thisX = new FieldReference(f.name, p); - Eclipse.setGeneratedBy(thisX, source); - thisX.receiver = new ThisReference(source.sourceStart, source.sourceEnd); - Eclipse.setGeneratedBy(thisX.receiver, source); + TypeReference fType = getFieldType(field, useFieldsDirectly); + Expression fieldAccessor = createFieldAccessor(field, useFieldsDirectly, source); Expression ex; - if (f.type.dimensions() > 0) { + if (fType.dimensions() > 0) { MessageSend arrayToString = new MessageSend(); arrayToString.sourceStart = pS; arrayToString.sourceEnd = pE; arrayToString.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.UTIL, "Arrays".toCharArray()); - arrayToString.arguments = new Expression[] { thisX }; + arrayToString.arguments = new Expression[] { fieldAccessor }; Eclipse.setGeneratedBy(arrayToString.arguments[0], source); - if (f.type.dimensions() > 1 || !BUILT_IN_TYPES.contains(new String(f.type.getLastToken()))) { + if (fType.dimensions() > 1 || !BUILT_IN_TYPES.contains(new String(fType.getLastToken()))) { arrayToString.selector = "deepToString".toCharArray(); } else { arrayToString.selector = "toString".toCharArray(); } ex = arrayToString; } else { - ex = thisX; + ex = fieldAccessor; } Eclipse.setGeneratedBy(ex, source); @@ -253,7 +247,7 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> { StringLiteral fieldNameLiteral; if (includeFieldNames) { - char[] namePlusEqualsSign = (infixS + new String(f.name) + "=").toCharArray(); + char[] namePlusEqualsSign = (infixS + field.getName() + "=").toCharArray(); fieldNameLiteral = new StringLiteral(namePlusEqualsSign, pS, pE, 0); } else { fieldNameLiteral = new StringLiteral(infix, pS, pE, 0); |