/** * Returns <code>true</code> if the method being inserted has at least one parameter. Note * that this does not say anything about whether the argument list should be inserted. * * @return <code>true</code> if the method has any parameters, <code>false</code> if it has no parameters * @since 3.4 */ private boolean hasParameters() { CompletionProposal proposal= ((MemberProposalInfo)getProposalInfo()).fProposal; return Signature.getParameterCount(proposal.getSignature()) > 0; }
/** * Returns <code>true</code> if the method being inserted has at least one parameter. Note * that this does not say anything about whether the argument list should be inserted. * * @return <code>true</code> if the method has any parameters, <code>false</code> if it has no parameters * @since 3.4 */ private boolean hasParameters() { CompletionProposal proposal= ((MemberProposalInfo)getProposalInfo()).fProposal; return Signature.getParameterCount(proposal.getSignature()) > 0; }
@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 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 ProposalInfo getProposalInfo() { ProposalInfo info = super.getProposalInfo(); if (info == null) { final IJavaProject project = fInvocationContext.getProject(); info = new AnonymousTypeProposalInfo(project, coreProposal); setProposalInfo(info); } return info; }
@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 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 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 int getPrefixCompletionStart(IDocument document, int completionOffset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefixCompletionStart(document, completionOffset); return coreProposal.getRequiredProposals()[0].getReplaceStart(); }
@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 int getPrefixCompletionStart(IDocument document, int completionOffset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefixCompletionStart(document, completionOffset); return coreProposal.getRequiredProposals()[0].getReplaceStart(); }
@Override protected ProposalInfo getProposalInfo() { ProposalInfo info = super.getProposalInfo(); if (info == null) { final IJavaProject project = subwordsContext.getContext().getProject(); final CompletionProposal proposal = subwordsContext.getProposal(); info = new AnonymousTypeProposalInfo(project, proposal); setProposalInfo(info); } return info; }
@Override protected String getPrefix(IDocument document, int offset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefix(document, offset); int replacementOffset= coreProposal.getRequiredProposals()[0].getReplaceStart(); try { int length= offset - replacementOffset; if (length > 0) return document.get(replacementOffset, length); } catch (BadLocationException x) { } return ""; //$NON-NLS-1$ }
@Override protected String getPrefix(IDocument document, int offset) { CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; if (coreProposal.getKind() != CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) return super.getPrefix(document, offset); int replacementOffset= coreProposal.getRequiredProposals()[0].getReplaceStart(); try { int length= offset - replacementOffset; if (length > 0) return document.get(replacementOffset, length); } catch (BadLocationException x) { } return ""; //$NON-NLS-1$ }
protected IContextInformation computeContextInformation() { try { fContextInformationPosition= getReplacementOffset() - 1; CompletionProposal proposal= ((MemberProposalInfo)getProposalInfo()).fProposal; // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if (hasParameters() && (getReplacementString().endsWith(")") || getReplacementString().length() == 0)) { //$NON-NLS-1$ ProposalContextInformation contextInformation= new ProposalContextInformation(proposal); fContextInformationPosition= getReplacementOffset() + getCursorPosition(); if (fContextInformationPosition != 0 && proposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return null; } finally { fIsContextInformationComputed= true; } }
protected IContextInformation computeContextInformation() { try { fContextInformationPosition= getReplacementOffset() - 1; CompletionProposal proposal= ((MemberProposalInfo)getProposalInfo()).fProposal; // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if (hasParameters() && (getReplacementString().endsWith(")") || getReplacementString().length() == 0)) { //$NON-NLS-1$ ProposalContextInformation contextInformation= new ProposalContextInformation(proposal); fContextInformationPosition= getReplacementOffset() + getCursorPosition(); if (fContextInformationPosition != 0 && proposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return null; } finally { fIsContextInformationComputed= true; } }
return false; CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; boolean isAnonymousConstructorInvoc= coreProposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION;
return false; CompletionProposal coreProposal= ((MemberProposalInfo)getProposalInfo()).fProposal; boolean isAnonymousConstructorInvoc= coreProposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION;