Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Default Ordering of XText Content Assistant
Default Ordering of XText Content Assistant [message #1745576] Wed, 12 October 2016 12:10 Go to next message
Eclipse UserFriend
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 12:28 Go to previous messageGo to next message
Eclipse UserFriend
Hi

the extension point is ICompletionProposalComparator implemented by ICompletionProposalComparator.NaturalOrder by default
Re: Default Ordering of XText Content Assistant [message #1745585 is a reply to message #1745577] Wed, 12 October 2016 14:47 Go to previous messageGo to next message
Eclipse UserFriend
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 15:00 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Default Ordering of XText Content Assistant [message #1745588 is a reply to message #1745586] Wed, 12 October 2016 15:13 Go to previous messageGo to next message
Eclipse UserFriend
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 15:40 Go to previous message
Eclipse UserFriend
No. There is no declarative way.
Previous Topic:Strange Serialization
Next Topic:Terminal Rule Token based on previous crossreference
Goto Forum:
  


Current Time: Sun May 11 07:59:44 EDT 2025

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

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

Back to the top