Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Order if content assist items(why has it changed ?)
Order if content assist items [message #895061] Wed, 11 July 2012 14:57 Go to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
I have moved my XText application to Eclipse 4.2 and XText 2.3 and have the following problem:

I named all my templates starting with - (e.g. -Script), and in the CA list they used to come on top of the list; now they come at the bottom.

Can somebody explain it to me, and even better tell me how to revert it ?

MS

Re: Order if content assist items [message #895262 is a reply to message #895061] Thu, 12 July 2012 09:40 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Content proposals have a priority that is used for sorting. The one for
template proposals is specified int the
org.eclipse.xtext.ui.editor.templates.DefaultTemplateProposalProvider.getRelevance(Template)

Am 11.07.12 16:57, schrieb Michel Simeon:
> I have moved my XText application to Eclipse 4.2 and XText 2.3 and have
> the following problem:
>
> I named all my templates starting with - (e.g. -Script), and in the CA
> list they used to come on top of the list; now they come at the bottom.
>
> Can somebody explain it to me, and even better tell me how to revert it ?
>
> MS
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Order if content assist items [message #895299 is a reply to message #895262] Thu, 12 July 2012 12:00 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thanks for the comment, but I am not sure what to do with it.
I looked into org.eclipse.xtext.ui.editor.templates.DefaultTemplateProposalProvider.getRelevance(Template)
and what I found is:

public int getRelevance(Template template) {
return 90;
}

I guess I could overwrite this method in order to change the relative order of templates, but my problem is different: pressing Ctrl-Space produces a list of proposals that in my case would generally include a mix of IDs, keywords and template names. By naming all my templates starting with - (e.g. -Script), they are automatically grouped together, and in the CA list of the previous version of my DSL they used to come on top of the list, which is what I wanted. In other words, -Axx or -Zxx came before Axx.

But now the group comes at the bottom, and i do not know how to change the overall sorting order of the content-assist list.

Any other suggestions would be most welcome.
MS
Re: Order if content assist items [message #895308 is a reply to message #895299] Thu, 12 July 2012 12:24 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Michel,

did you try to return a relevance that is higher than the relevance of
the other proposals, eg. 10k ?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 12.07.12 14:00, schrieb Michel Simeon:
> Thanks for the comment, but I am not sure what to do with it.
> I looked into
> org.eclipse.xtext.ui.editor.templates.DefaultTemplateProposalProvider.getRelevance(Template)
>
> and what I found is:
>
> public int getRelevance(Template template) {
> return 90;
> }
>
> I guess I could overwrite this method in order to change the relative
> order of templates, but my problem is different: pressing Ctrl-Space
> produces a list of proposals that in my case would generally include a
> mix of IDs, keywords and template names. By naming all my templates
> starting with - (e.g. -Script), they are automatically grouped together,
> and in the CA list of the previous version of my DSL they used to come
> on top of the list, which is what I wanted. In other words, -Axx or -Zxx
> came before Axx.
>
> But now the group comes at the bottom, and i do not know how to change
> the overall sorting order of the content-assist list.
> Any other suggestions would be most welcome.
> MS
Re: Order of content assist items [message #895376 is a reply to message #895308] Thu, 12 July 2012 15:32 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thank you Sebastian for the suggestion. But I have no clue on how to do it ! Hope you can be more specific !!

MS

P.S. Even if that works it would not tell me why things have changed when moving to Juno
Re: Order of content assist items [message #895382 is a reply to message #895376] Thu, 12 July 2012 15:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
hi Michel,

it was changed because of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371731

You should override
org.eclipse.xtext.ui.editor.templates.DefaultTemplateProposalProvider.getRelevance(Template)
if you want to sort your proposals differently. (see Jan's answer)

Please refer to the docs on Guice and bindings etc for details.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 12.07.12 17:32, schrieb Michel Simeon:
> Thank you Sebastian for the suggestion. But I have no clue on how to do
> it ! Hope you can be more specific !!
>
> MS
>
> P.S. Even if that works it would not tell me why things have changed
> when moving to Juno
Re: Order of content assist items [message #895427 is a reply to message #895382] Thu, 12 July 2012 20:57 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thanks again.

It does work indeed, now all the templates come on top of the CA proposals list. For those interested, this is what I did, based on the suggestions I received:

My language being called Mads, I defined:

public class MadsTemplateProposalProvider extends DefaultTemplateProposalProvider{

@Inject
public MadsTemplateProposalProvider(TemplateStore templateStore,
ContextTypeRegistry registry, ContextTypeIdHelper helper) {
super(templateStore, registry, helper);
}

@Override
public int getRelevance(Template template){
return 10000;
}
}

and then I added the following to my MadsUiModule :

public Class<? extends DefaultTemplateProposalProvider>
bindDefaultTemplateProposalProvider(){
return MadsTemplateProposalProvider.class;
}
MS

P.S. Even if that works, I still would like to understand why things have changed
when moving from Indigo to Juno !!!
Re: Order of content assist items - CA test [message #895474 is a reply to message #895427] Fri, 13 July 2012 08:09 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Following up on the previous message, I found something strange with my CA tests.

I am extending xtext.ui.junit.editor.contentassist.AbstractContentAssistProcessorTest and using Builder append and assertText to check on CA content list. Some of the CA tests include both template names and IDs in the list.

The point is that the tests pass with the list of templates on top of the list, irrespective of the value I give to the relevance of templates.

In other work, the templates are either at the beginning or at the end or the CA list when I run the application with 10000 or 0 returned by getRelevance but the CA test is NOT affected and passes unmodified in both cases.

Is it a bug ?

MS
Re: Order of content assist items - CA test [message #897272 is a reply to message #895474] Mon, 23 July 2012 13:24 Go to previous message
frank fotso is currently offline frank fotsoFriend
Messages: 91
Registered: May 2012
Member
HI Michel,
did you have any simple example on how to write and apply a template proposal, i want to write some template such that during content assist ( crtl+space) i have the different proposition written by me .
The problem is i don't know where to start.
i will be very gratefull if you can show to me how to do it step by step.

Thks and Best regards,
Frank
Previous Topic:Xtext editors take a long time to open
Next Topic:Generating JvmTypeReference for Generics
Goto Forum:
  


Current Time: Sat Apr 20 00:21:55 GMT 2024

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

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

Back to the top