use of net.sourceforge.pmd.lang.java.ast.ASTType in project pmd by pmd.
the class CouplingBetweenObjectsRule method handleASTTypeChildren.
/**
* convience method to handle hierarchy. This is probably too much work and
* will go away once I figure out the framework
*/
private void handleASTTypeChildren(Node node) {
for (int x = 0; x < node.jjtGetNumChildren(); x++) {
Node sNode = node.jjtGetChild(x);
if (sNode instanceof ASTType) {
Node nameNode = sNode.jjtGetChild(0);
checkVariableType(nameNode, nameNode.getImage());
}
}
}
use of net.sourceforge.pmd.lang.java.ast.ASTType in project pmd by pmd.
the class AvoidCatchingThrowableRule method visit.
@Override
public Object visit(ASTCatchStatement node, Object data) {
ASTType type = node.getFirstDescendantOfType(ASTType.class);
ASTClassOrInterfaceType name = type.getFirstDescendantOfType(ASTClassOrInterfaceType.class);
if (name.hasImageEqualTo("Throwable")) {
addViolation(data, name);
}
return super.visit(node, data);
}
use of net.sourceforge.pmd.lang.java.ast.ASTType in project pmd-eclipse-plugin by pmd.
the class ASTUtil method getFieldLabel.
public static String getFieldLabel(ASTFieldDeclaration pmdField) {
StringBuilder sb = new StringBuilder();
addModifiers(pmdField, sb);
ASTType type = pmdField.getFirstChildOfType(ASTType.class);
if (type != null) {
sb.append(' ').append(type.getTypeImage());
}
sb.append(' ').append(pmdField.getVariableName());
return sb.toString();
}
use of net.sourceforge.pmd.lang.java.ast.ASTType in project pmd-eclipse-plugin by pmd.
the class ASTUtil method getLocalVarDeclarationLabel.
public static String getLocalVarDeclarationLabel(ASTLocalVariableDeclaration node) {
StringBuilder sb = new StringBuilder();
addModifiers(node, sb);
ASTType type = node.getTypeNode();
sb.append(' ').append(type.getTypeImage());
for (int i = 0; i < node.getArrayDepth(); i++) {
sb.append("[]");
}
sb.append(' ').append(node.getVariableName());
return sb.toString();
}
Aggregations