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

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


                (ReferenceBinding)guessedType,
                scope,
                scope.enclosingSourceType(),
                false,
                false,
                new ObjectVector(),
                missingElements,
                missingElementsStarts,
                missingElementsEnds,
                hasProblems);
          }
View Full Code Here


                (ReferenceBinding)guessedType,
                scope,
                scope.enclosingSourceType(),
                false,
                false,
                new ObjectVector(),
                missingElements,
                missingElementsStarts,
                missingElementsEnds,
                hasProblems);
          }
View Full Code Here

  public IPackageFragmentRoot[] computePackageFragmentRoots(
          IClasspathEntry[] resolvedClasspath,
          boolean retrieveExportedRoots,
          Map rootToResolvedEntries) throws JavaModelException {

    ObjectVector accumulatedRoots = new ObjectVector();
    computePackageFragmentRoots(
      resolvedClasspath,
      accumulatedRoots,
      new HashSet(5), // rootIDs
      null, // inside original project
      retrieveExportedRoots,
      rootToResolvedEntries);
    IPackageFragmentRoot[] rootArray = new IPackageFragmentRoot[accumulatedRoots.size()];
    accumulatedRoots.copyInto(rootArray);
    return rootArray;
  }
View Full Code Here

   * @return IClasspathEntry[]
   * @throws JavaModelException
   */
  public IClasspathEntry[] getExpandedClasspath()  throws JavaModelException {

      ObjectVector accumulatedEntries = new ObjectVector();
      computeExpandedClasspath(null, new HashSet(5), accumulatedEntries);

      IClasspathEntry[] expandedPath = new IClasspathEntry[accumulatedEntries.size()];
      accumulatedEntries.copyInto(expandedPath);

      return expandedPath;
  }
View Full Code Here

            pkgFragmentRoots = new PackageFragmentRoot[] { oldRoot };
          }
        }
        if (pkgFragmentRoots == null) {
          try {
            ObjectVector accumulatedRoots = new ObjectVector();
            HashSet rootIDs = new HashSet(5);
            rootIDs.add(this.project.rootID());
            this.project.computePackageFragmentRoots(
              this.oldResolvedClasspath[i],
              accumulatedRoots,
              rootIDs,
              null, // inside original project
              false, // don't retrieve exported roots
              null); /*no reverse map*/
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335986
            // When a package fragment's corresponding resource is removed from the project,
            // IJavaProject#computePackageFragmentRoots() doesn't include that entry. Hence
            // the cache become necessary in such cases. Add the cache to the accumulatedRoots
            // only when it's not already present.
            RootInfo rootInfo = (RootInfo) state.oldRoots.get(this.oldResolvedClasspath[i].getPath());
            if (rootInfo != null && rootInfo.cache != null) {
              IPackageFragmentRoot oldRoot = rootInfo.cache;
              boolean found = false;
              for (int j = 0; j < accumulatedRoots.size(); j++) {
                IPackageFragmentRoot root = (IPackageFragmentRoot) accumulatedRoots.elementAt(j);
                if (root.getPath().equals(oldRoot.getPath())) {
                  found = true;
                  break;
                }
              }
              if (!found)
                accumulatedRoots.add(oldRoot);
            }

            pkgFragmentRoots = new PackageFragmentRoot[accumulatedRoots.size()];
            accumulatedRoots.copyInto(pkgFragmentRoots);
          } catch (JavaModelException e) {
            pkgFragmentRoots =  new PackageFragmentRoot[] {};
          }
        }
        addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH);
View Full Code Here

  // Internal use only - use findMethod()
  public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) {
    ReferenceBinding currentType = receiverType;
    boolean receiverTypeIsInterface = receiverType.isInterface();
    ObjectVector found = new ObjectVector(3);
    CompilationUnitScope unitScope = compilationUnitScope();
    unitScope.recordTypeReferences(argumentTypes);

    if (receiverTypeIsInterface) {
      unitScope.recordTypeReference(receiverType);
      MethodBinding[] receiverMethods = receiverType.getMethods(selector, argumentTypes.length);
      if (receiverMethods.length > 0)
        found.addAll(receiverMethods);
      findMethodInSuperInterfaces(receiverType, selector, found, invocationSite);
      currentType = getJavaLangObject();
    }

    // superclass lookup
    long complianceLevel = compilerOptions().complianceLevel;
    boolean isCompliant14 = complianceLevel >= ClassFileConstants.JDK1_4;
    boolean isCompliant15 = complianceLevel >= ClassFileConstants.JDK1_5;
    ReferenceBinding classHierarchyStart = currentType;
    MethodVerifier verifier = environment().methodVerifier();
    while (currentType != null) {
      unitScope.recordTypeReference(currentType);
      currentType = (ReferenceBinding) currentType.capture(this, invocationSite == null ? 0 : invocationSite.sourceEnd());
      MethodBinding[] currentMethods = currentType.getMethods(selector, argumentTypes.length);
      int currentLength = currentMethods.length;
      if (currentLength > 0) {
        if (isCompliant14 && (receiverTypeIsInterface || found.size > 0)) {
          nextMethod: for (int i = 0, l = currentLength; i < l; i++) { // currentLength can be modified inside the loop
            MethodBinding currentMethod = currentMethods[i];
            if (currentMethod == null) continue nextMethod;
            if (receiverTypeIsInterface && !currentMethod.isPublic()) { // only public methods from Object are visible to interface receiverTypes
              currentLength--;
              currentMethods[i] = null;
              continue nextMethod;
            }

            // if 1.4 compliant, must filter out redundant protected methods from superclasses
            // protected method need to be checked only - default access is already dealt with in #canBeSeen implementation
            // when checking that p.C -> q.B -> p.A cannot see default access members from A through B.
            // if ((currentMethod.modifiers & AccProtected) == 0) continue nextMethod;
            // BUT we can also ignore any overridden method since we already know the better match (fixes 80028)
            for (int j = 0, max = found.size; j < max; j++) {
              MethodBinding matchingMethod = (MethodBinding) found.elementAt(j);
              if (verifier.isParameterSubsignature(matchingMethod.original(), currentMethod.original())) {
                if (isCompliant15) {
                  if (matchingMethod.isBridge() && !currentMethod.isBridge())
                    continue nextMethod; // keep inherited methods to find concrete method over a bridge method
                }
                currentLength--;
                currentMethods[i] = null;
                continue nextMethod;
              }
            }
          }
        }

        if (currentLength > 0) {
          // append currentMethods, filtering out null entries
          if (currentMethods.length == currentLength) {
            found.addAll(currentMethods);
          } else {
            for (int i = 0, max = currentMethods.length; i < max; i++) {
              MethodBinding currentMethod = currentMethods[i];
              if (currentMethod != null)
                found.add(currentMethod);
            }
          }
        }
      }
      currentType = currentType.superclass();
    }

    // if found several candidates, then eliminate those not matching argument types
    int foundSize = found.size;
    MethodBinding[] candidates = null;
    int candidatesCount = 0;
    MethodBinding problemMethod = null;
    boolean searchForDefaultAbstractMethod = isCompliant14 && ! receiverTypeIsInterface && (receiverType.isAbstract() || receiverType.isTypeVariable());
    if (foundSize > 0) {
      // argument type compatibility check
      for (int i = 0; i < foundSize; i++) {
        MethodBinding methodBinding = (MethodBinding) found.elementAt(i);
        MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
        if (compatibleMethod != null) {
          if (compatibleMethod.isValidBinding()) {
            if (foundSize == 1 && compatibleMethod.canBeSeenBy(receiverType, invocationSite, this)) {
              // return the single visible match now
              if (searchForDefaultAbstractMethod)
                return findDefaultAbstractMethod(receiverType, selector, argumentTypes, invocationSite, classHierarchyStart, found, compatibleMethod);
              unitScope.recordTypeReferences(compatibleMethod.thrownExceptions);
              return compatibleMethod;
            }
            if (candidatesCount == 0)
              candidates = new MethodBinding[foundSize];
            candidates[candidatesCount++] = compatibleMethod;
          } else if (problemMethod == null) {
            problemMethod = compatibleMethod;
          }
        }
      }
    }

    // no match was found
    if (candidatesCount == 0) {
      if (problemMethod != null) {
        switch (problemMethod.problemId()) {
          case ProblemReasons.TypeArgumentsForRawGenericMethod :
          case ProblemReasons.TypeParameterArityMismatch :
            return problemMethod;
        }
      }
      // abstract classes may get a match in interfaces; for non abstract
      // classes, reduces secondary errors since missing interface method
      // error is already reported
      MethodBinding interfaceMethod =
        findDefaultAbstractMethod(receiverType, selector, argumentTypes, invocationSite, classHierarchyStart, found, null);
      if (interfaceMethod != null) return interfaceMethod;
      if (found.size == 0) return null;
      if (problemMethod != null) return problemMethod;

      // still no match; try to find a close match when the parameter
      // order is wrong or missing some parameters

      // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=69471
      // bad guesses are foo(), when argument types have been supplied
      // and foo(X, Y), when the argument types are (int, float, Y)
      // so answer the method with the most argType matches and least parameter type mismatches
      int bestArgMatches = -1;
      MethodBinding bestGuess = (MethodBinding) found.elementAt(0); // if no good match so just use the first one found
      int argLength = argumentTypes.length;
      foundSize = found.size;
      nextMethod : for (int i = 0; i < foundSize; i++) {
        MethodBinding methodBinding = (MethodBinding) found.elementAt(i);
        TypeBinding[] params = methodBinding.parameters;
        int paramLength = params.length;
        int argMatches = 0;
        next: for (int a = 0; a < argLength; a++) {
          TypeBinding arg = argumentTypes[a];
View Full Code Here

      // at this point the scope is a compilation unit scope & need to check for imported static methods
      CompilationUnitScope unitScope = (CompilationUnitScope) scope;
      unitScope.faultInImports(); // field constants can cause static imports to be accessed before they're resolved
      ImportBinding[] imports = unitScope.imports;
      if (imports != null) {
        ObjectVector visible = null;
        boolean skipOnDemand = false; // set to true when matched static import of method name so stop looking for on demand methods
        for (int i = 0, length = imports.length; i < length; i++) {
          ImportBinding importBinding = imports[i];
          if (importBinding.isStatic()) {
            Binding resolvedImport = importBinding.resolvedImport;
            MethodBinding possible = null;
            if (importBinding.onDemand) {
              if (!skipOnDemand && resolvedImport instanceof ReferenceBinding)
                // answers closest approximation, may not check argumentTypes or visibility
                possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite, true);
            } else {
              if (resolvedImport instanceof MethodBinding) {
                MethodBinding staticMethod = (MethodBinding) resolvedImport;
                if (CharOperation.equals(staticMethod.selector, selector))
                  // answers closest approximation, may not check argumentTypes or visibility
                  possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite, true);
              } else if (resolvedImport instanceof FieldBinding) {
                // check to see if there are also methods with the same name
                FieldBinding staticField = (FieldBinding) resolvedImport;
                if (CharOperation.equals(staticField.name, selector)) {
                  // must find the importRef's type again since the field can be from an inherited type
                  char[][] importName = importBinding.reference.tokens;
                  TypeBinding referencedType = getType(importName, importName.length - 1);
                  if (referencedType != null)
                    // answers closest approximation, may not check argumentTypes or visibility
                    possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite, true);
                }
              }
            }
            if (possible != null && possible != foundProblem) {
              if (!possible.isValidBinding()) {
                if (foundProblem == null)
                  foundProblem = possible; // answer as error case match
              } else if (possible.isStatic()) {
                MethodBinding compatibleMethod = computeCompatibleMethod(possible, argumentTypes, invocationSite);
                if (compatibleMethod != null) {
                  if (compatibleMethod.isValidBinding()) {
                    if (compatibleMethod.canBeSeenBy(unitScope.fPackage)) {
                      if (visible == null || !visible.contains(compatibleMethod)) {
                        ImportReference importReference = importBinding.reference;
                        if (importReference != null) {
                          importReference.bits |= ASTNode.Used;
                        }
                        if (!skipOnDemand && !importBinding.onDemand) {
                          visible = null; // forget previous matches from on demand imports
                          skipOnDemand = true;
                        }
                        if (visible == null)
                          visible = new ObjectVector(3);
                        visible.add(compatibleMethod);
                      }
                    } else if (foundProblem == null) {
                      foundProblem = new ProblemMethodBinding(compatibleMethod, selector, compatibleMethod.parameters, ProblemReasons.NotVisible);
                    }
                  } else if (foundProblem == null) {
                    foundProblem = compatibleMethod;
                  }
                } else if (foundProblem == null) {
                  foundProblem = new ProblemMethodBinding(possible, selector, argumentTypes, ProblemReasons.NotFound);
                }
              }
            }
          }
        }
        if (visible != null) {
          MethodBinding[] temp = new MethodBinding[visible.size];
          visible.copyInto(temp);
          foundMethod = mostSpecificMethodBinding(temp, temp.length, argumentTypes, invocationSite, null);
        }
      }
    }
View Full Code Here

  public IPackageFragmentRoot[] computePackageFragmentRoots(
          IClasspathEntry[] resolvedClasspath,
          boolean retrieveExportedRoots,
          Map rootToResolvedEntries) throws JavaModelException {

    ObjectVector accumulatedRoots = new ObjectVector();
    computePackageFragmentRoots(
      resolvedClasspath,
      accumulatedRoots,
      new HashSet(5), // rootIDs
      null, // inside original project
      retrieveExportedRoots,
      rootToResolvedEntries);
    IPackageFragmentRoot[] rootArray = new IPackageFragmentRoot[accumulatedRoots.size()];
    accumulatedRoots.copyInto(rootArray);
    return rootArray;
  }
View Full Code Here

   * @return IClasspathEntry[]
   * @throws JavaModelException
   */
  public IClasspathEntry[] getExpandedClasspath()  throws JavaModelException {

      ObjectVector accumulatedEntries = new ObjectVector();
      computeExpandedClasspath(null, new HashSet(5), accumulatedEntries);

      IClasspathEntry[] expandedPath = new IClasspathEntry[accumulatedEntries.size()];
      accumulatedEntries.copyInto(expandedPath);

      return expandedPath;
  }
View Full Code Here

            pkgFragmentRoots = new PackageFragmentRoot[] { oldRoot };
          }
        }
        if (pkgFragmentRoots == null) {
          try {
            ObjectVector accumulatedRoots = new ObjectVector();
            HashSet rootIDs = new HashSet(5);
            rootIDs.add(this.project.rootID());
            this.project.computePackageFragmentRoots(
              this.oldResolvedClasspath[i],
              accumulatedRoots,
              rootIDs,
              null, // inside original project
              false, // don't retrieve exported roots
              null); /*no reverse map*/
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335986
            // When a package fragment's corresponding resource is removed from the project,
            // IJavaProject#computePackageFragmentRoots() doesn't include that entry. Hence
            // the cache become necessary in such cases. Add the cache to the accumulatedRoots
            // only when it's not already present.
            RootInfo rootInfo = (RootInfo) state.oldRoots.get(this.oldResolvedClasspath[i].getPath());
            if (rootInfo != null && rootInfo.cache != null) {
              IPackageFragmentRoot oldRoot = rootInfo.cache;
              boolean found = false;
              for (int j = 0; j < accumulatedRoots.size(); j++) {
                IPackageFragmentRoot root = (IPackageFragmentRoot) accumulatedRoots.elementAt(j);
                if (root.getPath().equals(oldRoot.getPath())) {
                  found = true;
                  break;
                }
              }
              if (!found)
                accumulatedRoots.add(oldRoot);
            }

            pkgFragmentRoots = new PackageFragmentRoot[accumulatedRoots.size()];
            accumulatedRoots.copyInto(pkgFragmentRoots);
          } catch (JavaModelException e) {
            pkgFragmentRoots =  new PackageFragmentRoot[] {};
          }
        }
        addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH);
View Full Code Here

TOP

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

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.