Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Default Ordering of XText Content Assistant
Default Ordering of XText Content Assistant [message #1745576] Wed, 12 October 2016 16:10 Go to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Hi,

Does anybody know: what is the default algorithm to sort/order the items in the content assistant list ? Is there any reference to look at it ?

Thanks,
Parsa
Re: Default Ordering of XText Content Assistant [message #1745577 is a reply to message #1745576] Wed, 12 October 2016 16:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12937
Registered: July 2009
Senior Member
Hi

the extension point is ICompletionProposalComparator implemented by ICompletionProposalComparator.NaturalOrder by default


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default Ordering of XText Content Assistant [message #1745585 is a reply to message #1745577] Wed, 12 October 2016 18:47 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Thanks,

What I mean was is it Alphabetically sorted or is it by the local scopes first , or sth else ? It seems that it randomly distributes the items in the list , because there is no specific sorting for it (at least to me).

Thanks,
Parsa
Re: Default Ordering of XText Content Assistant [message #1745586 is a reply to message #1745585] Wed, 12 October 2016 19:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12937
Registered: July 2009
Senior Member
as i said it depends of the use of the comparator.

if you have a look at the code you can see

Integer relevance1 = getRelevance(o1);
Integer relevance2 = getRelevance(o2);
if (relevance1 != null && relevance2 != null) {
int res = relevance2.compareTo(relevance1);
if (res != 0) {
return res;
}
}
return o1.getDisplayString().compareToIgnoreCase(o2.getDisplayString());

that it is sorted by relevance/priority and then by display string

the priority comes from org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.createCompletionProposal(String, StyledString, Image, int, String, ContentAssistContext) in the proposal provider


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default Ordering of XText Content Assistant [message #1745588 is a reply to message #1745586] Wed, 12 October 2016 19:13 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Thanks Christian,

I see, to me it is still not obvious that do they assign priority/relevance in the createCompletionProposal method . It seems that they create it based on the grammar definition and just add the objects based on what is defined in the grammar (i.e. SYNTACTIC ordering). It is not clear if there is a specific SEMANTIC ordering algorithm for the items.

Thanks anyways, I think I need to try and see to see if there is a pattern for it.

Regards,
Parsa

P.S. I don't want to implement or extend it, I just need to know if there is any syntactic ordering of items. I need to write it somewhere.

Re: Default Ordering of XText Content Assistant [message #1745590 is a reply to message #1745588] Wed, 12 October 2016 19:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12937
Registered: July 2009
Senior Member
No. There is no declarative way.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Strange Serialization
Next Topic:Terminal Rule Token based on previous crossreference
Goto Forum:
  


Current Time: Thu Jun 27 10:30:04 GMT 2019

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

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

Back to the top