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 32-38
Link Here
|
32 |
private int dimensions; |
34 |
private int dimensions; |
33 |
private RecoveredTypeBinding innerTypeBinding; |
35 |
private RecoveredTypeBinding innerTypeBinding; |
34 |
private ITypeBinding[] typeArguments; |
36 |
private ITypeBinding[] typeArguments; |
35 |
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding; |
37 |
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding; |
36 |
|
38 |
|
37 |
RecoveredTypeBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { |
39 |
RecoveredTypeBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { |
38 |
this.variableDeclaration = variableDeclaration; |
40 |
this.variableDeclaration = variableDeclaration; |
Lines 44-53
Link Here
|
44 |
} |
46 |
} |
45 |
} |
47 |
} |
46 |
|
48 |
|
47 |
RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) { |
49 |
RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding) { |
48 |
this.resolver = resolver; |
50 |
this.resolver = resolver; |
49 |
this.dimensions = referenceBinding.dimensions(); |
51 |
this.dimensions = typeBinding.dimensions(); |
50 |
this.referenceBinding = referenceBinding; |
52 |
this.typeBinding = typeBinding; |
51 |
} |
53 |
} |
52 |
|
54 |
|
53 |
RecoveredTypeBinding(BindingResolver resolver, Type type) { |
55 |
RecoveredTypeBinding(BindingResolver resolver, Type type) { |
Lines 147-158
Link Here
|
147 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() |
149 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() |
148 |
*/ |
150 |
*/ |
149 |
public ITypeBinding getElementType() { |
151 |
public ITypeBinding getElementType() { |
150 |
if (this.referenceBinding != null) { |
152 |
if (this.typeBinding != null) { |
151 |
if (this.referenceBinding.isArrayType()) { |
153 |
if (this.typeBinding.isArrayType()) { |
152 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
154 |
ArrayBinding arrayBinding = (ArrayBinding) this.typeBinding; |
153 |
return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); |
155 |
return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); |
154 |
} else { |
156 |
} else { |
155 |
return new RecoveredTypeBinding(this.resolver, this.referenceBinding); |
157 |
return new RecoveredTypeBinding(this.resolver, this.typeBinding); |
156 |
} |
158 |
} |
157 |
} |
159 |
} |
158 |
if (this.innerTypeBinding != null) { |
160 |
if (this.innerTypeBinding != null) { |
Lines 205-223
Link Here
|
205 |
private String getInternalName() { |
207 |
private String getInternalName() { |
206 |
if (this.innerTypeBinding != null) { |
208 |
if (this.innerTypeBinding != null) { |
207 |
return this.innerTypeBinding.getInternalName(); |
209 |
return this.innerTypeBinding.getInternalName(); |
208 |
} else if (this.referenceBinding != null) { |
210 |
} |
209 |
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding typeBinding = null; |
211 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
210 |
if (this.referenceBinding.isArrayType()) { |
212 |
if (referenceBinding != null) { |
211 |
ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; |
213 |
return new String(referenceBinding.compoundName[referenceBinding.compoundName.length - 1]); |
212 |
if (arrayBinding.leafComponentType instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
|
|
213 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) arrayBinding.leafComponentType; |
214 |
} |
215 |
} else if (this.referenceBinding instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { |
216 |
typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.referenceBinding; |
217 |
} |
218 |
if (typeBinding != null) { |
219 |
return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); |
220 |
} |
221 |
} |
214 |
} |
222 |
return this.getTypeNameFrom(getType()); |
215 |
return this.getTypeNameFrom(getType()); |
223 |
} |
216 |
} |
Lines 226-231
Link Here
|
226 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
219 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() |
227 |
*/ |
220 |
*/ |
228 |
public IPackageBinding getPackage() { |
221 |
public IPackageBinding getPackage() { |
|
|
222 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
223 |
if (referenceBinding != null) { |
224 |
IPackageBinding packageBinding = this.resolver.getPackageBinding(referenceBinding.fPackage); |
225 |
if (packageBinding != null) return packageBinding; |
226 |
} |
229 |
CompilationUnitScope scope = this.resolver.scope(); |
227 |
CompilationUnitScope scope = this.resolver.scope(); |
230 |
if (scope != null) { |
228 |
if (scope != null) { |
231 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
229 |
return this.resolver.getPackageBinding(scope.getCurrentPackage()); |
Lines 237-249
Link Here
|
237 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
235 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() |
238 |
*/ |
236 |
*/ |
239 |
public String getQualifiedName() { |
237 |
public String getQualifiedName() { |
240 |
return this.getName(); |
238 |
ReferenceBinding referenceBinding = getReferenceBinding(); |
|
|
239 |
if (referenceBinding != null) { |
240 |
return CharOperation.toString(referenceBinding.compoundName); |
241 |
} |
242 |
return getName(); |
243 |
} |
244 |
|
245 |
private ReferenceBinding getReferenceBinding() { |
246 |
if (this.typeBinding != null) { |
247 |
if (this.typeBinding.isArrayType()) { |
248 |
ArrayBinding arrayBinding = (ArrayBinding) this.typeBinding; |
249 |
if (arrayBinding.leafComponentType instanceof ReferenceBinding) { |
250 |
return (ReferenceBinding) arrayBinding.leafComponentType; |
251 |
} |
252 |
} else if (this.typeBinding instanceof ReferenceBinding) { |
253 |
return (ReferenceBinding) this.typeBinding; |
254 |
} |
255 |
} |
256 |
return null; |
241 |
} |
257 |
} |
242 |
|
258 |
|
243 |
/* (non-Javadoc) |
259 |
/* (non-Javadoc) |
244 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
260 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() |
245 |
*/ |
261 |
*/ |
246 |
public ITypeBinding getSuperclass() { |
262 |
public ITypeBinding getSuperclass() { |
|
|
263 |
if (getQualifiedName().equals("java.lang.Object")) { //$NON-NLS-1$ |
264 |
return null; |
265 |
} |
247 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
266 |
return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ |
248 |
} |
267 |
} |
249 |
|
268 |
|
Lines 251-257
Link Here
|
251 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
270 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
252 |
*/ |
271 |
*/ |
253 |
public ITypeBinding[] getTypeArguments() { |
272 |
public ITypeBinding[] getTypeArguments() { |
254 |
if (this.referenceBinding != null) { |
273 |
if (this.typeBinding != null) { |
255 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
274 |
return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; |
256 |
} |
275 |
} |
257 |
if (this.typeArguments != null) { |
276 |
if (this.typeArguments != null) { |
Lines 331-342
Link Here
|
331 |
/* (non-Javadoc) |
350 |
/* (non-Javadoc) |
332 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
351 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
333 |
*/ |
352 |
*/ |
334 |
public boolean isAssignmentCompatible(ITypeBinding typeBinding) { |
353 |
public boolean isAssignmentCompatible(ITypeBinding binding) { |
335 |
if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ |
354 |
if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ |
336 |
return true; |
355 |
return true; |
337 |
} |
356 |
} |
338 |
// since recovered binding are not unique isEqualTo is required |
357 |
// since recovered binding are not unique isEqualTo is required |
339 |
return this.isEqualTo(typeBinding); |
358 |
return this.isEqualTo(binding); |
340 |
} |
359 |
} |
341 |
|
360 |
|
342 |
/* (non-Javadoc) |
361 |
/* (non-Javadoc) |
Lines 349-360
Link Here
|
349 |
/* (non-Javadoc) |
368 |
/* (non-Javadoc) |
350 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
369 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
351 |
*/ |
370 |
*/ |
352 |
public boolean isCastCompatible(ITypeBinding typeBinding) { |
371 |
public boolean isCastCompatible(ITypeBinding binding) { |
353 |
if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ |
372 |
if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ |
354 |
return true; |
373 |
return true; |
355 |
} |
374 |
} |
356 |
// since recovered binding are not unique isEqualTo is required |
375 |
// since recovered binding are not unique isEqualTo is required |
357 |
return this.isEqualTo(typeBinding); |
376 |
return this.isEqualTo(binding); |
358 |
} |
377 |
} |
359 |
|
378 |
|
360 |
/* (non-Javadoc) |
379 |
/* (non-Javadoc) |
Lines 450-461
Link Here
|
450 |
/* (non-Javadoc) |
469 |
/* (non-Javadoc) |
451 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
470 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding) |
452 |
*/ |
471 |
*/ |
453 |
public boolean isSubTypeCompatible(ITypeBinding typeBinding) { |
472 |
public boolean isSubTypeCompatible(ITypeBinding binding) { |
454 |
if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ |
473 |
if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ |
455 |
return true; |
474 |
return true; |
456 |
} |
475 |
} |
457 |
// since recovered binding are not unique isEqualTo is required |
476 |
// since recovered binding are not unique isEqualTo is required |
458 |
return this.isEqualTo(typeBinding); |
477 |
return this.isEqualTo(binding); |
459 |
} |
478 |
} |
460 |
|
479 |
|
461 |
/* (non-Javadoc) |
480 |
/* (non-Javadoc) |
Lines 523-531
Link Here
|
523 |
} else if (this.currentType != null) { |
542 |
} else if (this.currentType != null) { |
524 |
buffer.append("currentType") //$NON-NLS-1$ |
543 |
buffer.append("currentType") //$NON-NLS-1$ |
525 |
.append(this.currentType.toString()); |
544 |
.append(this.currentType.toString()); |
526 |
} else if (this.referenceBinding != null) { |
545 |
} else if (this.typeBinding != null) { |
527 |
buffer.append("referenceBinding") //$NON-NLS-1$ |
546 |
buffer.append("typeBinding") //$NON-NLS-1$ |
528 |
.append(this.referenceBinding.computeUniqueKey()); |
547 |
.append(this.typeBinding.computeUniqueKey()); |
529 |
} else if (variableDeclaration != null) { |
548 |
} else if (variableDeclaration != null) { |
530 |
buffer |
549 |
buffer |
531 |
.append("variableDeclaration") //$NON-NLS-1$ |
550 |
.append("variableDeclaration") //$NON-NLS-1$ |