本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_NEW属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_NEW属性的具体用法?Java TokenTypes.LITERAL_NEW怎么用?Java TokenTypes.LITERAL_NEW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_NEW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final ClassFanOutComplexityCheck classFanOutComplexityCheckObj =
new ClassFanOutComplexityCheck();
final int[] actual = classFanOutComplexityCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.PACKAGE_DEF,
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.TYPE,
TokenTypes.LITERAL_NEW,
TokenTypes.LITERAL_THROWS,
TokenTypes.ANNOTATION_DEF,
};
Assert.assertNotNull("Acceptable tokens should not be null", actual);
Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
示例2: isInEnumBlock
/**
* Returns whether a node is directly contained within an enum block.
*
* @param node the node to check if directly contained within an enum block.
* @return a {@code boolean} value
*/
public static boolean isInEnumBlock(DetailAST node) {
boolean returnValue = false;
// Loop up looking for a containing interface block
for (DetailAST token = node.getParent();
token != null && !returnValue;
token = token.getParent()) {
final int type = token.getType();
if (type == TokenTypes.ENUM_DEF) {
returnValue = true;
}
else if (type == TokenTypes.INTERFACE_DEF
|| type == TokenTypes.ANNOTATION_DEF
|| type == TokenTypes.CLASS_DEF
|| type == TokenTypes.LITERAL_NEW) {
break;
}
}
return returnValue;
}
示例3: 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,
};
}
示例4: 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,
};
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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);
}
示例9: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AnonInnerLengthCheck anonInnerLengthCheckObj =
new AnonInnerLengthCheck();
final int[] actual = anonInnerLengthCheckObj.getAcceptableTokens();
final int[] expected = {TokenTypes.LITERAL_NEW};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例10: visitToken
@Override
public void visitToken(final DetailAST ast) {
final TextBlock javadoc =
getFileContents().getJavadocBefore(ast.getLineNo());
final boolean containsTag = containsJavadocTag(javadoc);
if (containsTag && !JavadocTagInfo.INHERIT_DOC.isValidOn(ast)) {
log(ast.getLineNo(), MSG_KEY_TAG_NOT_VALID_ON,
JavadocTagInfo.INHERIT_DOC.getText());
}
else {
boolean check = true;
if (javaFiveCompatibility) {
final DetailAST defOrNew = ast.getParent().getParent();
if (defOrNew.findFirstToken(TokenTypes.EXTENDS_CLAUSE) != null
|| defOrNew.findFirstToken(TokenTypes.IMPLEMENTS_CLAUSE) != null
|| defOrNew.getType() == TokenTypes.LITERAL_NEW) {
check = false;
}
}
if (check
&& containsTag
&& !AnnotationUtility.containsAnnotation(ast, OVERRIDE)
&& !AnnotationUtility.containsAnnotation(ast, FQ_OVERRIDE)) {
log(ast.getLineNo(), MSG_KEY_ANNOTATION_MISSING_OVERRIDE);
}
}
}
示例11: getIndentImpl
@Override
protected IndentLevel getIndentImpl() {
final DetailAST parentAST = getMainAst().getParent();
IndentLevel indent = getParent().getIndent();
if (parentAST.getType() == TokenTypes.LITERAL_NEW) {
indent.addAcceptedIndent(super.getIndentImpl());
}
else if (parentAST.getType() == TokenTypes.ENUM_CONSTANT_DEF) {
indent = super.getIndentImpl();
}
return indent;
}
示例12: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.PACKAGE_DEF,
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.LITERAL_NEW,
};
}
示例13: 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));
}
}
示例14: checkIndentation
@Override
public void checkIndentation() {
// if we have a class or interface as a parent, don't do anything,
// as this is checked by class def; so
// only do this if we have a new for a parent (anonymous inner
// class)
final DetailAST parentAST = getMainAst().getParent();
if (parentAST.getType() == TokenTypes.LITERAL_NEW) {
super.checkIndentation();
}
}
示例15: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.IMPORT,
TokenTypes.LITERAL_NEW,
TokenTypes.PACKAGE_DEF,
TokenTypes.CLASS_DEF,
};
}