本文整理匯總了Java中org.eclipse.jface.text.contentassist.IContentAssistProcessor類的典型用法代碼示例。如果您正苦於以下問題:Java IContentAssistProcessor類的具體用法?Java IContentAssistProcessor怎麽用?Java IContentAssistProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IContentAssistProcessor類屬於org.eclipse.jface.text.contentassist包,在下文中一共展示了IContentAssistProcessor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLanguageElementAt
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的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: getContentAssistant
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
IContentAssistProcessor processor = new EiffelContentAssistantProcessor();
assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.setContentAssistProcessor(new EiffelContentAssistantProcessor(),
IDocument.DEFAULT_CONTENT_TYPE);
assistant.setAutoActivationDelay(100);
assistant.enableAutoActivation(true);
assistant.enableAutoInsert(true);
assistant.setProposalSelectorBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
return assistant;
}
示例3: internalComputeCompletionProposals
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的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();
}
}
示例4: getContextInformationValidator
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
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;
}
示例5: getContentAssistant
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
@Override public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer)
{
// Create content assistant
final ContentAssistant assistant = new ContentAssistant();
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500);
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setInformationControlCreator(this.getInformationControlCreator(sourceViewer));
// Create content assistant processor
final IContentAssistProcessor processor = new DMContentAssistProcessor();
// Set this processor for each supported content type
assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(processor, DMPartitionScanner.DM_STRING);
// Return the content assistant
return assistant;
}
示例6: computeProposals
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
/**
* Returns the completion proposal available at the given offset of the viewer's document. Delegates the work to the
* code assistant.
*
* @param offset
* the offset
* @param autoActivated
* @return the completion proposals available at this offset
*/
private ICompletionProposal[] computeProposals(int offset, boolean autoActivated)
{
if (fContentAssistSubjectControl != null)
{
return fContentAssistant.computeCompletionProposals(fContentAssistSubjectControl, offset, fActivationKey);
}
IContentAssistProcessor processor = fContentAssistant.getProcessor(fViewer, offset);
if (processor == null) {
return null;
}
if (processor instanceof ICommonContentAssistProcessor) {
ICommonContentAssistProcessor commonProcessor = (ICommonContentAssistProcessor)processor;
return commonProcessor.computeCompletionProposals(fViewer, offset, fActivationKey, autoActivated);
} else {
return processor.computeCompletionProposals(fViewer, offset);
}
}
示例7: setContentAssistProcessor
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
/**
* Registers a given code assist processor for a particular content type. If there is already a processor registered
* for this type, the new processor is registered instead of the old one.
*
* @param processor
* the code assist processor to register, or <code>null</code> to remove an existing one
* @param contentType
* the content type under which to register
*/
public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType)
{
if (fProcessors == null)
{
fProcessors = new HashMap<String, IContentAssistProcessor>();
}
if (processor == null)
{
fProcessors.remove(contentType);
}
else
{
fProcessors.put(contentType, processor);
}
}
示例8: getProcessor
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
/**
* Returns the code assist processor for the content type of the specified document position.
*
* @param viewer
* the text viewer
* @param offset
* a offset within the document
* @return a content-assist processor or <code>null</code> if none exists
* @since 3.0
*/
public IContentAssistProcessor getProcessor(ITextViewer viewer, int offset)
{
try
{
IDocument document = viewer.getDocument();
String type = TextUtilities.getContentType(document, getDocumentPartitioning(), offset, true);
return getContentAssistProcessor(type);
}
catch (BadLocationException x)
{
}
return null;
}
示例9: computeContextInformation
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
/**
* Returns an array of context information objects computed based on the specified document position. The position
* is used to determine the appropriate code assist processor to invoke.
*
* @param viewer
* the viewer for which to compute the context information
* @param offset
* a document offset
* @return an array of context information objects
* @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
*/
IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
fLastErrorMessage = null;
IContextInformation[] result = null;
IContentAssistProcessor p = getProcessor(viewer, offset);
if (p != null)
{
result = p.computeContextInformation(viewer, offset);
fLastErrorMessage = p.getErrorMessage();
}
return result;
}
示例10: getContentAssistProcessor
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
if (contentType.startsWith(JSSourceConfiguration.PREFIX))
{
return JSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
}
if (contentType.startsWith(CSSSourceConfiguration.PREFIX))
{
return CSSSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
}
if (contentType.startsWith(SVGSourceConfiguration.PREFIX))
{
return SVGSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
}
return new HTMLContentAssistProcessor(editor);
}
示例11: addFieldNameField
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
private void addFieldNameField(Composite result) {
Label nameLabel= new Label(result, SWT.NONE);
nameLabel.setText(RefactoringMessages.PromoteTempInputPage_Field_name);
nameLabel.setLayoutData(new GridData());
String[] guessedFieldNames= getPromoteTempRefactoring().guessFieldNames();
String firstGuessedFieldName= guessedFieldNames[0];
fNameField = new Text(result, SWT.BORDER | SWT.SINGLE);
fNameField.setText(firstGuessedFieldName);
getPromoteTempRefactoring().setFieldName(firstGuessedFieldName);
fNameField.selectAll();
fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameField.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e) {
PromoteTempInputPage.this.getPromoteTempRefactoring().setFieldName(fNameField.getText());
PromoteTempInputPage.this.updateStatus();
}
});
IContentAssistProcessor processor= new FieldNameProcessor(guessedFieldNames, getPromoteTempRefactoring());
ControlContentAssistHelper.createTextContentAssistant(fNameField, processor);
TextFieldNavigationHandler.install(fNameField);
}
示例12: addFieldNameField
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
private void addFieldNameField(Composite result) {
Label nameLabel= new Label(result, SWT.NONE);
nameLabel.setText(RefactoringMessages.PromoteTempInputPage_Field_name);
nameLabel.setLayoutData(new GridData());
String[] guessedFieldNames= getPromoteTempRefactoring().guessFieldNames();
fNameField = new Text(result, SWT.BORDER | SWT.SINGLE);
fNameField.setText(guessedFieldNames[0]);
fNameField.selectAll();
fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameField.addModifyListener(new ModifyListener(){
public void modifyText(ModifyEvent e) {
PromoteTempInputPage.this.getPromoteTempRefactoring().setFieldName(fNameField.getText());
PromoteTempInputPage.this.updateStatus();
}
});
IContentAssistProcessor processor= new FieldNameProcessor(guessedFieldNames, getPromoteTempRefactoring());
ControlContentAssistHelper.createTextContentAssistant(fNameField, processor);
TextFieldNavigationHandler.install(fNameField);
}
示例13: configContentAssistant
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
public static IContentAssistant configContentAssistant(IPySyntaxHighlightingAndCodeCompletionEditor edit,
PyContentAssistant pyContentAssistant) {
// next create a content assistant processor to populate the completions window
IContentAssistProcessor processor = new SimpleAssistProcessor(edit, new PythonCompletionProcessor(edit,
pyContentAssistant), pyContentAssistant);
PythonStringCompletionProcessor stringProcessor = new PythonStringCompletionProcessor(edit, pyContentAssistant);
// No code completion in comments and strings
for (String s : STRING_PROCESSOR_PARTITIONS) {
pyContentAssistant.setContentAssistProcessor(stringProcessor, s);
}
pyContentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
pyContentAssistant.enableAutoActivation(true); //always true, but the chars depend on whether it is activated or not in the preferences
//note: delay and auto activate are set on PyContentAssistant constructor.
pyContentAssistant.setDocumentPartitioning(IPythonPartitions.PYTHON_PARTITION_TYPE);
pyContentAssistant.setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay());
return pyContentAssistant;
}
示例14: createSourceViewerConfiguration
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
@Override
public SourceViewerConfiguration createSourceViewerConfiguration() {
PyContentAssistant contentAssist = new PyContentAssistant();
IContentAssistProcessor processor = createConsoleCompletionProcessor(contentAssist);
contentAssist.setContentAssistProcessor(processor, PydevScriptConsoleSourceViewerConfiguration.PARTITION_TYPE);
contentAssist.enableAutoActivation(true);
contentAssist.enableAutoInsert(false);
contentAssist.setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay());
PyCorrectionAssistant quickAssist = new PyCorrectionAssistant();
// next create a content assistant processor to populate the completions window
IQuickAssistProcessor quickAssistProcessor = createConsoleQuickAssistProcessor(quickAssist);
// Correction assist works on all
quickAssist.setQuickAssistProcessor(quickAssistProcessor);
SourceViewerConfiguration cfg = new PydevScriptConsoleSourceViewerConfiguration(createHover(), contentAssist,
quickAssist);
return cfg;
}
示例15: getContentAssistant
import org.eclipse.jface.text.contentassist.IContentAssistProcessor; //導入依賴的package包/類
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant contentAssistant = new ContentAssistant();
IContentAssistProcessor processor = new AsciidocContentAssistProcessor();
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
return contentAssistant;
}