diff options
author | Roel Spilker <r.spilker@gmail.com> | 2010-07-25 02:17:54 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2010-07-25 02:17:54 +0200 |
commit | 42107d6a8ef41ed13565b041f00a3d9e6b6c1989 (patch) | |
tree | 23dad045dd6ca18e7f3d5be370947cbc688d1c99 /src/core/lombok/eclipse | |
parent | acb0e52bc09a66e9a5b5446c374cbc90a732762a (diff) | |
download | lombok-42107d6a8ef41ed13565b041f00a3d9e6b6c1989.tar.gz lombok-42107d6a8ef41ed13565b041f00a3d9e6b6c1989.tar.bz2 lombok-42107d6a8ef41ed13565b041f00a3d9e6b6c1989.zip |
Issue 133: @ToString on an inner class should print Outer.Inner instead of Inner
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleToString.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java index 37c73bc8..93821412 100644 --- a/src/core/lombok/eclipse/handlers/HandleToString.java +++ b/src/core/lombok/eclipse/handlers/HandleToString.java @@ -177,9 +177,7 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> { private MethodDeclaration createToString(EclipseNode type, Collection<EclipseNode> fields, boolean includeFieldNames, boolean callSuper, ASTNode source, boolean useFieldsDirectly) { - TypeDeclaration typeDeclaration = (TypeDeclaration)type.get(); - char[] rawTypeName = typeDeclaration.name; - String typeName = rawTypeName == null ? "" : new String(rawTypeName); + String typeName = getTypeName(type); char[] suffix = ")".toCharArray(); String infixS = ", "; char[] infix = infixS.toCharArray(); @@ -285,6 +283,22 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> { return method; } + private String getTypeName(EclipseNode type) { + String typeName = getSingleTypeName(type); + EclipseNode upType = type.up(); + while (upType.getKind() == Kind.TYPE) { + typeName = getSingleTypeName(upType) + "." + typeName; + upType = upType.up(); + } + return typeName; + } + + private String getSingleTypeName(EclipseNode type) { + TypeDeclaration typeDeclaration = (TypeDeclaration)type.get(); + char[] rawTypeName = typeDeclaration.name; + return rawTypeName == null ? "" : new String(rawTypeName); + } + private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); |