Java Code Examples for com.puppycrawl.tools.checkstyle.api.TokenTypes#LPAREN

The following examples show how to use com.puppycrawl.tools.checkstyle.api.TokenTypes#LPAREN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableMaker.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * process the given <code>SymTabAST</code> as a class definition
 *
 * @param tree the <code>SymTabAST</code> to process
 * @return <code>void</code>
 * @see #makeClass(String, SymTabAST)
 * @see #walkSiblings(SymTabAST, boolean)
 * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
 */
public void processClass(SymTabAST tree) {
  String name = tree.findFirstToken(TokenTypes.IDENT).getText();

  makeClass(name, tree);
  final SymTabAST objblock =
      tree.findFirstToken(TokenTypes.OBJBLOCK);
  SymTabAST start = (SymTabAST)objblock.getFirstChild();
  if (start != null) {
      //skip LPAREN
      if (start.getType() == TokenTypes.LPAREN) {
          start = (SymTabAST)start.getNextSibling();
      }
      walkSiblings(start, false);
  }
  
  symbolTable.popScope();
}
 
Example 2
Source File: TableMaker.java    From contribution with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * process the given <code>SymTabAST</code> as a class definition
 *
 * @param tree the <code>SymTabAST</code> to process
 * @return <code>void</code>
 * @see #makeClass(String, SymTabAST)
 * @see #walkSiblings(SymTabAST, boolean)
 * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
 */
public void processClass(SymTabAST tree) {
  String name = tree.findFirstToken(TokenTypes.IDENT).getText();

  makeClass(name, tree);
  final SymTabAST objblock =
      tree.findFirstToken(TokenTypes.OBJBLOCK);
  SymTabAST start = (SymTabAST)objblock.getFirstChild();
  if (start != null) {
      //skip LPAREN
      if (start.getType() == TokenTypes.LPAREN) {
          start = (SymTabAST)start.getNextSibling();
      }
      walkSiblings(start, false);
  }
  
  symbolTable.popScope();
}
 
Example 3
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean newIsConstructor(SymTabAST newNode) {
    boolean result = false;

    SymTabAST typeNode =
        (SymTabAST) (newNode.getFirstChild().getNextSibling());
    //handle Checkstyle grammar
    if (typeNode.getType() == TokenTypes.LPAREN) {
        typeNode = (SymTabAST) typeNode.getNextSibling();
    }
    if (typeNode.getType() == TokenTypes.ELIST) {
        result = true;
    }
    return result;

}
 
Example 4
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private IClass resolveQuestion(
    SymTabAST question,
    Scope location,
    IClass context,
    boolean referencePhase) {
    SymTabAST test = (SymTabAST) question.getFirstChild();
    while (test.getType() == TokenTypes.LPAREN) {
        test = (SymTabAST) test.getNextSibling();
    }
    SymTabAST leftBranch = (SymTabAST) test.getNextSibling();
    while (leftBranch.getType() == TokenTypes.RPAREN) {
        leftBranch = (SymTabAST) leftBranch.getNextSibling();
    }
    SymTabAST rightBranch = (SymTabAST) leftBranch.getNextSibling();
    while (rightBranch.getType() != TokenTypes.COLON) {
        rightBranch = (SymTabAST) rightBranch.getNextSibling();
    }
    rightBranch = (SymTabAST) rightBranch.getNextSibling();

    resolveExpression(test, location, context, referencePhase);
    IClass leftClass =
        resolveExpression(leftBranch, location, context, referencePhase);
    IClass rightClass =
        resolveExpression(rightBranch, location, context, referencePhase);

    return moreGeneral(leftClass, rightClass);
}
 
Example 5
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Finds the left child of a binary operator, skipping parentheses.
 * @param aExpression the node for the binary operator.
 * @return the node for the left child.
 */  
private SymTabAST findLeftChild(SymTabAST aExpression) {
    SymTabAST leftChild = (SymTabAST) (aExpression.getFirstChild());
    // handle Checkstyle grammar
    while (leftChild.getType() == TokenTypes.LPAREN) {
        leftChild = (SymTabAST) leftChild.getNextSibling();
    }
    return leftChild;
}
 
Example 6
Source File: TableMaker.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * begins at the base of the Table and starts finishing definition creation.
 *
 * @param def <code>Definition</code> needs to be completed
 * @return <code>void</code>
 * @throws <code>SymbolTableException</code>
 * @see ClassFinisher
 * @see VariableFinisher
 * @see MethodFinisher
 * @see CatchFinisher
 */
private void finishCreatingDefinition(Definition def) throws SymbolTableException {

  if (def instanceof AnonymousInnerClass) {
    AnonymousInnerClass innerClass = (AnonymousInnerClass)def;
    innerClass.finishMakingDefinition();
  }
  else if (def instanceof ClassDef) {
    new ClassFinisher(def).finish();
  }
  else if ( def instanceof VariableDef ) {
    new VariableFinisher( def ).finish();
  }
  else if (def instanceof DefaultConstructor) {}
  else if ( def instanceof MethodDef ) {
    new MethodFinisher( def ).finish();
  }
  else if (def instanceof BlockDef) {
    SymTabAST firstChild = (SymTabAST)def.getTreeNode().getFirstChild();
    //handle Checkstyle grammar
    if (firstChild.getType() == TokenTypes.LPAREN) {
        firstChild = (SymTabAST) firstChild.getNextSibling();
    }
    if (firstChild.getType() == TokenTypes.PARAMETER_DEF) {
      // this is a catch block
      new CatchFinisher((BlockDef)def).finish();
    }
  }

  if ( def instanceof Scope ) {
    finishCreatingChildren((Scope)def);
  }
}
 
Example 7
Source File: TableMaker.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes the current tree node as BlockDef
 * @param tree current tree node
 * @param makeAnonymousScopes
 * @return <code>void</code>
 */
public void processBlock(SymTabAST tree, boolean makeAnonymousScopes) {
  BlockDef block = makeBlock(tree);
  symbolTable.pushScope(block);
  //handle Checkstyle grammar
  SymTabAST child = (SymTabAST)tree.getFirstChild();
  if ((child != null) && (child.getType() == TokenTypes.LPAREN)) {
      child = (SymTabAST) child.getNextSibling();
  }
  walkSiblings(child, makeAnonymousScopes);
  symbolTable.popScope();
}
 
Example 8
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean newIsConstructor(SymTabAST newNode) {
    boolean result = false;

    SymTabAST typeNode =
        (SymTabAST) (newNode.getFirstChild().getNextSibling());
    //handle Checkstyle grammar
    if (typeNode.getType() == TokenTypes.LPAREN) {
        typeNode = (SymTabAST) typeNode.getNextSibling();
    }
    if (typeNode.getType() == TokenTypes.ELIST) {
        result = true;
    }
    return result;

}
 
Example 9
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
private IClass resolveQuestion(
    SymTabAST question,
    Scope location,
    IClass context,
    boolean referencePhase) {
    SymTabAST test = (SymTabAST) question.getFirstChild();
    while (test.getType() == TokenTypes.LPAREN) {
        test = (SymTabAST) test.getNextSibling();
    }
    SymTabAST leftBranch = (SymTabAST) test.getNextSibling();
    while (leftBranch.getType() == TokenTypes.RPAREN) {
        leftBranch = (SymTabAST) leftBranch.getNextSibling();
    }
    SymTabAST rightBranch = (SymTabAST) leftBranch.getNextSibling();
    while (rightBranch.getType() != TokenTypes.COLON) {
        rightBranch = (SymTabAST) rightBranch.getNextSibling();
    }
    rightBranch = (SymTabAST) rightBranch.getNextSibling();

    resolveExpression(test, location, context, referencePhase);
    IClass leftClass =
        resolveExpression(leftBranch, location, context, referencePhase);
    IClass rightClass =
        resolveExpression(rightBranch, location, context, referencePhase);

    return moreGeneral(leftClass, rightClass);
}
 
Example 10
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Finds the left child of a binary operator, skipping parentheses.
 * @param aExpression the node for the binary operator.
 * @return the node for the left child.
 */  
private SymTabAST findLeftChild(SymTabAST aExpression) {
    SymTabAST leftChild = (SymTabAST) (aExpression.getFirstChild());
    // handle Checkstyle grammar
    while (leftChild.getType() == TokenTypes.LPAREN) {
        leftChild = (SymTabAST) leftChild.getNextSibling();
    }
    return leftChild;
}
 
Example 11
Source File: TableMaker.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * begins at the base of the Table and starts finishing definition creation.
 *
 * @param def <code>Definition</code> needs to be completed
 * @return <code>void</code>
 * @throws <code>SymbolTableException</code>
 * @see ClassFinisher
 * @see VariableFinisher
 * @see MethodFinisher
 * @see CatchFinisher
 */
private void finishCreatingDefinition(Definition def) throws SymbolTableException {

  if (def instanceof AnonymousInnerClass) {
    AnonymousInnerClass innerClass = (AnonymousInnerClass)def;
    innerClass.finishMakingDefinition();
  }
  else if (def instanceof ClassDef) {
    new ClassFinisher(def).finish();
  }
  else if ( def instanceof VariableDef ) {
    new VariableFinisher( def ).finish();
  }
  else if (def instanceof DefaultConstructor) {}
  else if ( def instanceof MethodDef ) {
    new MethodFinisher( def ).finish();
  }
  else if (def instanceof BlockDef) {
    SymTabAST firstChild = (SymTabAST)def.getTreeNode().getFirstChild();
    //handle Checkstyle grammar
    if (firstChild.getType() == TokenTypes.LPAREN) {
        firstChild = (SymTabAST) firstChild.getNextSibling();
    }
    if (firstChild.getType() == TokenTypes.PARAMETER_DEF) {
      // this is a catch block
      new CatchFinisher((BlockDef)def).finish();
    }
  }

  if ( def instanceof Scope ) {
    finishCreatingChildren((Scope)def);
  }
}
 
Example 12
Source File: TableMaker.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes the current tree node as BlockDef
 * @param tree current tree node
 * @param makeAnonymousScopes
 * @return <code>void</code>
 */
public void processBlock(SymTabAST tree, boolean makeAnonymousScopes) {
  BlockDef block = makeBlock(tree);
  symbolTable.pushScope(block);
  //handle Checkstyle grammar
  SymTabAST child = (SymTabAST)tree.getFirstChild();
  if ((child != null) && (child.getType() == TokenTypes.LPAREN)) {
      child = (SymTabAST) child.getNextSibling();
  }
  walkSiblings(child, makeAnonymousScopes);
  symbolTable.popScope();
}