### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/Signature.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java,v retrieving revision 1.87 diff -u -r1.87 Signature.java --- model/org/eclipse/jdt/core/Signature.java 24 Nov 2006 01:32:02 -0000 1.87 +++ model/org/eclipse/jdt/core/Signature.java 26 Apr 2007 15:19:13 -0000 @@ -2495,6 +2495,8 @@ } int p = start + 1; int checkpoint = buffer.length(); + int innerTypeStart = -1; + boolean inAnonymousType = false; while (true) { if (p >= string.length) { throw new IllegalArgumentException(); @@ -2527,6 +2529,8 @@ } break; case C_DOLLAR : + innerTypeStart = buffer.length(); + inAnonymousType = false; if (resolved) { // once we hit "$" there are no more package prefixes removePackageQualifiers = false; @@ -2540,7 +2544,15 @@ } break; default : - buffer.append(c); + if (innerTypeStart != -1 && !inAnonymousType && Character.isDigit(c)) { + inAnonymousType = true; + buffer.setLength(innerTypeStart); // remove '.' + buffer.insert(0, "new "); //$NON-NLS-1$ + buffer.append("(){}"); //$NON-NLS-1$ + } + if (!inAnonymousType) + buffer.append(c); + innerTypeStart = -1; } p++; } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/SignatureTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SignatureTests.java,v retrieving revision 1.43 diff -u -r1.43 SignatureTests.java --- src/org/eclipse/jdt/core/tests/model/SignatureTests.java 6 Nov 2006 14:20:15 -0000 1.43 +++ src/org/eclipse/jdt/core/tests/model/SignatureTests.java 26 Apr 2007 15:19:14 -0000 @@ -813,6 +813,18 @@ assertEquals("Signature#toQualifiedName is not correct3", "", Signature.toQualifiedName(new String[0])); } + +/* + * Ensures that the toString() signature of an anonymous type is correct + * (regression test for bug 180713 Anonymous type rendered as number in hover) + */ +public void testToStringAnonymousType() { + assertEquals( + "Signature#toString is not correct", + "new X(){}", + Signature.toString("LX$123;")); +} + /** * @see Signature#toString(String) */ @@ -1031,6 +1043,17 @@ Signature.toString("Lx.y.A$Inner;")); } +/* + * Ensures that the toString() signature of a member type with a number in its name is correct + * (regression test for bug 180713 Anonymous type rendered as number in hover) + */ +public void testToStringInnerType2() { + assertEquals( + "Signature#toString is not correct", + "X.Y1", + Signature.toString("LX$Y1;")); +} + /** * @see Signature#getTypeSignatureKind(String) */