Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Delay of Content Assist Autoactivation(Is there a way to set/remove the delay of content assist when it is automatically activated?)
Delay of Content Assist Autoactivation [message #1800869] Wed, 09 January 2019 05:01 Go to next message
Eclipse UserFriend
Hello,

With the help of this link, I made the content assist proposals of my Xtext language to appear automatically when certain characters are pressed:

https://www.dietrich-it.de/xtext/2011/09/19/xtext-content-assist-auto-activation.html

However, I noticed there is a delay when showing the proposals, as oposed to showing instantly when using the hotkey (ctrl+space).

In Eclipse's Java editor preferences you can set this delay. Is there a way to configure the delay in my Xtext editor?

Thank you very much.
Re: Delay of Content Assist Autoactivation [message #1800872 is a reply to message #1800869] Wed, 09 January 2019 05:17 Go to previous messageGo to next message
Eclipse UserFriend
org.eclipse.jface.text.contentassist.ContentAssistant.setAutoActivationDelay(int)
default is 500 ms

org.eclipse.xtext.ui.editor.contentassist.DefaultContentAssistantFactory.createAssistant()
Re: Delay of Content Assist Autoactivation [message #1800892 is a reply to message #1800872] Wed, 09 January 2019 08:23 Go to previous message
Eclipse UserFriend
Thank you very much Christian, that worked perfectly.

If anyone want a detailed step-by-step, I did the following:

Create my own content assistant factory where I change the preferences of the assistant:

package ...;

import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.xtext.ui.editor.contentassist.DefaultContentAssistantFactory;

public class MyDSLCustomContentAssistantFactory
  extends DefaultContentAssistantFactory {

  @Override
  protected void loadPreferences(ContentAssistant assistant) {
    assistant.setAutoActivationDelay(100);  // in ms (default: 500 ms)
  }
}


And then, in the ui module class, bind the new factory overriding the DefaultContentAssistantFactory one:

package ...;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ui.editor.contentassist.IContentAssistantFactory;
import org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor;

import com.google.inject.Binder;

import [...].MyDSLCustomContentAssistantFactory;

/**
 * Use this class to register components to be used within the IDE.
 */
public class MyDSLUiModule extends [...].AbstractMyDSLUiModule {

  [...]

  @Override
  public Class<? extends IContentAssistantFactory> bindIContentAssistantFactory() {
    return MyDSLCustomContentAssistantFactory.class;
  }
}


Thanks again,
Alfonso
Previous Topic:Overriding default validator of one particular reference object
Next Topic:How to access index from wizard (without eObject)
Goto Forum:
  


Current Time: Sun Jun 15 18:28:31 EDT 2025

Powered by FUDForum. Page generated in 1.08006 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top