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 / +23 lines)
Lines 48-53 Link Here
48
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
48
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
49
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
49
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
50
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
50
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
51
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
51
import org.eclipse.jdt.internal.compiler.util.Util;
52
import org.eclipse.jdt.internal.compiler.util.Util;
52
import org.eclipse.jdt.internal.core.ClassFile;
53
import org.eclipse.jdt.internal.core.ClassFile;
53
import org.eclipse.jdt.internal.core.JavaElement;
54
import org.eclipse.jdt.internal.core.JavaElement;
Lines 396-408 Link Here
396
		else
397
		else
397
			referenceBinding = (ReferenceBinding) typeBinding;
398
			referenceBinding = (ReferenceBinding) typeBinding;
398
		char[] fileName = referenceBinding.getFileName();
399
		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()) {
400
		if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) {
405
			// local or anonymous type
401
			// local or anonymous type
402
			if (Util.isClassFileName(fileName)) {
403
				int lastSlash = CharOperation.lastIndexOf('/', fileName);
404
				if (lastSlash == -1) 
405
					lastSlash = CharOperation.lastIndexOf(File.separatorChar, fileName);
406
				if (lastSlash == -1)
407
					return null;
408
				IPackageFragment pkg = getPackageFragment(fileName, lastSlash);
409
				char[] constantPoolName = referenceBinding.constantPoolName();
410
				if (constantPoolName == null) {
411
					ClassFile classFile = (ClassFile) getClassFile(fileName);
412
					return classFile == null ? null : (JavaElement) classFile.getType();
413
				}
414
				lastSlash = CharOperation.lastIndexOf('/', constantPoolName);
415
				char[] classFileName = CharOperation.subarray(constantPoolName, lastSlash+1, constantPoolName.length);
416
				ClassFile classFile = (ClassFile) pkg.getClassFile(new String(classFileName) + SuffixConstants.SUFFIX_STRING_class);
417
				return (JavaElement) classFile.getType();
418
			}
406
			ICompilationUnit cu = getCompilationUnit(fileName);
419
			ICompilationUnit cu = getCompilationUnit(fileName);
407
			if (cu == null) return null;
420
			if (cu == null) return null;
408
			if (!(this.resolver instanceof DefaultBindingResolver)) return null;
421
			if (!(this.resolver instanceof DefaultBindingResolver)) return null;
Lines 435-440 Link Here
435
			ITypeBinding declaringTypeBinding = getDeclaringClass();
448
			ITypeBinding declaringTypeBinding = getDeclaringClass();
436
			if (declaringTypeBinding == null) {
449
			if (declaringTypeBinding == null) {
437
				// top level type
450
				// top level type
451
				if (Util.isClassFileName(fileName)) {
452
					ClassFile classFile = (ClassFile) getClassFile(fileName);
453
					if (classFile == null) return null;
454
					return (JavaElement) classFile.getType();
455
				}
438
				ICompilationUnit cu = getCompilationUnit(fileName);
456
				ICompilationUnit cu = getCompilationUnit(fileName);
439
				if (cu == null) return null;
457
				if (cu == null) return null;
440
				return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
458
				return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));

Return to bug 100636