// Path: org.chromium.gnsupport.core/src/org/chromium/gnsupport/core/GnCorePlugin.java
// public class GnCorePlugin extends Plugin {
// 
//   // The plug-in ID
//   public static final String PLUGIN_ID = "org.chromium.gnsupport.core"; //$NON-NLS-1$
// 
//   // The shared instance
//   private static GnCorePlugin plugin;
// 
//   private final ListenerList shutdownListeners = new ListenerList();
// 
//   public GnCorePlugin() {}
// 
//   @Override
//   public void start(BundleContext context) throws Exception {
//     super.start(context);
//     plugin = this;
//   }
// 
//   @Override
//   public void stop(BundleContext context) throws Exception {
//     plugin = null;
//     super.stop(context);
//   }
// 
//   public static GnCorePlugin getDefault() {
//     return plugin;
//   }
// 
//   public static void log(Exception e) {
//     if (DLTKCore.DEBUG) {
//       e.printStackTrace();
//     }
//     String message = e.getMessage();
//     if (message == null) {
//       message = "(no message)"; //$NON-NLS-1$
//     }
//     getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, e));
//   }
// 
//   public static void log(String message) {
//     if (DLTKCore.DEBUG) {
//       System.out.println(message);
//     }
//     getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null));
//   }
// 
//   public void addShutdownListener(IShutdownListener listener) {
//     shutdownListeners.add(listener);
//   }
// }
// 
// Path: org.chromium.gnsupport.core/src/org/chromium/gnsupport/core/ast/GnFieldDeclaration.java
// public class GnFieldDeclaration extends FieldDeclaration {
//   public static final int GLOBAL = 1;
//   public static final int LOCAL = 2;
// 
//   private final int kind;
// 
//   public GnFieldDeclaration(
//       String name, int type, int nameStart, int nameEnd, int declStart, int declEnd) {
//     super(name, nameStart, nameEnd, declStart, declEnd);
//     this.kind = type;
//   }
// 
//   @Override
//   public int getKind() {
//     return kind;
//   }
// }


import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.statements.Block;
import org.chromium.gnsupport.core.GnCorePlugin;
import org.chromium.gnsupport.core.ast.GnFieldDeclaration;
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.ast.ASTVisitor;
    } catch (Exception e) {
      GnCorePlugin.log(e);
    }

    return visitor.getResult();
  }

  private static class Visitor extends ASTVisitor {
    private ASTNode result;
    private final int start;
    private final int end;

    public Visitor(int start, int end) {
      this.start = start;
      this.end = end;
    }

    public ASTNode getResult() {
      return result;
    }

    @Override
    public boolean visitGeneral(ASTNode node) throws Exception {
      int realStart = node.sourceStart();
      int realEnd = node.sourceEnd();
      if (node instanceof Block) {
        return true;
      }
      if (realStart <= start && realEnd >= end) {
        if (result == null || isBetterMatch(node)) {
// Path: org.chromium.gnsupport.core/src/org/chromium/gnsupport/core/GnCorePlugin.java
// public class GnCorePlugin extends Plugin {
// 
//   // The plug-in ID
//   public static final String PLUGIN_ID = "org.chromium.gnsupport.core"; //$NON-NLS-1$
// 
//   // The shared instance
//   private static GnCorePlugin plugin;
// 
//   private final ListenerList shutdownListeners = new ListenerList();
// 
//   public GnCorePlugin() {}
// 
//   @Override
//   public void start(BundleContext context) throws Exception {
//     super.start(context);
//     plugin = this;
//   }
// 
//   @Override
//   public void stop(BundleContext context) throws Exception {
//     plugin = null;
//     super.stop(context);
//   }
// 
//   public static GnCorePlugin getDefault() {
//     return plugin;
//   }
// 
//   public static void log(Exception e) {
//     if (DLTKCore.DEBUG) {
//       e.printStackTrace();
//     }
//     String message = e.getMessage();
//     if (message == null) {
//       message = "(no message)"; //$NON-NLS-1$
//     }
//     getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, e));
//   }
// 
//   public static void log(String message) {
//     if (DLTKCore.DEBUG) {
//       System.out.println(message);
//     }
//     getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, 0, message, null));
//   }
// 
//   public void addShutdownListener(IShutdownListener listener) {
//     shutdownListeners.add(listener);
//   }
// }
// 
// Path: org.chromium.gnsupport.core/src/org/chromium/gnsupport/core/ast/GnFieldDeclaration.java
// public class GnFieldDeclaration extends FieldDeclaration {
//   public static final int GLOBAL = 1;
//   public static final int LOCAL = 2;
// 
//   private final int kind;
// 
//   public GnFieldDeclaration(
//       String name, int type, int nameStart, int nameEnd, int declStart, int declEnd) {
//     super(name, nameStart, nameEnd, declStart, declEnd);
//     this.kind = type;
//   }
// 
//   @Override
//   public int getKind() {
//     return kind;
//   }
// }


// Path: org.chromium.gnsupport.core/src/org/chromium/gnsupport/internal/core/tree/AstUtil.java
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.statements.Block;
import org.chromium.gnsupport.core.GnCorePlugin;
import org.chromium.gnsupport.core.ast.GnFieldDeclaration;
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.ast.ASTVisitor;

    } catch (Exception e) {
      GnCorePlugin.log(e);
    }

    return visitor.getResult();
  }

  private static class Visitor extends ASTVisitor {
    private ASTNode result;
    private final int start;
    private final int end;

    public Visitor(int start, int end) {
      this.start = start;
      this.end = end;
    }

    public ASTNode getResult() {
      return result;
    }

    @Override
    public boolean visitGeneral(ASTNode node) throws Exception {
      int realStart = node.sourceStart();
      int realEnd = node.sourceEnd();
      if (node instanceof Block) {
        return true;
      }
      if (realStart <= start && realEnd >= end) {
        if (result == null || isBetterMatch(node)) {
          result = node;