use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintsSolver method runSolver.
private void runSolver(SubProgressMonitor pm) {
//$NON-NLS-1$
pm.beginTask("", fWorkList.size() * 3);
while (!fWorkList.isEmpty()) {
// Get a variable whose type estimate has changed
ConstraintVariable2 cv = fWorkList.removeFirst();
List<ITypeConstraint2> usedIn = fTCModel.getUsedIn(cv);
processConstraints(usedIn);
pm.worked(1);
if (pm.isCanceled())
throw new OperationCanceledException();
}
pm.done();
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintsSolver method maintainSimpleConstraint.
private void maintainSimpleConstraint(ITypeConstraint2 stc) {
ConstraintVariable2 left = stc.getLeft();
ConstraintVariable2 right = stc.getRight();
TypeEquivalenceSet leftSet = left.getTypeEquivalenceSet();
TypeEquivalenceSet rightSet = right.getTypeEquivalenceSet();
TypeSet leftEstimate = (TypeSet) leftSet.getTypeEstimate();
TypeSet rightEstimate = (TypeSet) rightSet.getTypeEstimate();
if (leftEstimate.isUniverse() && rightEstimate.isUniverse())
// nothing to do
return;
if (leftEstimate.equals(rightEstimate))
// nothing to do
return;
TypeSet lhsSuperTypes = leftEstimate.superTypes();
TypeSet rhsSubTypes = rightEstimate.subTypes();
if (!rhsSubTypes.containsAll(leftEstimate)) {
TypeSet xsection = leftEstimate.intersectedWith(rhsSubTypes);
// if (xsection.isEmpty()) // too bad, but this can happen
// throw new IllegalStateException("Type estimate set is now empty for LHS in " + left + " <= " + right + "; estimates were " + leftEstimate + " <= " + rightEstimate); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
leftSet.setTypeEstimate(xsection);
fWorkList.addAll(Arrays.asList(leftSet.getContributingVariables()));
}
if (!lhsSuperTypes.containsAll(rightEstimate)) {
TypeSet xsection = rightEstimate.intersectedWith(lhsSuperTypes);
// if (xsection.isEmpty())
// throw new IllegalStateException("Type estimate set is now empty for RHS in " + left + " <= " + right + "; estimates were " + leftEstimate + " <= " + rightEstimate); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
rightSet.setTypeEstimate(xsection);
fWorkList.addAll(Arrays.asList(rightSet.getContributingVariables()));
}
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method makeCastVariable.
public CastVariable2 makeCastVariable(CastExpression castExpression, ConstraintVariable2 expressionCv) {
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
ICompilationUnit cu = RefactoringASTParser.getCompilationUnit(castExpression);
CompilationUnitRange range = new CompilationUnitRange(cu, castExpression);
CastVariable2 castCv = new CastVariable2(createTType(typeBinding), range, expressionCv);
fCastVariables.add(castCv);
return castCv;
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method makeArrayElementVariable.
public void makeArrayElementVariable(ConstraintVariable2 constraintVariable2) {
if (constraintVariable2.getType() == null || !constraintVariable2.getType().isArrayType())
return;
ArrayElementVariable2 storedArrayElementVariable = getArrayElementVariable(constraintVariable2);
if (storedArrayElementVariable != null)
return;
ArrayElementVariable2 arrayElementCv = new ArrayElementVariable2(constraintVariable2);
arrayElementCv = (ArrayElementVariable2) storedCv(arrayElementCv);
setArrayElementVariable(constraintVariable2, arrayElementCv);
//recursive
makeArrayElementVariable(arrayElementCv);
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method makeElementVariable.
private CollectionElementVariable2 makeElementVariable(ConstraintVariable2 expressionCv, TypeVariable typeVariable, int declarationTypeVariableIndex) {
if (expressionCv == null)
return null;
CollectionElementVariable2 storedElementVariable = getElementVariable(expressionCv, typeVariable);
if (storedElementVariable != null)
return storedElementVariable;
CollectionElementVariable2 cv = new CollectionElementVariable2(expressionCv, typeVariable, declarationTypeVariableIndex);
cv = (CollectionElementVariable2) storedCv(cv);
setElementVariable(expressionCv, cv, typeVariable);
return cv;
}
Aggregations