@Override protected void doVisitTypeReference(LightweightTypeReference reference, CompoundTypeReference declaration) { List<LightweightTypeReference> components = declaration.getMultiTypeComponents(); if (!components.isEmpty()) { for (LightweightTypeReference component: components) { outerVisit(component, reference); } } } }
@Override protected LightweightTypeReference doVisitCompoundTypeReference(final CompoundTypeReference reference) { return this.visit(reference.getMultiTypeComponents()); }
@Override protected List<JvmType> doVisitSynonymTypeReference(CompoundTypeReference reference, ResourceSet resourceSet) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); if (components.isEmpty()) throw new IllegalStateException("Components may not be empty"); return components.get(components.size() - 1).accept(this, resourceSet); }
@Override public Boolean doVisitCompoundTypeReference(CompoundTypeReference reference, LightweightTraversalData data) { // TODO error message, cannot extend compound reference - error handling does not belong here boolean result = true; for(LightweightTypeReference component: reference.getMultiTypeComponents()) { Boolean componentsDone = component.accept(this, data); result &= componentsDone != null && componentsDone.booleanValue(); } return result; }
@Override protected List<JvmType> doVisitCompoundTypeReference(CompoundTypeReference reference, ResourceSet resourceSet) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); if (components.isEmpty()) throw new IllegalStateException("Components may not be empty"); return collectRawTypes(components, resourceSet); }
@Override protected LightweightTypeReference doVisitSynonymTypeReference(CompoundTypeReference reference, ResourceSet resourceSet) { if (reference.isRawType()) return reference; List<LightweightTypeReference> components = reference.getMultiTypeComponents(); return components.get(components.size() - 1).accept(this, resourceSet); }
protected void doVisitCompoundTypeReference(CompoundTypeReference reference) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); if (components.isEmpty()) doVisitTypeReference(reference); else for (LightweightTypeReference component: components) { component.accept(this); } }
protected void doVisitCompoundTypeReference(CompoundTypeReference reference, Param param) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); if (components.isEmpty()) doVisitTypeReference(reference, param); else for (LightweightTypeReference component: components) { component.accept(this, param); } }
@Override protected void doVisitCompoundTypeReference(CompoundTypeReference reference, StringBuilder param) { String delimiter; if (reference.isSynonym()) { delimiter = " | "; } else { delimiter = " & "; } List<LightweightTypeReference> components = reference.getMultiTypeComponents(); for(int i = 0; i < components.size(); i++) { if (i != 0) { param.append(delimiter); } components.get(i).accept(this, param); } }
@Override protected void doVisitMultiTypeReference(CompoundTypeReference reference) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); for(LightweightTypeReference component: components) { result.addComponent(component.copyInto(owner)); } } @Override
@Override protected Boolean doVisitCompoundTypeReference(CompoundTypeReference reference) { if (reference.isResolved()) { return true; } return visit(reference.getMultiTypeComponents()); }
StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef); CompoundTypeReference lightweightTypeReference = (CompoundTypeReference) owner.toLightweightTypeReference(typeRef); List<LightweightTypeReference> components = lightweightTypeReference.getMultiTypeComponents(); for(int left = 0; left < components.size(); left++) { for(int right = 0; right < components.size(); right++) {
@Override public LightweightTypeReference toJavaType() { if (isMultiType()) { LightweightTypeReference result = null; for(LightweightTypeReference component: getMultiTypeComponents()) { if (!component.isInterfaceType()) { if (result != null) { result = null; break; } result = component; } } if (result != null) { return result; } } LightweightTypeReference result = getServices().getTypeConformanceComputer().getCommonSuperType(getMultiTypeComponents(), getOwner()); if (result == null) { throw new IllegalStateException("Cannot expression " + this + " as Java type reference"); } return result.toJavaType(); }
@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); }
@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; }
private void convertMultiType(LightweightTypeReference expectation, CompoundTypeReference multiType, XExpression context, ITreeAppendable b, Later expression) { LightweightTypeReference castTo = null; List<LightweightTypeReference> components = multiType.getMultiTypeComponents(); ITypeReferenceOwner owner = multiType.getOwner(); LightweightTypeReference commonType = owner.getServices().getTypeConformanceComputer().getCommonSuperType(components, owner); if (!isJavaConformant(expectation, commonType)) { for(LightweightTypeReference candidate: multiType.getMultiTypeComponents()) { if (isJavaConformant(expectation, candidate)) { castTo = candidate; break; } } } if (castTo != null && mustInsertTypeCast(context, castTo)) { b.append("(("); b.append(castTo); b.append(")"); expression.exec(b); b.append(")"); } else { expression.exec(b); } }