本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.PARAMETER_DEF属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.PARAMETER_DEF属性的具体用法?Java TokenTypes.PARAMETER_DEF怎么用?Java TokenTypes.PARAMETER_DEF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.PARAMETER_DEF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSignature
/**
*
* 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());
}
}
示例2: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_THROWS,
TokenTypes.IMPLEMENTS_CLAUSE,
TokenTypes.TYPE_ARGUMENT,
TokenTypes.LITERAL_NEW,
TokenTypes.DOT,
TokenTypes.ANNOTATION_FIELD_DEF,
};
}
示例3: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.METHOD_DEF:
if (isVerifiable(ast)) {
visitMethodDef(ast);
}
break;
case TokenTypes.VARIABLE_DEF:
if (isVerifiable(ast)) {
visitVariableDef(ast);
}
break;
case TokenTypes.PARAMETER_DEF:
visitParameterDef(ast);
break;
case TokenTypes.IMPORT:
visitImport(ast);
break;
default:
throw new IllegalStateException(ast.toString());
}
}
示例4: visitMethod
/**
* Checks parameters of the method or ctor.
* @param method method or ctor to check.
*/
private void visitMethod(final DetailAST method) {
final DetailAST modifiers =
method.findFirstToken(TokenTypes.MODIFIERS);
// exit on fast lane if there is nothing to check here
if (method.findFirstToken(TokenTypes.PARAMETERS)
.findFirstToken(TokenTypes.PARAMETER_DEF) != null
// ignore abstract and native methods
&& modifiers.findFirstToken(TokenTypes.ABSTRACT) == null
&& modifiers.findFirstToken(TokenTypes.LITERAL_NATIVE) == null) {
// we can now be sure that there is at least one parameter
final DetailAST parameters =
method.findFirstToken(TokenTypes.PARAMETERS);
DetailAST child = parameters.getFirstChild();
while (child != null) {
// children are PARAMETER_DEF and COMMA
if (child.getType() == TokenTypes.PARAMETER_DEF) {
checkParam(child);
}
child = child.getNextSibling();
}
}
}
示例5: leaveToken
@Override
public void leaveToken(DetailAST ast) {
final int astType = ast.getType();
if (astType != TokenTypes.VARIABLE_DEF
&& astType != TokenTypes.PARAMETER_DEF
&& astType != TokenTypes.METHOD_CALL
&& astType != TokenTypes.SLIST
&& astType != TokenTypes.LITERAL_NEW
|| astType == TokenTypes.LITERAL_NEW
&& ast.findFirstToken(TokenTypes.OBJBLOCK) != null) {
currentFrame = currentFrame.getParent();
}
else if (astType == TokenTypes.SLIST) {
leaveSlist(ast);
}
}
示例6: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AnnotationOnSameLineCheck constantNameCheckObj = new AnnotationOnSameLineCheck();
final int[] actual = constantNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_THROWS,
TokenTypes.IMPLEMENTS_CLAUSE,
TokenTypes.TYPE_ARGUMENT,
TokenTypes.LITERAL_NEW,
TokenTypes.DOT,
TokenTypes.ANNOTATION_FIELD_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例7: processVariable
/**
* Process a variable token.
* Check whether a local variable or parameter shadows a field.
* Store a field for later comparison with local variables and parameters.
* @param ast the variable token.
*/
private void processVariable(DetailAST ast) {
if (!ScopeUtils.isInInterfaceOrAnnotationBlock(ast)
&& !CheckUtils.isReceiverParameter(ast)
&& (ScopeUtils.isLocalVariableDef(ast)
|| ast.getType() == TokenTypes.PARAMETER_DEF)) {
// local variable or parameter. Does it shadow a field?
final DetailAST nameAST = ast.findFirstToken(TokenTypes.IDENT);
final String name = nameAST.getText();
if ((frame.containsStaticField(name) || isInstanceField(ast, name))
&& !isMatchingRegexp(name)
&& !isIgnoredParam(ast, name)) {
log(nameAST, MSG_KEY, name);
}
}
}
示例8: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_THROWS,
TokenTypes.IMPLEMENTS_CLAUSE,
TokenTypes.TYPE_ARGUMENT,
TokenTypes.LITERAL_NEW,
TokenTypes.DOT,
TokenTypes.ANNOTATION_FIELD_DEF,
};
}
示例9: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AnnotationLocationCheck constantNameCheckObj = new AnnotationLocationCheck();
final int[] actual = constantNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_THROWS,
TokenTypes.IMPLEMENTS_CLAUSE,
TokenTypes.TYPE_ARGUMENT,
TokenTypes.LITERAL_NEW,
TokenTypes.DOT,
TokenTypes.ANNOTATION_FIELD_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例10: finishCreatingDefinition
/**
* 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);
}
}
示例11: getDefaultTokens
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
return new int[] {
TokenTypes.PARAMETER_DEF,
};
}
示例12: getAcceptableTokens
@Override
public final int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
};
}
示例13: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.IMPORT,
};
}
示例14: getAcceptableParent
/**
* Returns parent of given ast if parent has one of the following types:
* ANNOTATION_DEF, PACKAGE_DEF, CLASS_DEF, ENUM_DEF, ENUM_CONSTANT_DEF, CTOR_DEF,
* METHOD_DEF, PARAMETER_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, TYPE, LITERAL_NEW,
* LITERAL_THROWS, TYPE_ARGUMENT, IMPLEMENTS_CLAUSE, DOT.
* @param child an ast
* @return returns ast - parent of given
*/
private static DetailAST getAcceptableParent(DetailAST child) {
final DetailAST result;
final DetailAST parent = child.getParent();
switch (parent.getType()) {
case TokenTypes.ANNOTATION_DEF:
case TokenTypes.PACKAGE_DEF:
case TokenTypes.CLASS_DEF:
case TokenTypes.INTERFACE_DEF:
case TokenTypes.ENUM_DEF:
case TokenTypes.ENUM_CONSTANT_DEF:
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
case TokenTypes.PARAMETER_DEF:
case TokenTypes.VARIABLE_DEF:
case TokenTypes.ANNOTATION_FIELD_DEF:
case TokenTypes.TYPE:
case TokenTypes.LITERAL_NEW:
case TokenTypes.LITERAL_THROWS:
case TokenTypes.TYPE_ARGUMENT:
case TokenTypes.IMPLEMENTS_CLAUSE:
case TokenTypes.DOT:
result = parent;
break;
default:
// it's possible case, but shouldn't be processed here
result = null;
}
return result;
}
示例15: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final ParameterNameCheck parameterNameCheckObj = new ParameterNameCheck();
final int[] actual = parameterNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.PARAMETER_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}