Search in sources :

Example 26 with IVariableBinding

use of org.eclipse.jdt.core.dom.IVariableBinding in project che by eclipse.

the class FullConstraintCreator method create.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.FieldAccess)
	 */
@Override
public ITypeConstraint[] create(FieldAccess access) {
    Expression expression = access.getExpression();
    SimpleName name = access.getName();
    IBinding binding = name.resolveBinding();
    if (!(binding instanceof IVariableBinding))
        return new ITypeConstraint[0];
    IVariableBinding vb = (IVariableBinding) binding;
    return createConstraintsForAccessToField(vb, expression, access);
}
Also used : ConditionalExpression(org.eclipse.jdt.core.dom.ConditionalExpression) InstanceofExpression(org.eclipse.jdt.core.dom.InstanceofExpression) ThisExpression(org.eclipse.jdt.core.dom.ThisExpression) Expression(org.eclipse.jdt.core.dom.Expression) ParenthesizedExpression(org.eclipse.jdt.core.dom.ParenthesizedExpression) CastExpression(org.eclipse.jdt.core.dom.CastExpression) VariableDeclarationExpression(org.eclipse.jdt.core.dom.VariableDeclarationExpression) SimpleName(org.eclipse.jdt.core.dom.SimpleName) IBinding(org.eclipse.jdt.core.dom.IBinding) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding)

Example 27 with IVariableBinding

use of org.eclipse.jdt.core.dom.IVariableBinding in project che by eclipse.

the class FullConstraintCreator method create.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.QualifiedName)
	 */
@Override
public ITypeConstraint[] create(QualifiedName qualifiedName) {
    SimpleName name = qualifiedName.getName();
    Name qualifier = qualifiedName.getQualifier();
    IBinding nameBinding = name.resolveBinding();
    if (nameBinding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) nameBinding;
        if (vb.isField())
            return createConstraintsForAccessToField(vb, qualifier, qualifiedName);
    }
    //TODO other bindings
    return new ITypeConstraint[0];
}
Also used : SimpleName(org.eclipse.jdt.core.dom.SimpleName) IBinding(org.eclipse.jdt.core.dom.IBinding) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) SimpleName(org.eclipse.jdt.core.dom.SimpleName) Name(org.eclipse.jdt.core.dom.Name) QualifiedName(org.eclipse.jdt.core.dom.QualifiedName)

Example 28 with IVariableBinding

use of org.eclipse.jdt.core.dom.IVariableBinding in project che by eclipse.

the class FullConstraintCreator method create.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperFieldAccess)
	 */
@Override
public ITypeConstraint[] create(SuperFieldAccess access) {
    SimpleName name = access.getName();
    IBinding binding = name.resolveBinding();
    if (!(binding instanceof IVariableBinding))
        return new ITypeConstraint[0];
    IVariableBinding vb = (IVariableBinding) binding;
    return createConstraintsForAccessToField(vb, null, access);
}
Also used : SimpleName(org.eclipse.jdt.core.dom.SimpleName) IBinding(org.eclipse.jdt.core.dom.IBinding) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding)

Example 29 with IVariableBinding

use of org.eclipse.jdt.core.dom.IVariableBinding in project che by eclipse.

the class FullConstraintCreator method getConstraintsForHiding.

private Collection<ITypeConstraint> getConstraintsForHiding(VariableDeclarationFragment fragment) {
    Collection<ITypeConstraint> result = new ArrayList<ITypeConstraint>();
    IVariableBinding fieldBinding = fragment.resolveBinding();
    Assert.isTrue(fieldBinding.isField());
    Set<ITypeBinding> declaringTypes = getDeclaringSuperTypes(fieldBinding);
    ConstraintVariable hiddingFieldVar = fConstraintVariableFactory.makeDeclaringTypeVariable(fieldBinding);
    for (Iterator<ITypeBinding> iter = declaringTypes.iterator(); iter.hasNext(); ) {
        ITypeBinding declaringSuperType = iter.next();
        IVariableBinding hiddenField = findField(fieldBinding, declaringSuperType);
        Assert.isTrue(hiddenField.isField());
        ConstraintVariable hiddenFieldVar = fConstraintVariableFactory.makeDeclaringTypeVariable(hiddenField);
        result.addAll(Arrays.asList(fTypeConstraintFactory.createStrictSubtypeConstraint(hiddingFieldVar, hiddenFieldVar)));
    }
    return result;
}
Also used : ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) ArrayList(java.util.ArrayList) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding)

Example 30 with IVariableBinding

use of org.eclipse.jdt.core.dom.IVariableBinding in project che by eclipse.

the class LocalDeclarationAnalyzer method visit.

@Override
public boolean visit(SimpleName node) {
    IVariableBinding binding = null;
    if (node.isDeclaration() || !considerNode(node) || (binding = ASTNodes.getLocalVariableBinding(node)) == null)
        return false;
    handleReferenceToLocal(node, binding);
    return true;
}
Also used : IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding)

Aggregations

IVariableBinding (org.eclipse.jdt.core.dom.IVariableBinding)101 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)48 IBinding (org.eclipse.jdt.core.dom.IBinding)45 SimpleName (org.eclipse.jdt.core.dom.SimpleName)41 ASTNode (org.eclipse.jdt.core.dom.ASTNode)30 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)28 ArrayList (java.util.ArrayList)22 Expression (org.eclipse.jdt.core.dom.Expression)22 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)16 Name (org.eclipse.jdt.core.dom.Name)13 CastExpression (org.eclipse.jdt.core.dom.CastExpression)12 MethodInvocation (org.eclipse.jdt.core.dom.MethodInvocation)12 ParenthesizedExpression (org.eclipse.jdt.core.dom.ParenthesizedExpression)12 ThisExpression (org.eclipse.jdt.core.dom.ThisExpression)12 FieldAccess (org.eclipse.jdt.core.dom.FieldAccess)11 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)11 VariableDeclarationExpression (org.eclipse.jdt.core.dom.VariableDeclarationExpression)11 VariableDeclarationFragment (org.eclipse.jdt.core.dom.VariableDeclarationFragment)10 AST (org.eclipse.jdt.core.dom.AST)9 Assignment (org.eclipse.jdt.core.dom.Assignment)9