Index: dom/org/eclipse/jdt/core/dom/ASTParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v retrieving revision 1.44 diff -u -r1.44 ASTParser.java --- dom/org/eclipse/jdt/core/dom/ASTParser.java 8 Jun 2005 01:11:22 -0000 1.44 +++ dom/org/eclipse/jdt/core/dom/ASTParser.java 22 Jun 2005 12:51:38 -0000 @@ -20,14 +20,14 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.WorkingCopyOwner; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; import org.eclipse.jdt.internal.compiler.ast.Statement; import org.eclipse.jdt.internal.compiler.env.IBinaryType; +import org.eclipse.jdt.internal.compiler.util.SuffixConstants; import org.eclipse.jdt.internal.core.*; -import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner; -import org.eclipse.jdt.internal.core.PackageFragment; import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil; import org.eclipse.jdt.internal.core.util.RecordedParsingInformation; import org.eclipse.jdt.internal.core.util.Util; @@ -756,8 +756,18 @@ PackageFragment packageFragment = (PackageFragment) this.classFileSource.getParent(); BinaryType type = (BinaryType) this.classFileSource.getType(); IBinaryType binaryType = (IBinaryType) type.getElementInfo(); - String fileName = new String(binaryType.getFileName()); // file name is used to recreate the Java element, so it has to be the .class file name - sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), fileName, this.project); + // file name is used to recreate the Java element, so it has to be the toplevel .class file name + char[] fileName = binaryType.getFileName(); + int firstDollar = CharOperation.indexOf('$', fileName); + if (firstDollar != -1) { + char[] suffix = SuffixConstants.SUFFIX_class; + int suffixLength = suffix.length; + char[] newFileName = new char[firstDollar + suffixLength]; + System.arraycopy(fileName, 0, newFileName, 0, firstDollar); + System.arraycopy(suffix, 0, newFileName, firstDollar, suffixLength); + fileName = newFileName; + } + sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), new String(fileName), this.project); element = this.classFileSource; } catch(JavaModelException e) { // an error occured accessing the java element Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v retrieving revision 1.104 diff -u -r1.104 TypeBinding.java --- dom/org/eclipse/jdt/core/dom/TypeBinding.java 15 Jun 2005 16:29:45 -0000 1.104 +++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 22 Jun 2005 12:51:39 -0000 @@ -396,13 +396,14 @@ else referenceBinding = (ReferenceBinding) typeBinding; char[] fileName = referenceBinding.getFileName(); - if (Util.isClassFileName(fileName)) { - ClassFile classFile = (ClassFile) getClassFile(fileName); - if (classFile == null) return null; - return (JavaElement) classFile.getType(); - } if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) { // local or anonymous type + if (Util.isClassFileName(fileName)) { + // TODO (jerome) use constant pool name to create the right class file name for anonymous + ClassFile classFile = (ClassFile) getClassFile(fileName); + if (classFile == null) return null; + return (JavaElement) classFile.getType(); + } ICompilationUnit cu = getCompilationUnit(fileName); if (cu == null) return null; if (!(this.resolver instanceof DefaultBindingResolver)) return null; @@ -435,6 +436,11 @@ ITypeBinding declaringTypeBinding = getDeclaringClass(); if (declaringTypeBinding == null) { // top level type + if (Util.isClassFileName(fileName)) { + ClassFile classFile = (ClassFile) getClassFile(fileName); + if (classFile == null) return null; + return (JavaElement) classFile.getType(); + } ICompilationUnit cu = getCompilationUnit(fileName); if (cu == null) return null; return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));