Search in sources :

Example 6 with ImmutableTypeVariable2

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

the class InferTypeArgumentsConstraintCreator method endVisit.

/*
	 * @see org.eclipse.jdt.internal.corext.dom.HierarchicalASTVisitor#endVisit(org.eclipse.jdt.core.dom.Type)
	 */
@Override
public void endVisit(Type node) {
    if (node.isParameterizedType()) {
        // retain already parameterized types
        ImmutableTypeVariable2 typeVariable = fTCModel.makeImmutableTypeVariable(node.resolveBinding(), /*no boxing*/
        null);
        setConstraintVariable(node, typeVariable);
    } else {
        TypeVariable2 typeVariable = fTCModel.makeTypeVariable(node);
        setConstraintVariable(node, typeVariable);
    }
}
Also used : ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ParameterTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterTypeVariable2) TypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2) IndependentTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.IndependentTypeVariable2) ParameterizedTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterizedTypeVariable2) ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ReturnTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ReturnTypeVariable2)

Example 7 with ImmutableTypeVariable2

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

the class InferTypeArgumentsConstraintCreator method endVisit.

@Override
public void endVisit(StringLiteral node) {
    ITypeBinding typeBinding = node.resolveTypeBinding();
    ImmutableTypeVariable2 cv = fTCModel.makeImmutableTypeVariable(typeBinding, /*no boxing*/
    null);
    setConstraintVariable(node, cv);
}
Also used : ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding)

Example 8 with ImmutableTypeVariable2

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

the class InferTypeArgumentsConstraintCreator method endVisit.

@Override
public void endVisit(CharacterLiteral node) {
    ITypeBinding typeBinding = node.resolveTypeBinding();
    ImmutableTypeVariable2 cv = fTCModel.makeImmutableTypeVariable(typeBinding, node);
    setConstraintVariable(node, cv);
}
Also used : ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding)

Example 9 with ImmutableTypeVariable2

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

the class InferTypeArgumentsConstraintCreator method endVisit.

@Override
public void endVisit(CastExpression node) {
    //		if (! (expressionCv instanceof CollectionElementVariable2))
    //			return; //TODO: returns too early when dealing with nested collections.
    Type type = node.getType();
    ITypeBinding typeBinding = type.resolveBinding();
    if (typeBinding.isPrimitive()) {
        ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(typeBinding, node);
        setConstraintVariable(node, boxed);
        // avoid removing numeric conversions
        return;
    }
    ConstraintVariable2 typeCv = getConstraintVariable(type);
    if (typeCv == null)
        return;
    //TODO: can this be loosened when we remove casts?
    setConstraintVariable(node, typeCv);
    Expression expression = node.getExpression();
    ConstraintVariable2 expressionCv = getConstraintVariable(expression);
    //Avoid removing casts that have not been made obsolete by this refactoring:
    if (expressionCv == null)
        return;
    if (expressionCv instanceof ImmutableTypeVariable2)
        return;
    if (!(expressionCv instanceof TypeVariable2 || expressionCv instanceof IndependentTypeVariable2 || expressionCv instanceof CollectionElementVariable2) && fTCModel.getElementVariables(expressionCv).size() == 0 && fTCModel.getArrayElementVariable(expressionCv) == null)
        return;
    fTCModel.createAssignmentElementConstraints(typeCv, expressionCv);
    if (expression instanceof MethodInvocation) {
        MethodInvocation invoc = (MethodInvocation) expression;
        if (!isSpecialCloneInvocation(invoc.resolveMethodBinding(), invoc.getExpression())) {
            fTCModel.makeCastVariable(node, expressionCv);
        }
    } else {
        fTCModel.makeCastVariable(node, expressionCv);
    }
    boolean eitherIsIntf = typeBinding.isInterface() || expression.resolveTypeBinding().isInterface();
    if (eitherIsIntf)
        return;
//TODO: preserve up- and down-castedness!
}
Also used : GenericType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType) ParameterizedType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType) WildcardType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.WildcardType) ArrayType(org.eclipse.jdt.core.dom.ArrayType) Type(org.eclipse.jdt.core.dom.Type) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType) ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) CollectionElementVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2) ConditionalExpression(org.eclipse.jdt.core.dom.ConditionalExpression) ThisExpression(org.eclipse.jdt.core.dom.ThisExpression) Expression(org.eclipse.jdt.core.dom.Expression) CastExpression(org.eclipse.jdt.core.dom.CastExpression) VariableDeclarationExpression(org.eclipse.jdt.core.dom.VariableDeclarationExpression) ParenthesizedExpression(org.eclipse.jdt.core.dom.ParenthesizedExpression) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) ParameterTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterTypeVariable2) TypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2) IndependentTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.IndependentTypeVariable2) ParameterizedTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterizedTypeVariable2) ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ReturnTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ReturnTypeVariable2) MethodInvocation(org.eclipse.jdt.core.dom.MethodInvocation) ConstraintVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2) IndependentTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.IndependentTypeVariable2)

Example 10 with ImmutableTypeVariable2

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

the class InferTypeArgumentsConstraintCreator method endVisit.

@Override
public void endVisit(FieldAccess node) {
    if (node.resolveBoxing()) {
        ImmutableTypeVariable2 boxed = fTCModel.makeImmutableTypeVariable(node.resolveTypeBinding(), node);
        setConstraintVariable(node, boxed);
        return;
    }
    ConstraintVariable2 nameCv = getConstraintVariable(node.getName());
    setConstraintVariable(node, nameCv);
}
Also used : ImmutableTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2) ConstraintVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2)

Aggregations

ImmutableTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2)19 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)11 ConstraintVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2)10 CastExpression (org.eclipse.jdt.core.dom.CastExpression)5 ConditionalExpression (org.eclipse.jdt.core.dom.ConditionalExpression)5 Expression (org.eclipse.jdt.core.dom.Expression)5 ParenthesizedExpression (org.eclipse.jdt.core.dom.ParenthesizedExpression)5 ThisExpression (org.eclipse.jdt.core.dom.ThisExpression)5 VariableDeclarationExpression (org.eclipse.jdt.core.dom.VariableDeclarationExpression)5 TType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)4 IndependentTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.IndependentTypeVariable2)3 ParameterTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterTypeVariable2)3 ParameterizedTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ParameterizedTypeVariable2)3 ReturnTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ReturnTypeVariable2)3 ArrayType (org.eclipse.jdt.core.dom.ArrayType)2 WildcardType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.WildcardType)2 ArrayElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayElementVariable2)2 CollectionElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2)2 TypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.TypeVariable2)2 HashMap (java.util.HashMap)1