- added include declarations to Outline view
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / lookup / CompilationUnitScope.java
index d50f6f7..c6dcbb6 100644 (file)
@@ -43,8 +43,8 @@ public class CompilationUnitScope extends Scope {
     this.environment = environment;
     this.referenceContext = unit;
     unit.scope = this;
-    this.currentPackageName = unit.currentPackage == null ? CharOperation.NO_CHAR_CHAR : unit.currentPackage.tokens;
-
+//    this.currentPackageName = unit.currentPackage == null ? CharOperation.NO_CHAR_CHAR : unit.currentPackage.tokens;
+    this.currentPackageName = null; 
     // if (environment.options.produceReferenceInfo) {
     //         this.qualifiedReferences = new CompoundNameVector();
     //         this.simpleNameReferences = new SimpleNameVector();
@@ -130,66 +130,66 @@ public class CompilationUnitScope extends Scope {
     if (count != topLevelTypes.length)
       System.arraycopy(topLevelTypes, 0, topLevelTypes = new SourceTypeBinding[count], 0, count);
   }
-  void checkAndSetImports() {
-    // initialize the default imports if necessary... share the default java.lang.* import
-    if (environment.defaultImports == null) {
-      Binding importBinding = environment.getTopLevelPackage(JAVA);
-      if (importBinding != null)
-        importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
-
-      // abort if java.lang cannot be found...
-      if (importBinding == null || !importBinding.isValidBinding())
-        problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
-
-      environment.defaultImports = new ImportBinding[] { new ImportBinding(JAVA_LANG, true, importBinding, null)};
-    }
-    if (referenceContext.imports == null) {
-      imports = environment.defaultImports;
-      return;
-    }
-
-    // allocate the import array, add java.lang.* by default
-    int numberOfStatements = referenceContext.imports.length;
-    int numberOfImports = numberOfStatements + 1;
-    for (int i = 0; i < numberOfStatements; i++) {
-      ImportReference importReference = referenceContext.imports[i];
-      if (importReference.onDemand && CharOperation.equals(JAVA_LANG, importReference.tokens)) {
-        numberOfImports--;
-        break;
-      }
-    }
-    ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
-    resolvedImports[0] = environment.defaultImports[0];
-    int index = 1;
-
-    nextImport : for (int i = 0; i < numberOfStatements; i++) {
-      ImportReference importReference = referenceContext.imports[i];
-      char[][] compoundName = importReference.tokens;
-
-      // skip duplicates or imports of the current package
-      for (int j = 0; j < index; j++)
-        if (resolvedImports[j].onDemand == importReference.onDemand)
-          if (CharOperation.equals(compoundName, resolvedImports[j].compoundName))
-            continue nextImport;
-      if (importReference.onDemand == true)
-        if (CharOperation.equals(compoundName, currentPackageName))
-          continue nextImport;
-
-      if (importReference.onDemand) {
-        Binding importBinding = findOnDemandImport(compoundName);
-        if (!importBinding.isValidBinding())
-          continue nextImport; // we report all problems in faultInImports()
-        resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference);
-      } else {
-        resolvedImports[index++] = new ImportBinding(compoundName, false, null, importReference);
-      }
-    }
-
-    // shrink resolvedImports... only happens if an error was reported
-    if (resolvedImports.length > index)
-      System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
-    imports = resolvedImports;
-  }
+//  void checkAndSetImports() {
+//    // initialize the default imports if necessary... share the default java.lang.* import
+//    if (environment.defaultImports == null) {
+//      Binding importBinding = environment.getTopLevelPackage(JAVA);
+//      if (importBinding != null)
+//        importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
+//
+//      // abort if java.lang cannot be found...
+//      if (importBinding == null || !importBinding.isValidBinding())
+//        problemReporter().isClassPathCorrect(JAVA_LANG_OBJECT, referenceCompilationUnit());
+//
+//      environment.defaultImports = new ImportBinding[] { new ImportBinding(JAVA_LANG, true, importBinding, null)};
+//    }
+//    if (referenceContext.imports == null) {
+//      imports = environment.defaultImports;
+//      return;
+//    }
+//
+//    // allocate the import array, add java.lang.* by default
+//    int numberOfStatements = referenceContext.imports.length;
+//    int numberOfImports = numberOfStatements + 1;
+//    for (int i = 0; i < numberOfStatements; i++) {
+//      ImportReference importReference = referenceContext.imports[i];
+//      if (importReference.onDemand && CharOperation.equals(JAVA_LANG, importReference.tokens)) {
+//        numberOfImports--;
+//        break;
+//      }
+//    }
+//    ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
+//    resolvedImports[0] = environment.defaultImports[0];
+//    int index = 1;
+//
+//    nextImport : for (int i = 0; i < numberOfStatements; i++) {
+//      ImportReference importReference = referenceContext.imports[i];
+//      char[][] compoundName = importReference.tokens;
+//
+//      // skip duplicates or imports of the current package
+//      for (int j = 0; j < index; j++)
+//        if (resolvedImports[j].onDemand == importReference.onDemand)
+//          if (CharOperation.equals(compoundName, resolvedImports[j].compoundName))
+//            continue nextImport;
+//      if (importReference.onDemand == true)
+//        if (CharOperation.equals(compoundName, currentPackageName))
+//          continue nextImport;
+//
+//      if (importReference.onDemand) {
+//        Binding importBinding = findOnDemandImport(compoundName);
+//        if (!importBinding.isValidBinding())
+//          continue nextImport; // we report all problems in faultInImports()
+//        resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference);
+//      } else {
+//        resolvedImports[index++] = new ImportBinding(compoundName, false, null, importReference);
+//      }
+//    }
+//
+//    // shrink resolvedImports... only happens if an error was reported
+//    if (resolvedImports.length > index)
+//      System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
+//    imports = resolvedImports;
+//  }
   /*
    * INTERNAL USE-ONLY
    * Innerclasses get their name computed as they are generated, since some may not
@@ -239,102 +239,102 @@ public class CompilationUnitScope extends Scope {
     for (int i = 0, length = topLevelTypes.length; i < length; i++)
       topLevelTypes[i].scope.connectTypeHierarchy();
   }
-  void faultInImports() {
-    if (referenceContext.imports == null)
-      return;
-
-    // collect the top level type names if a single type import exists
-    int numberOfStatements = referenceContext.imports.length;
-    HashtableOfType typesBySimpleNames = null;
-    for (int i = 0; i < numberOfStatements; i++) {
-      if (!referenceContext.imports[i].onDemand) {
-        typesBySimpleNames = new HashtableOfType(topLevelTypes.length + numberOfStatements);
-        for (int j = 0, length = topLevelTypes.length; j < length; j++)
-          typesBySimpleNames.put(topLevelTypes[j].sourceName, topLevelTypes[j]);
-        break;
-      }
-    }
-
-    // allocate the import array, add java.lang.* by default
-    int numberOfImports = numberOfStatements + 1;
-    for (int i = 0; i < numberOfStatements; i++) {
-      ImportReference importReference = referenceContext.imports[i];
-      if (importReference.onDemand && CharOperation.equals(JAVA_LANG, importReference.tokens)) {
-        numberOfImports--;
-        break;
-      }
-    }
-    ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
-    resolvedImports[0] = environment.defaultImports[0];
-    int index = 1;
-
-    nextImport : for (int i = 0; i < numberOfStatements; i++) {
-      ImportReference importReference = referenceContext.imports[i];
-      char[][] compoundName = importReference.tokens;
-
-      // skip duplicates or imports of the current package
-      for (int j = 0; j < index; j++)
-        if (resolvedImports[j].onDemand == importReference.onDemand)
-          if (CharOperation.equals(compoundName, resolvedImports[j].compoundName)) {
-            problemReporter().unusedImport(importReference); // since skipped, must be reported now
-            continue nextImport;
-          }
-      if (importReference.onDemand == true)
-        if (CharOperation.equals(compoundName, currentPackageName)) {
-          problemReporter().unusedImport(importReference); // since skipped, must be reported now
-          continue nextImport;
-        }
-      if (importReference.onDemand) {
-        Binding importBinding = findOnDemandImport(compoundName);
-        if (!importBinding.isValidBinding()) {
-          problemReporter().importProblem(importReference, importBinding);
-          continue nextImport;
-        }
-        resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference);
-      } else {
-        Binding typeBinding = findSingleTypeImport(compoundName);
-        if (!typeBinding.isValidBinding()) {
-          problemReporter().importProblem(importReference, typeBinding);
-          continue nextImport;
-        }
-        if (typeBinding instanceof PackageBinding) {
-          problemReporter().cannotImportPackage(importReference);
-          continue nextImport;
-        }
-        if (typeBinding instanceof ReferenceBinding) {
-          ReferenceBinding referenceBinding = (ReferenceBinding) typeBinding;
-          if (importReference.isTypeUseDeprecated(referenceBinding, this)) {
-            problemReporter().deprecatedType((TypeBinding) typeBinding, importReference);
-          }
-        }
-        ReferenceBinding existingType = typesBySimpleNames.get(compoundName[compoundName.length - 1]);
-        if (existingType != null) {
-          // duplicate test above should have caught this case, but make sure
-          if (existingType == typeBinding) {
-            continue nextImport;
-          }
-          // either the type collides with a top level type or another imported type
-          for (int j = 0, length = topLevelTypes.length; j < length; j++) {
-            if (CharOperation.equals(topLevelTypes[j].sourceName, existingType.sourceName)) {
-              problemReporter().conflictingImport(importReference);
-              continue nextImport;
-            }
-          }
-          problemReporter().duplicateImport(importReference);
-          continue nextImport;
-        }
-        resolvedImports[index++] = new ImportBinding(compoundName, false, typeBinding, importReference);
-        typesBySimpleNames.put(compoundName[compoundName.length - 1], (ReferenceBinding) typeBinding);
-      }
-    }
-
-    // shrink resolvedImports... only happens if an error was reported
-    if (resolvedImports.length > index)
-      System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
-    imports = resolvedImports;
-  }
+//  void faultInImports() {
+//    if (referenceContext.imports == null)
+//      return;
+//
+//    // collect the top level type names if a single type import exists
+//    int numberOfStatements = referenceContext.imports.length;
+//    HashtableOfType typesBySimpleNames = null;
+//    for (int i = 0; i < numberOfStatements; i++) {
+//      if (!referenceContext.imports[i].onDemand) {
+//        typesBySimpleNames = new HashtableOfType(topLevelTypes.length + numberOfStatements);
+//        for (int j = 0, length = topLevelTypes.length; j < length; j++)
+//          typesBySimpleNames.put(topLevelTypes[j].sourceName, topLevelTypes[j]);
+//        break;
+//      }
+//    }
+//
+//    // allocate the import array, add java.lang.* by default
+//    int numberOfImports = numberOfStatements + 1;
+//    for (int i = 0; i < numberOfStatements; i++) {
+//      ImportReference importReference = referenceContext.imports[i];
+//      if (importReference.onDemand && CharOperation.equals(JAVA_LANG, importReference.tokens)) {
+//        numberOfImports--;
+//        break;
+//      }
+//    }
+//    ImportBinding[] resolvedImports = new ImportBinding[numberOfImports];
+//    resolvedImports[0] = environment.defaultImports[0];
+//    int index = 1;
+//
+//    nextImport : for (int i = 0; i < numberOfStatements; i++) {
+//      ImportReference importReference = referenceContext.imports[i];
+//      char[][] compoundName = importReference.tokens;
+//
+//      // skip duplicates or imports of the current package
+//      for (int j = 0; j < index; j++)
+//        if (resolvedImports[j].onDemand == importReference.onDemand)
+//          if (CharOperation.equals(compoundName, resolvedImports[j].compoundName)) {
+//            problemReporter().unusedImport(importReference); // since skipped, must be reported now
+//            continue nextImport;
+//          }
+//      if (importReference.onDemand == true)
+//        if (CharOperation.equals(compoundName, currentPackageName)) {
+//          problemReporter().unusedImport(importReference); // since skipped, must be reported now
+//          continue nextImport;
+//        }
+//      if (importReference.onDemand) {
+//        Binding importBinding = findOnDemandImport(compoundName);
+//        if (!importBinding.isValidBinding()) {
+//          problemReporter().importProblem(importReference, importBinding);
+//          continue nextImport;
+//        }
+//        resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference);
+//      } else {
+//        Binding typeBinding = findSingleTypeImport(compoundName);
+//        if (!typeBinding.isValidBinding()) {
+//          problemReporter().importProblem(importReference, typeBinding);
+//          continue nextImport;
+//        }
+//        if (typeBinding instanceof PackageBinding) {
+//          problemReporter().cannotImportPackage(importReference);
+//          continue nextImport;
+//        }
+//        if (typeBinding instanceof ReferenceBinding) {
+//          ReferenceBinding referenceBinding = (ReferenceBinding) typeBinding;
+//          if (importReference.isTypeUseDeprecated(referenceBinding, this)) {
+//            problemReporter().deprecatedType((TypeBinding) typeBinding, importReference);
+//          }
+//        }
+//        ReferenceBinding existingType = typesBySimpleNames.get(compoundName[compoundName.length - 1]);
+//        if (existingType != null) {
+//          // duplicate test above should have caught this case, but make sure
+//          if (existingType == typeBinding) {
+//            continue nextImport;
+//          }
+//          // either the type collides with a top level type or another imported type
+//          for (int j = 0, length = topLevelTypes.length; j < length; j++) {
+//            if (CharOperation.equals(topLevelTypes[j].sourceName, existingType.sourceName)) {
+//              problemReporter().conflictingImport(importReference);
+//              continue nextImport;
+//            }
+//          }
+//          problemReporter().duplicateImport(importReference);
+//          continue nextImport;
+//        }
+//        resolvedImports[index++] = new ImportBinding(compoundName, false, typeBinding, importReference);
+//        typesBySimpleNames.put(compoundName[compoundName.length - 1], (ReferenceBinding) typeBinding);
+//      }
+//    }
+//
+//    // shrink resolvedImports... only happens if an error was reported
+//    if (resolvedImports.length > index)
+//      System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
+//    imports = resolvedImports;
+//  }
   public void faultInTypes() {
-    faultInImports();
+//    faultInImports();
     if (topLevelTypes==null) {
                        topLevelTypes = new SourceTypeBinding[0];
     }