Java Code Examples for org.eclipse.jdt.internal.compiler.util.Util#effectivelyEqual()
The following examples show how to use
org.eclipse.jdt.internal.compiler.util.Util#effectivelyEqual() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotatableTypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public ArrayBinding getArrayType(TypeBinding leafType, int dimensions, AnnotationBinding [] annotations) { ArrayBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(leafType); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isArrayType() || derivedType.dimensions() != dimensions || derivedType.leafComponentType() != leafType) //$IDENTITY-COMPARISON$ continue; if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) return (ArrayBinding) derivedType; if (!derivedType.hasTypeAnnotations()) nakedType = (ArrayBinding) derivedType; } if (nakedType == null) nakedType = super.getArrayType(leafType, dimensions); if (!haveTypeAnnotations(leafType, annotations)) return nakedType; ArrayBinding arrayType = new ArrayBinding(leafType, dimensions, this.environment); arrayType.id = nakedType.id; arrayType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); return (ArrayBinding) cacheDerivedType(leafType, nakedType, arrayType); }
Example 2
Source File: TypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public ParameterizedTypeBinding getParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { ReferenceBinding unannotatedGenericType = (ReferenceBinding) getUnannotatedType(genericType); int typeArgumentsLength = typeArguments == null ? 0: typeArguments.length; TypeBinding [] unannotatedTypeArguments = typeArguments == null ? null : new TypeBinding[typeArgumentsLength]; for (int i = 0; i < typeArgumentsLength; i++) { unannotatedTypeArguments[i] = getUnannotatedType(typeArguments[i]); } ReferenceBinding unannotatedEnclosingType = enclosingType == null ? null : (ReferenceBinding) getUnannotatedType(enclosingType); TypeBinding[] derivedTypes = this.types[unannotatedGenericType.id]; int i, length = derivedTypes.length; for (i = 0 ; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isParameterizedType() || derivedType.actualType() != unannotatedGenericType || derivedType.hasTypeAnnotations()) //$IDENTITY-COMPARISON$ continue; if (derivedType.enclosingType() == unannotatedEnclosingType && Util.effectivelyEqual(derivedType.typeArguments(), unannotatedTypeArguments)) //$IDENTITY-COMPARISON$ return (ParameterizedTypeBinding) derivedType; } if (i == length) { System.arraycopy(derivedTypes, 0, derivedTypes = new TypeBinding[length * 2], 0, length); this.types[unannotatedGenericType.id] = derivedTypes; } TypeBinding parameterizedType = derivedTypes[i] = new ParameterizedTypeBinding(unannotatedGenericType, unannotatedTypeArguments, unannotatedEnclosingType, this.environment); int typesLength = this.types.length; if (this.typeid == typesLength) System.arraycopy(this.types, 0, this.types = new TypeBinding[typesLength * 2][], 0, typesLength); this.types[this.typeid] = new TypeBinding[1]; return (ParameterizedTypeBinding) (this.types[parameterizedType.id = this.typeid++][0] = parameterizedType); }
Example 3
Source File: TypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public WildcardBinding getWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind) { if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation genericType = ReferenceBinding.LUB_GENERIC; ReferenceBinding unannotatedGenericType = (ReferenceBinding) getUnannotatedType(genericType); int otherBoundsLength = otherBounds == null ? 0: otherBounds.length; TypeBinding [] unannotatedOtherBounds = otherBounds == null ? null : new TypeBinding[otherBoundsLength]; for (int i = 0; i < otherBoundsLength; i++) { unannotatedOtherBounds[i] = getUnannotatedType(otherBounds[i]); } TypeBinding unannotatedBound = bound == null ? null : getUnannotatedType(bound); TypeBinding[] derivedTypes = this.types[unannotatedGenericType.id]; // by construction, cachedInfo != null now. int i, length = derivedTypes.length; for (i = 0; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isWildcard() || derivedType.actualType() != unannotatedGenericType || derivedType.hasTypeAnnotations()) //$IDENTITY-COMPARISON$ continue; if (derivedType.rank() != rank || derivedType.boundKind() != boundKind || derivedType.bound() != unannotatedBound) //$IDENTITY-COMPARISON$ continue; if (Util.effectivelyEqual(derivedType.additionalBounds(), unannotatedOtherBounds)) return (WildcardBinding) derivedType; } if (i == length) { System.arraycopy(derivedTypes, 0, derivedTypes = new TypeBinding[length * 2], 0, length); this.types[unannotatedGenericType.id] = derivedTypes; } TypeBinding wildcard = derivedTypes[i] = new WildcardBinding(unannotatedGenericType, rank, unannotatedBound, unannotatedOtherBounds, boundKind, this.environment); int typesLength = this.types.length; if (this.typeid == typesLength) System.arraycopy(this.types, 0, this.types = new TypeBinding[typesLength * 2][], 0, typesLength); this.types[this.typeid] = new TypeBinding[1]; return (WildcardBinding) (this.types[wildcard.id = this.typeid++][0] = wildcard); }
Example 4
Source File: AnnotatableTypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public ParameterizedTypeBinding getParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType, AnnotationBinding [] annotations) { if (genericType.hasTypeAnnotations()) // @NonNull (List<String>) and not (@NonNull List)<String> throw new IllegalStateException(); ParameterizedTypeBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(genericType); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isParameterizedType() || derivedType.actualType() != genericType) //$IDENTITY-COMPARISON$ continue; if (derivedType.enclosingType() != enclosingType || !Util.effectivelyEqual(derivedType.typeArguments(), typeArguments)) //$IDENTITY-COMPARISON$ continue; if (Util.effectivelyEqual(annotations, derivedType.getTypeAnnotations())) return (ParameterizedTypeBinding) derivedType; if (!derivedType.hasTypeAnnotations()) nakedType = (ParameterizedTypeBinding) derivedType; } if (nakedType == null) nakedType = super.getParameterizedType(genericType, typeArguments, enclosingType); if (!haveTypeAnnotations(genericType, enclosingType, typeArguments, annotations)) return nakedType; TypeBinding parameterizedType = new ParameterizedTypeBinding(genericType, typeArguments, enclosingType, this.environment); parameterizedType.id = nakedType.id; parameterizedType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); return (ParameterizedTypeBinding) cacheDerivedType(genericType, nakedType, parameterizedType); }
Example 5
Source File: AnnotatableTypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RawTypeBinding getRawType(ReferenceBinding genericType, ReferenceBinding enclosingType, AnnotationBinding [] annotations) { if (genericType.hasTypeAnnotations()) throw new IllegalStateException(); RawTypeBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(genericType); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isRawType() || derivedType.actualType() != genericType || derivedType.enclosingType() != enclosingType) //$IDENTITY-COMPARISON$ continue; if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) return (RawTypeBinding) derivedType; if (!derivedType.hasTypeAnnotations()) nakedType = (RawTypeBinding) derivedType; } if (nakedType == null) nakedType = super.getRawType(genericType, enclosingType); if (!haveTypeAnnotations(genericType, enclosingType, null, annotations)) return nakedType; RawTypeBinding rawType = new RawTypeBinding(genericType, enclosingType, this.environment); rawType.id = nakedType.id; rawType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); return (RawTypeBinding) cacheDerivedType(genericType, nakedType, rawType); }
Example 6
Source File: AnnotatableTypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public WildcardBinding getWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind, AnnotationBinding [] annotations) { if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation genericType = ReferenceBinding.LUB_GENERIC; if (genericType.hasTypeAnnotations()) throw new IllegalStateException(); WildcardBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(genericType); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (!derivedType.isWildcard() || derivedType.actualType() != genericType || derivedType.rank() != rank) //$IDENTITY-COMPARISON$ continue; if (derivedType.boundKind() != boundKind || derivedType.bound() != bound || !Util.effectivelyEqual(derivedType.additionalBounds(), otherBounds)) //$IDENTITY-COMPARISON$ continue; if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) return (WildcardBinding) derivedType; if (!derivedType.hasTypeAnnotations()) nakedType = (WildcardBinding) derivedType; } if (nakedType == null) nakedType = super.getWildcard(genericType, rank, bound, otherBounds, boundKind); if (!haveTypeAnnotations(genericType, bound, otherBounds, annotations)) return nakedType; WildcardBinding wildcard = new WildcardBinding(genericType, rank, bound, otherBounds, boundKind, this.environment); wildcard.id = nakedType.id; wildcard.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); return (WildcardBinding) cacheDerivedType(genericType, nakedType, wildcard); }
Example 7
Source File: AnnotatableTypeSystem.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private TypeBinding getAnnotatedType(TypeBinding type, TypeBinding enclosingType, AnnotationBinding[] annotations) { TypeBinding nakedType = null; TypeBinding[] derivedTypes = getDerivedTypes(type); for (int i = 0, length = derivedTypes.length; i < length; i++) { TypeBinding derivedType = derivedTypes[i]; if (derivedType == null) break; if (derivedType.enclosingType() != enclosingType || !Util.effectivelyEqual(derivedType.typeArguments(), type.typeArguments())) //$IDENTITY-COMPARISON$ continue; switch(type.kind()) { case Binding.ARRAY_TYPE: if (!derivedType.isArrayType() || derivedType.dimensions() != type.dimensions() || derivedType.leafComponentType() != type.leafComponentType()) //$IDENTITY-COMPARISON$ continue; break; case Binding.PARAMETERIZED_TYPE: if (!derivedType.isParameterizedType() || derivedType.actualType() != type.actualType()) //$IDENTITY-COMPARISON$ continue; break; case Binding.RAW_TYPE: if (!derivedType.isRawType() || derivedType.actualType() != type.actualType()) //$IDENTITY-COMPARISON$ continue; break; case Binding.WILDCARD_TYPE: if (!derivedType.isWildcard() || derivedType.actualType() != type.actualType() || derivedType.rank() != type.rank() || derivedType.boundKind() != type.boundKind()) //$IDENTITY-COMPARISON$ continue; if (derivedType.bound() != type.bound() || !Util.effectivelyEqual(derivedType.additionalBounds(), type.additionalBounds())) //$IDENTITY-COMPARISON$ continue; break; default: switch(derivedType.kind()) { case Binding.ARRAY_TYPE: case Binding.PARAMETERIZED_TYPE: case Binding.RAW_TYPE: case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_CAST_TYPE: case Binding.INTERSECTION_TYPE: continue; } break; } if (Util.effectivelyEqual(derivedType.getTypeAnnotations(), annotations)) { // point-fix for https://bugs.eclipse.org/432977 if (!type.isUnresolvedType() && derivedType.isUnresolvedType()) return ((UnresolvedReferenceBinding)derivedType).resolve(this.environment, false); return derivedType; } if (!derivedType.hasTypeAnnotations()) nakedType = derivedType; } if (nakedType == null) nakedType = getUnannotatedType(type); if (!haveTypeAnnotations(type, enclosingType, null, annotations)) return nakedType; TypeBinding annotatedType = type.clone(enclosingType); annotatedType.id = nakedType.id; annotatedType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); TypeBinding keyType; switch (type.kind()) { case Binding.ARRAY_TYPE: keyType = type.leafComponentType(); break; case Binding.PARAMETERIZED_TYPE: case Binding.RAW_TYPE: case Binding.WILDCARD_TYPE: keyType = type.actualType(); break; default: keyType = nakedType; break; } return cacheDerivedType(keyType, nakedType, annotatedType); }