/** * Adds a proposal. * * @param proposal the string to be inserted * @param cursorPosition the cursor position after insertion, * relative to the start of the proposal * @param displayString the proposal's label * @param additionalInfo the additional information */ private void addProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) { fProposals.add(new CompletionProposal(proposal, fDocumentOffset, 0, cursorPosition, null, displayString, null, additionalInfo)); }
/** * Adds a proposal to the priority proposals list. * * @param proposal the string to be inserted * @param displayString the proposal's label * @param additionalInfo the additional information */ private void addPriorityProposal(String proposal, String displayString, String additionalInfo) { fPriorityProposals.add(new CompletionProposal(proposal, fDocumentOffset, 0, proposal.length(), null, displayString, null, additionalInfo)); }
/** * Adds a proposal. * * @param proposal the string to be inserted * @param displayString the proposal's label * @param additionalInfo the additional information */ private void addProposal(String proposal, String displayString, String additionalInfo) { fProposals.add(new CompletionProposal(proposal, fDocumentOffset, 0, proposal.length(), null, displayString, null, additionalInfo)); }
public class CustomSourceAssistProcessor implements IXMLContentAssistProcessor { @Override public void addAttributeValuesProposals(XMLNode currentNode, String attributeName, String prefix, ITextViewer viewer, int offset, Collection<ICompletionProposal> results) { if("x".equals(currentNode.getTagName()) && "type".equals(attributeName)) { for (String possibleValue : this.getPossibleValuesFromXML()) { results.add(new CompletionProposal(possibleValue, offset, prefix.length(), 0, null, "Proposal Description...", null, null)); } } if("x".equals(currentNode.getTagName()) && "value".equals(attributeName)) { for (String possibleValue : this.getPossibleValuesFromJavaClass()) { results.add(new CompletionProposal(possibleValue, offset, prefix.length(), 0, null, "Proposal Description...", null, null)); } } }
/** * Returns an array of completion proposals computed based on * the specified document position. The position is used to * determine the appropriate content assist processor to invoke. * * @param viewer the viewer for which to compute the proposals * @param position a document position * @return an array of completion proposals * * @see IContentAssistProcessor#computeCompletionProposals */ ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int position) { if (fProposals != null) { return fProposals; } else if (fProposalStrings != null) { ICompletionProposal[] result= new ICompletionProposal[fProposalStrings.length]; for (int i= 0; i < fProposalStrings.length; i++) { result[i]= new CompletionProposal(fProposalStrings[i], position, fProposalStrings[i].length(), fProposalStrings[i].length()); } return result; } else return null; }
public ICompletionProposal createProposal(int offset, int length) { return new CompletionProposal(display, offset, length, display.length(), getImage(), display, null, null); } }
/** * Returns an array of completion proposals computed based on * the specified document position. The position is used to * determine the appropriate content assist processor to invoke. * * @param viewer the viewer for which to compute the proposals * @param position a document position * @return an array of completion proposals * * @see IContentAssistProcessor#computeCompletionProposals */ ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int position) { if (fProposals != null) { return fProposals; } else if (fProposalStrings != null) { ICompletionProposal[] result= new ICompletionProposal[fProposalStrings.length]; for (int i= 0; i < fProposalStrings.length; i++) { result[i]= new CompletionProposal(fProposalStrings[i], position, fProposalStrings[i].length(), fProposalStrings[i].length()); } return result; } else return null; }
/** * Adds the dn: proposal to the proposal list. * * @param proposalList the proposal list * @param dnAttr the dn attr * @param offset the offset */ private void addDnAttr( List<ICompletionProposal> proposalList, String dnAttr, int offset ) { if ( "dn".toUpperCase().startsWith( dnAttr.toUpperCase() ) ) //$NON-NLS-1$ { String replacementString = "dn:"; //$NON-NLS-1$ String displayString = "dn: ()"; //$NON-NLS-1$ ICompletionProposal proposal = new CompletionProposal( replacementString, offset, dnAttr.length(), replacementString.length(), null, displayString, null, null ); proposalList.add( proposal ); } }
/** * Adds a proposal that starts with a backslash. * * @param proposal the string to be inserted * @param displayString the proposal's label * @param additionalInfo the additional information */ private void addBsProposal(String proposal, String displayString, String additionalInfo) { if (fIsEscape) { fPriorityProposals.add(new CompletionProposal(proposal.substring(1), fDocumentOffset, 0, proposal.length() - 1, null, displayString, null, additionalInfo)); } else { addProposal(proposal, displayString, additionalInfo); } } }
/** * Adds a proposal. Ensures that existing pre- and postfixes are not duplicated. * * @param proposal the string to be inserted * @param cursorPosition the cursor position after insertion, * relative to the start of the proposal * @param displayString the proposal's label * @param additionalInfo the additional information */ private void addBracketProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) { String prolog= fExpression.substring(0, fDocumentOffset); if (! fIsEscape && prolog.endsWith("\\") && proposal.startsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ fProposals.add(new CompletionProposal(proposal, fDocumentOffset, 0, cursorPosition, null, displayString, null, additionalInfo)); return; } for (int i= 1; i <= cursorPosition; i++) { String prefix= proposal.substring(0, i); if (prolog.endsWith(prefix)) { String postfix= proposal.substring(cursorPosition); String epilog= fExpression.substring(fDocumentOffset); if (epilog.startsWith(postfix)) { fPriorityProposals.add(new CompletionProposal(proposal.substring(i, cursorPosition), fDocumentOffset, 0, cursorPosition - i, null, displayString, null, additionalInfo)); } else { fPriorityProposals.add(new CompletionProposal(proposal.substring(i), fDocumentOffset, 0, cursorPosition - i, null, displayString, null, additionalInfo)); } return; } } fProposals.add(new CompletionProposal(proposal, fDocumentOffset, 0, cursorPosition, null, displayString, null, additionalInfo)); }
protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) { List newProposals = super.filterAndSortProposals(proposals, monitor, context); for (Iterator iter = newProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); if (proposal.getDisplayString().startsWith(intertypeMemberTag)) { iter.remove(); } } if (newProposals.size() > 0) { // only add limited message if there are any proposals newProposals.add(newProposals.size(), new CompletionProposal("", offset, 0, 0, null, UIMessages.codeAssist_limited_title, null, UIMessages.codeAssist_limited_message));//$NON-NLS-1$ ) } return newProposals; }
ICompletionProposal proposal = new CompletionProposal( string + ", ", start, //$NON-NLS-1$ documentOffset - start, string.length() + 2, null, string, null, null ); proposalList.add( proposal );
ICompletionProposal proposal = new CompletionProposal( replacementString, offset, attributeType .length(), replacementString.length(), getAttributeTypeImage(), displayString, null, info ); proposalList.add( proposal );
String displayString = copy.get( possibleFilterType ); ICompletionProposal proposal = new CompletionProposal( replacementString, offset, filterType.length(), possibleFilterType.length(), getFilterTypeImage(), displayString, null, null ); proposalList.add( proposal );
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ICompletionProposal[] result= new ICompletionProposal[Syntax.HELP.size()]; int i=0; for ( Syntax s : Syntax.HELP.values()) { IContextInformation info= new ContextInformation( s.getHeader(), s.getHeader()); result[i++]= new CompletionProposal(s.getHeader()+": ", offset-1, 1, s.getHeader().length()+2, null, s.getHeader(), info, s.getLead()); //$NON-NLS-1$ } return result; }
ICompletionProposal proposal = new CompletionProposal( replacementString, offset, objectClass .length(), replacementString.length(), getObjectClassImage(), displayString, null, SchemaUtils .getLdifLine( schema.getObjectClassDescription( possibleObjectClass ) ) );
for (String message : messages) if (message.startsWith(prefix)) proposals.add(new CompletionProposal(message, replacementOffset, replacementLength, message .length(), (Image) resourceManager } else { for (String message : messages) proposals.add(new CompletionProposal(message, offset, 0, message.length(), (Image) resourceManager .get(UIIcons.ELCL16_COMMENTS),
ICompletionProposal proposal = new CompletionProposal( replacementString, offset, matchingRule .length(), replacementString.length(), getMatchingRuleImage(), displayString, null, info ); proposalList.add( proposal );
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ICompletionProposal[] result= new ICompletionProposal[Syntax.HELP.size()]; int i=0; for ( Syntax s : Syntax.HELP.values()) { IContextInformation info= new ContextInformation( s.getHeader(), s.getHeader() +"-"+s.getLead()); result[i++]= new CompletionProposal(s.getHeader(), offset, 0, s.getHeader().length(), null, s.getLead(), info, s.getExample()); //$NON-NLS-1$ } return result; }
proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.MissingEndTag : int firstChildStartOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[4]).intValue(); int endOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[5]).intValue(); proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$ proposals.add(new CompletionProposal("", invocationContext.getOffset(), startTagEndOffset - invocationContext.getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ break; case ProblemIDsXML.AttrsInEndTag : proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.MissingAttrValue : String defaultAttrValue = (String) ((Object[]) fAdditionalFixInfo)[0]; int insertOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue(); proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", invocationContext.getOffset() + invocationContext.getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.NoAttrValue : defaultAttrValue = (String) fAdditionalFixInfo; proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", invocationContext.getOffset() + invocationContext.getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.SpacesBeforeTagName : proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ break; case ProblemIDsXML.SpacesBeforePI :