/**
  * 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);
 }
  private boolean isStandAlonePostfix(Node primaryExpression) {
    if (!(primaryExpression instanceof ASTPostfixExpression)
        || !(primaryExpression.jjtGetParent() instanceof ASTStatementExpression)) {
      return false;
    }

    ASTPrimaryPrefix pf =
        (ASTPrimaryPrefix) ((ASTPrimaryExpression) primaryExpression.jjtGetChild(0)).jjtGetChild(0);
    if (pf.usesThisModifier()) {
      return true;
    }

    return thirdChildHasDottedName(primaryExpression);
  }
예제 #3
0
 private String getExpressionVarName(Node e) {
   String assignedVar = getFirstNameImage(e);
   if (assignedVar == null) {
     ASTPrimarySuffix suffix = e.getFirstDescendantOfType(ASTPrimarySuffix.class);
     if (suffix != null) {
       assignedVar = suffix.getImage();
       ASTPrimaryPrefix prefix = e.getFirstDescendantOfType(ASTPrimaryPrefix.class);
       if (prefix != null) {
         if (prefix.usesThisModifier()) {
           assignedVar = "this." + assignedVar;
         } else if (prefix.usesSuperModifier()) {
           assignedVar = "super." + assignedVar;
         }
       }
     }
   }
   return assignedVar;
 }