Search in sources :

Example 6 with AbstractNode

use of net.sourceforge.pmd.lang.ast.AbstractNode in project pmd-eclipse-plugin by pmd.

the class ASTUtil method returnType.

public static String returnType(ASTMethodDeclaration node) {
    for (int ix = 0; ix < node.jjtGetNumChildren(); ix++) {
        Node sn = node.jjtGetChild(ix);
        if (sn instanceof ASTResultType) {
            ASTResultType resultType = (ASTResultType) sn;
            AbstractNode param = resultType.getFirstDescendantOfType(ASTClassOrInterfaceType.class);
            if (param == null) {
                param = resultType.getFirstDescendantOfType(ASTPrimitiveType.class);
            }
            if (param == null) {
                continue;
            }
            return param.getImage();
        }
    }
    return null;
}
Also used : ASTPrimitiveType(net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType) AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode) AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode) Node(net.sourceforge.pmd.lang.ast.Node) AbstractJavaAccessNode(net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode) ASTResultType(net.sourceforge.pmd.lang.java.ast.ASTResultType)

Example 7 with AbstractNode

use of net.sourceforge.pmd.lang.ast.AbstractNode in project pmd-eclipse-plugin by pmd.

the class ASTViewPage method highlightItem.

private void highlightItem(Object item) {
    AbstractNode node = (AbstractNode) item;
    highlight(node.getBeginLine() - 1, node.getBeginColumn() - 1, node.getEndLine() - 1, node.getEndColumn());
}
Also used : AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode)

Aggregations

AbstractNode (net.sourceforge.pmd.lang.ast.AbstractNode)7 Node (net.sourceforge.pmd.lang.ast.Node)4 Comment (net.sourceforge.pmd.lang.java.ast.Comment)3 ASTCompilationUnit (net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit)2 ASTPrimitiveType (net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType)2 AbstractJavaAccessNode (net.sourceforge.pmd.lang.java.ast.AbstractJavaAccessNode)2 ArrayList (java.util.ArrayList)1 ASTFormalParameter (net.sourceforge.pmd.lang.java.ast.ASTFormalParameter)1 ASTImportDeclaration (net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration)1 ASTMethodDeclarator (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator)1 ASTResultType (net.sourceforge.pmd.lang.java.ast.ASTResultType)1 JavadocElement (net.sourceforge.pmd.lang.java.ast.JavadocElement)1 ASTMethodDeclaration (net.sourceforge.pmd.lang.plsql.ast.ASTMethodDeclaration)1 ASTProgramUnit (net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit)1 PLSQLNode (net.sourceforge.pmd.lang.plsql.ast.PLSQLNode)1 TextStyle (org.eclipse.swt.graphics.TextStyle)1 Test (org.junit.Test)1