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

The following examples show how to use com.puppycrawl.tools.checkstyle.api.TokenTypes#PARAMETER_DEF . 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
/**
*
* setSignature adds a reference to the methods paramaters
* to the method definition
* @return <code>void</code>
* @see #makeVariableDef(SymTabAST, Definition)
* @see VariableFinisher
* @see net.sourceforge.transmogrify.symtab.MethodDef
*/
private void setSignature() {
  SymTabAST parametersNode
    = _node.findFirstToken(TokenTypes.PARAMETERS);

  SymTabAST parameterNode = (SymTabAST)(parametersNode.getFirstChild());
  while ( parameterNode != null ) {
    if (parameterNode.getType() == TokenTypes.PARAMETER_DEF) {
        VariableDef parameter = makeVariableDef( parameterNode, _def );
        new VariableFinisher( parameter ).finish();
        _def.addParameter( parameter );
    }
    parameterNode = (SymTabAST)(parameterNode.getNextSibling());
  }

}
 
Example 2
Source File: TableMaker.java    From contribution with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
*
* setSignature adds a reference to the methods paramaters
* to the method definition
* @return <code>void</code>
* @see #makeVariableDef(SymTabAST, Definition)
* @see VariableFinisher
* @see net.sourceforge.transmogrify.symtab.MethodDef
*/
private void setSignature() {
  SymTabAST parametersNode
    = _node.findFirstToken(TokenTypes.PARAMETERS);

  SymTabAST parameterNode = (SymTabAST)(parametersNode.getFirstChild());
  while ( parameterNode != null ) {
    if (parameterNode.getType() == TokenTypes.PARAMETER_DEF) {
        VariableDef parameter = makeVariableDef( parameterNode, _def );
        new VariableFinisher( parameter ).finish();
        _def.addParameter( parameter );
    }
    parameterNode = (SymTabAST)(parameterNode.getNextSibling());
  }

}
 
Example 3
Source File: SpringCatchCheck.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private void visitCatch(DetailAST ast) {
	DetailAST child = ast.getFirstChild();
	while (child != null && child.getType() != TokenTypes.PARAMETER_DEF) {
		child = child.getNextSibling();
	}
	if (child != null) {
		visitParameterDef(child);
	}
}
 
Example 4
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 5
Source File: UnusedParameterCheck.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.PARAMETER_DEF,
    };
}
 
Example 6
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 7
Source File: UnusedParameterCheck.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
    return new int[] {
        TokenTypes.PARAMETER_DEF,
    };
}