本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_PUBLIC属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_PUBLIC属性的具体用法?Java TokenTypes.LITERAL_PUBLIC怎么用?Java TokenTypes.LITERAL_PUBLIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_PUBLIC属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVisibility
public int getVisibility() {
int result = DEFAULT_VISIBILITY;
SymTabAST visibilityNode = getVisibilityNode();
if (visibilityNode != null) {
if (visibilityNode.getType() == TokenTypes.LITERAL_PRIVATE) {
result = PRIVATE_VISIBILITY;
}
else if (
visibilityNode.getType() == TokenTypes.LITERAL_PROTECTED) {
result = PROTECTED_VISIBILITY;
}
else if (visibilityNode.getType() == TokenTypes.LITERAL_PUBLIC) {
result = PUBLIC_VISIBILITY;
}
}
return result;
}
示例2: processInterfaceOrAnnotation
/**
* Do validation of interface of annotation.
* @param ast token AST
*/
private void processInterfaceOrAnnotation(DetailAST ast) {
final DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS);
DetailAST modifier = modifiers.getFirstChild();
while (modifier != null) {
// javac does not allow final or static in interface methods
// order annotation fields hence no need to check that this
// is not a method or annotation field
final int type = modifier.getType();
if (type == TokenTypes.LITERAL_PUBLIC
|| type == TokenTypes.LITERAL_STATIC
&& ast.getType() != TokenTypes.METHOD_DEF
|| type == TokenTypes.ABSTRACT
&& ast.getType() != TokenTypes.CLASS_DEF
|| type == TokenTypes.FINAL
&& ast.getType() != TokenTypes.CLASS_DEF) {
log(modifier.getLineNo(), modifier.getColumnNo(),
MSG_KEY, modifier.getText());
break;
}
modifier = modifier.getNextSibling();
}
}
示例3: getAccessModifierFromModifiersToken
/**
* Returns {@link AccessModifier} based on the information about access modifier
* taken from the given token of type {@link TokenTypes#MODIFIERS}.
* @param modifiersToken token of type {@link TokenTypes#MODIFIERS}.
* @return {@link AccessModifier}.
*/
public static AccessModifier getAccessModifierFromModifiersToken(DetailAST modifiersToken) {
if (modifiersToken == null || modifiersToken.getType() != TokenTypes.MODIFIERS) {
throw new IllegalArgumentException("expected non-null AST-token with type 'MODIFIERS'");
}
// default access modifier
AccessModifier accessModifier = AccessModifier.PACKAGE;
for (AST token = modifiersToken.getFirstChild(); token != null;
token = token.getNextSibling()) {
final int tokenType = token.getType();
if (tokenType == TokenTypes.LITERAL_PUBLIC) {
accessModifier = AccessModifier.PUBLIC;
}
else if (tokenType == TokenTypes.LITERAL_PROTECTED) {
accessModifier = AccessModifier.PROTECTED;
}
else if (tokenType == TokenTypes.LITERAL_PRIVATE) {
accessModifier = AccessModifier.PRIVATE;
}
}
return accessModifier;
}
示例4: isVisibilityNode
private boolean isVisibilityNode(SymTabAST node) {
return (
node.getType() == TokenTypes.LITERAL_PUBLIC
|| node.getType() == TokenTypes.LITERAL_PROTECTED
|| node.getType() == TokenTypes.LITERAL_PRIVATE);
}