org.eclipse.jface.text.contentassist.IContentAssistProcessor Java Examples

The following examples show how to use org.eclipse.jface.text.contentassist.IContentAssistProcessor. 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 vote down vote up
/**
 * 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: ContentAssistant.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #3
Source File: ConfigPropertyWidgetRegex.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #4
Source File: HTMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: SetupContentAssist.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
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 #6
Source File: ContentAssistant.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 contentAssistSubjectControl
 *            the code assist subject control
 * @param offset
 *            a document offset
 * @return an array of context information objects
 * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
 * @since 3.0
 */
IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int offset)
{
	fLastErrorMessage = null;

	IContextInformation[] result = null;

	IContentAssistProcessor p = getProcessor(contentAssistSubjectControl, offset);
	if (p instanceof ISubjectControlContentAssistProcessor)
	{
		result = ((ISubjectControlContentAssistProcessor) p).computeContextInformation(contentAssistSubjectControl,
				offset);
		fLastErrorMessage = p.getErrorMessage();
	}

	return result;
}
 
Example #7
Source File: ScriptTaskLabel2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #8
Source File: XORGatewayLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #9
Source File: IntermediateCatchTimerEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #10
Source File: StartEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #11
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static ContentAssistant setupSimpleContentAssistant(IContentAssistProcessor cap, String[] contentTypes) {
	ContentAssistant ca = new ContentAssistant();
	ca.enableAutoActivation(true);
	ca.enableAutoInsert(true);
	
	for (String partitionType : contentTypes) {
		ca.setContentAssistProcessor(cap, partitionType);
	}
	
	return ca;
}
 
Example #12
Source File: NonInterruptingBoundaryTimerEventName2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #13
Source File: IntermediateErrorCatchEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #14
Source File: SubProcessEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #15
Source File: ThrowLinkEventLabel2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #16
Source File: XMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public IContentAssistProcessor getContentAssistProcessor(AbstractThemeableEditor editor, String contentType)
{
	if (contentType.startsWith(DTDSourceConfiguration.PREFIX))
	{
		return DTDSourceConfiguration.getDefault().getContentAssistProcessor(editor, contentType);
	}
	return new XMLContentAssistProcessor(editor);
}
 
Example #17
Source File: ContentAssistant.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param offset
 * @param document
 */
private boolean isValidAutoAssistLocation(KeyEvent e, StyledText styledText)
{
	// Don't pop up CA if we pressed a Ctrl or Command character. On Linux, Unicode characters can be inserted with
	// Ctrl + Shift + u + key sequence, but at this point, all we get is the character, no modifiers.
	if (e.stateMask == SWT.MOD1)
	{
		return false;
	}

	int keyCode = e.keyCode;
	if (keyCode == SWT.ESC || keyCode == SWT.BS || keyCode == SWT.DEL || keyCode == SWT.ARROW
			|| (keyCode & SWT.KEYCODE_BIT) != 0)
	{
		return false;
	}

	int offset = styledText.getCaretOffset();
	IContentAssistProcessor processor = getProcessor(fContentAssistSubjectControlAdapter, offset);
	if (processor instanceof ICommonContentAssistProcessor)
	{
		ICommonContentAssistProcessor cp = (ICommonContentAssistProcessor) processor;
		// are we typing a valid identifier, and the previous "location" (character or lexeme) should pop up CA
		return cp.isValidIdentifier(e.character, keyCode)
				&& isAutoActivationLocation(cp, styledText, e.character, keyCode);
	}
	else
	{
		return false;
	}
}
 
Example #18
Source File: DotProposalProviderDelegator.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private 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 #19
Source File: SVGSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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);
	}
	return new SVGContentAssistProcessor(editor);
}
 
Example #20
Source File: GssResourceSourceViewerConfiguration.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) {
  IContentAssistProcessor[] processors = super.getContentAssistProcessors(sourceViewer, partitionType);

  if ((partitionType == ICSSPartitions.STYLE) || (partitionType == IStructuredPartitions.UNKNOWN_PARTITION)) {
    processors = new IContentAssistProcessor[] { new IndentationFixingGssContentAssistProcessor() };
  }

  return processors;
}
 
Example #21
Source File: GWTSourceViewerConfiguration.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
  ContentAssistant assistant = (ContentAssistant) super.getContentAssistant(sourceViewer);

  ICompilationUnit cu = ((GWTJavaEditor) getEditor()).getCompilationUnit();
  IContentAssistProcessor processor = new JsniCompletionProcessor(cu);
  assistant.setContentAssistProcessor(processor, GWTPartitions.JSNI_METHOD);

  return assistant;
}
 
Example #22
Source File: TaskNameEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #23
Source File: StartErrorEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #24
Source File: CallActivityName2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #25
Source File: IntermediateErrorCatchEventLabel3EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #26
Source File: EndTerminatedEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #27
Source File: AbstractContentAssistUiTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #28
Source File: IntermediateErrorCatchEventLabel5EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public IContentAssistProcessor getCompletionProcessor() {
	if (getParserElement() == null || getParser() == null) {
		return null;
	}
	return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
}
 
Example #29
Source File: CalciteSourceViewerConfiguration.java    From mat-calcite-plugin with Apache License 2.0 5 votes vote down vote up
@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 #30
Source File: EditorSettings_Actual.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static SourceViewerConfiguration createTemplateEditorSourceViewerConfiguration(
		IPreferenceStore store, final IContentAssistProcessor templateCAP) {
	return new SimpleSourceViewerConfiguration(store) {
		@Override
		public ContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
			return setupSimpleContentAssistant(templateCAP, array(
				LangPartitionTypes.CODE.getId(), 
				LangPartitionTypes.LINE_COMMENT.getId(), 
				LangPartitionTypes.STRING.getId(),
				LangPartitionTypes.BLOCK_COMMENT.getId() 
			));
		}
	};
}