Lines 69-74
Link Here
|
69 |
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; |
69 |
private 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 |
private ITypeBinding[] members; |
73 |
private ITypeBinding[] interfaces; |
74 |
private ITypeBinding[] typeArguments; |
75 |
private ITypeBinding[] typeParameters; |
76 |
private ITypeBinding[] bounds; |
72 |
|
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; |
Lines 84-91
Link Here
|
84 |
int length = internalAnnotations == null ? 0 : internalAnnotations.length; |
89 |
int length = internalAnnotations == null ? 0 : internalAnnotations.length; |
85 |
if (length > 0) { |
90 |
if (length > 0) { |
86 |
domInstances = new AnnotationBinding[length]; |
91 |
domInstances = new AnnotationBinding[length]; |
87 |
for (int i = 0; i < length; i++) |
92 |
for (int i = 0; i < length; i++) { |
88 |
domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); |
93 |
IAnnotationBinding annotationInstance = this.resolver.getAnnotationInstance(internalAnnotations[i]); |
|
|
94 |
if (annotationInstance == null) { |
95 |
return AnnotationBinding.NoAnnotations; |
96 |
} |
97 |
domInstances[i] = annotationInstance; |
98 |
} |
89 |
} |
99 |
} |
90 |
} |
100 |
} |
91 |
return domInstances; |
101 |
return domInstances; |
Lines 234-249
Link Here
|
234 |
* @see ITypeBinding#getDeclaredTypes() |
244 |
* @see ITypeBinding#getDeclaredTypes() |
235 |
*/ |
245 |
*/ |
236 |
public ITypeBinding[] getDeclaredTypes() { |
246 |
public ITypeBinding[] getDeclaredTypes() { |
|
|
247 |
if (this.members != null) { |
248 |
return this.members; |
249 |
} |
237 |
try { |
250 |
try { |
238 |
if (isClass() || isInterface() || isEnum()) { |
251 |
if (isClass() || isInterface() || isEnum()) { |
239 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
252 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
240 |
ReferenceBinding[] members = referenceBinding.memberTypes(); |
253 |
ReferenceBinding[] referenceBindingMembers = referenceBinding.memberTypes(); |
241 |
int length = members.length; |
254 |
int length = referenceBindingMembers.length; |
242 |
ITypeBinding[] newMembers = new ITypeBinding[length]; |
255 |
ITypeBinding[] newMembers = new ITypeBinding[length]; |
243 |
for (int i = 0; i < length; i++) { |
256 |
for (int i = 0; i < length; i++) { |
244 |
newMembers[i] = this.resolver.getTypeBinding(members[i]); |
257 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingMembers[i]); |
|
|
258 |
if (typeBinding == null) { |
259 |
return this.members = NO_TYPE_BINDINGS; |
260 |
} |
261 |
newMembers[i] = typeBinding; |
245 |
} |
262 |
} |
246 |
return newMembers; |
263 |
return this.members = newMembers; |
247 |
} |
264 |
} |
248 |
} catch (RuntimeException e) { |
265 |
} catch (RuntimeException e) { |
249 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
266 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
Lines 252-258
Link Here
|
252 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
269 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
253 |
*/ |
270 |
*/ |
254 |
} |
271 |
} |
255 |
return NO_TYPE_BINDINGS; |
272 |
return this.members = NO_TYPE_BINDINGS; |
256 |
} |
273 |
} |
257 |
|
274 |
|
258 |
/* |
275 |
/* |
Lines 365-381
Link Here
|
365 |
} |
382 |
} |
366 |
|
383 |
|
367 |
public ITypeBinding[] getInterfaces() { |
384 |
public ITypeBinding[] getInterfaces() { |
|
|
385 |
if (this.interfaces != null) { |
386 |
return this.interfaces; |
387 |
} |
368 |
if (this.binding == null) |
388 |
if (this.binding == null) |
369 |
return NO_TYPE_BINDINGS; |
389 |
return this.interfaces = NO_TYPE_BINDINGS; |
370 |
switch (this.binding.kind()) { |
390 |
switch (this.binding.kind()) { |
371 |
case Binding.ARRAY_TYPE : |
391 |
case Binding.ARRAY_TYPE : |
372 |
case Binding.BASE_TYPE : |
392 |
case Binding.BASE_TYPE : |
373 |
return NO_TYPE_BINDINGS; |
393 |
return this.interfaces = NO_TYPE_BINDINGS; |
374 |
} |
394 |
} |
375 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
395 |
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; |
376 |
ReferenceBinding[] interfaces = null; |
396 |
ReferenceBinding[] referenceBindingInterfaces = null; |
377 |
try { |
397 |
try { |
378 |
interfaces = referenceBinding.superInterfaces(); |
398 |
referenceBindingInterfaces = referenceBinding.superInterfaces(); |
379 |
} catch (RuntimeException e) { |
399 |
} catch (RuntimeException e) { |
380 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
400 |
/* in case a method cannot be resolvable due to missing jars on the classpath |
381 |
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 |
401 |
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 |
Lines 383-400
Link Here
|
383 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
403 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 |
384 |
*/ |
404 |
*/ |
385 |
} |
405 |
} |
386 |
if (interfaces == null) { |
406 |
if (referenceBindingInterfaces == null) { |
387 |
return NO_TYPE_BINDINGS; |
407 |
return this.interfaces = NO_TYPE_BINDINGS; |
388 |
} |
408 |
} |
389 |
int length = interfaces.length; |
409 |
int length = referenceBindingInterfaces.length; |
390 |
if (length == 0) { |
410 |
if (length == 0) { |
391 |
return NO_TYPE_BINDINGS; |
411 |
return this.interfaces = NO_TYPE_BINDINGS; |
392 |
} else { |
412 |
} else { |
393 |
ITypeBinding[] newInterfaces = new ITypeBinding[length]; |
413 |
ITypeBinding[] newInterfaces = new ITypeBinding[length]; |
394 |
for (int i = 0; i < length; i++) { |
414 |
for (int i = 0; i < length; i++) { |
395 |
newInterfaces[i] = this.resolver.getTypeBinding(interfaces[i]); |
415 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingInterfaces[i]); |
|
|
416 |
if (typeBinding == null) { |
417 |
return this.interfaces = NO_TYPE_BINDINGS; |
418 |
} |
419 |
newInterfaces[i] = typeBinding; |
396 |
} |
420 |
} |
397 |
return newInterfaces; |
421 |
return this.interfaces = newInterfaces; |
398 |
} |
422 |
} |
399 |
} |
423 |
} |
400 |
|
424 |
|
Lines 470-476
Link Here
|
470 |
IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement(); |
494 |
IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement(); |
471 |
return (JavaElement) declaringMethod.getTypeParameter(typeVariableName); |
495 |
return (JavaElement) declaringMethod.getTypeParameter(typeVariableName); |
472 |
} else { |
496 |
} else { |
473 |
declaringTypeBinding = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); |
497 |
ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); |
|
|
498 |
if (typeBinding2 == null) return null; |
499 |
declaringTypeBinding = typeBinding2; |
474 |
IType declaringType = (IType) declaringTypeBinding.getJavaElement(); |
500 |
IType declaringType = (IType) declaringTypeBinding.getJavaElement(); |
475 |
return (JavaElement) declaringType.getTypeParameter(typeVariableName); |
501 |
return (JavaElement) declaringType.getTypeParameter(typeVariableName); |
476 |
} |
502 |
} |
Lines 576-590
Link Here
|
576 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
602 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
577 |
buffer = new StringBuffer(); |
603 |
buffer = new StringBuffer(); |
578 |
buffer.append(parameterizedTypeBinding.sourceName()); |
604 |
buffer.append(parameterizedTypeBinding.sourceName()); |
579 |
ITypeBinding[] typeArguments = getTypeArguments(); |
605 |
ITypeBinding[] tArguments = getTypeArguments(); |
580 |
final int typeArgumentsLength = typeArguments.length; |
606 |
final int typeArgumentsLength = tArguments.length; |
581 |
if (typeArgumentsLength != 0) { |
607 |
if (typeArgumentsLength != 0) { |
582 |
buffer.append('<'); |
608 |
buffer.append('<'); |
583 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
609 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
584 |
if (i > 0) { |
610 |
if (i > 0) { |
585 |
buffer.append(','); |
611 |
buffer.append(','); |
586 |
} |
612 |
} |
587 |
buffer.append(typeArguments[i].getName()); |
613 |
buffer.append(tArguments[i].getName()); |
588 |
} |
614 |
} |
589 |
buffer.append('>'); |
615 |
buffer.append('>'); |
590 |
} |
616 |
} |
Lines 729-758
Link Here
|
729 |
.append('.'); |
755 |
.append('.'); |
730 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
756 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
731 |
buffer.append(parameterizedTypeBinding.sourceName()); |
757 |
buffer.append(parameterizedTypeBinding.sourceName()); |
732 |
ITypeBinding[] typeArguments = getTypeArguments(); |
758 |
ITypeBinding[] tArguments = getTypeArguments(); |
733 |
final int typeArgumentsLength = typeArguments.length; |
759 |
final int typeArgumentsLength = tArguments.length; |
734 |
if (typeArgumentsLength != 0) { |
760 |
if (typeArgumentsLength != 0) { |
735 |
buffer.append('<'); |
761 |
buffer.append('<'); |
736 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
762 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
737 |
if (i > 0) { |
763 |
if (i > 0) { |
738 |
buffer.append(','); |
764 |
buffer.append(','); |
739 |
} |
765 |
} |
740 |
buffer.append(typeArguments[i].getQualifiedName()); |
766 |
buffer.append(tArguments[i].getQualifiedName()); |
741 |
} |
767 |
} |
742 |
buffer.append('>'); |
768 |
buffer.append('>'); |
743 |
} |
769 |
} |
744 |
return String.valueOf(buffer); |
770 |
return String.valueOf(buffer); |
745 |
} |
771 |
} |
746 |
buffer.append(getTypeDeclaration().getQualifiedName()); |
772 |
buffer.append(getTypeDeclaration().getQualifiedName()); |
747 |
ITypeBinding[] typeArguments = getTypeArguments(); |
773 |
ITypeBinding[] tArguments = getTypeArguments(); |
748 |
final int typeArgumentsLength = typeArguments.length; |
774 |
final int typeArgumentsLength = tArguments.length; |
749 |
if (typeArgumentsLength != 0) { |
775 |
if (typeArgumentsLength != 0) { |
750 |
buffer.append('<'); |
776 |
buffer.append('<'); |
751 |
for (int i = 0, max = typeArguments.length; i < max; i++) { |
777 |
for (int i = 0, max = tArguments.length; i < max; i++) { |
752 |
if (i > 0) { |
778 |
if (i > 0) { |
753 |
buffer.append(','); |
779 |
buffer.append(','); |
754 |
} |
780 |
} |
755 |
buffer.append(typeArguments[i].getQualifiedName()); |
781 |
buffer.append(tArguments[i].getQualifiedName()); |
756 |
} |
782 |
} |
757 |
buffer.append('>'); |
783 |
buffer.append('>'); |
758 |
} |
784 |
} |
Lines 820-844
Link Here
|
820 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
846 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() |
821 |
*/ |
847 |
*/ |
822 |
public ITypeBinding[] getTypeArguments() { |
848 |
public ITypeBinding[] getTypeArguments() { |
|
|
849 |
if (this.typeArguments != null) { |
850 |
return this.typeArguments; |
851 |
} |
823 |
if (this.binding.isParameterizedType()) { |
852 |
if (this.binding.isParameterizedType()) { |
824 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
853 |
ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; |
825 |
final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments; |
854 |
final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments; |
826 |
if (arguments != null) { |
855 |
if (arguments != null) { |
827 |
int argumentsLength = arguments.length; |
856 |
int argumentsLength = arguments.length; |
828 |
ITypeBinding[] typeArguments = new ITypeBinding[argumentsLength]; |
857 |
if (argumentsLength != 0) { |
829 |
for (int i = 0; i < argumentsLength; i++) { |
858 |
ITypeBinding[] tArguments = new ITypeBinding[argumentsLength]; |
830 |
typeArguments[i] = this.resolver.getTypeBinding(arguments[i]); |
859 |
for (int i = 0; i < argumentsLength; i++) { |
|
|
860 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(arguments[i]); |
861 |
if (typeBinding == null) { |
862 |
return this.typeArguments = NO_TYPE_BINDINGS; |
863 |
} |
864 |
tArguments[i] = typeBinding; |
865 |
} |
866 |
return this.typeArguments = tArguments; |
831 |
} |
867 |
} |
832 |
return typeArguments; |
|
|
833 |
} |
868 |
} |
834 |
} |
869 |
} |
835 |
return NO_TYPE_BINDINGS; |
870 |
return this.typeArguments = NO_TYPE_BINDINGS; |
836 |
} |
871 |
} |
837 |
|
872 |
|
838 |
/* (non-Javadoc) |
873 |
/* (non-Javadoc) |
839 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeBounds() |
874 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeBounds() |
840 |
*/ |
875 |
*/ |
841 |
public ITypeBinding[] getTypeBounds() { |
876 |
public ITypeBinding[] getTypeBounds() { |
|
|
877 |
if (this.bounds != null) { |
878 |
return this.bounds; |
879 |
} |
842 |
if (this.binding instanceof TypeVariableBinding) { |
880 |
if (this.binding instanceof TypeVariableBinding) { |
843 |
TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; |
881 |
TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; |
844 |
ReferenceBinding varSuperclass = typeVariableBinding.superclass(); |
882 |
ReferenceBinding varSuperclass = typeVariableBinding.superclass(); |
Lines 863-902
Link Here
|
863 |
ITypeBinding[] typeBounds = new ITypeBinding[boundsLength]; |
901 |
ITypeBinding[] typeBounds = new ITypeBinding[boundsLength]; |
864 |
int boundsIndex = 0; |
902 |
int boundsIndex = 0; |
865 |
if (firstClassOrArrayBound != null) { |
903 |
if (firstClassOrArrayBound != null) { |
866 |
typeBounds[boundsIndex++] = this.resolver.getTypeBinding(firstClassOrArrayBound); |
904 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(firstClassOrArrayBound); |
|
|
905 |
if (typeBinding == null) { |
906 |
return this.bounds = NO_TYPE_BINDINGS; |
907 |
} |
908 |
typeBounds[boundsIndex++] = typeBinding; |
867 |
} |
909 |
} |
868 |
if (superinterfaces != null) { |
910 |
if (superinterfaces != null) { |
869 |
for (int i = 0; i < superinterfacesLength; i++, boundsIndex++) { |
911 |
for (int i = 0; i < superinterfacesLength; i++, boundsIndex++) { |
870 |
typeBounds[boundsIndex] = this.resolver.getTypeBinding(superinterfaces[i]); |
912 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(superinterfaces[i]); |
|
|
913 |
if (typeBinding == null) { |
914 |
return this.bounds = NO_TYPE_BINDINGS; |
915 |
} |
916 |
typeBounds[boundsIndex] = typeBinding; |
871 |
} |
917 |
} |
872 |
} |
918 |
} |
873 |
return typeBounds; |
919 |
return this.bounds = typeBounds; |
874 |
} |
920 |
} |
875 |
} |
921 |
} |
876 |
return NO_TYPE_BINDINGS; |
922 |
return this.bounds = NO_TYPE_BINDINGS; |
877 |
} |
923 |
} |
878 |
|
924 |
|
879 |
/* (non-Javadoc) |
925 |
/* (non-Javadoc) |
880 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeParameters() |
926 |
* @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeParameters() |
881 |
*/ |
927 |
*/ |
882 |
public ITypeBinding[] getTypeParameters() { |
928 |
public ITypeBinding[] getTypeParameters() { |
|
|
929 |
if (this.typeParameters != null) { |
930 |
return this.typeParameters; |
931 |
} |
883 |
switch(this.binding.kind()) { |
932 |
switch(this.binding.kind()) { |
884 |
case Binding.RAW_TYPE : |
933 |
case Binding.RAW_TYPE : |
885 |
case Binding.PARAMETERIZED_TYPE : |
934 |
case Binding.PARAMETERIZED_TYPE : |
886 |
return NO_TYPE_BINDINGS; |
935 |
return this.typeParameters = NO_TYPE_BINDINGS; |
887 |
} |
936 |
} |
888 |
TypeVariableBinding[] typeVariableBindings = this.binding.typeVariables(); |
937 |
TypeVariableBinding[] typeVariableBindings = this.binding.typeVariables(); |
889 |
if (typeVariableBindings != null) { |
938 |
if (typeVariableBindings != null) { |
890 |
int typeVariableBindingsLength = typeVariableBindings.length; |
939 |
int typeVariableBindingsLength = typeVariableBindings.length; |
891 |
if (typeVariableBindingsLength != 0) { |
940 |
if (typeVariableBindingsLength != 0) { |
892 |
ITypeBinding[] typeParameters = new ITypeBinding[typeVariableBindingsLength]; |
941 |
ITypeBinding[] tParameters = new ITypeBinding[typeVariableBindingsLength]; |
893 |
for (int i = 0; i < typeVariableBindingsLength; i++) { |
942 |
for (int i = 0; i < typeVariableBindingsLength; i++) { |
894 |
typeParameters[i] = this.resolver.getTypeBinding(typeVariableBindings[i]); |
943 |
ITypeBinding typeBinding = this.resolver.getTypeBinding(typeVariableBindings[i]); |
|
|
944 |
if (typeBinding == null) { |
945 |
return this.typeParameters = NO_TYPE_BINDINGS; |
946 |
} |
947 |
tParameters[i] = typeBinding; |
895 |
} |
948 |
} |
896 |
return typeParameters; |
949 |
return this.typeParameters = tParameters; |
897 |
} |
950 |
} |
898 |
} |
951 |
} |
899 |
return NO_TYPE_BINDINGS; |
952 |
return this.typeParameters = NO_TYPE_BINDINGS; |
900 |
} |
953 |
} |
901 |
|
954 |
|
902 |
/* (non-Javadoc) |
955 |
/* (non-Javadoc) |