@Override public void run() throws Exception { result[0]= p.computeCompletionProposals(viewer, offset); fLastErrorMessage= p.getErrorMessage(); } });
@Override public void run() throws Exception { result[0]= p.computeContextInformation(viewer, offset); fLastErrorMessage= p.getErrorMessage(); } });
/** * @return whether the given char is an auto-activation trigger char * @since 3.15 */ boolean isAutoActivationTriggerChar(char c) { if (fProcessors == null) return false; for (Set<IContentAssistProcessor> processorsForContentType : fProcessors.values()) { for (IContentAssistProcessor processor : processorsForContentType) { char[] triggers= processor.getCompletionProposalAutoActivationCharacters(); if (triggers != null && new String(triggers).indexOf(c) >= 0) { return true; } triggers= processor.getContextInformationAutoActivationCharacters(); if (triggers != null && new String(triggers).indexOf(c) >= 0) { return true; } } } return false; }
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { ICompletionProposal[] allProposals = null; for (IContentAssistProcessor delegate : delegates) { allProposals = merge(allProposals, delegate.computeCompletionProposals(viewer, offset)); } return allProposals; }
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { IContextInformation[] allInformation = null; for (IContentAssistProcessor delegate : delegates) { IContextInformation[] information = delegate.computeContextInformation(viewer, offset); allInformation = merge(allInformation, information); } return allInformation; }
public IContextInformationValidator getContextInformationValidator() { List<IContextInformationValidator> validators = null; for (IContentAssistProcessor delegate : delegates) { IContextInformationValidator validator = delegate.getContextInformationValidator(); if (validator != null) { if (validators == null) { validators = new ArrayList<IContextInformationValidator>(); } } } if (validators != null) { // FIXME: return a compound validator return validators.get(0); } return null; }
public String getErrorMessage() { for (IContentAssistProcessor delegate : delegates) { String message = delegate.getErrorMessage(); if (message != null) { return message; } } return null; }
protected void setAutoActivation(ContentAssistant assistant) { if (contentAssistProcessor != null) { boolean activated = contentAssistProcessor.getCompletionProposalAutoActivationCharacters() != null; assistant.enableAutoActivation(activated); } }
/** * Returns the characters which when typed by the user should automatically * initiate the presentation of context information. The position is used * to determine the appropriate content assist processor to invoke. * * @param textViewer the text viewer * @param offset a document offset * @return the auto activation characters * * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters */ private char[] getContextInformationAutoActivationCharacters(ITextViewer textViewer, int offset) { IContentAssistProcessor p= getProcessor(textViewer, offset); return p != null ? p.getContextInformationAutoActivationCharacters() : null; }
/** * Figures out what the correct ICompletionProposalProcessor is and * computesCompletionProposals on that. * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, * int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { IContentAssistProcessor p = null; ICompletionProposal[] results = EMPTY_PROPOSAL_SET; p = guessContentAssistProcessor(viewer, documentOffset); if (p != null) { results = p.computeCompletionProposals(viewer, documentOffset); } return (results != null) ? results : EMPTY_PROPOSAL_SET; }
@Override public boolean isContextInformationValid(int offset) { IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset); if (infos != null && infos.length > 0) { for (int i= 0; i < infos.length; i++) if (fContextInformation.equals(infos[i])) return true; } return false; } }
/** * Returns the context information validator that should be used to determine when the currently * displayed context information should be dismissed. The position is used to determine the * appropriate content assist processor to invoke. * * @param contentAssistSubjectControl the content assist subject control * @param offset a document offset * @return an validator * @see IContentAssistProcessor#getContextInformationValidator() * @since 3.0 */ IContextInformationValidator getContextInformationValidator(IContentAssistSubjectControl contentAssistSubjectControl, int offset) { IContentAssistProcessor p= getProcessor(contentAssistSubjectControl, offset); return p != null ? p.getContextInformationValidator() : null; }
@Override public void run() throws Exception { processors.forEach(p -> { IContextInformation[] contextInformation= p.computeContextInformation(viewer, offset); if (contextInformation != null) { result.addAll(Arrays.asList(contextInformation)); } fLastErrorMessage= p.getErrorMessage(); }); } });
/** * Returns the characters which when typed by the user should automatically initiate proposing * completions. The position is used to determine the appropriate content assist processor to * invoke. * * @param viewer the text viewer * @param offset a document offset * @return the auto activation characters * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ char[] getCompletionProposalAutoActivationCharacters(ITextViewer viewer, int offset) { IContentAssistProcessor p= getProcessor(viewer, offset); return p != null ? p.getCompletionProposalAutoActivationCharacters() : null; }
/** * Returns the characters which when typed by the user should automatically * initiate the presentation of context information. The position is used * to determine the appropriate content assist processor to invoke. * * @param textViewer the text viewer * @param offset a document offset * @return the auto activation characters * * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters */ private char[] getContextInformationAutoActivationCharacters(ITextViewer textViewer, int offset) { IContentAssistProcessor p= getProcessor(textViewer, offset); return p != null ? p.getContextInformationAutoActivationCharacters() : null; }
/** * Returns an array of context information objects 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 context information * @param position a document position * @return an array of context information objects * * @see IContentAssistProcessor#computeContextInformation */ IContextInformation[] computeContextInformation(ITextViewer viewer, int position) { fLastErrorMessage= null; IContextInformation[] result= null; IContentAssistProcessor p= getProcessor(viewer, position); if (p != null) { result= p.computeContextInformation(viewer, position); fLastErrorMessage= p.getErrorMessage(); } return result; }
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition, XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException { IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer); String contentType = xtextDocument.getContentType(cursorPosition); IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType); if (processor != null) { return processor.computeCompletionProposals(sourceViewer, cursorPosition); } return new ICompletionProposal[0]; }
@Override public boolean isContextInformationValid(int offset) { IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset); if (infos != null && infos.length > 0) { for (IContextInformation info : infos) if (fContextInformation.equals(info)) return true; } return false; } }
/** * Returns the context information validator that should be used to determine when the currently * displayed context information should be dismissed. The position is used to determine the * appropriate content assist processor to invoke. * * @param viewer the text viewer * @param offset a document offset * @return an validator * @see IContentAssistProcessor#getContextInformationValidator() * @since 3.0 */ IContextInformationValidator getContextInformationValidator(ITextViewer viewer, int offset) { IContentAssistProcessor p= getProcessor(viewer, offset); return p != null ? p.getContextInformationValidator() : null; }
/** * Computes the sorted set of all auto activation trigger characters. * * @return the sorted set of all auto activation trigger characters * @since 3.1 */ private String computeAllAutoActivationTriggers() { if (fProcessors == null) return ""; //$NON-NLS-1$ StringBuffer buf= new StringBuffer(5); Iterator<Entry<String, IContentAssistProcessor>> iter= fProcessors.entrySet().iterator(); while (iter.hasNext()) { Entry<String, IContentAssistProcessor> entry= iter.next(); IContentAssistProcessor processor= entry.getValue(); char[] triggers= processor.getCompletionProposalAutoActivationCharacters(); if (triggers != null) buf.append(triggers); triggers= processor.getContextInformationAutoActivationCharacters(); if (triggers != null) buf.append(triggers); } return buf.toString(); }