View | Details | Raw Unified | Return to bug 100636 | Differences between
and this patch

Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/ASTParser.java (-4 / +14 lines)
Lines 20-33 Link Here
20
import org.eclipse.jdt.core.JavaCore;
20
import org.eclipse.jdt.core.JavaCore;
21
import org.eclipse.jdt.core.JavaModelException;
21
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.WorkingCopyOwner;
22
import org.eclipse.jdt.core.WorkingCopyOwner;
23
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.IProblem;
24
import org.eclipse.jdt.core.compiler.IProblem;
24
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
25
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
25
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
26
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
26
import org.eclipse.jdt.internal.compiler.ast.Statement;
27
import org.eclipse.jdt.internal.compiler.ast.Statement;
27
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
28
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
29
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
28
import org.eclipse.jdt.internal.core.*;
30
import org.eclipse.jdt.internal.core.*;
29
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
30
import org.eclipse.jdt.internal.core.PackageFragment;
31
import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil;
31
import org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil;
32
import org.eclipse.jdt.internal.core.util.RecordedParsingInformation;
32
import org.eclipse.jdt.internal.core.util.RecordedParsingInformation;
33
import org.eclipse.jdt.internal.core.util.Util;
33
import org.eclipse.jdt.internal.core.util.Util;
Lines 756-763 Link Here
756
							PackageFragment packageFragment = (PackageFragment) this.classFileSource.getParent();
756
							PackageFragment packageFragment = (PackageFragment) this.classFileSource.getParent();
757
							BinaryType type = (BinaryType) this.classFileSource.getType();
757
							BinaryType type = (BinaryType) this.classFileSource.getType();
758
							IBinaryType binaryType = (IBinaryType) type.getElementInfo();
758
							IBinaryType binaryType = (IBinaryType) type.getElementInfo();
759
							String fileName = new String(binaryType.getFileName()); // file name is used to recreate the Java element, so it has to be the .class file name
759
							// file name is used to recreate the Java element, so it has to be the toplevel .class file name
760
							sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), fileName, this.project);
760
							char[] fileName = binaryType.getFileName();
761
							int firstDollar = CharOperation.indexOf('$', fileName);
762
							if (firstDollar != -1) {
763
								char[] suffix = SuffixConstants.SUFFIX_class;
764
								int suffixLength = suffix.length;
765
								char[] newFileName = new char[firstDollar + suffixLength];
766
								System.arraycopy(fileName, 0, newFileName, 0, firstDollar);
767
								System.arraycopy(suffix, 0, newFileName, firstDollar, suffixLength);
768
								fileName = newFileName;
769
							}
770
							sourceUnit = new BasicCompilationUnit(sourceString.toCharArray(), Util.toCharArrays(packageFragment.names), new String(fileName), this.project);
761
							element = this.classFileSource;
771
							element = this.classFileSource;
762
						} catch(JavaModelException e) {
772
						} catch(JavaModelException e) {
763
							// an error occured accessing the java element
773
							// an error occured accessing the java element
(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-5 / +11 lines)
Lines 396-408 Link Here
396
		else
396
		else
397
			referenceBinding = (ReferenceBinding) typeBinding;
397
			referenceBinding = (ReferenceBinding) typeBinding;
398
		char[] fileName = referenceBinding.getFileName();
398
		char[] fileName = referenceBinding.getFileName();
399
		if (Util.isClassFileName(fileName)) {
400
			ClassFile classFile = (ClassFile) getClassFile(fileName);
401
			if (classFile == null) return null;
402
			return (JavaElement) classFile.getType();
403
		}
404
		if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) {
399
		if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) {
405
			// local or anonymous type
400
			// local or anonymous type
401
			if (Util.isClassFileName(fileName)) {
402
				// TODO (jerome) use constant pool name to create the right class file name for anonymous
403
				ClassFile classFile = (ClassFile) getClassFile(fileName);
404
				if (classFile == null) return null;
405
				return (JavaElement) classFile.getType();
406
			}
406
			ICompilationUnit cu = getCompilationUnit(fileName);
407
			ICompilationUnit cu = getCompilationUnit(fileName);
407
			if (cu == null) return null;
408
			if (cu == null) return null;
408
			if (!(this.resolver instanceof DefaultBindingResolver)) return null;
409
			if (!(this.resolver instanceof DefaultBindingResolver)) return null;
Lines 435-440 Link Here
435
			ITypeBinding declaringTypeBinding = getDeclaringClass();
436
			ITypeBinding declaringTypeBinding = getDeclaringClass();
436
			if (declaringTypeBinding == null) {
437
			if (declaringTypeBinding == null) {
437
				// top level type
438
				// top level type
439
				if (Util.isClassFileName(fileName)) {
440
					ClassFile classFile = (ClassFile) getClassFile(fileName);
441
					if (classFile == null) return null;
442
					return (JavaElement) classFile.getType();
443
				}
438
				ICompilationUnit cu = getCompilationUnit(fileName);
444
				ICompilationUnit cu = getCompilationUnit(fileName);
439
				if (cu == null) return null;
445
				if (cu == null) return null;
440
				return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
446
				return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));

Return to bug 100636