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

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


    String selector = new String(methodPattern.selector);
    int parameterCount = methodPattern.parameterCount;
    ITypeHierarchy superHierarchy = type.newSupertypeHierarchy(null);
    IType[] allTypes = superHierarchy.getAllSupertypes(type);
    int length = allTypes.length;
    SimpleSet focusSet = new SimpleSet(length+1);
    if (focusElement != null) focusSet.add(focusElement);
    for (int i=0; i<length; i++) {
      IMethod[] methods = allTypes[i].getMethods();
      int mLength = methods.length;
      for (int m=0; m<mLength; m++) {
        if (parameterCount == methods[m].getNumberOfParameters() && methods[m].getElementName().equals(selector)) {
          IPackageFragmentRoot root = (IPackageFragmentRoot) allTypes[i].getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
          IJavaElement element = root.isArchive() ? root : root.getParent();
          focusSet.add(element);
          if (superTypes != null) superTypes.add(allTypes[i]);
          break;
        }
      }
    }
View Full Code Here


      // 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);
          int canSeeFocus = canSeeFocus(focuses, project, focusQualifiedNames);
          if (canSeeFocus == PROJECT_CAN_SEE_FOCUS) {
            locations.add(manager.computeIndexLocation(path));
          }
          if (canSeeFocus != PROJECT_CAN_NOT_SEE_FOCUS) {
            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

                }
              }
              // 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

                    mostSpecificExceptions = current.thrownExceptions;
                  }
                  int mostSpecificLength = mostSpecificExceptions.length;
                  ReferenceBinding[] nextExceptions = getFilteredExceptions(next);
                  int nextLength = nextExceptions.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 = nextExceptions[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

    }
    PackageDeclarationPattern pkgPattern = (PackageDeclarationPattern) searchPattern;
    boolean isWorkspaceScope = this.scope == JavaModelManager.getJavaModelManager().getWorkspaceScope();
    IPath[] scopeProjectsAndJars =  isWorkspaceScope ? null : this.scope.enclosingProjectsAndJars();
    int scopeLength = isWorkspaceScope ? 0 : scopeProjectsAndJars.length;
    SimpleSet packages = new SimpleSet();
    for (int i = 0, length = projects.length; i < length; i++) {
      IJavaProject javaProject = projects[i];
      if (this.progressMonitor != null) {
        if (this.progressMonitor.isCanceled()) throw new OperationCanceledException();
        this.progressWorked++;
        if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
      }
      // Verify that project belongs to the scope
      if (!isWorkspaceScope) {
        boolean found = false;
        for (int j=0; j<scopeLength; j++) {
          if (javaProject.getPath().equals(scopeProjectsAndJars[j])) {
            found = true;
            break;
          }
        }
        if (!found) continue;
      }
      // Get all project package fragment names
      this.nameLookup = ((JavaProject) projects[i]).newNameLookup(this.workingCopies);
      IPackageFragment[] packageFragments = this.nameLookup.findPackageFragments(new String(pkgPattern.pkgName), false, true);
      int pLength = packageFragments == null ? 0 : packageFragments.length;
      // Report matches avoiding duplicate names
      for (int p=0; p<pLength; p++) {
        IPackageFragment fragment = packageFragments[p];
        if (packages.addIfNotIncluded(fragment) == null) continue;
        if (encloses(fragment)) {
          IResource resource = fragment.getResource();
          if (resource == null) // case of a file in an external jar
            resource = javaProject.getProject();
          try {
View Full Code Here

        this.patternLocator.matchLevelAndReportImportRef(importRef, binding, this);
      } else {
        nodeSet.addMatch(node, this.patternLocator.resolveLevel(node));
      }
    }
    nodeSet.possibleMatchingNodesSet = new SimpleSet(3);
    if (BasicSearchEngine.VERBOSE) {
      int size = nodeSet.matchingNodes==null ? 0 : nodeSet.matchingNodes.elementSize;
      System.out.print("  - node set: accurate="+size); //$NON-NLS-1$
      size = nodeSet.possibleMatchingNodesSet==null ? 0 : nodeSet.possibleMatchingNodesSet.elementSize;
      System.out.println(", possible="+size); //$NON-NLS-1$
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

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.