The problem in found = true; line
public boolean containsBlock(String nodeName, ASTNode node)
{
    boolean found = false;
    if(nodeName.equals("if"))
    {
        node.accept(new ASTVisitor()
        {
            public boolean visit(IfStatement s)
            {
                found = true;
                return false;
            }
        });
    }
    return found;
}
I know that I will be able to access this if I make found a class global variable, but I don't want to do this. Maybe there is another way? I just need to let the other code know that something was found
UPD: Is that code better and will return the right
public boolean containsBlock(Text nodeName, ASTNode node)
{
    final AtomicBoolean flag = new AtomicBoolean(false);
    Thread thread = new Thread(new Runnable()
    {
        @Override
        public void run()
        {
            if(nodeName.matches("if"))
            {
                node.accept(new ASTVisitor()
                {
                    public boolean visit(IfStatement s)
                    {
                        flag.set(true);
                        return false;
                    }
                });
            }
            else
                throw new RuntimeException("Unknown NodeName: " + nodeName);
        }
    });
    thread.start();
    try {
        thread.join();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return flag.get();
}
 
    