Lines 15-22
Link Here
|
15 |
|
15 |
|
16 |
import org.eclipse.jdt.core.IJavaElement; |
16 |
import org.eclipse.jdt.core.IJavaElement; |
17 |
import org.eclipse.jdt.core.JavaModelException; |
17 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
|
|
21 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
20 |
import org.eclipse.jdt.internal.compiler.util.Util; |
22 |
import org.eclipse.jdt.internal.compiler.util.Util; |
21 |
import org.eclipse.jdt.internal.core.CompilationUnit; |
23 |
import org.eclipse.jdt.internal.core.CompilationUnit; |
22 |
import org.eclipse.jdt.internal.core.PackageFragment; |
24 |
import org.eclipse.jdt.internal.core.PackageFragment; |
Lines 73-78
Link Here
|
73 |
} |
75 |
} |
74 |
|
76 |
|
75 |
/* (non-Javadoc) |
77 |
/* (non-Javadoc) |
|
|
78 |
* @see java.lang.Object#equals(java.lang.Object) |
79 |
*/ |
80 |
public boolean equals(Object obj) { |
81 |
if (this == obj) return true; // super implementation |
82 |
if (obj instanceof RecoveredTypeBinding) { |
83 |
RecoveredTypeBinding otherTypeBinding = (RecoveredTypeBinding) obj; |
84 |
if (this.innerTypeBinding != null) { |
85 |
return getName().equals(otherTypeBinding.getName()) && this.innerTypeBinding.equals(otherTypeBinding.innerTypeBinding); |
86 |
} |
87 |
if (this.referenceBinding != null && otherTypeBinding.referenceBinding != null) { |
88 |
ReferenceBinding currentReferenceTypeBinding = null; |
89 |
ReferenceBinding otherReferenceTypeBinding = null; |
90 |
if (this.referenceBinding.isArrayType() && otherTypeBinding.referenceBinding.isArrayType()) { |
91 |
ArrayBinding currentArrayBinding = (ArrayBinding) this.referenceBinding; |
92 |
ArrayBinding otherArrayBinding = (ArrayBinding) otherTypeBinding.referenceBinding; |
93 |
if (currentArrayBinding.leafComponentType instanceof ReferenceBinding && |
94 |
otherArrayBinding.leafComponentType instanceof ReferenceBinding) { |
95 |
currentReferenceTypeBinding = (ReferenceBinding) currentArrayBinding.leafComponentType; |
96 |
otherReferenceTypeBinding = (ReferenceBinding) otherArrayBinding.leafComponentType; |
97 |
} |
98 |
} else if (this.referenceBinding instanceof ReferenceBinding && |
99 |
otherTypeBinding.referenceBinding instanceof ReferenceBinding) { |
100 |
currentReferenceTypeBinding = (ReferenceBinding) this.referenceBinding; |
101 |
otherReferenceTypeBinding = (ReferenceBinding) otherTypeBinding.referenceBinding; |
102 |
} |
103 |
if (currentReferenceTypeBinding != null && otherReferenceTypeBinding != null) { |
104 |
return CharOperation.equals(currentReferenceTypeBinding.compoundName, otherReferenceTypeBinding.compoundName); |
105 |
} |
106 |
} else { |
107 |
return getType().toString().equals(otherTypeBinding.toString()); |
108 |
} |
109 |
} |
110 |
return false; |
111 |
} |
112 |
|
113 |
/* (non-Javadoc) |
76 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getBinaryName() |
114 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getBinaryName() |
77 |
*/ |
115 |
*/ |
78 |
public String getBinaryName() { |
116 |
public String getBinaryName() { |
Lines 206-219
Link Here
|
206 |
if (this.innerTypeBinding != null) { |
244 |
if (this.innerTypeBinding != null) { |
207 |
return this.innerTypeBinding.getInternalName(); |
245 |
return this.innerTypeBinding.getInternalName(); |
208 |
} else if (this.referenceBinding != null) { |
246 |
} else if (this.referenceBinding != null) { |
209 |
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding typeBinding = null; |
247 |
ReferenceBinding typeBinding = null; |
210 |
if (this.referenceBinding.isArrayType()) { |
248 |
if (this.referenceBinding.isArrayType()) { |
211 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
249 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
212 |
if (arrayBinding.leafComponentType instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
250 |
if (arrayBinding.leafComponentType instanceof ReferenceBinding) { |
213 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) arrayBinding.leafComponentType; |
251 |
typeBinding = (ReferenceBinding) arrayBinding.leafComponentType; |
214 |
} |
252 |
} |
215 |
} else if (this.referenceBinding instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
253 |
} else if (this.referenceBinding instanceof ReferenceBinding) { |
216 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.referenceBinding; |
254 |
typeBinding = (ReferenceBinding) this.referenceBinding; |
217 |
} |
255 |
} |
218 |
if (typeBinding != null) { |
256 |
if (typeBinding != null) { |
219 |
return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); |
257 |
return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); |
Lines 244-250
Link Here
|
244 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
282 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
245 |
*/ |
283 |
*/ |
246 |
public ITypeBinding getSuperclass() { |
284 |
public ITypeBinding getSuperclass() { |
247 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
285 |
ITypeBinding object = this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
|
|
286 |
if (equals(object)) { |
287 |
// avoid loop when java.lang.Object is also recovered |
288 |
return null; |
289 |
} |
290 |
return object; |
248 |
} |
291 |
} |
249 |
|
292 |
|
250 |
/* (non-Javadoc) |
293 |
/* (non-Javadoc) |