Package org.eclipse.jdt.internal.compiler.util

Examples of org.eclipse.jdt.internal.compiler.util.SimpleSet


  long fileSize = new File(zipFileName).length();
  PackageCacheEntry cacheEntry = (PackageCacheEntry) PackageCache.get(zipFileName);
  if (cacheEntry != null && cacheEntry.lastModified == lastModified && cacheEntry.fileSize == fileSize)
    return cacheEntry.packageSet;

  SimpleSet packageSet = new SimpleSet(41);
  packageSet.add(""); //$NON-NLS-1$
  nextEntry : for (Enumeration e = jar.zipFile.entries(); e.hasMoreElements(); ) {
    String fileName = ((ZipEntry) e.nextElement()).getName();

    // add the package name & all of its parent packages
    int last = fileName.lastIndexOf('/');
    while (last > 0) {
      // extract the package name
      String packageName = fileName.substring(0, last);
      if (packageSet.addIfNotIncluded(packageName) == null)
        continue nextEntry; // already existed
      last = packageName.lastIndexOf('/');
    }
  }
View Full Code Here


      this.zipFile = new ZipFile(this.zipFilename);
      this.closeZipFileAtEnd = true;
    }
    this.knownPackageNames = findPackageSet(this);
  } catch(Exception e) {
    this.knownPackageNames = new SimpleSet(); // assume for this build the zipFile is empty
  }
  return this.knownPackageNames.includes(qualifiedPackageName);
}
View Full Code Here

}

void checkForRedundantSuperinterfaces(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
  if (superInterfaces == Binding.NO_SUPERINTERFACES) return;

  SimpleSet interfacesToCheck = new SimpleSet(superInterfaces.length);
  for (int i = 0, l = superInterfaces.length; i < l; i++)
    interfacesToCheck.add(superInterfaces[i]);
  ReferenceBinding[] itsInterfaces = null;
  SimpleSet inheritedInterfaces = new SimpleSet(5);
  ReferenceBinding superType = superclass;
  while (superType != null && superType.isValidBinding()) {
    if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
      for (int i = 0, l = itsInterfaces.length; i < l; i++) {
        ReferenceBinding inheritedInterface = itsInterfaces[i];
        if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
          if (interfacesToCheck.includes(inheritedInterface)) {
            TypeReference[] refs = this.type.scope.referenceContext.superInterfaces;
            for (int r = 0, rl = refs.length; r < rl; r++) {
              if (refs[r].resolvedType == inheritedInterface) {
                problemReporter().redundantSuperInterface(this.type, refs[r], inheritedInterface, superType);
                break;
              }
            }
          } else {
            inheritedInterfaces.add(inheritedInterface);
          }
        }
      }
    }
    superType = superType.superclass();
  }

  int nextPosition = inheritedInterfaces.elementSize;
  if (nextPosition == 0) return;
  ReferenceBinding[] interfacesToVisit = new ReferenceBinding[nextPosition];
  inheritedInterfaces.asArray(interfacesToVisit);
  for (int i = 0; i < nextPosition; i++) {
    superType = interfacesToVisit[i];
    if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
      int itsLength = itsInterfaces.length;
      if (nextPosition + itsLength >= interfacesToVisit.length)
        System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
      for (int a = 0; a < itsLength; a++) {
        ReferenceBinding inheritedInterface = itsInterfaces[a];
        if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
          if (interfacesToCheck.includes(inheritedInterface)) {
            TypeReference[] refs = this.type.scope.referenceContext.superInterfaces;
            for (int r = 0, rl = refs.length; r < rl; r++) {
              if (refs[r].resolvedType == inheritedInterface) {
                problemReporter().redundantSuperInterface(this.type, refs[r], inheritedInterface, superType);
                break;
              }
            }
          } else {
            inheritedInterfaces.add(inheritedInterface);
            interfacesToVisit[nextPosition++] = inheritedInterface;
          }
        }
      }
    }
View Full Code Here

    }
    superType = superType.superclass();
  }
  if (nextPosition == 0) return;

  SimpleSet skip = findSuperinterfaceCollisions(superclass, superInterfaces);
  for (int i = 0; i < nextPosition; i++) {
    superType = interfacesToVisit[i];
    if (superType.isValidBinding()) {
      if (skip != null && skip.includes(superType)) continue;
      if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
        int itsLength = itsInterfaces.length;
        if (nextPosition + itsLength >= interfacesToVisit.length)
          System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
        nextInterface : for (int a = 0; a < itsLength; a++) {
View Full Code Here

      }
    }
  }

  if (!isInconsistent) return null; // hierarchy is consistent so no collisions are possible
  SimpleSet copy = null;
  for (int i = 0; i < nextPosition; i++) {
    ReferenceBinding current = interfacesToVisit[i];
    if (current.isValidBinding()) {
      TypeBinding erasure = current.erasure();
      for (int j = i + 1; j < nextPosition; j++) {
        ReferenceBinding next = interfacesToVisit[j];
        if (next.isValidBinding() && next.erasure() == erasure) {
          if (copy == null)
            copy = new SimpleSet(nextPosition);
          copy.add(interfacesToVisit[i]);
          copy.add(interfacesToVisit[j]);
        }
      }
    }
  }
  return copy;
View Full Code Here

                  if (mostSpecificExceptions == null) {
                    mostSpecificExceptions = current.thrownExceptions;
                  }
                  int mostSpecificLength = mostSpecificExceptions.length;
                  int nextLength = next.thrownExceptions.length;
                  SimpleSet temp = new SimpleSet(mostSpecificLength);
                  boolean changed = false;
                  nextException : for (int t = 0; t < mostSpecificLength; t++) {
                    ReferenceBinding exception = mostSpecificExceptions[t];
                    for (int s = 0; s < nextLength; s++) {
                      ReferenceBinding nextException = next.thrownExceptions[s];
                      if (exception.isCompatibleWith(nextException)) {
                        temp.add(exception);
                        continue nextException;
                      } else if (nextException.isCompatibleWith(exception)) {
                        temp.add(nextException);
                        changed = true;
                        continue nextException;
                      } else {
                        changed = true;
                      }
                    }
                  }
                  if (changed) {
                    mostSpecificExceptions = temp.elementSize == 0 ? Binding.NO_EXCEPTIONS : new ReferenceBinding[temp.elementSize];
                    temp.asArray(mostSpecificExceptions);
                  }
                }
              }
            }
          }
View Full Code Here

  this.indexLocation = location;
}
SimpleSet addDocumentNames(String substring, MemoryIndex memoryIndex) throws IOException {
  // must skip over documents which have been added/changed/deleted in the memory index
  String[] docNames = readAllDocumentNames();
  SimpleSet results = new SimpleSet(docNames.length);
  if (substring == null) {
    if (memoryIndex == null) {
      for (int i = 0, l = docNames.length; i < l; i++)
        results.add(docNames[i]);
    } else {
      SimpleLookupTable docsToRefs = memoryIndex.docsToReferences;
      for (int i = 0, l = docNames.length; i < l; i++) {
        String docName = docNames[i];
        if (!docsToRefs.containsKey(docName))
          results.add(docName);
      }
    }
  } else {
    if (memoryIndex == null) {
      for (int i = 0, l = docNames.length; i < l; i++)
        if (docNames[i].startsWith(substring, 0))
          results.add(docNames[i]);
    } else {
      SimpleLookupTable docsToRefs = memoryIndex.docsToReferences;
      for (int i = 0, l = docNames.length; i < l; i++) {
        String docName = docNames[i];
        if (docName.startsWith(substring, 0) && !docsToRefs.containsKey(docName))
          results.add(docName);
      }
    }
  }
  return results;
}
View Full Code Here

   * by the method and whose super type has been caught already.
   * @param tryStatement
   * @param scope
   */
  public void processThrownExceptions(TryStatement tryStatement, BlockScope scope) {
    this.thrownExceptions = new SimpleSet();
    this.exceptionsStack = new Stack();
    this.caughtExceptions = new SimpleSet();
    this.discouragedExceptions = new SimpleSet();
    tryStatement.traverse(this, scope);
    removeCaughtExceptions(tryStatement, true /*remove unchecked exceptions this time*/);
  }
 
View Full Code Here

    return false;
  }

  public boolean visit(TryStatement tryStatement, BlockScope scope) {
    this.exceptionsStack.push(this.thrownExceptions);
    SimpleSet exceptionSet = new SimpleSet();
    this.thrownExceptions = exceptionSet;
    tryStatement.tryBlock.traverse(this, scope);

    removeCaughtExceptions(tryStatement, false);
View Full Code Here

  super.matchLevelAndReportImportRef(importRef, refBinding, locator);
}
protected void matchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
  if (this.isDeclarationOfReferencedTypesPattern) {
    if ((element = findElement(element, accuracy)) != null) {
      SimpleSet knownTypes = ((DeclarationOfReferencedTypesPattern) this.pattern).knownTypes;
      while (binding instanceof ReferenceBinding) {
        ReferenceBinding typeBinding = (ReferenceBinding) binding;
        reportDeclaration(typeBinding, 1, locator, knownTypes);
        binding = typeBinding.enclosingType();
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.util.SimpleSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.