Lines 69-75
Link Here
|
69 |
org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; |
69 |
org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; |
70 |
private String key; |
70 |
private String key; |
71 |
private BindingResolver resolver; |
71 |
private BindingResolver resolver; |
72 |
|
72 |
private ITypeBinding[] interfaces; |
|
|
73 |
private ITypeBinding[] typeParameters; |
74 |
private ITypeBinding[] typeArguments; |
75 |
private ITypeBinding[] typeBounds; |
76 |
private ITypeBinding[] members; |
77 |
|
73 |
public TypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) { |
78 |
public TypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) { |
74 |
this.binding = binding; |
79 |
this.binding = binding; |
75 |
this.resolver = resolver; |
80 |
this.resolver = resolver; |
Lines 248-263
Link Here
|
248 |
* @see ITypeBinding#getDeclaredTypes() |
253 |
* @see ITypeBinding#getDeclaredTypes() |
249 |
*/ |
254 |
*/ |
250 |
public ITypeBinding[] getDeclaredTypes() { |
255 |
public ITypeBinding[] getDeclaredTypes() { |
|
|
256 |
if (this.members != null) { |
257 |
return this.members; |
258 |
} |
251 |
try { |
259 |
try { |
252 |
if (isClass() || isInterface() || isEnum()) { |
260 |
if (isClass() || isInterface() || isEnum()) { |
253 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
261 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
254 |
ReferenceBinding[] members = referenceBinding.memberTypes(); |
262 |
ReferenceBinding[] referenceBindingMembers = referenceBinding.memberTypes(); |
255 |
int length = members.length; |
263 |
int length = referenceBindingMembers == null ? 0 : referenceBindingMembers.length; |
256 |
ITypeBinding[] newMembers = new ITypeBinding[length]; |
264 |
if (length != 0) { |
257 |
for (int i = 0; i < length; i++) { |
265 |
ITypeBinding[] newMembers = new ITypeBinding[length]; |
258 |
newMembers[i] = this.resolver.getTypeBinding(members[i]); |
266 |
for (int i = 0; i < length; i++) { |
|
|
267 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingMembers[i]); |
268 |
if (typeBinding == null) { |
269 |
return this.members = NO_TYPE_BINDINGS; |
270 |
} |
271 |
newMembers[i] = typeBinding; |
272 |
} |
273 |
return this.members = newMembers; |
259 |
} |
274 |
} |
260 |
return newMembers; |
|
|
261 |
} |
275 |
} |
262 |
} catch (RuntimeException e) { |
276 |
} catch (RuntimeException e) { |
263 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
277 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
Lines 266-272
Link Here
|
266 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
280 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
267 |
*/ |
281 |
*/ |
268 |
} |
282 |
} |
269 |
return NO_TYPE_BINDINGS; |
283 |
return this.members = NO_TYPE_BINDINGS; |
270 |
} |
284 |
} |
271 |
|
285 |
|
272 |
/* |
286 |
/* |
Lines 379-395
Link Here
|
379 |
} |
393 |
} |
380 |
|
394 |
|
381 |
public ITypeBinding[] getInterfaces() { |
395 |
public ITypeBinding[] getInterfaces() { |
|
|
396 |
if (this.interfaces != null) { |
397 |
return this.interfaces; |
398 |
} |
382 |
if (this.binding == null) |
399 |
if (this.binding == null) |
383 |
return NO_TYPE_BINDINGS; |
400 |
return this.interfaces = NO_TYPE_BINDINGS; |
384 |
switch (this.binding.kind()) { |
401 |
switch (this.binding.kind()) { |
385 |
case Binding.ARRAY_TYPE : |
402 |
case Binding.ARRAY_TYPE : |
386 |
case Binding.BASE_TYPE : |
403 |
case Binding.BASE_TYPE : |
387 |
return NO_TYPE_BINDINGS; |
404 |
return this.interfaces = NO_TYPE_BINDINGS; |
388 |
} |
405 |
} |
389 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
406 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
390 |
ReferenceBinding[] interfaces = null; |
407 |
ReferenceBinding[] interfacesBinding = null; |
391 |
try { |
408 |
try { |
392 |
interfaces = referenceBinding.superInterfaces(); |
409 |
interfacesBinding = referenceBinding.superInterfaces(); |
393 |
} catch (RuntimeException e) { |
410 |
} catch (RuntimeException e) { |
394 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
411 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
395 |
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 |
412 |
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 |
Lines 397-414
Link Here
|
397 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
414 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
398 |
*/ |
415 |
*/ |
399 |
} |
416 |
} |
400 |
if (interfaces == null) { |
417 |
if (interfacesBinding == null) { |
401 |
return NO_TYPE_BINDINGS; |
418 |
return this.interfaces = NO_TYPE_BINDINGS; |
402 |
} |
419 |
} |
403 |
int length = interfaces.length; |
420 |
int length = interfacesBinding.length; |
404 |
if (length == 0) { |
421 |
if (length == 0) { |
405 |
return NO_TYPE_BINDINGS; |
422 |
return this.interfaces = NO_TYPE_BINDINGS; |
406 |
} else { |
423 |
} else { |
407 |
ITypeBinding[] newInterfaces = new ITypeBinding[length]; |
424 |
ITypeBinding[] newInterfaces = new ITypeBinding[length]; |
408 |
for (int i = 0; i < length; i++) { |
425 |
for (int i = 0; i < length; i++) { |
409 |
newInterfaces[i] = this.resolver.getTypeBinding(interfaces[i]); |
426 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(interfacesBinding[i]); |
|
|
427 |
if (typeBinding == null) { |
428 |
return this.interfaces = NO_TYPE_BINDINGS; |
429 |
} |
430 |
newInterfaces[i] = typeBinding; |
410 |
} |
431 |
} |
411 |
return newInterfaces; |
432 |
return this.interfaces = newInterfaces; |
412 |
} |
433 |
} |
413 |
} |
434 |
} |
414 |
|
435 |
|
Lines 484-490
Link Here
|
484 |
IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement(); |
505 |
IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement(); |
485 |
return (JavaElement) declaringMethod.getTypeParameter(typeVariableName); |
506 |
return (JavaElement) declaringMethod.getTypeParameter(typeVariableName); |
486 |
} else { |
507 |
} else { |
487 |
declaringTypeBinding = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); |
508 |
ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); |
|
|
509 |
if (typeBinding2 == null) return null; |
510 |
declaringTypeBinding = typeBinding2; |
488 |
IType declaringType = (IType) declaringTypeBinding.getJavaElement(); |
511 |
IType declaringType = (IType) declaringTypeBinding.getJavaElement(); |
489 |
return (JavaElement) declaringType.getTypeParameter(typeVariableName); |
512 |
return (JavaElement) declaringType.getTypeParameter(typeVariableName); |
490 |
} |
513 |
} |
Lines 590-604
Link Here
|
590 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
613 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
591 |
buffer = new StringBuffer(); |
614 |
buffer = new StringBuffer(); |
592 |
buffer.append(parameterizedTypeBinding.sourceName()); |
615 |
buffer.append(parameterizedTypeBinding.sourceName()); |
593 |
ITypeBinding[] typeArguments = getTypeArguments(); |
616 |
ITypeBinding[] tArguments = getTypeArguments(); |
594 |
final int typeArgumentsLength = typeArguments.length; |
617 |
final int typeArgumentsLength = tArguments.length; |
595 |
if (typeArgumentsLength != 0) { |
618 |
if (typeArgumentsLength != 0) { |
596 |
buffer.append('<'); |
619 |
buffer.append('<'); |
597 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
620 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
598 |
if (i > 0) { |
621 |
if (i > 0) { |
599 |
buffer.append(','); |
622 |
buffer.append(','); |
600 |
} |
623 |
} |
601 |
buffer.append(typeArguments[i].getName()); |
624 |
buffer.append(tArguments[i].getName()); |
602 |
} |
625 |
} |
603 |
buffer.append('>'); |
626 |
buffer.append('>'); |
604 |
} |
627 |
} |
Lines 743-772
Link Here
|
743 |
.append('.'); |
766 |
.append('.'); |
744 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
767 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
745 |
buffer.append(parameterizedTypeBinding.sourceName()); |
768 |
buffer.append(parameterizedTypeBinding.sourceName()); |
746 |
ITypeBinding[] typeArguments = getTypeArguments(); |
769 |
ITypeBinding[] tArguments = getTypeArguments(); |
747 |
final int typeArgumentsLength = typeArguments.length; |
770 |
final int typeArgumentsLength = tArguments.length; |
748 |
if (typeArgumentsLength != 0) { |
771 |
if (typeArgumentsLength != 0) { |
749 |
buffer.append('<'); |
772 |
buffer.append('<'); |
750 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
773 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
751 |
if (i > 0) { |
774 |
if (i > 0) { |
752 |
buffer.append(','); |
775 |
buffer.append(','); |
753 |
} |
776 |
} |
754 |
buffer.append(typeArguments[i].getQualifiedName()); |
777 |
buffer.append(tArguments[i].getQualifiedName()); |
755 |
} |
778 |
} |
756 |
buffer.append('>'); |
779 |
buffer.append('>'); |
757 |
} |
780 |
} |
758 |
return String.valueOf(buffer); |
781 |
return String.valueOf(buffer); |
759 |
} |
782 |
} |
760 |
buffer.append(getTypeDeclaration().getQualifiedName()); |
783 |
buffer.append(getTypeDeclaration().getQualifiedName()); |
761 |
ITypeBinding[] typeArguments = getTypeArguments(); |
784 |
ITypeBinding[] tArguments = getTypeArguments(); |
762 |
final int typeArgumentsLength = typeArguments.length; |
785 |
final int typeArgumentsLength = tArguments.length; |
763 |
if (typeArgumentsLength != 0) { |
786 |
if (typeArgumentsLength != 0) { |
764 |
buffer.append('<'); |
787 |
buffer.append('<'); |
765 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
788 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
766 |
if (i > 0) { |
789 |
if (i > 0) { |
767 |
buffer.append(','); |
790 |
buffer.append(','); |
768 |
} |
791 |
} |
769 |
buffer.append(typeArguments[i].getQualifiedName()); |
792 |
buffer.append(tArguments[i].getQualifiedName()); |
770 |
} |
793 |
} |
771 |
buffer.append('>'); |
794 |
buffer.append('>'); |
772 |
} |
795 |
} |
Lines 827-858
Link Here
|
827 |
if (superclass == null) { |
850 |
if (superclass == null) { |
828 |
return null; |
851 |
return null; |
829 |
} |
852 |
} |
830 |
return this.resolver.getTypeBinding(superclass); |
853 |
return this.resolver.getTypeBinding(superclass); |
831 |
} |
854 |
} |
832 |
|
855 |
|
833 |
/* (non-Javadoc) |
856 |
/* (non-Javadoc) |
834 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
857 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
835 |
*/ |
858 |
*/ |
836 |
public ITypeBinding[] getTypeArguments() { |
859 |
public ITypeBinding[] getTypeArguments() { |
|
|
860 |
if (this.typeArguments != null) { |
861 |
return this.typeArguments; |
862 |
} |
837 |
if (this.binding.isParameterizedType()) { |
863 |
if (this.binding.isParameterizedType()) { |
838 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
864 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
839 |
final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments; |
865 |
final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments; |
840 |
if (arguments != null) { |
866 |
if (arguments != null) { |
841 |
int argumentsLength = arguments.length; |
867 |
int argumentsLength = arguments.length; |
842 |
ITypeBinding[] typeArguments = new ITypeBinding[argumentsLength]; |
868 |
ITypeBinding[] newTypeArguments = new ITypeBinding[argumentsLength]; |
843 |
for (int i = 0; i < argumentsLength; i++) { |
869 |
for (int i = 0; i < argumentsLength; i++) { |
844 |
typeArguments[i] = this.resolver.getTypeBinding(arguments[i]); |
870 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(arguments[i]); |
|
|
871 |
if (typeBinding == null) { |
872 |
return this.typeArguments = NO_TYPE_BINDINGS; |
873 |
} |
874 |
newTypeArguments[i] = typeBinding; |
845 |
} |
875 |
} |
846 |
return typeArguments; |
876 |
return this.typeArguments = newTypeArguments; |
847 |
} |
877 |
} |
848 |
} |
878 |
} |
849 |
return NO_TYPE_BINDINGS; |
879 |
return this.typeArguments = NO_TYPE_BINDINGS; |
850 |
} |
880 |
} |
851 |
|
881 |
|
852 |
/* (non-Javadoc) |
882 |
/* (non-Javadoc) |
853 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeBounds() |
883 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeBounds() |
854 |
*/ |
884 |
*/ |
855 |
public ITypeBinding[] getTypeBounds() { |
885 |
public ITypeBinding[] getTypeBounds() { |
|
|
886 |
if (this.typeBounds != null) { |
887 |
return this.typeBounds; |
888 |
} |
856 |
if (this.binding instanceof TypeVariableBinding) { |
889 |
if (this.binding instanceof TypeVariableBinding) { |
857 |
TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; |
890 |
TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; |
858 |
ReferenceBinding varSuperclass = typeVariableBinding.superclass(); |
891 |
ReferenceBinding varSuperclass = typeVariableBinding.superclass(); |
Lines 874-916
Link Here
|
874 |
boundsLength += superinterfacesLength; |
907 |
boundsLength += superinterfacesLength; |
875 |
} |
908 |
} |
876 |
if (boundsLength != 0) { |
909 |
if (boundsLength != 0) { |
877 |
ITypeBinding[] typeBounds = new ITypeBinding[boundsLength]; |
910 |
ITypeBinding[] newTypeBounds = new ITypeBinding[boundsLength]; |
878 |
int boundsIndex = 0; |
911 |
int boundsIndex = 0; |
879 |
if (firstClassOrArrayBound != null) { |
912 |
if (firstClassOrArrayBound != null) { |
880 |
typeBounds[boundsIndex++] = this.resolver.getTypeBinding(firstClassOrArrayBound); |
913 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(firstClassOrArrayBound); |
|
|
914 |
if (typeBinding == null) { |
915 |
return this.typeBounds = NO_TYPE_BINDINGS; |
916 |
} |
917 |
newTypeBounds[boundsIndex++] = typeBinding; |
881 |
} |
918 |
} |
882 |
if (superinterfaces != null) { |
919 |
if (superinterfaces != null) { |
883 |
for (int i = 0; i < superinterfacesLength; i++, boundsIndex++) { |
920 |
for (int i = 0; i < superinterfacesLength; i++, boundsIndex++) { |
884 |
typeBounds[boundsIndex] = this.resolver.getTypeBinding(superinterfaces[i]); |
921 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(superinterfaces[i]); |
|
|
922 |
if (typeBinding == null) { |
923 |
return this.typeBounds = NO_TYPE_BINDINGS; |
924 |
} |
925 |
newTypeBounds[boundsIndex] = typeBinding; |
885 |
} |
926 |
} |
886 |
} |
927 |
} |
887 |
return typeBounds; |
928 |
return this.typeBounds = newTypeBounds; |
888 |
} |
929 |
} |
889 |
} |
930 |
} |
890 |
return NO_TYPE_BINDINGS; |
931 |
return this.typeBounds = NO_TYPE_BINDINGS; |
891 |
} |
932 |
} |
892 |
|
933 |
|
893 |
/* (non-Javadoc) |
934 |
/* (non-Javadoc) |
894 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeParameters() |
935 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeParameters() |
895 |
*/ |
936 |
*/ |
896 |
public ITypeBinding[] getTypeParameters() { |
937 |
public ITypeBinding[] getTypeParameters() { |
|
|
938 |
if (this.typeParameters != null) { |
939 |
return this.typeParameters; |
940 |
} |
897 |
switch(this.binding.kind()) { |
941 |
switch(this.binding.kind()) { |
898 |
case Binding.RAW_TYPE : |
942 |
case Binding.RAW_TYPE : |
899 |
case Binding.PARAMETERIZED_TYPE : |
943 |
case Binding.PARAMETERIZED_TYPE : |
900 |
return NO_TYPE_BINDINGS; |
944 |
return this.typeParameters = NO_TYPE_BINDINGS; |
901 |
} |
945 |
} |
902 |
TypeVariableBinding[] typeVariableBindings = this.binding.typeVariables(); |
946 |
TypeVariableBinding[] typeVariableBindings = this.binding.typeVariables(); |
903 |
if (typeVariableBindings != null) { |
947 |
if (typeVariableBindings != null) { |
904 |
int typeVariableBindingsLength = typeVariableBindings.length; |
948 |
int typeVariableBindingsLength = typeVariableBindings.length; |
905 |
if (typeVariableBindingsLength != 0) { |
949 |
if (typeVariableBindingsLength != 0) { |
906 |
ITypeBinding[] typeParameters = new ITypeBinding[typeVariableBindingsLength]; |
950 |
ITypeBinding[] tParameters = new ITypeBinding[typeVariableBindingsLength]; |
907 |
for (int i = 0; i < typeVariableBindingsLength; i++) { |
951 |
for (int i = 0; i < typeVariableBindingsLength; i++) { |
908 |
typeParameters[i] = this.resolver.getTypeBinding(typeVariableBindings[i]); |
952 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(typeVariableBindings[i]); |
|
|
953 |
if (typeBinding == null) { |
954 |
return this.typeParameters = NO_TYPE_BINDINGS; |
955 |
} |
956 |
tParameters[i] = typeBinding; |
909 |
} |
957 |
} |
910 |
return typeParameters; |
958 |
return this.typeParameters = tParameters; |
911 |
} |
959 |
} |
912 |
} |
960 |
} |
913 |
return NO_TYPE_BINDINGS; |
961 |
return this.typeParameters = NO_TYPE_BINDINGS; |
914 |
} |
962 |
} |
915 |
|
963 |
|
916 |
/* (non-Javadoc) |
964 |
/* (non-Javadoc) |