you would not do that in the <Language>ProposalProvider. Bind your own implementation of ITemplateProposalProvider (probably extending DefaultTemplateProposalProvider).
The validate-Methods seem to be good points for including or excluding templates...
Thank you very much for your reply.
I have followed your suggestion and defined my own template provider.
If I understood you correctly, you suggested that the call for the (de)activation call to be done in the validation methods (ex. org.xtext.example.mydsl.validation). If so, can you give me tell me if there is a clean way to access the template provider from there.
have you bound your implementation in the UIModule? If you override the validate methods, you should have everything you need available.
The context allows you to determine at which position content assist is invoked (what is to be completed), the template is the candidate template that is to be proposed.
So you check whether you want to show the template at that point and return true or false accordingly... (Breakpoints and debug mode are always helpful.)
My grammar is basically a generic JSon parser which uses a JSon schema in the background for validation. So, in my createTemplates method, I check the current node's parent and (de)activate the templates based on his key before the actual template proposal creation (i.e. the super method)
i think you still missed that alex was talking about
org.eclipse.xtext.ui.editor.templates.AbstractTemplateProposalProvider.validate(Template, ContentAssistContext)
and not the normal java validator