|
44 | 44 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; |
45 | 45 | import org.eclipse.jdt.core.dom.AnonymousClassDeclaration; |
46 | 46 | import org.eclipse.jdt.core.dom.BodyDeclaration; |
| 47 | +import org.eclipse.jdt.core.dom.ClassInstanceCreation; |
47 | 48 | import org.eclipse.jdt.core.dom.CompilationUnit; |
48 | 49 | import org.eclipse.jdt.core.dom.IAnnotationBinding; |
49 | 50 | import org.eclipse.jdt.core.dom.IBinding; |
@@ -231,7 +232,7 @@ private IJavaElement computeJavaElement() { |
231 | 232 | if (getDeclaringMethod() != null && getDeclaringMethod().getJavaElement() instanceof IMethod method) { |
232 | 233 | // TODO find proper occurenceCount (eg checking the source range) |
233 | 234 | return resolved(method.getType(this.typeSymbol.name.toString(), 1)); |
234 | | - } |
| 235 | + } |
235 | 236 | } |
236 | 237 |
|
237 | 238 | JavaFileObject jfo = classSymbol == null ? null : classSymbol.sourcefile; |
@@ -361,7 +362,7 @@ public String getGenericTypeSignature(boolean useSlashes) { |
361 | 362 | return getGenericTypeSignature(this.type, this.typeSymbol, useSlashes); |
362 | 363 | } |
363 | 364 | public String getGenericTypeSignature(Type t, TypeSymbol s, boolean useSlashes) { |
364 | | - if( t instanceof ClassType ct && ct.getEnclosingType() != null ) { |
| 365 | + if( t instanceof ClassType ct && !s.isAnonymous() && ct.getEnclosingType() != null ) { |
365 | 366 | // return Lg1/t/s/def/Generic<Ljava/lang/Exception;>.Member; |
366 | 367 | // Don't return Lg1/t/s/def/Generic$Member<>; |
367 | 368 | Type enclosing = ct.getEnclosingType(); |
@@ -487,16 +488,17 @@ static void getKey(StringBuilder builder, Type typeToBuild, String n, boolean is |
487 | 488 | } |
488 | 489 | } |
489 | 490 |
|
490 | | - /* |
491 | | - * TODO - this name 'n' might be something like test0502.A$1 |
492 | | - * but the test suite expects test0502.A$182, |
493 | | - * where 182 is the location in the source of the symbol. |
494 | | - */ |
495 | 491 | String nameAsString = n.toString(); |
496 | 492 | if (useSlashes) { |
497 | 493 | nameAsString = nameAsString.replace('.', '/'); |
498 | 494 | } |
499 | 495 | nameAsString = nameAsString.replaceFirst("\\$([0-9]+)([A-Za-z$_][A-Za-z$_0-9]*)", "\\$$1\\$$2"); |
| 496 | + if (typeToBuild.tsym.isAnonymous()) { |
| 497 | + ASTNode node = resolver.symbolToDeclaration.get(typeToBuild.tsym); |
| 498 | + if (node != null && node.getParent() instanceof ClassInstanceCreation cic) { |
| 499 | + nameAsString = nameAsString.replaceFirst("\\$([0-9]+)", "\\$" + cic.getType().getStartPosition()); |
| 500 | + } |
| 501 | + } |
500 | 502 | builder.append(nameAsString); |
501 | 503 | // This is a hack and will likely need to be enhanced |
502 | 504 | if (typeToBuild.tsym instanceof ClassSymbol classSymbol && !(classSymbol.type instanceof ErrorType) && classSymbol.owner instanceof PackageSymbol) { |
|
0 commit comments