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

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


void setNames(String[] typeNames, SourceFile[] additionalFiles) {
  // convert the initial typeNames to a set
  if (typeNames == null) {
    this.initialTypeNames = null;
  } else {
    this.initialTypeNames = new SimpleSet(typeNames.length);
    for (int i = 0, l = typeNames.length; i < l; i++)
      this.initialTypeNames.add(typeNames[i]);
  }
  // map the additional source files by qualified type name
  if (additionalFiles == null) {
View Full Code Here


  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

      for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++) {
        if (this.javaBuilder.participants[i].isAnnotationProcessor()) {
          // initialize this set so the builder knows to gather CUs that define Annotation types
          // each Annotation processor participant is then asked to process these files AFTER
          // the compile loop. The normal dependency loop will then recompile all affected types
          this.filesWithAnnotations = new SimpleSet(1);
          break;
        }
      }
    }
  }
View Full Code Here

  // and if so should we pass the generated files from the each processor to the others to process?
  // and what happens if some participants do not expect to be called with only a few files, after seeing 'all' the files?
  for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++)
    this.javaBuilder.participants[i].buildStarting(results, this instanceof BatchImageBuilder);

  SimpleSet uniqueFiles = null;
  CompilationParticipantResult[] toAdd = null;
  int added = 0;
  for (int i = results.length; --i >= 0;) {
    CompilationParticipantResult result = results[i];
    if (result == null) continue;

    IFile[] deletedGeneratedFiles = result.deletedFiles;
    if (deletedGeneratedFiles != null)
      deleteGeneratedFiles(deletedGeneratedFiles);

    IFile[] addedGeneratedFiles = result.addedFiles;
    if (addedGeneratedFiles != null) {
      for (int j = addedGeneratedFiles.length; --j >= 0;) {
        SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j], true);
        if (sourceFile == null) continue;
        if (uniqueFiles == null) {
          uniqueFiles = new SimpleSet(unitsAboutToCompile.length + 3);
          for (int f = unitsAboutToCompile.length; --f >= 0;)
            uniqueFiles.add(unitsAboutToCompile[f]);
        }
        if (uniqueFiles.addIfNotIncluded(sourceFile) == sourceFile) {
          CompilationParticipantResult newResult = new CompilationParticipantResult(sourceFile);
          // is there enough room to add all the addedGeneratedFiles.length ?
          if (toAdd == null) {
            toAdd = new CompilationParticipantResult[addedGeneratedFiles.length];
          } else {
View Full Code Here

                }
              }
              // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335751
              if (compilerOptions().complianceLevel > ClassFileConstants.JDK1_6) {
                if (typeVariable.rank >= varSuperType.rank && varSuperType.declaringElement == typeVariable.declaringElement) {
                  SimpleSet set = new SimpleSet(typeParameters.length);
                  set.add(typeVariable);
                  ReferenceBinding superBinding = varSuperType;
                  while (superBinding instanceof TypeVariableBinding) {
                    if (set.includes(superBinding)) {
                      problemReporter().hierarchyCircularity(typeVariable, varSuperType, typeRef);
                      typeVariable.tagBits |= TagBits.HierarchyHasProblems;
                      break firstBound; // do not keep first bound
                    } else {
                      set.add(superBinding);
                      superBinding = ((TypeVariableBinding)superBinding).superclass;
                    }
                  }
                }
              }
View Full Code Here

}

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

  SimpleSet interfacesToCheck = new SimpleSet(superInterfaces.length);
  SimpleSet redundantInterfaces = null// bark but once.
  for (int i = 0, l = superInterfaces.length; i < l; i++) {
    ReferenceBinding toCheck = superInterfaces[i];
    for (int j = 0; j < l; j++) {
      ReferenceBinding implementedInterface = superInterfaces[j];
      if (i != j && toCheck.implementsInterface(implementedInterface, true)) {
        if (redundantInterfaces == null) {
          redundantInterfaces = new SimpleSet(3);
        } else if (redundantInterfaces.includes(implementedInterface)) {
          continue;
        }
        redundantInterfaces.add(implementedInterface);
        TypeReference[] refs = this.type.scope.referenceContext.superInterfaces;
        for (int r = 0, rl = refs.length; r < rl; r++) {
          if (refs[r].resolvedType == toCheck) {
            problemReporter().redundantSuperInterface(this.type, refs[j], implementedInterface, toCheck);
            break; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=320911
          }
        }
      }
    }
    interfacesToCheck.add(toCheck);
  }

  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)) {
            if (redundantInterfaces == null) {
              redundantInterfaces = new SimpleSet(3);
            } else if (redundantInterfaces.includes(inheritedInterface)) {
              continue;
            }
            redundantInterfaces.add(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)) {
            if (redundantInterfaces == null) {
              redundantInterfaces = new SimpleSet(3);
            } else if (redundantInterfaces.includes(inheritedInterface)) {
              continue;
            }
            redundantInterfaces.add(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

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.