private void findFields( char[] token, boolean canCompleteEmptyToken, List<IField> fields, int kind, List names) { if (fields == null || fields.size() == 0) return; int length = token.length; // String tok = new String(token); if (canCompleteEmptyToken || length > 0) { for (int i = 0; i < fields.size(); i++) { IField field = fields.get(i); String qname = (String) names.get(i); 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.setModelElement(field); proposal.setName(name); proposal.setCompletion(qname); proposal.setRelevance(relevance); accept(proposal); } } } } }
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); } } } } }
public void findTypes(char[] token, boolean canCompleteEmptyToken, List<IType> types) { if (types == null || types.size() == 0) return; int length = token.length; String tok = new String(token); if (canCompleteEmptyToken || length > 0) { for (int i = 0; i < types.size(); i++) { IType type = types.get(i); String qname = processTypeName(type, 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(CompletionProposal.TYPE_REF)) { CompletionProposal proposal = this.createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); // proposal.setSignature(getSignature(typeBinding)); // proposal.setPackageName(q); // proposal.setTypeName(displayName); proposal.setModelElement(type); proposal.setName(name); proposal.setCompletion(name); // proposal.setFlags(Flags.AccDefault); proposal.setRelevance(relevance); accept(proposal); } } } } }