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/javac/handlers/HandleToString.java | |
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/javac/handlers/HandleToString.java')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleToString.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java index 7b1b3b81..4dce4b9f 100644 --- a/src/core/lombok/javac/handlers/HandleToString.java +++ b/src/core/lombok/javac/handlers/HandleToString.java @@ -174,7 +174,7 @@ public class HandleToString implements JavacAnnotationHandler<ToString> { boolean first = true; - String typeName = ((JCClassDecl) typeNode.get()).name.toString(); + String typeName = getTypeName(typeNode); String infix = ", "; String suffix = ")"; String prefix; @@ -237,4 +237,14 @@ public class HandleToString implements JavacAnnotationHandler<ToString> { return maker.MethodDef(mods, typeNode.toName("toString"), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null); } + + private String getTypeName(JavacNode typeNode) { + String typeName = ((JCClassDecl) typeNode.get()).name.toString(); + JavacNode upType = typeNode.up(); + while (upType.getKind() == Kind.TYPE) { + typeName = ((JCClassDecl) upType.get()).name.toString() + "." + typeName; + upType = upType.up(); + } + return typeName; + } } |