private boolean isSupportingRequiredProposals(CompletionProposal proposal) { return proposal != null && (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.FIELD_REF || proposal.getKind() == CompletionProposal.TYPE_REF || proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION); }
private String getProposal(CompletionProposal proposal) { try { for (Field field : CompletionProposal.class.getDeclaredFields()) { if (int.class.equals(field.getType()) && Integer.valueOf(proposal.getKind()).equals(field.get(null))) { return field.getName(); } } } catch (Exception e) { } return "unknown"; } }
protected char[] computeTriggerCharacters() { if (fProposal.getKind() == CompletionProposal.METHOD_NAME_REFERENCE) return METHOD_NAME_TRIGGERS; if (hasParameters()) return METHOD_WITH_ARGUMENTS_TRIGGERS; return METHOD_TRIGGERS; }
protected boolean hasArgumentList(CompletionProposal proposal) { if (CompletionProposal.METHOD_NAME_REFERENCE == proposal.getKind()) { return false; } char[] completion= proposal.getCompletion(); return !isInJavadoc() && completion.length > 0 && completion[completion.length - 1] == RPAREN; }
/** * Creates the context information for a given method reference proposal. * The passed proposal must be of kind {@link CompletionProposal#METHOD_REF}. * * @param methodProposal the method proposal for which to create context information * @return the context information for <code>methodProposal</code> */ protected final IContextInformation createMethodContextInformation(CompletionProposal methodProposal) { Assert.isTrue(methodProposal.getKind() == CompletionProposal.METHOD_REF); return new ProposalContextInformation(methodProposal); }
/** * Creates the context information for a given method reference proposal. * The passed proposal must be of kind {@link CompletionProposal#METHOD_REF}. * * @param methodProposal the method proposal for which to create context information * @return the context information for <code>methodProposal</code> */ protected final IContextInformation createMethodContextInformation(CompletionProposal methodProposal) { Assert.isTrue(methodProposal.getKind() == CompletionProposal.METHOD_REF); return new ProposalContextInformation(methodProposal); }
/** * Creates the context information for a given method reference proposal. * The passed proposal must be of kind {@link CompletionProposal#METHOD_REF}. * * @param methodProposal the method proposal for which to create context information * @return the context information for <code>methodProposal</code> */ protected final IContextInformation createMethodContextInformation(CompletionProposal methodProposal) { Assert.isTrue(methodProposal.getKind() == CompletionProposal.METHOD_REF); return new ProposalContextInformation(methodProposal); }
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefixCompletionText(document, completionOffset); return String.valueOf(coreProposal.getName()); }
@Override protected boolean isPrefix(String prefix, String string) { if (fProposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER && prefix != null) prefix= prefix.substring(fProposal.getReceiverEnd() - fProposal.getReceiverStart() + 1); return super.isPrefix(prefix, string); }
@Override public void accept(CompletionProposal proposal) { if (!isIgnored(proposal.getKind())) { if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) { // Hacky way to boost relevance of current package, for package completions, until // https://bugs.eclipse.org/518140 is fixed proposal.setRelevance(proposal.getRelevance() + 1); } proposals.add(proposal); } }
StyledString createModuleProposalLabel(CompletionProposal proposal) { int kind= proposal.getKind(); Assert.isTrue(kind == CompletionProposal.MODULE_REF || kind == CompletionProposal.MODULE_DECLARATION); char[] label= proposal.getDeclarationSignature(); Assert.isNotNull(label); return Strings.markJavaElementLabelLTR(new StyledString(String.valueOf(label))); }
@Override protected IContextInformation computeContextInformation() { // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if ((fProposal.getKind() == CompletionProposal.METHOD_REF || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) && hasParameters() && (getReplacementString().endsWith(RPAREN) || getReplacementString().endsWith(SEMICOLON) || getReplacementString().length() == 0)) { ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return super.computeContextInformation(); }
@Override protected boolean isOffsetValid(int offset) { if (fProposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) return super.isOffsetValid(offset); return fProposal.getRequiredProposals()[0].getReplaceStart() <= offset; }
protected IJavaCompletionProposal createJavaCompletionProposal(CompletionProposal proposal) { switch (proposal.getKind()) { case CompletionProposal.METHOD_REF: return createMethodReferenceProposal(proposal); case CompletionProposal.TYPE_REF: return createTypeProposal(proposal); default: return super.createJavaCompletionProposal(proposal); } }
@Override protected boolean isValidPrefix(String prefix) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.isValidPrefix(prefix); return super.isValidPrefix(prefix) || isPrefix(prefix, String.valueOf(coreProposal.getName())); }
@Override public void accept(CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.TYPE_REF) { addType(proposal.getSignature(), proposal.getFlags(), proposal.getRelevance()); } }
@Override protected boolean isValidPrefix(String prefix) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.isValidPrefix(prefix); return super.isValidPrefix(prefix) || isPrefix(prefix, String.valueOf(coreProposal.getName())); }
protected IContextInformation computeContextInformation() { // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if (fProposal.getKind() == CompletionProposal.METHOD_REF && hasParameters() && (getReplacementString().endsWith(RPAREN) || getReplacementString().length() == 0)) { ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return super.computeContextInformation(); }
@Override protected boolean isOffsetValid(int offset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.isOffsetValid(offset); return coreProposal.getRequiredProposals()[0].getReplaceStart() <= offset; }
@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { if (hasArgumentList() || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) { String completion= String.valueOf(fProposal.getName()); if (isCamelCaseMatching()) { String prefix= getPrefix(document, completionOffset); return getCamelCaseCompound(prefix, completion); } return completion; } return super.getPrefixCompletionText(document, completionOffset); }