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
21 * results onto a <code>org.eclipse.jdt.internal.codeassist.api.ISearchRequestor</code>.
23 class SearchableEnvironmentRequestor extends JavaElementRequestor implements IJavaElementRequestor {
25 * The <code>ISearchRequestor</code> this JavaElementRequestor wraps
26 * and forwards results to.
28 protected ISearchRequestor fRequestor;
30 * The <code>ICompilationUNit</code> this JavaElementRequestor will not
31 * accept types within.
33 protected ICompilationUnit fUnitToSkip;
35 * Constructs a SearchableEnvironmentRequestor that wraps the
36 * given SearchRequestor.
38 public SearchableEnvironmentRequestor(ISearchRequestor requestor) {
39 fRequestor = requestor;
43 * Constructs a SearchableEnvironmentRequestor that wraps the
44 * given SearchRequestor. The requestor will not accept types in
45 * the <code>unitToSkip</code>.
47 public SearchableEnvironmentRequestor(ISearchRequestor requestor, ICompilationUnit unitToSkip) {
48 fRequestor = requestor;
49 fUnitToSkip= unitToSkip;
52 * Do nothing, a SearchRequestor does not accept initializers
53 * so there is no need to forward this results.
55 * @see IJavaElementRequestor
57 //public void acceptInitializer(IInitializer initializer) {
61 * @see IJavaElementRequestor
63 public void acceptPackageFragment(IPackageFragment packageFragment) {
64 fRequestor.acceptPackage(packageFragment.getElementName().toCharArray());
67 * @see IJavaElementRequestor
69 public void acceptType(IType type) {
71 if (fUnitToSkip != null && fUnitToSkip.equals(type.getCompilationUnit())){
75 fRequestor.acceptClass(type.getPackageFragment().getElementName().toCharArray(), type.getElementName().toCharArray(), type.getFlags());
77 fRequestor.acceptInterface(type.getPackageFragment().getElementName().toCharArray(), type.getElementName().toCharArray(), type.getFlags());
79 } catch (JavaModelException npe) {