new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / SearchableEnvironmentRequestor.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
12
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;
18
19 /**
20  * Implements <code>IJavaElementRequestor</code>, wrappering and forwarding
21  * results onto a <code>org.eclipse.jdt.internal.codeassist.api.ISearchRequestor</code>.
22  */
23 class SearchableEnvironmentRequestor extends JavaElementRequestor implements IJavaElementRequestor {
24         /**
25          * The <code>ISearchRequestor</code> this JavaElementRequestor wraps
26          * and forwards results to.
27          */
28         protected ISearchRequestor fRequestor;
29         /**
30          * The <code>ICompilationUNit</code> this JavaElementRequestor will not
31          * accept types within.
32          */
33         protected ICompilationUnit fUnitToSkip;
34 /**
35  * Constructs a SearchableEnvironmentRequestor that wraps the
36  * given SearchRequestor.
37  */
38 public SearchableEnvironmentRequestor(ISearchRequestor requestor) {
39         fRequestor = requestor;
40         fUnitToSkip= null;
41 }
42 /**
43  * Constructs a SearchableEnvironmentRequestor that wraps the
44  * given SearchRequestor.  The requestor will not accept types in
45  * the <code>unitToSkip</code>.
46  */
47 public SearchableEnvironmentRequestor(ISearchRequestor requestor, ICompilationUnit unitToSkip) {
48         fRequestor = requestor;
49         fUnitToSkip= unitToSkip;
50 }
51 /**
52  * Do nothing, a SearchRequestor does not accept initializers
53  * so there is no need to forward this results.
54  *
55  * @see IJavaElementRequestor
56  */
57 //public void acceptInitializer(IInitializer initializer) {
58 //
59 //}
60 /**
61  * @see IJavaElementRequestor
62  */
63 public void acceptPackageFragment(IPackageFragment packageFragment) {
64         fRequestor.acceptPackage(packageFragment.getElementName().toCharArray());
65 }
66 /**
67  * @see IJavaElementRequestor
68  */
69 public void acceptType(IType type) {
70         try {
71                 if (fUnitToSkip != null && fUnitToSkip.equals(type.getCompilationUnit())){
72                         return;
73                 }
74                 if (type.isClass()) {
75                         fRequestor.acceptClass(type.getPackageFragment().getElementName().toCharArray(), type.getElementName().toCharArray(), type.getFlags());
76                 } else {
77                         fRequestor.acceptInterface(type.getPackageFragment().getElementName().toCharArray(), type.getElementName().toCharArray(), type.getFlags());
78                 }
79         } catch (JavaModelException npe) {
80         }
81 }
82 }