/** * Simply return if the image start with keyword 'this' or 'super'. * * @return true, if keyword is used, false otherwise. */ public boolean useThisOrSuper() { Node node = location.jjtGetParent(); if (node instanceof ASTPrimaryExpression) { ASTPrimaryExpression primaryExpression = (ASTPrimaryExpression) node; ASTPrimaryPrefix prefix = (ASTPrimaryPrefix) primaryExpression.jjtGetChild(0); if (prefix != null) { return prefix.usesSuperModifier() || prefix.usesThisModifier(); } } return image.startsWith(THIS_DOT) || image.startsWith(SUPER_DOT); }
public boolean isOnLeftHandSide() { // I detest this method with every atom of my being Node primaryExpression; if (location.jjtGetParent() instanceof ASTPrimaryExpression) { primaryExpression = location.jjtGetParent().jjtGetParent(); } else if (location.jjtGetParent().jjtGetParent() instanceof ASTPrimaryExpression) { primaryExpression = location.jjtGetParent().jjtGetParent().jjtGetParent(); } else { throw new RuntimeException( "Found a NameOccurrence that didn't have an ASTPrimary Expression as parent or grandparent. Parent = " + location.jjtGetParent() + " and grandparent = " + location.jjtGetParent().jjtGetParent()); } if (isStandAlonePostfix(primaryExpression)) { return true; } if (primaryExpression.jjtGetNumChildren() <= 1) { return false; } if (!(primaryExpression.jjtGetChild(1) instanceof ASTAssignmentOperator)) { return false; } if (isPartOfQualifiedName() /* or is an array type */) { return false; } if (isCompoundAssignment(primaryExpression)) { return false; } return true; }
public boolean isOnRightHandSide() { Node node = location.jjtGetParent().jjtGetParent().jjtGetParent(); return node instanceof ASTExpression && node.jjtGetNumChildren() == 3; }