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 19 Aug 2005 10:06:06 -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.105 diff -u -r1.105 TypeBinding.java --- dom/org/eclipse/jdt/core/dom/TypeBinding.java 7 Jul 2005 10:44:03 -0000 1.105 +++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 19 Aug 2005 10:06:07 -0000 @@ -48,6 +48,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; +import org.eclipse.jdt.internal.compiler.util.SuffixConstants; import org.eclipse.jdt.internal.compiler.util.Util; import org.eclipse.jdt.internal.core.ClassFile; import org.eclipse.jdt.internal.core.JavaElement; @@ -396,13 +397,25 @@ 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)) { + int lastSlash = CharOperation.lastIndexOf('/', fileName); + if (lastSlash == -1) + lastSlash = CharOperation.lastIndexOf(File.separatorChar, fileName); + if (lastSlash == -1) + return null; + IPackageFragment pkg = getPackageFragment(fileName, lastSlash); + char[] constantPoolName = referenceBinding.constantPoolName(); + if (constantPoolName == null) { + ClassFile classFile = (ClassFile) getClassFile(fileName); + return classFile == null ? null : (JavaElement) classFile.getType(); + } + lastSlash = CharOperation.lastIndexOf('/', constantPoolName); + char[] classFileName = CharOperation.subarray(constantPoolName, lastSlash+1, constantPoolName.length); + ClassFile classFile = (ClassFile) pkg.getClassFile(new String(classFileName) + SuffixConstants.SUFFIX_STRING_class); + return (JavaElement) classFile.getType(); + } ICompilationUnit cu = getCompilationUnit(fileName); if (cu == null) return null; if (!(this.resolver instanceof DefaultBindingResolver)) return null; @@ -435,6 +448,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()));