use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(MethodInvocation node) {
IMethodBinding methodBinding = node.resolveMethodBinding();
if (methodBinding == null)
return;
Expression receiver;
if (JdtFlags.isStatic(methodBinding))
receiver = null;
else
receiver = node.getExpression();
if (isSpecialCloneInvocation(methodBinding, receiver)) {
ConstraintVariable2 expressionCv = getConstraintVariable(receiver);
// [retVal] =^= [receiver]:
setConstraintVariable(node, expressionCv);
} else if ("getClass".equals(methodBinding.getName()) && methodBinding.getParameterTypes().length == 0) {
//$NON-NLS-1$
//special case: see JLS3 4.3.2
ITypeBinding returnType = node.resolveTypeBinding();
ITypeBinding returnTypeDeclaration = returnType.getTypeDeclaration();
ParameterizedTypeVariable2 expressionCv = fTCModel.makeParameterizedTypeVariable(returnTypeDeclaration);
setConstraintVariable(node, expressionCv);
ConstraintVariable2 classTypeVariable = fTCModel.getElementVariable(expressionCv, returnTypeDeclaration.getTypeParameters()[0]);
//type of expression 'e.getClass()' is 'Class<? extends X>' where X is the static type of e
ITypeBinding capture = returnType.getTypeArguments()[0];
ITypeBinding wildcard = capture.getWildcard();
if (wildcard.getBound() == null)
// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=234619
return;
ImmutableTypeVariable2 wildcardType = fTCModel.makeImmutableTypeVariable(wildcard, /*no boxing*/
null);
fTCModel.createSubtypeConstraint(classTypeVariable, wildcardType);
// ITypeBinding bound= wildcard.getBound();
// ImmutableTypeVariable2 boundType= fTCModel.makeImmutableTypeVariable(bound, node.getAST());
// fTCModel.createSubtypeConstraint(classTypeVariable, boundType);
} else {
Map<String, IndependentTypeVariable2> methodTypeVariables = createMethodTypeArguments(methodBinding);
doVisitMethodInvocationReturnType(node, methodBinding, receiver, methodTypeVariables);
doVisitMethodInvocationArguments(methodBinding, node.arguments(), receiver, methodTypeVariables, /*no created type*/
null);
}
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(TypeLiteral node) {
ITypeBinding typeBinding = node.resolveTypeBinding();
ImmutableTypeVariable2 cv = fTCModel.makeImmutableTypeVariable(typeBinding, /*no boxing*/
null);
setConstraintVariable(node, cv);
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(Assignment node) {
Expression lhs = node.getLeftHandSide();
Expression rhs = node.getRightHandSide();
ConstraintVariable2 left = getConstraintVariable(lhs);
ConstraintVariable2 right = getConstraintVariable(rhs);
if (node.resolveBoxing()) {
ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
setConstraintVariable(node, boxed);
} else {
// type of assignement is type of 'left'
setConstraintVariable(node, left);
}
if (left == null || right == null)
return;
Assignment.Operator op = node.getOperator();
if (op == Assignment.Operator.PLUS_ASSIGN && (lhs.resolveTypeBinding() == node.getAST().resolveWellKnownType("java.lang.String"))) {
//$NON-NLS-1$
//Special handling for automatic String conversion: do nothing; the RHS can be anything.
} else {
fTCModel.createElementEqualsConstraints(left, right);
// left= right; --> [right] <= [left]
fTCModel.createSubtypeConstraint(right, left);
}
//TODO: other implicit conversions: numeric promotion, autoboxing?
}
use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2 in project che by eclipse.
the class InferTypeArgumentsConstraintCreator method endVisit.
@Override
public void endVisit(ConditionalExpression node) {
// for now, no support for passing generic types through conditional expressions
ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
setConstraintVariable(node, boxed);
}
Aggregations