use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(SimpleName node) {
if (node.resolveBoxing()) {
ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
setConstraintVariable(node, boxed);
return;
}
IBinding binding = node.resolveBinding();
if (binding instanceof IVariableBinding) {
//TODO: code is similar to handling of method return value
IVariableBinding variableBinding = (IVariableBinding) binding;
ITypeBinding declaredVariableType = variableBinding.getVariableDeclaration().getType();
if (declaredVariableType.isTypeVariable()) {
Expression receiver = getSimpleNameReceiver(node);
if (receiver != null) {
ConstraintVariable2 receiverCv = getConstraintVariable(receiver);
// the type variable must come from the receiver!
Assert.isNotNull(receiverCv);
ConstraintVariable2 elementCv = fTCModel.getElementVariable(receiverCv, declaredVariableType);
// [retVal] =^= Elem[receiver]:
setConstraintVariable(node, elementCv);
return;
}
} else if (declaredVariableType.isParameterizedType()) {
Expression receiver = getSimpleNameReceiver(node);
if (receiver != null) {
ConstraintVariable2 receiverCv = getConstraintVariable(receiver);
if (receiverCv != null) {
// ITypeBinding genericVariableType= declaredVariableType.getTypeDeclaration();
ConstraintVariable2 returnTypeCv = fTCModel.makeParameterizedTypeVariable(declaredVariableType);
setConstraintVariable(node, returnTypeCv);
// Elem[retVal] =^= Elem[receiver]
TType declaredVariableTType = fTCModel.createTType(declaredVariableType);
fTCModel.createTypeVariablesEqualityConstraints(receiverCv, Collections.<String, IndependentTypeVariable2>emptyMap(), returnTypeCv, declaredVariableTType);
return;
}
}
} else {
//TODO: array...
//logUnexpectedNode(node, null);
}
// default:
VariableVariable2 cv = fTCModel.makeVariableVariable(variableBinding);
setConstraintVariable(node, cv);
}
// TODO else?
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method visit.
@Override
public boolean visit(CatchClause node) {
SingleVariableDeclaration exception = node.getException();
IVariableBinding variableBinding = exception.resolveBinding();
VariableVariable2 cv = fTCModel.makeDeclaredVariableVariable(variableBinding, fCU);
setConstraintVariable(exception, cv);
return true;
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(VariableDeclarationFragment node) {
VariableVariable2 cv = fTCModel.makeDeclaredVariableVariable(node.resolveBinding(), fCU);
if (cv == null)
return;
setConstraintVariable(node, cv);
//TODO: prune unused CV for local variables (but not fields)
Expression initializer = node.getInitializer();
if (initializer == null)
return;
ConstraintVariable2 initializerCv = getConstraintVariable(initializer);
if (initializerCv == null)
return;
fTCModel.createElementEqualsConstraints(cv, initializerCv);
// name= initializer --> [initializer] <= [name]
// if (initializerCv instanceof CollectionElementVariable2)
// fTCModel.createSubtypeConstraint(initializerCv, cv);
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2 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;
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.VariableVariable2 in project che by eclipse.
the class InferTypeArgumentsTCModel method makeDeclaredVariableVariable.
public VariableVariable2 makeDeclaredVariableVariable(IVariableBinding variableBinding, ICompilationUnit cu) {
VariableVariable2 cv = makeVariableVariable(variableBinding);
if (cv == null)
return null;
cv.setCompilationUnit(cu);
return cv;
}
Aggregations