1 /*******************************************************************************
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core.dom;
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration;
15 import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration;
16 import net.sourceforge.phpdt.internal.compiler.ast.Initializer;
17 import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration;
18 import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration;
19 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
20 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
21 import net.sourceforge.phpdt.internal.compiler.lookup.MethodScope;
23 class NodeSearcher extends ASTVisitor {
24 public net.sourceforge.phpdt.internal.compiler.ast.ASTNode found;
25 public TypeDeclaration enclosingType;
28 NodeSearcher(int position) {
29 this.position = position;
33 ConstructorDeclaration constructorDeclaration,
36 if (constructorDeclaration.declarationSourceStart <= position
37 && position <= constructorDeclaration.declarationSourceEnd) {
38 found = constructorDeclaration;
45 FieldDeclaration fieldDeclaration,
47 if (fieldDeclaration.declarationSourceStart <= position
48 && position <= fieldDeclaration.declarationSourceEnd) {
49 found = fieldDeclaration;
55 public boolean visit(Initializer initializer, MethodScope scope) {
56 if (initializer.declarationSourceStart <= position
57 && position <= initializer.declarationSourceEnd) {
65 TypeDeclaration memberTypeDeclaration,
67 if (memberTypeDeclaration.declarationSourceStart <= position
68 && position <= memberTypeDeclaration.declarationSourceEnd) {
69 enclosingType = memberTypeDeclaration;
77 MethodDeclaration methodDeclaration,
80 if (methodDeclaration.declarationSourceStart <= position
81 && position <= methodDeclaration.declarationSourceEnd) {
82 found = methodDeclaration;
89 TypeDeclaration typeDeclaration,
90 CompilationUnitScope scope) {
91 if (typeDeclaration.declarationSourceStart <= position
92 && position <= typeDeclaration.declarationSourceEnd) {
93 enclosingType = typeDeclaration;