Refactory: remove unused classes, imports, fields and methods.
[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
22  * <code>org.eclipse.jdt.internal.codeassist.api.ISearchRequestor</code>.
23  */
24 class SearchableEnvironmentRequestor extends JavaElementRequestor implements
25                 IJavaElementRequestor {
26         /**
27          * The <code>ISearchRequestor</code> this JavaElementRequestor wraps and
28          * forwards results to.
29          */
30         protected ISearchRequestor fRequestor;
31
32         /**
33          * The <code>ICompilationUNit</code> this JavaElementRequestor will not
34          * accept types within.
35          */
36         protected ICompilationUnit fUnitToSkip;
37
38         /**
39          * Constructs a SearchableEnvironmentRequestor that wraps the given
40          * SearchRequestor.
41          */
42 //      public SearchableEnvironmentRequestor(ISearchRequestor requestor) {
43 //              fRequestor = requestor;
44 //              fUnitToSkip = null;
45 //      }
46
47         /**
48          * Constructs a SearchableEnvironmentRequestor that wraps the given
49          * SearchRequestor. The requestor will not accept types in the
50          * <code>unitToSkip</code>.
51          */
52         public SearchableEnvironmentRequestor(ISearchRequestor requestor,
53                         ICompilationUnit unitToSkip) {
54                 fRequestor = requestor;
55                 fUnitToSkip = unitToSkip;
56         }
57
58         /**
59          * Do nothing, a SearchRequestor does not accept initializers so there is no
60          * need to forward this results.
61          * 
62          * @see IJavaElementRequestor
63          */
64         // public void acceptInitializer(IInitializer initializer) {
65         //
66         // }
67         /**
68          * @see IJavaElementRequestor
69          */
70         public void acceptPackageFragment(IPackageFragment packageFragment) {
71                 fRequestor
72                                 .acceptPackage(packageFragment.getElementName().toCharArray());
73         }
74
75         /**
76          * @see IJavaElementRequestor
77          */
78         public void acceptType(IType type) {
79                 try {
80                         if (fUnitToSkip != null
81                                         && fUnitToSkip.equals(type.getCompilationUnit())) {
82                                 return;
83                         }
84                         if (type.isClass()) {
85                                 fRequestor.acceptClass(type.getPackageFragment()
86                                                 .getElementName().toCharArray(), type.getElementName()
87                                                 .toCharArray(), type.getFlags());
88                         } else {
89                                 fRequestor.acceptInterface(type.getPackageFragment()
90                                                 .getElementName().toCharArray(), type.getElementName()
91                                                 .toCharArray(), type.getFlags());
92                         }
93                 } catch (JavaModelException npe) {
94                 }
95         }
96 }