Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dynamic content assist proposals order(Change the order of proposals as the user types)
Dynamic content assist proposals order [message #1818402] Sat, 14 December 2019 14:29 Go to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Hi,

I am using Xtext 2.14 and I would like to provide an autocomplete that matches all the proposals that contain what the user typed. For example, if the user types na then the autocomplete should show name and enable.

No problem so far: I extended the generated AbstractMyDslProposalProvider and used a custom PrefixMatcher.

My issue is that I would like to order the proposals so that the proposal which starts with what the user typed is shown first. To continue my example, name should be shown before enable. However by default Xtext orders alphabetically and I can't use ConfigurableCompletionProposal's priority because the order may change as the user types. I hence need to re-order the proposals each time the user types or erases something.

I tried the following:

  1. Provide my own IContentProposalPriorities; it is never used. Actually, by looking at uses of the interface I have the feeling that I am the one supposed to use it, so it cannot provide any dynamic ordering.
  2. Provide my own ICompletionProposalComparator; although I can re-order proposals I do not have access to what the user typed (i.e. what Xtext calls the prefix).
  3. Provide my own ICompletionProposalSorter in the hope that it will be lifted to JFace's CompletionProposalPopup but that didn't work.
  4. Dynamically change proposal's priority in the corresponding PrefixMatcher but the change was ignored.

Note: by "provide" I mean adding a bind*() method in MyDslUiModule.

Would anyone have another idea I could try?
Re: Dynamic content assist proposals order [message #1818404 is a reply to message #1818402] Sat, 14 December 2019 14:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
maybe you can store the information in the configurable completion proposals additonal data

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Dynamic content assist proposals order [message #1818405 is a reply to message #1818404] Sat, 14 December 2019 16:26 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
You mean to access the prefix from the ICompletionProposalComparator? I tried but sadly the comparator seems to be used only once when the content assist popup is shown; it is not called again when the user types. My bad for not having specified it.
Re: Dynamic content assist proposals order [message #1818407 is a reply to message #1818405] Sat, 14 December 2019 16:33 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
sorry then i have no idea

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Build a language server for DSL
Next Topic:[Newbie Q.] Grammar Failing: Element: -UNKNOWN-
Goto Forum:
  


Current Time: Wed Oct 21 14:12:41 GMT 2020

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

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

Back to the top