org.eclipse.jface.text.contentassist.IContentAssistant Java Examples
The following examples show how to use
org.eclipse.jface.text.contentassist.IContentAssistant.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckstyleMarkerFilterDialog.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates the content assistant. * * @return the content assistant */ private SubjectControlContentAssistant createContentAssistant() { final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant(); contentAssistant.setRestoreCompletionProposalSize( CheckstyleUIPlugin.getDefault().getDialogSettings()); IContentAssistProcessor processor = new RegExContentAssistProcessor(true); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { /* * @see org.eclipse.jface.text.IInformationControlCreator# createInformationControl( * org.eclipse.swt.widgets.Shell) */ @Override public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); return contentAssistant; }
Example #2
Source File: ConstraintExpressionSourceViewerConfiguration.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) { // returns only Groovy-approved completion proposal categories ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer); assistant.enableAutoActivation(true); assistant.setStatusLineVisible(false); // retain only contract input categories final ExtendedJavaCompletionProcessor processor = new ExtendedJavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); List<CompletionProposalCategory> categories = (List<CompletionProposalCategory>) ReflectionUtils .getPrivateField(ContentAssistProcessor.class, "fCategories", processor); ReflectionUtils.setPrivateField(ContentAssistProcessor.class, "fCategories", processor, categories.stream() .filter(category -> Objects.equals(category.getId(), CONSTRAINT_CONTENT_ASSIST_CATEGORY_ID)) .collect(Collectors.toList())); ContentAssistPreference.configure(assistant, fPreferenceStore); return assistant; }
Example #3
Source File: BonitaGroovyConfiguration.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public IContentAssistant getContentAssistant(final ISourceViewer sourceViewer) { // returns only Groovy-approved completion proposal categories ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer); assistant.setStatusLineVisible(false); // retain only relevant categories IContentAssistProcessor processor = assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE); List<CompletionProposalCategory> categories = (List<CompletionProposalCategory>) ReflectionUtils .getPrivateField(ContentAssistProcessor.class, "fCategories", processor); ReflectionUtils.setPrivateField(ContentAssistProcessor.class, "fCategories", processor, categories.stream() .filter(category -> ALLOWED_CATEGORIES.contains(category.getId())) .collect(Collectors.toList())); ContentAssistPreference.configure(assistant, fPreferenceStore); return assistant; }
Example #4
Source File: AbstractLangSourceViewerConfiguration.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override public ContentAssistant getContentAssistant(ISourceViewer sourceViewer) { if(sourceViewer instanceof LangSourceViewer) { LangSourceViewer langSourceViewer = (LangSourceViewer) sourceViewer; ContentAssistantExt assistant = createContentAssitant(langSourceViewer); assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); assistant.setRestoreCompletionProposalSize(LangUIPlugin.getDialogSettings("completion_proposal_size")); assistant.setInformationControlCreator( getInformationControl_ContentAsssist(getAdditionalInfoAffordanceString())); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.enableColoredLabels(true); configureContentAssistantProcessors(assistant); // Note: configuration must come after processors are created assistant.configure(); return assistant; } return null; }
Example #5
Source File: LangCompletionProposal.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override public void selected(ITextViewer viewer, boolean smartToggle) { if(viewer instanceof ISourceViewerExt) { ISourceViewerExt sourceViewer = (ISourceViewerExt) viewer; IContentAssistant ca = sourceViewer.getContentAssistant(); if(ca instanceof ContentAssistantExt) { caext = (ContentAssistantExt) ca; if(!isAutoInsertable()) { caext.setAdditionalStatusMessage("Press 'Ctrl+Enter' for name-only insertion;"); } else { caext.setAdditionalStatusMessage(null); caext = null; } } } }
Example #6
Source File: SetupContentAssist.java From Pydev with Eclipse Public License 1.0 | 6 votes |
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 : PythonPartitions.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(PyCodeCompletionPreferences.getAutocompleteDelay()); return pyContentAssistant; }
Example #7
Source File: AbstractWorkbenchTestCase.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Requests proposals in the last location of the given editor. */ protected ICompletionProposalHandle[] 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()); ArrayList<ICompletionProposalHandle> lst = new ArrayList<>(props.length); for (ICompletionProposal iCompletionProposal : props) { lst.add((ICompletionProposalHandle) iCompletionProposal); } return lst.toArray(new ICompletionProposalHandle[0]); }
Example #8
Source File: SQLSourceViewerConfiguration.java From birt with Eclipse Public License 1.0 | 6 votes |
public IContentAssistant getContentAssistant( ISourceViewer sourceViewer ) { if ( !enableCodeAssist ) { return null; } ContentAssistant assistant = new ContentAssistant( ); JdbcSQLContentAssistProcessor contentAssist = new JdbcSQLContentAssistProcessor( timeout ); contentAssist.setDataSourceHandle( dsd ); assistant.setContentAssistProcessor( contentAssist, IDocument.DEFAULT_CONTENT_TYPE ); assistant.enableAutoActivation( true ); assistant.setAutoActivationDelay( 500 ); assistant.setProposalPopupOrientation( IContentAssistant.PROPOSAL_OVERLAY ); return assistant; }
Example #9
Source File: TaskSourceViewerConfiguration.java From codeexamples-eclipse with Eclipse Public License 1.0 | 6 votes |
public TaskSourceViewerConfiguration(IPreferenceStore preferenceStore) { super(preferenceStore); // Initialize ContentAssistant contentAssistant = new ContentAssistant(); // define a default ContentAssistProcessor contentAssistant.setContentAssistProcessor (new TaskCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); // enable auto activation contentAssistant.enableAutoActivation(true); // set a proper orientation for the content assist proposal contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); }
Example #10
Source File: JsonSourceViewerConfiguration.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 6 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant ca = new ContentAssistant(); JsonContentAssistProcessor processor = createContentAssistProcessor(ca); ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); ca.setInformationControlCreator(getInformationControlCreator(sourceViewer)); ca.enableAutoInsert(false); ca.enablePrefixCompletion(false); ca.enableAutoActivation(true); ca.setAutoActivationDelay(100); ca.enableColoredLabels(true); ca.setShowEmptyList(true); ca.setRepeatedInvocationMode(true); ca.addCompletionListener(processor); ca.setStatusLineVisible(true); return ca; }
Example #11
Source File: TLASourceViewerConfiguration.java From tlaplus with MIT License | 6 votes |
/** * Content assistant */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(new PCalCompletionProcessor(), TLAPartitionScanner.TLA_PCAL); assistant.enableColoredLabels(true); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setInformationControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(final Shell parent) { return new DefaultInformationControl(parent, (DefaultInformationControl.IInformationPresenter) null); } }); assistant.setSorter(new ICompletionProposalSorter() { public int compare(ICompletionProposal p1, ICompletionProposal p2) { return 0; } }); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor( TLAColorProvider.CONTENT_ASSIST_BACKGROUND_KEY)); return assistant; }
Example #12
Source File: AcfContentAssistProcessorTestBuilder.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * 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(); } }
Example #13
Source File: ModulaSourceViewerConfiguration.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { if (contentAssistant == null) { contentAssistant = new ModulaContentAssistant(sourceViewer); contentAssistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); // configureContentAssistanceProcessorsOld(contentAssistant); configureContentAssistanceProcessors(contentAssistant); contentAssistant.setRepeatedInvocationMode(true); contentAssistant.setAutoActivationDelay(100); contentAssistant.enableAutoActivation(true); contentAssistant.enablePrefixCompletion(false); contentAssistant.enableColoredLabels(true); contentAssistant.enableAutoInsert(true); contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); } return contentAssistant; }
Example #14
Source File: ModulaEditor.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private void refreshContentProposals() { final IContentAssistant contentAssistant = configuration.getContentAssistant(getSourceViewer()); if (contentAssistant instanceof ModulaContentAssistant) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { if (isDisposed()) { return; } ModulaContentAssistant modulaContentAssistant = (ModulaContentAssistant) contentAssistant; if (modulaContentAssistant.isProposalPopupActive()) { modulaContentAssistant.showPossibleCompletions(true); } } }); } }
Example #15
Source File: BibSourceViewerConfiguration.java From texlipse with Eclipse Public License 1.0 | 6 votes |
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { assistant = new ContentAssistant(); assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()), BibPartitionScanner.BIB_ENTRY); assistant.setContentAssistProcessor(new BibCompletionProcessor(this.editor.getDocumentModel()), IDocument.DEFAULT_CONTENT_TYPE); assistant.enableAutoActivation(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BIB_COMPLETION)); assistant.enableAutoInsert(true); assistant.setAutoActivationDelay(TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.BIB_COMPLETION_DELAY)); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); return assistant; }
Example #16
Source File: FileMatchPatternEditDialog.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates the content assistant. * * @return the content assistant */ private SubjectControlContentAssistant createContentAssistant() { final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant(); contentAssistant .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings()); IContentAssistProcessor processor = new RegExContentAssistProcessor(true); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { /* * @see org.eclipse.jface.text.IInformationControlCreator# * createInformationControl( org.eclipse.swt.widgets.Shell) */ @Override public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); return contentAssistant; }
Example #17
Source File: ResolvablePropertyEditDialog.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates the content assistant. * * @return the content assistant */ private SubjectControlContentAssistant createContentAssistant() { final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant(); contentAssistant .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings()); IContentAssistProcessor processor = new PropertiesContentAssistProcessor(); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { /* * @see IInformationControlCreator#createInformationControl(Shell) */ @Override public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); return contentAssistant; }
Example #18
Source File: ContentAssistProcessorTestBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public ContentAssistProcessorTestBuilder assertMatchString(String matchString) throws Exception { String currentModelToParse = getModel(); final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse, getEncoding())); final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse); 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(currentModelToParse.length()); if (contentAssistant.getContentAssistProcessor(contentType) != null) { ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class); ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource); for(ContentAssistContext context: contexts) { Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) || matchString.equals(context.getPrefix())); } } else { Assert.fail("No content assistant for content type " + contentType); } return this; } finally { shell.dispose(); } }
Example #19
Source File: ConfigPropertyWidgetFile.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates the content assistant. * * @return the content assistant */ private SubjectControlContentAssistant createContentAssistant() { final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant(); contentAssistant .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings()); IContentAssistProcessor processor = new PropertiesContentAssistProcessor(); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { /* * @see IInformationControlCreator#createInformationControl(Shell) */ @Override public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); return contentAssistant; }
Example #20
Source File: ConfigPropertyWidgetRegex.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates the content assistant. * * @return the content assistant */ private SubjectControlContentAssistant createContentAssistant() { final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant(); contentAssistant .setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings()); IContentAssistProcessor processor = new RegExContentAssistProcessor(true); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { /* * @see IInformationControlCreator#createInformationControl(Shell) */ @Override public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); return contentAssistant; }
Example #21
Source File: ParameterizeTextView.java From http4e with Apache License 2.0 | 6 votes |
private StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument1()); sourceViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed( KeyEvent e){ // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) { if (Utils.isAutoAssistInvoked(e)) { IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer); ca.showPossibleCompletions(); } } }); return sourceViewer.getTextWidget(); }
Example #22
Source File: ContentAssistProcessorTestBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public ContentAssistProcessorTestBuilder assertMatchString(String matchString) throws Exception { String currentModelToParse = getModel(); final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse)); final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse); 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(currentModelToParse.length()); if (contentAssistant.getContentAssistProcessor(contentType) != null) { ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class); ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource); for(ContentAssistContext context: contexts) { Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) || matchString.equals(context.getPrefix())); } } else { Assert.fail("No content assistant for content type " + contentType); } return this; } finally { shell.dispose(); } }
Example #23
Source File: ExpandSnippetVerifyKeyListener.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public ExpandSnippetVerifyKeyListener(ITextEditor textEditor, ITextViewer viewer, IContentAssistant contentAssistant) { this.textEditor = textEditor; this.canModifyEditor = canModifyEditor(textEditor); // Can we cache this value? this.textViewer = viewer; this.contentAssistant = contentAssistant; document = (textEditor != null) ? textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()) : null; }
Example #24
Source File: JavaSourceViewerConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { if (getEditor() != null) { ContentAssistant assistant= new ContentAssistant(); assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$ IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE); ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING); assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING); ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant); assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC); ContentAssistPreference.configure(assistant, fPreferenceStore); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setInformationControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString()); } }); return assistant; } return null; }
Example #25
Source File: ControlContentAssistHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static SubjectControlContentAssistant createJavaContentAssistant(IContentAssistProcessor processor) { final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant(); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); ContentAssistPreference.configure(contentAssistant, JavaPlugin.getDefault().getPreferenceStore()); contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); contentAssistant.setInformationControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString()); } }); return contentAssistant; }
Example #26
Source File: ContentAssistProcessorTestBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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]; }
Example #27
Source File: CodeTemplateSourceViewerConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); IColorManager manager= textTools.getColorManager(); ContentAssistant assistant= new ContentAssistant(); assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE); // Register the same processor for strings and single line comments to get code completion at the start of those partitions. assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_STRING); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_CHARACTER); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_DOC); assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT)); assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION)); assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setInformationControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString()); } }); Color background= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, manager); assistant.setContextInformationPopupBackground(background); assistant.setContextSelectorBackground(background); Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, manager); assistant.setContextInformationPopupForeground(foreground); assistant.setContextSelectorForeground(foreground); return assistant; }
Example #28
Source File: CalciteSourceViewerConfiguration.java From mat-calcite-plugin with Apache License 2.0 | 5 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { IContentAssistProcessor proc = new CalciteContentAssistantProcessor(); ContentAssistant assistant = new ContentAssistant(); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setContentAssistProcessor(proc, IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(proc, CalcitePartitionScanner.SQL_QUOTED_IDENTIFIER); return assistant; }
Example #29
Source File: TextUMLSourceViewerConfiguration.java From textuml with Eclipse Public License 1.0 | 5 votes |
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); assistant.setContentAssistProcessor(new TextUMLCompletionProcessor(editor), IDocument.DEFAULT_CONTENT_TYPE); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); return assistant; }
Example #30
Source File: DefaultContentAssistantFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IContentAssistant createConfiguredAssistant(SourceViewerConfiguration configuration, ISourceViewer sourceViewer) { ContentAssistant assistant = createAssistant(); configureContentAssistant(assistant, configuration, sourceViewer); return assistant; }