Search in sources :

Example 31 with ConstraintVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.

the class ParametricStructureComputer method updateElementVarStructureFromParent.

/**
	 * Updates the structure of any subsidiary element variables (if any) for
	 * the given ConstraintVariable2 (if it is in fact a container).
	 */
private void updateElementVarStructureFromParent(ConstraintVariable2 v) {
    // Propagate structure from container variable to any subsidiary element variables
    if (elemStructure(v) != ParametricStructure.NONE && fTCModel.getElementVariables(v).size() > 0) {
        ParametricStructure t = elemStructure(v);
        for (Iterator<CollectionElementVariable2> iterator = fTCModel.getElementVariables(v).values().iterator(); iterator.hasNext(); ) {
            CollectionElementVariable2 typeVar = iterator.next();
            int declarationTypeVariableIndex = typeVar.getDeclarationTypeVariableIndex();
            if (declarationTypeVariableIndex != CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX)
                updateStructureOfVar(typeVar, t.getParameters()[declarationTypeVariableIndex], TypeOperator.Equals);
        }
    }
}
Also used : CollectionElementVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2)

Example 32 with ConstraintVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.

the class ParametricStructureComputer method computeContainerStructure.

private void computeContainerStructure() {
    if (DEBUG_INITIALIZATION)
        //$NON-NLS-1$
        System.out.println("\n*** Computing Container Structure ***\n");
    initializeContainerStructure();
    if (DEBUG_INITIALIZATION)
        dumpContainerStructure();
    while (!fWorkList2.isEmpty()) {
        ConstraintVariable2 v = fWorkList2.pop();
        List<ITypeConstraint2> usedIn = fTCModel.getUsedIn(v);
        for (Iterator<ITypeConstraint2> iter = usedIn.iterator(); iter.hasNext(); ) {
            SubTypeConstraint2 stc = (SubTypeConstraint2) iter.next();
            ConstraintVariable2 lhs = stc.getLeft();
            ConstraintVariable2 rhs = stc.getRight();
            unifyContainerStructure(lhs, rhs);
        }
        TypeEquivalenceSet typeEquivalenceSet = v.getTypeEquivalenceSet();
        if (typeEquivalenceSet != null) {
            ConstraintVariable2[] contributingVariables = typeEquivalenceSet.getContributingVariables();
            for (int i = 0; i + 1 < contributingVariables.length; i++) {
                ConstraintVariable2 first = contributingVariables[i];
                ConstraintVariable2 second = contributingVariables[i + 1];
                unifyContainerStructure(first, second);
            }
        }
    }
    if (DEBUG_INITIALIZATION)
        dumpContainerStructure();
}
Also used : TypeEquivalenceSet(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeEquivalenceSet) ConstraintVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2) ITypeConstraint2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ITypeConstraint2) SubTypeConstraint2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.SubTypeConstraint2)

Example 33 with ConstraintVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.

the class InferTypeArgumentsTCModel method pruneUnusedCuScopedCvs.

private void pruneUnusedCuScopedCvs() {
    for (Iterator<ConstraintVariable2> iter = fCuScopedConstraintVariables.iterator(); iter.hasNext(); ) {
        ConstraintVariable2 cv = iter.next();
        pruneCvIfUnused(cv);
    }
}
Also used : ConstraintVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2)

Example 34 with ConstraintVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.

the class InferTypeArgumentsTCModel method makeParameterizedTypeVariable.

private ParameterizedTypeVariable2 makeParameterizedTypeVariable(TType type) {
    Assert.isTrue(isAGenericType(type));
    ParameterizedTypeVariable2 cv = new ParameterizedTypeVariable2(type);
    ParameterizedTypeVariable2 storedCv = (ParameterizedTypeVariable2) storedCv(cv);
    if (cv == storedCv) {
        fCuScopedConstraintVariables.add(storedCv);
        makeElementVariables(storedCv, type);
        if (fStoreToString)
            //$NON-NLS-1$ //$NON-NLS-2$
            storedCv.setData(ConstraintVariable2.TO_STRING, "ParameterizedType(" + type.getPrettySignature() + ")");
    }
    return storedCv;
}
Also used : ParameterizedTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterizedTypeVariable2)

Example 35 with ConstraintVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.

the class InferTypeArgumentsTCModel method makeVariableVariable.

public VariableVariable2 makeVariableVariable(IVariableBinding variableBinding) {
    if (variableBinding == null)
        return null;
    TType type = getBoxedType(variableBinding.getType(), /*no boxing*/
    null);
    if (type == null)
        return null;
    VariableVariable2 cv = new VariableVariable2(type, variableBinding);
    VariableVariable2 storedCv = (VariableVariable2) storedCv(cv);
    if (storedCv == cv) {
        if (!variableBinding.isField() || Modifier.isPrivate(variableBinding.getModifiers()))
            fCuScopedConstraintVariables.add(storedCv);
        makeElementVariables(storedCv, type);
        makeArrayElementVariable(storedCv);
        if (fStoreToString)
            storedCv.setData(ConstraintVariable2.TO_STRING, '[' + variableBinding.getName() + ']');
    }
    return storedCv;
}
Also used : TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType) VariableVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2)

Aggregations

ConstraintVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2)32 TType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)20 CollectionElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2)16 ImmutableTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2)11 CastExpression (org.eclipse.jdt.core.dom.CastExpression)9 Expression (org.eclipse.jdt.core.dom.Expression)9 ParenthesizedExpression (org.eclipse.jdt.core.dom.ParenthesizedExpression)9 ConditionalExpression (org.eclipse.jdt.core.dom.ConditionalExpression)8 ThisExpression (org.eclipse.jdt.core.dom.ThisExpression)8 VariableDeclarationExpression (org.eclipse.jdt.core.dom.VariableDeclarationExpression)8 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)7 GenericType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType)7 ArrayElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayElementVariable2)7 TypeEquivalenceSet (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeEquivalenceSet)7 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)5 ParameterizedType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType)5 ITypeConstraint2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ITypeConstraint2)5 IndependentTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.IndependentTypeVariable2)5 ParameterTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterTypeVariable2)5 ReturnTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ReturnTypeVariable2)5