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

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


      findEnumConstants(
          enumConstantName,
          enumType,
          null /* doesn't need invocation scope */,
          new ObjectVector(),
          alreadyUsedConstants,
          alreadyUsedConstantCount,
          false);
    }
  }
View Full Code Here


    boolean missingElementsHaveProblems,
    char[] castedReceiver,
    int receiverStart,
    int receiverEnd) {

    ObjectVector newFieldsFound = new ObjectVector();
    // if the proposal is being asked inside a field's initialization, we'll record its id
    int fieldBeingCompletedId = -1;
    boolean isFieldBeingCompletedStatic = false;
    for (int f = fields.length; --f >=0;) {
      FieldBinding field = fields[f];
      FieldDeclaration fieldDeclaration = field.sourceField();
      // We maybe asking for a proposal inside this field's initialization. So record its id
      ASTNode astNode = this.parser.assistNode;
      if (fieldDeclaration != null && fieldDeclaration.initialization != null && astNode != null) {
        if (CharOperation.equals(this.fileName, field.declaringClass.getFileName()) && fieldDeclaration.initialization.sourceEnd > 0) {
          if (fieldDeclaration.initialization.sourceStart <= astNode.sourceStart &&
            astNode.sourceEnd <= fieldDeclaration.initialization.sourceEnd) {
            // completion is inside a field initializer
            fieldBeingCompletedId = field.id;
            isFieldBeingCompletedStatic = field.isStatic();
            break;
          }
        } else { // The sourceEnd may not yet be set
          CompletionNodeDetector detector = new CompletionNodeDetector(astNode, fieldDeclaration.initialization);
          if (detector.containsCompletionNode()) {  // completion is inside a field initializer
            fieldBeingCompletedId = field.id;
            isFieldBeingCompletedStatic = field.isStatic();
            break;
          }
        }
      }
    }
    // Inherited fields which are hidden by subclasses are filtered out
    // No visibility checks can be performed without the scope & invocationSite

    int fieldLength = fieldName.length;
    next : for (int f = fields.length; --f >= 0;) {
      FieldBinding field = fields[f];
     
      // Content assist invoked inside some field's initialization.
      // bug 310427 and 325481
      if (fieldBeingCompletedId >= 0 && field.id >= fieldBeingCompletedId) {
        // Don't propose field which is being declared currently
        // Don't propose fields declared after the current field declaration statement
        // Though, if field is static, then it can be still be proposed
        if (!field.isStatic()) {
          continue next;
        } else if (isFieldBeingCompletedStatic) {
          // static fields can't be proposed before they are actually declared if the
          // field currently being declared is also static
          continue next;
        }
      }
     
      if (field.isSynthetic())  continue next;

      if (onlyStaticFields && !field.isStatic()) continue next;

      if (fieldLength > field.name.length) continue next;

      if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */)
          && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(fieldName, field.name)))  continue next;

      if (this.options.checkDeprecation &&
          field.isViewedAsDeprecated() &&
          !scope.isDefinedInSameUnit(field.declaringClass))
        continue next;

      if (this.options.checkVisibility
        && !field.canBeSeenBy(receiverType, invocationSite, scope))  continue next;
     
      // don't propose non constant fields or strings (1.6 or below) in case expression
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=343342
      if (this.assistNodeIsInsideCase) {
        if (field.isFinal() && field.isStatic()) {
          if (this.assistNodeIsString){
            if (field.type == null || field.type.id != TypeIds.T_JavaLangString)
              continue next;
          } else if (!(field.type instanceof BaseTypeBinding))
            continue next;
        } else {
          continue next; // non-constants not allowed in case. 
        }
      }

      boolean prefixRequired = false;

      for (int i = fieldsFound.size; --i >= 0;) {
        Object[] other = (Object[])fieldsFound.elementAt(i);
        FieldBinding otherField = (FieldBinding) other[0];
        ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
        if (field == otherField && TypeBinding.equalsEquals(receiverType, otherReceiverType))
          continue next;
        if (CharOperation.equals(field.name, otherField.name, true)) {
          if (field.declaringClass.isSuperclassOf(otherField.declaringClass))
            continue next;
          if (otherField.declaringClass.isInterface()) {
            if (TypeBinding.equalsEquals(field.declaringClass, scope.getJavaLangObject()))
              continue next;
            if (field.declaringClass.implementsInterface(otherField.declaringClass, true))
              continue next;
          }
          if (field.declaringClass.isInterface())
            if (otherField.declaringClass.implementsInterface(field.declaringClass, true))
              continue next;
          if(canBePrefixed) {
            prefixRequired = true;
          } else {
            continue next;
          }
        }
      }

      for (int l = localsFound.size; --l >= 0;) {
        LocalVariableBinding local = (LocalVariableBinding) localsFound.elementAt(l);

        if (CharOperation.equals(field.name, local.name, true)) {
          SourceTypeBinding declarationType = scope.enclosingSourceType();
          if (declarationType.isAnonymousType() && TypeBinding.notEquals(declarationType, invocationScope.enclosingSourceType())) {
            continue next;
          }
          if(canBePrefixed) {
            prefixRequired = true;
          } else {
            continue next;
          }
          break;
        }
      }

      newFieldsFound.add(new Object[]{field, receiverType});

      char[] completion = field.name;

      if(prefixRequired || this.options.forceImplicitQualification){
        char[] prefix = computePrefix(scope.enclosingSourceType(), invocationScope.enclosingSourceType(), field.isStatic());
View Full Code Here

      findFields(
        token,
        (ReferenceBinding) receiverType,
        scope,
        fieldsFound,
        new ObjectVector(),
        false,
        invocationSite,
        invocationScope,
        implicitCall,
        false,
View Full Code Here

      Scope invocationScope,
      ObjectVector localsFound,
      ObjectVector fieldsFound,
      ObjectVector methodsFound) {

    ObjectVector methodsFoundFromFavorites = new ObjectVector();

    ImportBinding[] favoriteBindings = getFavoriteReferenceBindings(invocationScope);

    if (favoriteBindings != null && favoriteBindings.length > 0) {
      for (int i = 0; i < favoriteBindings.length; i++) {
View Full Code Here

            boolean hasProblems) {
          findFieldsAndMethods(
            CompletionEngine.this.completionToken,
            guessedType,
            scope,
            new ObjectVector(),
            new ObjectVector(),
            invocationSite,
            invocationScope,
            false,
            false,
            missingElements,
View Full Code Here

    ObjectVector methodsFound,
    //  boolean noVoidReturnType, how do you know?
    boolean exactMatch,
    ReferenceBinding receiverType) {

    ObjectVector newMethodsFound =  new ObjectVector();
    // Inherited methods which are hidden by subclasses are filtered out
    // No visibility checks can be performed without the scope & invocationSite
    int methodLength = methodName.length;
    next : for (int f = methods.length; --f >= 0;) {

      MethodBinding method = methods[f];
      if (method.isSynthetic())  continue next;

      if (method.isDefaultAbstract()) continue next;

      if (method.isConstructor()) continue next;

      if (method.isFinal()) {
                newMethodsFound.add(method);
                continue next;
            }

      if (this.options.checkDeprecation &&
          method.isViewedAsDeprecated() &&
          !scope.isDefinedInSameUnit(method.declaringClass))
        continue next;

      //    if (noVoidReturnType && method.returnType == BaseTypes.VoidBinding) continue next;
      if(method.isStatic()) continue next;

      if (!method.canBeSeenBy(receiverType, FakeInvocationSite , scope)) continue next;

      if (exactMatch) {
        if (!CharOperation.equals(methodName, method.selector, false /* ignore case */
          ))
          continue next;

      } else {

        if (methodLength > method.selector.length)
          continue next;

        if (!CharOperation.prefixEquals(methodName, method.selector, false/* ignore case */)
            && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector)))
          continue next;
      }

      for (int i = methodsFound.size; --i >= 0;) {
        MethodBinding otherMethod = (MethodBinding) methodsFound.elementAt(i);
        if (method == otherMethod)
          continue next;

        if (CharOperation.equals(method.selector, otherMethod.selector, true)
            && this.lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) {
          continue next;
        }
      }

      newMethodsFound.add(method);

      int length = method.parameters.length;
      char[][] parameterPackageNames = new char[length][];
      char[][] parameterFullTypeNames = new char[length][];

View Full Code Here

    char[] castedReceiver,
    int receiverStart,
    int receiverEnd) {

    boolean completionOnReferenceExpressionName = invocationSite instanceof ReferenceExpression;
    ObjectVector newMethodsFound =  new ObjectVector();
    // Inherited methods which are hidden by subclasses are filtered out
    // No visibility checks can be performed without the scope & invocationSite

    int methodLength = methodName.length;
    int minTypeArgLength = typeArgTypes == null ? 0 : typeArgTypes.length;
    int minArgLength = argTypes == null ? 0 : argTypes.length;

    next : for (int f = methods.length; --f >= 0;) {
      MethodBinding method = methods[f];

      if (method.isSynthetic()) continue next;

      if (method.isDefaultAbstract())  continue next;

      if (method.isConstructor()) continue next;

      if (this.options.checkDeprecation &&
          method.isViewedAsDeprecated() &&
          !scope.isDefinedInSameUnit(method.declaringClass))
        continue next;

      //TODO (david) perhaps the relevance of a void method must be lesser than other methods
      //if (expectedTypesPtr > -1 && method.returnType == BaseTypes.VoidBinding) continue next;

      if (onlyStaticMethods && !method.isStatic()) continue next;

      if (this.options.checkVisibility
        && !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next;

      if(superCall && method.isAbstract()) {
        methodsFound.add(new Object[]{method, receiverType});
        continue next;
      }

      if (exactMatch) {
        if (!CharOperation.equals(methodName, method.selector, false /* ignore case */)) {
          continue next;
        }
      } else {
        if (methodLength > method.selector.length) continue next;
        if (!CharOperation.prefixEquals(methodName, method.selector, false /* ignore case */)
            && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) {
          continue next;
        }
      }

      if (minTypeArgLength != 0 && minTypeArgLength != method.typeVariables.length)
        continue next;

      if (minTypeArgLength != 0) {
        method = scope.environment().createParameterizedGenericMethod(method, typeArgTypes);
      }

      if (minArgLength > method.parameters.length)
        continue next;

      for (int a = minArgLength; --a >= 0;){
        if (argTypes[a] != null) { // can be null if it could not be resolved properly
          if (!argTypes[a].isCompatibleWith(method.parameters[a])) {
            continue next;
          }
        }
      }

      boolean prefixRequired = false;

      for (int i = methodsFound.size; --i >= 0;) {
        Object[] other = (Object[]) methodsFound.elementAt(i);
        MethodBinding otherMethod = (MethodBinding) other[0];
        ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
        if (method == otherMethod && TypeBinding.equalsEquals(receiverType, otherReceiverType))
          continue next;

        if (CharOperation.equals(method.selector, otherMethod.selector, true)) {
          if (TypeBinding.equalsEquals(receiverType, otherReceiverType)) {
            if (this.lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) {
              if (!superCall || !otherMethod.declaringClass.isInterface()) {
                continue next;
              }
            }
          } else {
            if (this.lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) {
              if(receiverType.isAnonymousType()) continue next;

              if(!superCall) {
                if(!canBePrefixed) continue next;

                prefixRequired = true;
              }
            }
          }
        }
      }

      newMethodsFound.add(new Object[]{method, receiverType});

      ReferenceBinding superTypeWithSameErasure = (ReferenceBinding)receiverType.findSuperTypeOriginatingFrom(method.declaringClass);
      if (TypeBinding.notEquals(method.declaringClass, superTypeWithSameErasure)) {
        MethodBinding[] otherMethods = superTypeWithSameErasure.getMethods(method.selector);
        for (int i = 0; i < otherMethods.length; i++) {
View Full Code Here

    boolean exactMatch,
    ObjectVector methodsFound,
    ReferenceBinding receiverType,
    InvocationSite invocationSite) {

    ObjectVector newMethodsFound =  new ObjectVector();

    next : for (int f = methods.length; --f >= 0;) {
      MethodBinding method = methods[f];

      if (method.isSynthetic()) continue next;

      if (method.isDefaultAbstract())  continue next;

      if (method.isConstructor()) continue next;

      if (!method.isStatic()) continue next;

      if (this.options.checkDeprecation &&
          method.isViewedAsDeprecated() &&
          !scope.isDefinedInSameUnit(method.declaringClass))
        continue next;

      if (this.options.checkVisibility
        && !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next;

      for (int i = methodsFound.size; --i >= 0;) {
        Object[] other = (Object[]) methodsFound.elementAt(i);
        MethodBinding otherMethod = (MethodBinding) other[0];
        ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
        if (method == otherMethod && TypeBinding.equalsEquals(receiverType, otherReceiverType))
          continue next;

        if (CharOperation.equals(method.selector, otherMethod.selector, true)) {
          if (this.lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) {
            continue next;
          }
        }
      }

      newMethodsFound.add(new Object[]{method, receiverType});

      int length = method.parameters.length;
      char[][] parameterPackageNames = new char[length][];
      char[][] parameterTypeNames = new char[length][];
View Full Code Here

        scope,
        invocationSite,
        invocationScope,
        exactMatch,
        false,
        new ObjectVector(),
        new ObjectVector(),
        methodsFound,
        false,
        proposeMethod);
  }
View Full Code Here

          receiverType,
          scope,
          scope.enclosingSourceType(),
          false,
          true,
          new ObjectVector(),
          missingElements,
          missingElementsStarts,
          missingElementsEnds,
          missingElementsHaveProblems);
    }
    if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
      findClassField(
          token,
          receiverType,
          scope,
          missingElements,
          missingElementsStarts,
          missingElementsEnds,
          missingElementsHaveProblems);
    }

    MethodScope methodScope = null;
    if (!isInsideAnnotationAttribute &&
        !this.requestor.isIgnored(CompletionProposal.KEYWORD) &&
        ((scope instanceof MethodScope && !((MethodScope)scope).isStatic)
        || ((methodScope = scope.enclosingMethodScope()) != null && !methodScope.isStatic))) {
      if (token.length > 0) {
        findKeywords(token, new char[][]{Keywords.THIS}, true, false);
      } else {
        int relevance = computeBaseRelevance();
        relevance += computeRelevanceForResolution();
        relevance += computeRelevanceForInterestingProposal();
        relevance += computeRelevanceForCaseMatching(this.completionToken, Keywords.THIS);
        relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for keywords
        relevance += R_NON_INHERITED;

        this.noProposal = false;
        if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
          InternalCompletionProposal proposal =  createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition);
          proposal.setName(Keywords.THIS);
          proposal.setCompletion(Keywords.THIS);
          proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
          proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
          proposal.setRelevance(relevance);
          this.requestor.accept(proposal);
          if (DEBUG) {
            this.printDebug(proposal);
          }
        }
      }
    }

    if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
      findFields(
        token,
        receiverType,
        scope,
        new ObjectVector(),
        new ObjectVector(),
        true,
        invocationSite,
        scope,
        false,
        false,
        missingElements,
        missingElementsStarts,
        missingElementsEnds,
        missingElementsHaveProblems,
        null,
        -1,
        -1);
    }

    if (!isInsideAnnotationAttribute && !this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
      findMethods(
        token,
        null,
        null,
        receiverType,
        scope,
        new ObjectVector(),
        true,
        false,
        invocationSite,
        scope,
        false,
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.