use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method makeFixedSupertypeElementVariables.
private void makeFixedSupertypeElementVariables(ConstraintVariable2 expressionCv, TType supertype) {
if (supertype.isParameterizedType() || supertype.isRawType()) {
TType[] typeArguments = null;
if (supertype.isParameterizedType())
typeArguments = ((ParameterizedType) supertype).getTypeArguments();
TypeVariable[] typeParameters = ((GenericType) supertype.getTypeDeclaration()).getTypeParameters();
for (int i = 0; i < typeParameters.length; i++) {
TypeVariable typeParameter = typeParameters[i];
TType referenceTypeArgument;
if (typeArguments == null) {
// do not consider
continue;
} else {
referenceTypeArgument = typeArguments[i];
}
if (referenceTypeArgument.isTypeVariable()) {
CollectionElementVariable2 referenceTypeArgumentCv = getElementVariable(expressionCv, (TypeVariable) referenceTypeArgument);
setElementVariable(expressionCv, referenceTypeArgumentCv, typeParameter);
} else {
CollectionElementVariable2 elementCv = makeElementVariable(expressionCv, typeParameter, CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
createEqualsConstraint(elementCv, makeImmutableTypeVariable(referenceTypeArgument));
}
}
}
makeFixedElementVariablesFromSupertypes(expressionCv, supertype);
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method internalCreateElementEqualsConstraints.
private void internalCreateElementEqualsConstraints(ConstraintVariable2 cv, ConstraintVariable2 initializerCv, boolean isAssignment) {
if (cv == null || initializerCv == null)
return;
Map<String, CollectionElementVariable2> leftElements = getElementVariables(cv);
Map<String, CollectionElementVariable2> rightElements = getElementVariables(initializerCv);
for (Iterator<Entry<String, CollectionElementVariable2>> leftIter = leftElements.entrySet().iterator(); leftIter.hasNext(); ) {
Entry<String, CollectionElementVariable2> leftEntry = leftIter.next();
String leftTypeVariableKey = leftEntry.getKey();
CollectionElementVariable2 rightElementVariable = rightElements.get(leftTypeVariableKey);
if (rightElementVariable != null) {
CollectionElementVariable2 leftElementVariable = leftEntry.getValue();
createEqualsConstraint(leftElementVariable, rightElementVariable);
// recursive
internalCreateElementEqualsConstraints(leftElementVariable, rightElementVariable, false);
}
}
ArrayElementVariable2 leftArrayElement = getArrayElementVariable(cv);
ArrayElementVariable2 rightArrayElement = getArrayElementVariable(initializerCv);
if (leftArrayElement != null && rightArrayElement != null) {
if (isAssignment)
createSubtypeConstraint(rightArrayElement, leftArrayElement);
else
createEqualsConstraint(leftArrayElement, rightArrayElement);
// recursive
internalCreateElementEqualsConstraints(leftArrayElement, rightArrayElement, false);
}
}
Aggregations