Example usage for org.eclipse.jdt.core.dom InstanceofExpression getLeftOperand

List of usage examples for org.eclipse.jdt.core.dom InstanceofExpression getLeftOperand

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom InstanceofExpression getLeftOperand.

Prototype

public Expression getLeftOperand() 

Source Link

Document

Returns the left operand of this instanceof expression.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(InstanceofExpression node) {
    node.getLeftOperand().accept(this);
    this.fBuffer.append(" instanceof ");//$NON-NLS-1$
    node.getRightOperand().accept(this);
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(InstanceofExpression node) {
    boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder();
    //      b.setPosition(pos.build());
    b.setKind(boa.types.Ast.Expression.ExpressionKind.TYPECOMPARE);
    node.getLeftOperand().accept(this);
    b.addExpressions(expressions.pop());
    boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder();
    tb.setName(getIndex(typeName(node.getRightOperand())));
    tb.setKind(boa.types.Ast.TypeKind.OTHER);
    b.setNewType(tb.build());/*w ww . j  ava2s  . c o m*/
    expressions.push(b.build());
    return false;
}

From source file:ca.mcgill.cs.swevo.ppa.PPAASTUtil.java

License:Open Source License

public static boolean isIndicationOfField(Name node) {
    boolean isField = false;

    ASTNode parent = node.getParent();// ww w  .j a va 2 s .co m

    // The thing here is that if the parent is a qualified name, go one
    // level up.
    // If the parent is still a qualified name, then, it means we were in
    // the middle, so this is
    // not necessarily a field.
    if (parent instanceof QualifiedName) {
        QualifiedName qName = (QualifiedName) parent;
        if (qName.getName().equals(node)) {
            node = (Name) parent;
            parent = parent.getParent();
        }
    }

    if (parent instanceof ArrayAccess) {
        isField = true;
        // } else if (parent instanceof ArrayCreation) {
        // isField = true;
    } else if (parent instanceof ArrayInitializer) {
        isField = true;
    } else if (parent instanceof Assignment) {
        isField = true;
    } else if (parent instanceof CastExpression) {
        CastExpression cExpression = (CastExpression) parent;
        isField = cExpression.getExpression().equals(node);
    } else if (parent instanceof ConditionalExpression) {
        isField = true;
    } else if (parent instanceof InfixExpression) {
        isField = true;
    } else if (parent instanceof WhileStatement) {
        isField = true;
    } else if (parent instanceof DoStatement) {
        isField = true;
    } else if (parent instanceof ForStatement) {
        ForStatement forStatement = (ForStatement) parent;
        isField = forStatement.getExpression().equals(node);
    } else if (parent instanceof PrefixExpression) {
        isField = true;
    } else if (parent instanceof PostfixExpression) {
        isField = true;
    } else if (parent instanceof ReturnStatement) {
        isField = true;
    } else if (parent instanceof InstanceofExpression) {
        InstanceofExpression ioe = (InstanceofExpression) parent;
        isField = ioe.getLeftOperand().equals(node);
    } else if (parent instanceof FieldAccess) {
        isField = true;
    } else if (parent instanceof SuperFieldAccess) {
        isField = true;
    } else if (parent instanceof MethodInvocation) {
        MethodInvocation mi = (MethodInvocation) parent;
        for (Object object : mi.arguments()) {
            if (node == object) {
                isField = true;
                break;
            }
        }
    } else if (parent instanceof ClassInstanceCreation) {
        ClassInstanceCreation cic = (ClassInstanceCreation) parent;
        for (Object object : cic.arguments()) {
            if (node == object) {
                isField = true;
                break;
            }
        }
    } else if (parent instanceof VariableDeclarationFragment) {
        isField = true;
    }

    return isField;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(InstanceofExpression node) {
    node.getLeftOperand().accept(this);
    this.buffer.append(" instanceof ");//$NON-NLS-1$
    node.getRightOperand().accept(this);
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java

License:Open Source License

@Override
public boolean visit(InstanceofExpression node) {
    handleTokenAfter(node.getLeftOperand(), TokenNameinstanceof, true, true);
    return true;//w ww  .j  a va  2s  .  c o m
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

License:Open Source License

@Override
public boolean visit(org.eclipse.jdt.core.dom.InstanceofExpression node) {
    return done(isExpression(translateExpression(node.getLeftOperand()), false,
            (TypeName) translate(node.getRightOperand())));
}

From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java

License:Open Source License

@Override
public boolean visit(InstanceofExpression node) {
    ITypeBinding leftBinding = Types.getTypeBinding(node.getLeftOperand());
    ITypeBinding rightBinding = Types.getTypeBinding(node.getRightOperand());

    if (rightBinding.isArray()) {
        buffer.append("[[(IOSArray *) ");
        node.getLeftOperand().accept(this);
        buffer.append(" elementType] isEqual:[");
        buffer.append(NameTable.getFullName(rightBinding.getElementType()));
        buffer.append(" class]]");
        return false;
    }//from  www.  ja va2  s. c  o  m

    buffer.append('[');
    if (leftBinding.isInterface()) {
        // Obj-C complains when a id<Protocol> is tested for a different
        // protocol, so cast it to a generic id.
        buffer.append("(id) ");
    }
    node.getLeftOperand().accept(this);
    if (rightBinding.isInterface()) {
        buffer.append(" conformsToProtocol: @protocol(");
        node.getRightOperand().accept(this);
        buffer.append(")");
    } else {
        buffer.append(" isKindOfClass:[");
        node.getRightOperand().accept(this);
        buffer.append(" class]");
    }
    buffer.append(']');
    return false;
}

From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(InstanceofExpression node) {
    node.getLeftOperand().accept(this);
    sb.print(" instanceof ");
    node.getRightOperand().accept(this);
    return false;
}

From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java

License:Apache License

/** Visitor method for {@link InstanceofExpression}s. */
@Override/*from ww w .  ja v  a2  s.c om*/
public boolean visit(InstanceofExpression node) {
    sync(node);
    builder.open(plusFour);
    node.getLeftOperand().accept(this);
    builder.breakOp(" ");
    builder.open(ZERO);
    token("instanceof");
    builder.breakOp(" ");
    node.getRightOperand().accept(this);
    builder.close();
    builder.close();
    return false;
}

From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java

License:Open Source License

private CAstNode visit(InstanceofExpression n, WalkContext context) {
    return makeNode(context, fFactory, n, CAstNode.INSTANCEOF,
            fFactory.makeConstant(fTypeDict.getCAstTypeFor(n.getRightOperand().resolveBinding())),
            visitNode(n.getLeftOperand(), context));
}