本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.Scope.PUBLIC属性的典型用法代码示例。如果您正苦于以下问题:Java Scope.PUBLIC属性的具体用法?Java Scope.PUBLIC怎么用?Java Scope.PUBLIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.Scope
的用法示例。
在下文中一共展示了Scope.PUBLIC属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equalScope
/**
* Tests whether the scope of a field or method is compatible
* with the scope of this check. References for compatible
* fields or methods should be checked.
* @param aFieldOrMethod the field or method to check.
* @return true if the scope of aFieldOrMethod is compatible
* with the scope of this check.
*/
private boolean equalScope(FieldOrMethod aFieldOrMethod)
{
if (aFieldOrMethod.isPrivate()) {
return (mScope == Scope.PRIVATE);
}
else if (aFieldOrMethod.isProtected()) {
return (mScope == Scope.PROTECTED);
}
else if (aFieldOrMethod.isPublic()) {
return (mScope == Scope.PUBLIC);
}
else {
return (mScope == Scope.PACKAGE);
}
}
示例2: shouldCheck
/**
* Whether we should check this node.
* @param ast a given node.
* @return whether we should check a given node.
*/
private boolean shouldCheck(final DetailAST ast) {
final Scope customScope;
if (ScopeUtils.isInInterfaceOrAnnotationBlock(ast)) {
customScope = Scope.PUBLIC;
}
else {
final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS);
customScope = ScopeUtils.getScopeFromMods(mods);
}
final Scope surroundingScope = ScopeUtils.getSurroundingScope(ast);
return customScope.isIn(scope)
&& (surroundingScope == null || surroundingScope.isIn(scope))
&& (excludeScope == null
|| !customScope.isIn(excludeScope)
|| surroundingScope != null
&& !surroundingScope.isIn(excludeScope));
}
示例3: shouldCheck
/**
* Whether we should check this node.
* @param ast a given node.
* @return whether we should check a given node.
*/
private boolean shouldCheck(final DetailAST ast) {
boolean result = false;
if (!ScopeUtils.isInCodeBlock(ast) && !isIgnored(ast)) {
Scope customScope = Scope.PUBLIC;
if (ast.getType() != TokenTypes.ENUM_CONSTANT_DEF
&& !ScopeUtils.isInInterfaceOrAnnotationBlock(ast)) {
final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS);
customScope = ScopeUtils.getScopeFromMods(mods);
}
final Scope surroundingScope = ScopeUtils.getSurroundingScope(ast);
result = customScope.isIn(scope) && surroundingScope.isIn(scope)
&& (excludeScope == null
|| !customScope.isIn(excludeScope)
|| !surroundingScope.isIn(excludeScope));
}
return result;
}
示例4: getScopeFromMods
/**
* Returns the Scope specified by the modifier set.
*
* @param aMods root node of a modifier set
* @return a {@code Scope} value
*/
public static Scope getScopeFromMods(DetailAST aMods) {
// default scope
Scope returnValue = Scope.PACKAGE;
for (AST token = aMods.getFirstChild(); token != null
&& returnValue == Scope.PACKAGE;
token = token.getNextSibling()) {
if ("public".equals(token.getText())) {
returnValue = Scope.PUBLIC;
}
else if ("protected".equals(token.getText())) {
returnValue = Scope.PROTECTED;
}
else if ("private".equals(token.getText())) {
returnValue = Scope.PRIVATE;
}
}
return returnValue;
}
示例5: shouldCheck
/**
* Whether we should check this node.
*
* @param aAST
* a given node.
* @return whether we should check a given node.
*/
private boolean shouldCheck(final DetailAST aAST) {
if (ScopeUtils.inCodeBlock(aAST)) {
return false;
}
final Scope scope;
if (aAST.getType() == TokenTypes.ENUM_CONSTANT_DEF) {
scope = Scope.PUBLIC;
} else {
final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
final Scope declaredScope = ScopeUtils.getScopeFromMods(mods);
scope = ScopeUtils.inInterfaceOrAnnotationBlock(aAST) ? Scope.PUBLIC : declaredScope;
}
final Scope surroundingScope = ScopeUtils.getSurroundingScope(aAST);
return Utilities.isExportedPackage(aAST) && scope.isIn(mScope) && surroundingScope.isIn(mScope)
&& ((mExcludeScope == null) || !scope.isIn(mExcludeScope) || !surroundingScope.isIn(mExcludeScope));
}
开发者ID:Adobe-Consulting-Services,项目名称:checkstyle-osgi-checks,代码行数:26,代码来源:ExportedJavadocVariableCheck.java
示例6: processModifiersState
/**
* Process if given modifiers are appropriate in given state
* ({@code STATE_STATIC_VARIABLE_DEF}, {@code STATE_INSTANCE_VARIABLE_DEF},
* ({@code STATE_CTOR_DEF}, {@code STATE_METHOD_DEF}), if it is
* it updates states where appropriate or logs violation.
* @param modifierAst modifiers to process
* @param state current state
* @return true if modifierAst is valid in given state, false otherwise
*/
private boolean processModifiersState(DetailAST modifierAst, ScopeState state) {
boolean isStateValid = true;
if (modifierAst.findFirstToken(TokenTypes.LITERAL_STATIC) == null) {
if (state.currentScopeState > STATE_INSTANCE_VARIABLE_DEF) {
isStateValid = false;
log(modifierAst, MSG_INSTANCE);
}
else if (state.currentScopeState == STATE_STATIC_VARIABLE_DEF) {
state.declarationAccess = Scope.PUBLIC;
state.currentScopeState = STATE_INSTANCE_VARIABLE_DEF;
}
}
else {
if (state.currentScopeState > STATE_STATIC_VARIABLE_DEF) {
if (!ignoreModifiers
|| state.currentScopeState > STATE_INSTANCE_VARIABLE_DEF) {
isStateValid = false;
log(modifierAst, MSG_STATIC);
}
}
else {
state.currentScopeState = STATE_STATIC_VARIABLE_DEF;
}
}
return isStateValid;
}
示例7: shouldCheck
/**
* Whether we should check this node.
* @param ast a given node.
* @return whether we should check a given node.
*/
private boolean shouldCheck(final DetailAST ast) {
boolean check = false;
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
check = getFileContents().inPackageInfo();
}
else if (!ScopeUtils.isInCodeBlock(ast)) {
final Scope customScope;
if (ScopeUtils.isInInterfaceOrAnnotationBlock(ast)
|| ast.getType() == TokenTypes.ENUM_CONSTANT_DEF) {
customScope = Scope.PUBLIC;
}
else {
customScope = ScopeUtils.getScopeFromMods(ast.findFirstToken(TokenTypes.MODIFIERS));
}
final Scope surroundingScope = ScopeUtils.getSurroundingScope(ast);
check = customScope.isIn(scope)
&& (surroundingScope == null || surroundingScope.isIn(scope))
&& (excludeScope == null
|| !customScope.isIn(excludeScope)
|| surroundingScope != null
&& !surroundingScope.isIn(excludeScope));
}
return check;
}
示例8: calculateScope
/**
* Returns the scope for the method/constructor at the specified AST. If
* the method is in an interface or annotation block, the scope is assumed
* to be public.
*
* @param ast the token of the method/constructor
* @return the scope of the method/constructor
*/
private static Scope calculateScope(final DetailAST ast) {
final Scope scope;
if (ScopeUtils.isInInterfaceOrAnnotationBlock(ast)) {
scope = Scope.PUBLIC;
}
else {
final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS);
scope = ScopeUtils.getScopeFromMods(mods);
}
return scope;
}
示例9: shouldCheck
/**
* Whether we should check this node.
*
* @param aAST
* a given node.
* @return whether we should check a given node.
*/
private boolean shouldCheck(final DetailAST aAST) {
final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
final Scope declaredScope = ScopeUtils.getScopeFromMods(mods);
final Scope scope = ScopeUtils.inInterfaceOrAnnotationBlock(aAST) ? Scope.PUBLIC : declaredScope;
final Scope surroundingScope = ScopeUtils.getSurroundingScope(aAST);
return Utilities.isExportedPackage(aAST)
&& scope.isIn(mScope)
&& ((surroundingScope == null) || surroundingScope.isIn(mScope))
&& ((mExcludeScope == null) || !scope.isIn(mExcludeScope) || ((surroundingScope != null) && !surroundingScope
.isIn(mExcludeScope)));
}
开发者ID:Adobe-Consulting-Services,项目名称:checkstyle-osgi-checks,代码行数:19,代码来源:ExportedJavadocTypeCheck.java