use of com.puppycrawl.tools.checkstyle.api.FullIdent in project checkstyle by checkstyle.
the class AbstractTypeAwareCheck method processTypeParams.
/**
* 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 String alias = child.findFirstToken(TokenTypes.IDENT).getText();
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);
paramsMap.put(alias, classInfo);
}
}
}
}
}
use of com.puppycrawl.tools.checkstyle.api.FullIdent in project checkstyle by checkstyle.
the class CheckUtils method createFullType.
/**
* Creates {@code FullIdent} for given type node.
* @param typeAST a type node.
* @return {@code FullIdent} for given type.
*/
public static FullIdent createFullType(DetailAST typeAST) {
final DetailAST arrayDeclaratorAST = typeAST.findFirstToken(TokenTypes.ARRAY_DECLARATOR);
final FullIdent fullType;
if (arrayDeclaratorAST == null) {
fullType = createFullTypeNoArrays(typeAST);
} else {
fullType = createFullTypeNoArrays(arrayDeclaratorAST);
}
return fullType;
}
use of com.puppycrawl.tools.checkstyle.api.FullIdent in project checkstyle by checkstyle.
the class PackageNameCheck method visitToken.
@Override
public void visitToken(DetailAST ast) {
final DetailAST nameAST = ast.getLastChild().getPreviousSibling();
final FullIdent full = FullIdent.createFullIdent(nameAST);
if (!format.matcher(full.getText()).find()) {
log(full.getLineNo(), full.getColumnNo(), MSG_KEY, full.getText(), format.pattern());
}
}
use of com.puppycrawl.tools.checkstyle.api.FullIdent in project checkstyle by checkstyle.
the class AvoidStarImportCheck method logsStarredImportViolation.
/**
* Gets the full import identifier. If the import is a starred import and
* it's not excluded then a violation is logged.
* @param startingDot the starting dot for the import statement
*/
private void logsStarredImportViolation(DetailAST startingDot) {
final FullIdent name = FullIdent.createFullIdent(startingDot);
final String importText = name.getText();
if (importText.endsWith(STAR_IMPORT_SUFFIX) && !excludes.contains(importText)) {
log(startingDot.getLineNo(), MSG_KEY, importText);
}
}
use of com.puppycrawl.tools.checkstyle.api.FullIdent in project checkstyle by checkstyle.
the class IllegalCatchCheck method visitToken.
@Override
public void visitToken(DetailAST detailAST) {
final DetailAST parameterDef = detailAST.findFirstToken(TokenTypes.PARAMETER_DEF);
final DetailAST excTypeParent = parameterDef.findFirstToken(TokenTypes.TYPE);
final List<DetailAST> excTypes = getAllExceptionTypes(excTypeParent);
for (DetailAST excType : excTypes) {
final FullIdent ident = FullIdent.createFullIdent(excType);
if (illegalClassNames.contains(ident.getText())) {
log(detailAST, MSG_KEY, ident.getText());
}
}
}