Search in sources :

Example 1 with NodeFinder

use of org.eclipse.jdt.core.dom.NodeFinder in project processing by processing.

the class ASTUtils method getASTNodeAt.

public static ASTNode getASTNodeAt(ASTNode root, int startJavaOffset, int stopJavaOffset) {
    Messages.log("* getASTNodeAt");
    int length = stopJavaOffset - startJavaOffset;
    NodeFinder f = new NodeFinder(root, startJavaOffset, length);
    ASTNode node = f.getCoveredNode();
    if (node == null) {
        node = f.getCoveringNode();
    }
    if (node == null) {
        Messages.log("no node found");
    } else {
        Messages.log("found " + node.getClass().getSimpleName());
    }
    return node;
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder)

Example 2 with NodeFinder

use of org.eclipse.jdt.core.dom.NodeFinder in project che by eclipse.

the class CompilationUnitRange method getNode.

//rootNode must be the ast root for fCompilationUnit
public ASTNode getNode(CompilationUnit rootNode) {
    NodeFinder finder = new NodeFinder(rootNode, fSourceRange.getOffset(), fSourceRange.getLength());
    ASTNode result = finder.getCoveringNode();
    if (result != null)
        return result;
    return finder.getCoveredNode();
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder)

Example 3 with NodeFinder

use of org.eclipse.jdt.core.dom.NodeFinder in project che by eclipse.

the class ASTNodeSearchUtil method findNode.

private static ASTNode findNode(ISourceRange range, CompilationUnit cuNode) {
    NodeFinder nodeFinder = new NodeFinder(cuNode, range.getOffset(), range.getLength());
    ASTNode coveredNode = nodeFinder.getCoveredNode();
    if (coveredNode != null)
        return coveredNode;
    else
        return nodeFinder.getCoveringNode();
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder)

Example 4 with NodeFinder

use of org.eclipse.jdt.core.dom.NodeFinder in project AutoRefactor by JnRouvignac.

the class CommentsRefactoring method getNextNode.

private ASTNode getNextNode(Comment node) {
    final int nodeEndPosition = node.getStartPosition() + node.getLength();
    final ASTNode coveringNode = getCoveringNode(node);
    final int parentNodeEndPosition = coveringNode.getStartPosition() + coveringNode.getLength();
    final NodeFinder finder = new NodeFinder(coveringNode, nodeEndPosition, parentNodeEndPosition - nodeEndPosition);
    if (node instanceof Javadoc) {
        return finder.getCoveringNode();
    }
    return finder.getCoveredNode();
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) Javadoc(org.eclipse.jdt.core.dom.Javadoc) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder)

Aggregations

ASTNode (org.eclipse.jdt.core.dom.ASTNode)4 NodeFinder (org.eclipse.jdt.core.dom.NodeFinder)4 Javadoc (org.eclipse.jdt.core.dom.Javadoc)1