protected LightweightTypeReference wrapInCompoundTypeIfNecessary( List<LightweightTypeReference> referencesWithSameDistance) { if (referencesWithSameDistance.size() == 1) { return referencesWithSameDistance.get(0); } else if (referencesWithSameDistance.size() > 1) { CompoundTypeReference result = owner.newCompoundTypeReference(false); for(LightweightTypeReference reference: referencesWithSameDistance) { result.addComponent(reference); } return result; } return null; }
@Override protected LightweightTypeReference doCopyInto(ITypeReferenceOwner owner) { CompoundTypeReference result = owner.newCompoundTypeReference(synonym); if (components != null && !components.isEmpty()) { for(LightweightTypeReference typeArgument: components) { result.addComponent(typeArgument.copyInto(owner)); } } return result; }
protected LightweightTypeReference doVisitCompoundReference(JvmCompoundTypeReference reference, boolean synonym) { CompoundTypeReference result = owner.newCompoundTypeReference(synonym); for(JvmTypeReference component: reference.getReferences()) { result.addComponent(visit(component)); } return result; }
protected CompoundTypeReference toMultiType(LightweightTypeReference first, LightweightTypeReference second) { if (first == null) { throw new NullPointerException("first may not be null"); } if (second == null) { throw new NullPointerException("second may not be null"); } final ITypeReferenceOwner owner = second.getOwner(); final CompoundTypeReference result = owner.newCompoundTypeReference(false); TypeReferenceVisitor visitor = new TypeReferenceVisitor() { @Override protected void doVisitMultiTypeReference(CompoundTypeReference reference) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); for(LightweightTypeReference component: components) { result.addComponent(component.copyInto(owner)); } } @Override protected void doVisitTypeReference(LightweightTypeReference reference) { result.addComponent(reference.copyInto(owner)); } }; first.accept(visitor); second.accept(visitor); return result; }
@Override public LightweightTypeReference getUpperBoundSubstitute() { if (isUnbounded()) { return getOwner().newReferenceToObject(); } List<LightweightTypeReference> upperBounds = getUpperBounds(); if (upperBounds.size() == 1) { LightweightTypeReference result = upperBounds.get(0); return result; } CompoundTypeReference result = getOwner().newCompoundTypeReference(false); for(LightweightTypeReference upperBound: upperBounds) { result.addComponent(upperBound); } return result; }
CompoundTypeReference result = owner.newCompoundTypeReference(false); for(LightweightTypeReference upperBound: upperBounds) { result.addComponent(upperBound);
@Override protected LightweightTypeReference doVisitCompoundTypeReference(CompoundTypeReference reference, ResourceSet resourceSet) { if (reference.isRawType()) return reference; CompoundTypeReference result = reference.getOwner().newCompoundTypeReference(reference.isSynonym()); enhanceCompoundReference(reference.getMultiTypeComponents(), result, resourceSet); return result; }
@Override protected LocalTypeSubstitutor.SubstitutionResult doVisitCompoundTypeReference(CompoundTypeReference reference, VarianceInfo varianceInfo) { CompoundTypeReference result = owner.newCompoundTypeReference(reference.isSynonym()); boolean didSubstitute = false; for(LightweightTypeReference component: reference.getMultiTypeComponents()) { SubstitutionResult visited = visitTypeArgument(component, varianceInfo); result.addComponent(visited.typeReference); didSubstitute = didSubstitute || visited.didSubstitute; } return new SubstitutionResult(result, didSubstitute); }
protected LightweightTypeReference getRawTypeFromConstraints(ITypeReferenceOwner owner, JvmTypeParameter typeParameter, ResourceSet resourceSet) { if (visited.add(typeParameter)) { List<JvmTypeConstraint> constraints = typeParameter.getConstraints(); if (!constraints.isEmpty()) { if (constraints.size() > 1) { CompoundTypeReference result = owner.newCompoundTypeReference(false); for(JvmTypeConstraint constraint: constraints) { if (constraint instanceof JvmUpperBound) { JvmTypeReference typeReference = constraint.getTypeReference(); if (typeReference != null) result.addComponent(owner.toLightweightTypeReference(typeReference).accept(this, resourceSet)); } } return result; } else { JvmTypeReference typeReference = constraints.get(0).getTypeReference(); if (typeReference != null) { LightweightTypeReference result = owner.toLightweightTypeReference(typeReference).accept(this, resourceSet); return result; } } } } return createObjectReference(owner, resourceSet); }
@Override protected LightweightTypeReference doVisitWildcardTypeReference(WildcardTypeReference reference, ResourceSet resourceSet) { if (reference.isUnbounded()) { return reference.getUpperBoundSubstitute(); } if (reference.getUpperBounds().size() == 1) { return reference.getUpperBoundSubstitute().accept(this, resourceSet); } CompoundTypeReference result = reference.getOwner().newCompoundTypeReference(false); enhanceCompoundReference(reference.getUpperBounds(), result, resourceSet); return result; }
@Override public LightweightTypeReference getRawTypeReference() { if (isAllRawType()) { return this; } CompoundTypeReference result = getOwner().newCompoundTypeReference(isSynonym()); for(LightweightTypeReference component: expose(components)) { result.addComponent(component.getRawTypeReference()); } return result; }
@Override protected LightweightTypeReference doVisitCompoundTypeReference(CompoundTypeReference reference, Visiting visiting) { if (reference.isResolved() && reference.isOwnedBy(getOwner())) return reference; CompoundTypeReference result = getOwner().newCompoundTypeReference(reference.isSynonym()); for(LightweightTypeReference component: reference.getMultiTypeComponents()) { result.addComponent(visitTypeArgument(component, visiting)); } return result; }
@Override protected boolean accept(LightweightTypeReference synonymType, int flags) { List<JvmType> rawTypes = synonymType.getRawTypes(); ConformanceFlags.sanityCheck(flags); SynonymTypeBucket bucket = new SynonymTypeBucket(id++, rawTypes, resolvedFeaturesProvider, flags); CompoundTypeReference compoundTypeReference = synonymType.getOwner().newCompoundTypeReference(true); compoundTypeReference.addComponent(featureDeclarator); compoundTypeReference.addComponent(synonymType); wrapper.set(createReceiverFeatureScope(featureCall, receiver, compoundTypeReference, receiverFeature, implicit, validStaticScope, bucket, wrapper.get(), session)); return true; }
final CompoundTypeReference withSynonyms = state.getReferenceOwner().newCompoundTypeReference(true); LightweightTypeReference iterableOrArray = getAndEnhanceIterableOrArrayFromComponent(parameterType, iterableType, withSynonyms);
CompoundTypeReference bothExpectations = state.getReferenceOwner().newCompoundTypeReference(true); bothExpectations.addComponent(componentType); bothExpectations.addComponent(expectation);