本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.METHOD_CALL属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.METHOD_CALL属性的具体用法?Java TokenTypes.METHOD_CALL怎么用?Java TokenTypes.METHOD_CALL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.METHOD_CALL属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.METHOD_CALL,
TokenTypes.CLASS_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_TRY,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.SLIST,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.LITERAL_NEW,
};
}
示例2: visitToken
@Override
public void visitToken(final DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.VARIABLE_DEF:
case TokenTypes.PARAMETER_DEF:
currentFrame.addField(ast);
break;
case TokenTypes.METHOD_CALL:
processMethodCall(ast);
break;
case TokenTypes.SLIST:
processSlist(ast);
break;
case TokenTypes.LITERAL_NEW:
processLiteralNew(ast);
break;
default:
processFrame(ast);
}
}
示例3: 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);
}
}
示例4: getHandler
/**
* Get the handler for an AST.
*
* @param indentCheck the indentation check
* @param ast ast to handle
* @param parent the handler parent of this AST
*
* @return the ExpressionHandler for ast
*/
public AbstractExpressionHandler getHandler(IndentationCheck indentCheck,
DetailAST ast, AbstractExpressionHandler parent) {
final AbstractExpressionHandler resultHandler;
final AbstractExpressionHandler handler =
createdHandlers.get(ast);
if (handler != null) {
resultHandler = handler;
}
else if (ast.getType() == TokenTypes.METHOD_CALL) {
resultHandler = createMethodCallHandler(indentCheck, ast, parent);
}
else {
final Constructor<?> handlerCtor = typeHandlers.get(ast.getType());
resultHandler = (AbstractExpressionHandler) CommonUtils.invokeConstructor(
handlerCtor, indentCheck, ast, parent);
}
return resultHandler;
}
示例5: isChainedMethodCallWrapped
/**
* If this is the first chained method call which was moved to the next line.
* @return true if chained class are wrapped
*/
private boolean isChainedMethodCallWrapped() {
boolean result = false;
final DetailAST main = getMainAst();
final DetailAST dot = main.getFirstChild();
final DetailAST target = dot.getFirstChild();
final DetailAST dot1 = target.getFirstChild();
final DetailAST target1 = dot1.getFirstChild();
if (dot1.getType() == TokenTypes.DOT
&& target1.getType() == TokenTypes.METHOD_CALL) {
result = true;
}
return result;
}
示例6: makeAcceptableTokens
/**
* Returns array of acceptable tokens.
* @return acceptableTokens.
*/
private static int[] makeAcceptableTokens() {
return new int[] {TokenTypes.ANNOTATION,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.CTOR_CALL,
TokenTypes.CTOR_DEF,
TokenTypes.DOT,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.EXPR,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_NEW,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_WHILE,
TokenTypes.METHOD_CALL,
TokenTypes.METHOD_DEF,
TokenTypes.QUESTION,
TokenTypes.RESOURCE_SPECIFICATION,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.LAMBDA,
};
}
示例7: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.LITERAL_NEW,
TokenTypes.METHOD_CALL,
TokenTypes.METHOD_DEF,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.ENUM_CONSTANT_DEF,
};
}
示例8: visitToken
@Override
public void visitToken(DetailAST ast) {
final DetailAST parenAST;
if (ast.getType() == TokenTypes.METHOD_CALL) {
parenAST = ast;
}
else {
parenAST = ast.findFirstToken(TokenTypes.LPAREN);
// array construction => parenAST == null
}
if (parenAST != null) {
final String line = getLines()[parenAST.getLineNo() - 1];
if (CommonUtils.hasWhitespaceBefore(parenAST.getColumnNo(), line)) {
if (!allowLineBreaks) {
log(parenAST, MSG_LINE_PREVIOUS, parenAST.getText());
}
}
else {
final int before = parenAST.getColumnNo() - 1;
if (option == PadOption.NOSPACE
&& Character.isWhitespace(line.charAt(before))) {
log(parenAST, MSG_WS_PRECEDED, parenAST.getText());
}
else if (option == PadOption.SPACE
&& !Character.isWhitespace(line.charAt(before))) {
log(parenAST, MSG_WS_NOT_PRECEDED, parenAST.getText());
}
}
}
}
示例9: isGenericBeforeMethod
/**
* Is generic before method reference.
* @param ast ast
* @return true if generic before a method ref
*/
private static boolean isGenericBeforeMethod(DetailAST ast) {
return ast.getParent().getType() == TokenTypes.TYPE_ARGUMENTS
&& ast.getParent().getParent().getType() == TokenTypes.DOT
&& ast.getParent().getParent().getParent().getType() == TokenTypes.METHOD_CALL
|| isAfterMethodReference(ast);
}
示例10: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.METHOD_CALL:
processLeft(ast);
processRight(ast.findFirstToken(TokenTypes.RPAREN));
break;
case TokenTypes.DOT:
case TokenTypes.EXPR:
case TokenTypes.QUESTION:
processExpression(ast);
break;
case TokenTypes.LITERAL_FOR:
visitLiteralFor(ast);
break;
case TokenTypes.ANNOTATION:
case TokenTypes.ENUM_CONSTANT_DEF:
case TokenTypes.LITERAL_NEW:
case TokenTypes.LITERAL_SYNCHRONIZED:
case TokenTypes.LAMBDA:
visitTokenWithOptionalParentheses(ast);
break;
case TokenTypes.RESOURCE_SPECIFICATION:
visitResourceSpecification(ast);
break;
default:
processLeft(ast.findFirstToken(TokenTypes.LPAREN));
processRight(ast.findFirstToken(TokenTypes.RPAREN));
}
}
示例11: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final MethodParamPadCheck methodParamPadCheckObj = new MethodParamPadCheck();
final int[] actual = methodParamPadCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.CTOR_DEF,
TokenTypes.LITERAL_NEW,
TokenTypes.METHOD_CALL,
TokenTypes.METHOD_DEF,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.ENUM_CONSTANT_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例12: isInitializationSequence
/**
* Processes statements until usage of variable to detect sequence of
* initialization methods.
* @param variableUsageAst
* DetailAST of expression that uses variable named variableName.
* @param variableName
* name of considered variable.
* @return true if statements between declaration and usage of variable are
* initialization methods.
*/
private static boolean isInitializationSequence(
DetailAST variableUsageAst, String variableName) {
boolean result = true;
boolean isUsedVariableDeclarationFound = false;
DetailAST currentSiblingAst = variableUsageAst;
String initInstanceName = "";
while (result
&& !isUsedVariableDeclarationFound
&& currentSiblingAst != null) {
switch (currentSiblingAst.getType()) {
case TokenTypes.EXPR:
final DetailAST methodCallAst = currentSiblingAst.getFirstChild();
if (methodCallAst.getType() == TokenTypes.METHOD_CALL) {
final String instanceName =
getInstanceName(methodCallAst);
// method is called without instance
if (instanceName.isEmpty()) {
result = false;
}
// differs from previous instance
else if (!instanceName.equals(initInstanceName)) {
if (initInstanceName.isEmpty()) {
initInstanceName = instanceName;
}
else {
result = false;
}
}
}
else {
// is not method call
result = false;
}
break;
case TokenTypes.VARIABLE_DEF:
final String currentVariableName = currentSiblingAst
.findFirstToken(TokenTypes.IDENT).getText();
isUsedVariableDeclarationFound = variableName.equals(currentVariableName);
break;
case TokenTypes.SEMI:
break;
default:
result = false;
}
currentSiblingAst = currentSiblingAst.getPreviousSibling();
}
return result;
}