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

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


*  Compute the list of paths which are keying index files.
*/
private void initializeIndexLocations() {
  IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
  IndexManager manager = JavaModelManager.getIndexManager();
  SimpleSet locations = new SimpleSet();
  IJavaElement focus = MatchLocator.projectOrJarFocus(this.pattern);
  if (focus == null) {
    for (int i = 0; i < projectsAndJars.length; i++) {
      IPath path = projectsAndJars[i];
      Object target = JavaModel.getTarget(path, false/*don't check existence*/);
      if (target instanceof IFolder) // case of an external folder
        path = ((IFolder) target).getFullPath();
      locations.add(manager.computeIndexLocation(path));
    }
  } else {
    try {
      // See whether the state builder might be used to reduce the number of index locations
   
      // find the projects from projectsAndJars that see the focus then walk those projects looking for the jars from projectsAndJars
      int length = projectsAndJars.length;
      JavaProject[] projectsCanSeeFocus = new JavaProject[length];
      SimpleSet visitedProjects = new SimpleSet(length);
      int projectIndex = 0;
      SimpleSet externalLibsToCheck = new SimpleSet(length);
      ObjectVector superTypes = new ObjectVector();
      IJavaElement[] focuses = getFocusedElementsAndTypes(this.pattern, focus, superTypes);
      char[][][] focusQualifiedNames = null;
      boolean isAutoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
      if (isAutoBuilding && focus instanceof IJavaProject) {
        focusQualifiedNames = getQualifiedNames(superTypes);
      }
      IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
      for (int i = 0; i < length; i++) {
        IPath path = projectsAndJars[i];
        JavaProject project = (JavaProject) getJavaProject(path, model);
        if (project != null) {
          visitedProjects.add(project);
          if (canSeeFocus(focuses, project, focusQualifiedNames)) {
            locations.add(manager.computeIndexLocation(path));
            projectsCanSeeFocus[projectIndex++] = project;
          }
        } else {
          externalLibsToCheck.add(path);
        }
      }
      for (int i = 0; i < projectIndex && externalLibsToCheck.elementSize > 0; i++) {
        IClasspathEntry[] entries = projectsCanSeeFocus[i].getResolvedClasspath();
        for (int j = entries.length; --j >= 0;) {
          IClasspathEntry entry = entries[j];
          if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
            IPath path = entry.getPath();
            if (externalLibsToCheck.remove(path) != null) {
              Object target = JavaModel.getTarget(path, false/*don't check existence*/);
              if (target instanceof IFolder) // case of an external folder
                path = ((IFolder) target).getFullPath();
              locations.add(manager.computeIndexLocation(path));
            }
          }
        }
      }
      // jar files can be included in the search scope without including one of the projects that references them, so scan all projects that have not been visited
      if (externalLibsToCheck.elementSize > 0) {
        IJavaProject[] allProjects = model.getJavaProjects();
        for (int i = 0, l = allProjects.length; i < l && externalLibsToCheck.elementSize > 0; i++) {
          JavaProject project = (JavaProject) allProjects[i];
          if (!visitedProjects.includes(project)) {
            IClasspathEntry[] entries = project.getResolvedClasspath();
            for (int j = entries.length; --j >= 0;) {
              IClasspathEntry entry = entries[j];
              if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                IPath path = entry.getPath();
                if (externalLibsToCheck.remove(path) != null) {
                  Object target = JavaModel.getTarget(path, false/*don't check existence*/);
                  if (target instanceof IFolder) // case of an external folder
                    path = ((IFolder) target).getFullPath();
                  locations.add(manager.computeIndexLocation(path));
                }
View Full Code Here


  this.categoryEnds = null;
}
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

}
/**
* Returns the document names that contain the given substring, if null then returns all of them.
*/
public String[] queryDocumentNames(String substring) throws IOException {
  SimpleSet results;
  if (this.memoryIndex.hasChanged()) {
    results = this.diskIndex.addDocumentNames(substring, this.memoryIndex);
    this.memoryIndex.addDocumentNames(substring, results);
  } else {
    results = this.diskIndex.addDocumentNames(substring, null);
View Full Code Here

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

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

private SimpleSet needsCompileList;
private SimpleSet compiledList;

public WorkQueue() {
  this.needsCompileList = new SimpleSet();
  this.compiledList = new SimpleSet();
}
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() && TypeBinding.equalsEquals(next.erasure(), erasure)) {
          if (copy == null)
            copy = new SimpleSet(nextPosition);
          copy.add(interfacesToVisit[i]);
          copy.add(interfacesToVisit[j]);
        }
      }
    }
  }
  return copy;
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 (TypeBinding.equalsEquals(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 (TypeBinding.equalsEquals(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 (TypeBinding.equalsEquals(refs[r].resolvedType, inheritedInterface)) {
                problemReporter().redundantSuperInterface(this.type, refs[r], inheritedInterface, superType);
                break;
              }
            }
          } else {
            inheritedInterfaces.add(inheritedInterface);
            interfacesToVisit[nextPosition++] = inheritedInterface;
          }
        }
      }
    }
View Full Code Here

  } else {
    superInterfaces = (ReferenceBinding[]) superIfcList.toArray(new ReferenceBinding[superIfcList.size()]);
    superInterfaces = Sorting.sortTypes(superInterfaces);
  }
 
  SimpleSet skip = findSuperinterfaceCollisions(superclass, superInterfaces);
  int len = superInterfaces.length;
  for (int i = len-1; i >= 0; i--) {
    superType = superInterfaces[i];
    if (superType.isValidBinding()) {
      if (skip != null && skip.includes(superType)) continue;

      MethodBinding[] methods = superType.unResolvedMethods();
      nextMethod : for (int m = methods.length; --m >= 0;) { // Interface methods are all abstract public
        MethodBinding inheritedMethod = methods[m];
        if (inheritedMethod.isStatic()) continue nextMethod;
View Full Code Here

  if (table != null)
    this.documentTables = new Object[] {table};
}
public void addDocumentName(String documentName) {
  if (this.documentNames == null)
    this.documentNames = new SimpleSet(3);
  this.documentNames.add(documentName);
}
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.