本文整理匯總了Java中org.eclipse.jface.text.contentassist.IContentAssistant.getContentAssistProcessor方法的典型用法代碼示例。如果您正苦於以下問題:Java IContentAssistant.getContentAssistProcessor方法的具體用法?Java IContentAssistant.getContentAssistProcessor怎麽用?Java IContentAssistant.getContentAssistProcessor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.contentassist.IContentAssistant
的用法示例。
在下文中一共展示了IContentAssistant.getContentAssistProcessor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLanguageElementAt
import org.eclipse.jface.text.contentassist.IContentAssistant; //導入方法依賴的package包/類
/**
* Get language at given offset
*
* @param offset
* @param textViewer
* @return language element or <code>null</code>
*/
protected HoverDataRegion getLanguageElementAt(int offset, ITextViewer textViewer) {
IContentAssistant assist = gradleSourceViewerConfiguration.getContentAssistant(sourceViewer);
if (assist == null) {
return null;
}
IContentAssistProcessor processor = assist.getContentAssistProcessor(contentType);
if (!(processor instanceof GradleContentAssistProcessor)) {
return null;
}
GradleContentAssistProcessor gprocessor = (GradleContentAssistProcessor) processor;
String allText = textViewer.getDocument().get();
RelevantCodeCutter codeCutter = this.codeCutter;
Model model = gprocessor.getModel();
GradleFileType fileType = gradleSourceViewerConfiguration.getFileType();
GradleLanguageElementEstimater estimator = gprocessor.getEstimator();
HoverData data = hoverSupport.caclulateHoverData(allText, offset, codeCutter, model, fileType, estimator);
if (data == null) {
return null;
}
return new HoverDataRegion(data);
}
示例2: internalComputeCompletionProposals
import org.eclipse.jface.text.contentassist.IContentAssistant; //導入方法依賴的package包/類
/**
* Internally compute completion proposals.
*
* @param cursorPosition
* the position of the cursor in the {@link IXtextDocument}
* @param xtextDocument
* the {@link IXtextDocument}
* @return a pair of {@link ICompletionProposal}[] and {@link BadLocationException}. If the tail argument is not {@code null}, an exception occurred in the UI
* thread.
*/
private Pair<ICompletionProposal[], BadLocationException> internalComputeCompletionProposals(final int cursorPosition, final IXtextDocument xtextDocument) {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
Shell shell = new Shell();
try {
ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
String contentType = xtextDocument.getContentType(cursorPosition);
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
if (processor != null) {
return Tuples.create(processor.computeCompletionProposals(sourceViewer, cursorPosition), null);
}
return Tuples.create(new ICompletionProposal[0], null);
} catch (BadLocationException e) {
return Tuples.create(new ICompletionProposal[0], e);
} finally {
shell.dispose();
}
}
示例3: createCompletionProposalComputer
import org.eclipse.jface.text.contentassist.IContentAssistant; //導入方法依賴的package包/類
/**
* Helper function to find the correct CompletionProposalComputer for the given offset.
*
* @param offset
* offset in test file
* @return language and offset specific content assist proposal computer
*/
private CompletionProposalComputer createCompletionProposalComputer(final int offset) {
XtextSourceViewerConfiguration configuration = getEditor().getXtextSourceViewerConfiguration();
IContentAssistant contentAssistant = configuration.getContentAssistant(getViewer());
IContentAssistProcessor contentAssistProcessor;
try {
contentAssistProcessor = contentAssistant.getContentAssistProcessor(getDocument().getContentType(offset));
} catch (BadLocationException e) {
contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
}
if (contentAssistProcessor == null) {
contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
}
return new CompletionProposalComputer((State) contentAssistProcessor, (ITextViewer) getViewer(), offset);
}
示例4: requestProposals
import org.eclipse.jface.text.contentassist.IContentAssistant; //導入方法依賴的package包/類
/**
* Requests proposals in the last location of the given editor.
*/
protected ICompletionProposal[] requestProposals(String mod1Contents, PyEdit editor) {
editor.setSelection(mod1Contents.length(), 0);
IContentAssistant contentAssistant = editor.getEditConfiguration().getContentAssistant(
editor.getPySourceViewer());
SimpleAssistProcessor processor = (SimpleAssistProcessor) contentAssistant
.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
processor.doCycle(); //we want to show the default completions in this case (not the simple ones)
ICompletionProposal[] props = processor.computeCompletionProposals(editor.getPySourceViewer(),
mod1Contents.length());
return props;
}