예제 #1
0
  protected void findMethods(
      char[] token, boolean canCompleteEmptyToken, List<IMethod> methods, int kind) {
    if (methods == null || methods.size() == 0) return;

    int length = token.length;
    String tok = new String(token);
    if (canCompleteEmptyToken || length > 0) {
      for (int i = 0; i < methods.size(); i++) {
        IMethod method = methods.get(i);
        String qname = processMethodName(method, tok);
        String name = qname;
        if (DEBUG) {
          System.out.println("Completion:" + qname); // $NON-NLS-1$
        }
        if (length <= name.length() && CharOperation.prefixEquals(token, name, false)) {
          int relevance = computeBaseRelevance();
          relevance += computeRelevanceForInterestingProposal();
          relevance += computeRelevanceForCaseMatching(token, name);
          relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no

          // accept result
          this.noProposal = false;
          if (!this.requestor.isIgnored(kind)) {
            CompletionProposal proposal = this.createProposal(kind, this.actualCompletionPosition);
            // proposal.setSignature(getSignature(typeBinding));
            // proposal.setPackageName(q);
            // proposal.setTypeName(displayName);
            proposal.setModelElement(method);
            try {
              proposal.setFlags(method.getFlags());
            } catch (ModelException e1) {
              if (DLTKCore.DEBUG) {
                e1.printStackTrace();
              }
            }
            String[] arguments = null;

            try {
              arguments = method.getParameterNames();
            } catch (ModelException e) {
              if (DLTKCore.DEBUG) {
                e.printStackTrace();
              }
            }
            if (arguments != null && arguments.length > 0) {
              proposal.setParameterNames(arguments);
            }

            proposal.setName(name);
            proposal.setCompletion(name);
            // proposal.setFlags(Flags.AccDefault);
            proposal.setRelevance(relevance);
            accept(proposal);
          }
        }
      }
    }
  }
예제 #2
0
  protected void findLocalMethods(
      char[] token, boolean canCompleteEmptyToken, List methods, List methodNames) {
    if (methods == null || methods.size() == 0) return;

    int length = token.length;
    if (canCompleteEmptyToken || length > 0) {
      for (int i = 0; i < methods.size(); i++) {
        MethodDeclaration method = (MethodDeclaration) methods.get(i);
        String name = ((String) (methodNames.get(i)));
        if (length <= name.length() && CharOperation.prefixEquals(token, name, false)) {
          int relevance = computeBaseRelevance();
          relevance += computeRelevanceForInterestingProposal();
          relevance += computeRelevanceForCaseMatching(token, name);
          relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no

          // accept result
          this.noProposal = false;
          if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
            CompletionProposal proposal =
                this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
            // proposal.setSignature(getSignature(typeBinding));
            // proposal.setPackageName(q);
            // proposal.setTypeName(displayName);
            List arguments = method.getArguments();
            if (arguments != null && arguments.size() > 0) {
              String[] args = new String[arguments.size()];
              for (int j = 0; j < arguments.size(); ++j) {
                args[j] = ((Argument) arguments.get(j)).getName();
              }
              proposal.setParameterNames(args);
            }

            proposal.setName(name);
            proposal.setCompletion(name);
            // proposal.setFlags(Flags.AccDefault);
            proposal.setRelevance(relevance);
            accept(proposal);
          }
        }
      }
    }
  }