1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import net.sourceforge.phpdt.core.ICompilationUnit;
14 import net.sourceforge.phpdt.core.IPackageFragment;
15 import net.sourceforge.phpdt.core.IType;
16 import net.sourceforge.phpdt.core.JavaModelException;
17 import net.sourceforge.phpdt.internal.codeassist.ISearchRequestor;
20 * Implements <code>IJavaElementRequestor</code>, wrappering and forwarding
22 * <code>org.eclipse.jdt.internal.codeassist.api.ISearchRequestor</code>.
24 class SearchableEnvironmentRequestor extends JavaElementRequestor implements
25 IJavaElementRequestor {
27 * The <code>ISearchRequestor</code> this JavaElementRequestor wraps and
28 * forwards results to.
30 protected ISearchRequestor fRequestor;
33 * The <code>ICompilationUNit</code> this JavaElementRequestor will not
34 * accept types within.
36 protected ICompilationUnit fUnitToSkip;
39 * Constructs a SearchableEnvironmentRequestor that wraps the given
42 public SearchableEnvironmentRequestor(ISearchRequestor requestor) {
43 fRequestor = requestor;
48 * Constructs a SearchableEnvironmentRequestor that wraps the given
49 * SearchRequestor. The requestor will not accept types in the
50 * <code>unitToSkip</code>.
52 public SearchableEnvironmentRequestor(ISearchRequestor requestor,
53 ICompilationUnit unitToSkip) {
54 fRequestor = requestor;
55 fUnitToSkip = unitToSkip;
59 * Do nothing, a SearchRequestor does not accept initializers so there is no
60 * need to forward this results.
62 * @see IJavaElementRequestor
64 // public void acceptInitializer(IInitializer initializer) {
68 * @see IJavaElementRequestor
70 public void acceptPackageFragment(IPackageFragment packageFragment) {
72 .acceptPackage(packageFragment.getElementName().toCharArray());
76 * @see IJavaElementRequestor
78 public void acceptType(IType type) {
80 if (fUnitToSkip != null
81 && fUnitToSkip.equals(type.getCompilationUnit())) {
85 fRequestor.acceptClass(type.getPackageFragment()
86 .getElementName().toCharArray(), type.getElementName()
87 .toCharArray(), type.getFlags());
89 fRequestor.acceptInterface(type.getPackageFragment()
90 .getElementName().toCharArray(), type.getElementName()
91 .toCharArray(), type.getFlags());
93 } catch (JavaModelException npe) {