replaced a lot of deprecated code; if someone runs into a commit conflict afterwards...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / SearchableEnvironment.java
index 6bc4edc..87fe51a 100644 (file)
@@ -16,12 +16,14 @@ import net.sourceforge.phpdt.core.IJavaProject;
 import net.sourceforge.phpdt.core.IPackageFragment;
 import net.sourceforge.phpdt.core.IType;
 import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.core.WorkingCopyOwner;
 import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpdt.core.search.IJavaSearchConstants;
 import net.sourceforge.phpdt.core.search.ITypeNameRequestor;
 import net.sourceforge.phpdt.internal.codeassist.ISearchRequestor;
 import net.sourceforge.phpdt.internal.codeassist.ISearchableNameEnvironment;
 import net.sourceforge.phpdt.internal.compiler.env.IConstants;
+import net.sourceforge.phpdt.internal.compiler.env.INameEnvironment;
 import net.sourceforge.phpdt.internal.compiler.env.ISourceType;
 import net.sourceforge.phpdt.internal.compiler.env.NameEnvironmentAnswer;
 
@@ -36,8 +38,10 @@ public class SearchableEnvironment implements ISearchableNameEnvironment, IJavaS
   protected ICompilationUnit unitToSkip;
 
   protected IJavaProject project;
-  //   protected IJavaSearchScope searchScope;
+  //protected IJavaSearchScope searchScope;
 
+       /**
+        * Creates a Sea
   /**
    * Creates a SearchableEnvironment on the given project
    */
@@ -48,7 +52,19 @@ public class SearchableEnvironment implements ISearchableNameEnvironment, IJavaS
     // Create search scope with visible entry on the project's classpath
     //         this.searchScope = SearchEngine.createJavaSearchScope(this.project.getAllPackageFragmentRoots());
   }
+  
+       
 
+       /**
+        * Creates a SearchableEnvironment on the given project
+        */
+       public SearchableEnvironment(JavaProject project, WorkingCopyOwner owner) throws JavaModelException {
+               this.project = project;
+               this.nameLookup = project.newNameLookup(owner);
+
+               // Create search scope with visible entry on the project's classpath
+//             this.searchScope = SearchEngine.createJavaSearchScope(this.project.getAllPackageFragmentRoots());
+       }
   /**
    * Returns the given type in the the given package if it exists,
    * otherwise <code>null</code>.
@@ -57,6 +73,7 @@ public class SearchableEnvironment implements ISearchableNameEnvironment, IJavaS
     if (packageName == null)
       packageName = IPackageFragment.DEFAULT_PACKAGE_NAME;
    
+    if (this.nameLookup!=null) { // ins axelcl
     IType type = this.nameLookup.findType(typeName, packageName, false, NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES);
     if (type != null) {
       //                       if (type instanceof BinaryType) {
@@ -91,6 +108,7 @@ public class SearchableEnvironment implements ISearchableNameEnvironment, IJavaS
       }
       //                       }
     }
+    }
     return null;
   }