本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.FullIdent.createFullIdentBelow方法的典型用法代码示例。如果您正苦于以下问题:Java FullIdent.createFullIdentBelow方法的具体用法?Java FullIdent.createFullIdentBelow怎么用?Java FullIdent.createFullIdentBelow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.api.FullIdent
的用法示例。
在下文中一共展示了FullIdent.createFullIdentBelow方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
final FullIdent imp;
if (ast.getType() == TokenTypes.IMPORT) {
imp = FullIdent.createFullIdentBelow(ast);
}
else {
imp = FullIdent.createFullIdent(
ast.getFirstChild().getNextSibling());
}
if (isIllegalImport(imp.getText())) {
log(ast.getLineNo(),
ast.getColumnNo(),
MSG_KEY,
imp.getText());
}
}
示例2: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST aAST) {
final FullIdent imp;
if ( aAST.getType() == TokenTypes.IMPORT ) {
imp = FullIdent.createFullIdentBelow( aAST );
}
else {
// handle case of static imports of method names
imp = FullIdent.createFullIdent( aAST.getFirstChild().getNextSibling() );
}
final String text = imp.getText();
if ( isIllegalImport( text ) ) {
final String message = buildError( text );
log( aAST.getLineNo(), aAST.getColumnNo(), message, text );
}
}
示例3: isObjectParam
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Determines if an AST is a formal param of type Object.
* @param paramNode the AST to check
* @return true if firstChild is a parameter of an Object type.
*/
private static boolean isObjectParam(DetailAST paramNode) {
final DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE);
final FullIdent fullIdent = FullIdent.createFullIdentBelow(typeNode);
final String name = fullIdent.getText();
return "Object".equals(name) || "java.lang.Object".equals(name);
}
示例4: processImport
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Perform processing for an import token.
* @param ast the import token
*/
private void processImport(DetailAST ast) {
final FullIdent name = FullIdent.createFullIdentBelow(ast);
// Note: different from UnusedImportsCheck.processImport(),
// '.*' imports are also added here
imports.add(name);
}
示例5: isFirstParameterObject
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Tests whether a method's first parameter is an Object.
* @param methodDefAst the method definition AST to test.
* Precondition: ast is a TokenTypes.METHOD_DEF node.
* @return true if ast has first parameter of type Object.
*/
private static boolean isFirstParameterObject(DetailAST methodDefAst) {
final DetailAST paramsNode = methodDefAst.findFirstToken(TokenTypes.PARAMETERS);
// parameter type "Object"?
final DetailAST paramNode =
paramsNode.findFirstToken(TokenTypes.PARAMETER_DEF);
final DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE);
final FullIdent fullIdent = FullIdent.createFullIdentBelow(typeNode);
final String name = fullIdent.getText();
return "Object".equals(name) || "java.lang.Object".equals(name);
}
示例6: processTypeParams
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Process type params (if any) for given class, enum or method.
* @param ast class, enum or method to process.
*/
private void processTypeParams(DetailAST ast) {
final DetailAST params =
ast.findFirstToken(TokenTypes.TYPE_PARAMETERS);
final Map<String, AbstractClassInfo> paramsMap = new HashMap<String, AbstractClassInfo>();
typeParams.push(paramsMap);
if (params != null) {
for (DetailAST child = params.getFirstChild();
child != null;
child = child.getNextSibling()) {
if (child.getType() == TokenTypes.TYPE_PARAMETER) {
final DetailAST bounds =
child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS);
if (bounds != null) {
final FullIdent name =
FullIdent.createFullIdentBelow(bounds);
final AbstractClassInfo classInfo =
createClassInfo(new Token(name), currentClassName);
final String alias =
child.findFirstToken(TokenTypes.IDENT).getText();
paramsMap.put(alias, classInfo);
}
}
}
}
}
示例7: processImport
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Collects the details of imports.
* @param ast node containing the import details
*/
private void processImport(DetailAST ast) {
final FullIdent name = FullIdent.createFullIdentBelow(ast);
if (!name.getText().endsWith(STAR_IMPORT_SUFFIX)) {
imports.add(name);
}
}
示例8: getImportText
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Returns import text.
* @param ast ast node that represents import
* @return String that represents importing class
*/
private static String getImportText(DetailAST ast) {
final FullIdent imp;
if (ast.getType() == TokenTypes.IMPORT) {
imp = FullIdent.createFullIdentBelow(ast);
}
else {
// know it is a static import
imp = FullIdent.createFullIdent(ast
.getFirstChild().getNextSibling());
}
return imp.getText();
}
示例9: processTypeParams
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Process type params (if any) for given class, enum or method.
* @param ast class, enum or method to process.
*/
private void processTypeParams(DetailAST ast) {
final DetailAST params =
ast.findFirstToken(TokenTypes.TYPE_PARAMETERS);
final Map<String, AbstractClassInfo> paramsMap = new HashMap<>();
typeParams.push(paramsMap);
if (params != null) {
for (DetailAST child = params.getFirstChild();
child != null;
child = child.getNextSibling()) {
if (child.getType() == TokenTypes.TYPE_PARAMETER) {
final DetailAST bounds =
child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS);
if (bounds != null) {
final FullIdent name =
FullIdent.createFullIdentBelow(bounds);
final AbstractClassInfo classInfo =
createClassInfo(new Token(name), currentClassName);
final String alias =
child.findFirstToken(TokenTypes.IDENT).getText();
paramsMap.put(alias, classInfo);
}
}
}
}
}
示例10: processImport
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
/**
* Collects the details of imports.
* @param ast node containing the import details
*/
private void processImport(DetailAST ast) {
final FullIdent name = FullIdent.createFullIdentBelow(ast);
imports.add(name.getText());
}
示例11: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
final FullIdent ident;
final boolean isStatic;
if (ast.getType() == TokenTypes.IMPORT) {
ident = FullIdent.createFullIdentBelow(ast);
isStatic = false;
}
else {
ident = FullIdent.createFullIdent(ast.getFirstChild()
.getNextSibling());
isStatic = true;
}
final boolean isStaticAndNotLastImport = isStatic && !lastImportStatic;
final boolean isLastImportAndNonStatic = lastImportStatic && !isStatic;
// using set of IF instead of SWITCH to analyze Enum options to satisfy coverage.
// https://github.com/checkstyle/checkstyle/issues/1387
if (option == ImportOrderOption.TOP) {
if (isLastImportAndNonStatic) {
lastGroup = Integer.MIN_VALUE;
lastImport = "";
}
doVisitToken(ident, isStatic, isStaticAndNotLastImport);
if (isStaticAndNotLastImport && !beforeFirstImport) {
log(ident.getLineNo(), MSG_ORDERING, ident.getText());
}
}
else if (option == ImportOrderOption.BOTTOM) {
if (isStaticAndNotLastImport) {
lastGroup = Integer.MIN_VALUE;
lastImport = "";
}
doVisitToken(ident, isStatic, isLastImportAndNonStatic);
if (isLastImportAndNonStatic) {
log(ident.getLineNo(), MSG_ORDERING, ident.getText());
}
}
else if (option == ImportOrderOption.ABOVE) {
// previous non-static but current is static
doVisitToken(ident, isStatic, isStaticAndNotLastImport);
}
else if (option == ImportOrderOption.UNDER) {
doVisitToken(ident, isStatic, isLastImportAndNonStatic);
}
else if (option == ImportOrderOption.INFLOW) {
// "previous" argument is useless here
doVisitToken(ident, isStatic, true);
}
else {
throw new IllegalStateException(
"Unexpected option for static imports: " + option);
}
lastImportLine = ast.findFirstToken(TokenTypes.SEMI).getLineNo();
lastImportStatic = isStatic;
beforeFirstImport = false;
}
示例12: visitToken
import com.puppycrawl.tools.checkstyle.api.FullIdent; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
final FullIdent ident;
final boolean isStatic;
if (ast.getType() == TokenTypes.IMPORT) {
ident = FullIdent.createFullIdentBelow(ast);
isStatic = false;
}
else {
ident = FullIdent.createFullIdent(ast.getFirstChild()
.getNextSibling());
isStatic = true;
}
final boolean isStaticAndNotLastImport = isStatic && !lastImportStatic;
final boolean isLastImportAndNonStatic = lastImportStatic && !isStatic;
// using set of IF instead of SWITCH to analyze Enum options to satisfy coverage.
// https://github.com/checkstyle/checkstyle/issues/1387
if (option == ImportOrderOption.TOP) {
if (isLastImportAndNonStatic) {
lastGroup = Integer.MIN_VALUE;
lastImport = "";
}
doVisitToken(ident, isStatic, isStaticAndNotLastImport);
if (isStaticAndNotLastImport && !beforeFirstImport) {
log(ident.getLineNo(), MSG_ORDERING, ident.getText());
}
}
else if (option == ImportOrderOption.BOTTOM) {
if (isStaticAndNotLastImport) {
lastGroup = Integer.MIN_VALUE;
lastImport = "";
}
doVisitToken(ident, isStatic, isLastImportAndNonStatic);
if (isLastImportAndNonStatic) {
log(ident.getLineNo(), MSG_ORDERING, ident.getText());
}
}
else if (option == ImportOrderOption.ABOVE) {
// previous non-static but current is static
doVisitToken(ident, isStatic, isStaticAndNotLastImport);
}
else if (option == ImportOrderOption.UNDER) {
doVisitToken(ident, isStatic, isLastImportAndNonStatic);
}
else if (option == ImportOrderOption.INFLOW) {
// "previous" argument is useless here
doVisitToken(ident, isStatic, true);
}
else {
throw new IllegalStateException(
"Unexpected option for static imports: " + option);
}
lastImportLine = ast.findFirstToken(TokenTypes.SEMI).getLineNo();
lastImportStatic = isStatic;
beforeFirstImport = false;
}