Dynamic Template Proposals in Xtext [message #870738] |
Wed, 09 May 2012 13:46 |
|
Hi
I have a problem with the template! In practice I should view them with the content assist in a certain context, I tried this but these do not appear anywhere in that context! This is what I did:
Model:
FunctionHash
;
FunctionHash:
'HASH' '(' (stringValue=STRING ',' bytes=Bytes ',' integer=INT) ')'
;
after
public class EditorSqlUiModule extends org.xtext.ui.AbstractEditorSqlUiModule {
public EditorSqlUiModule(AbstractUIPlugin plugin) {
super(plugin);
}
public Class<? extends ITemplateProposalProvider> bindITemplateProposalProvider(){
return MyTemplateProposalProvider.class;
}
}
public class MyTemplateProposalProvider extends DefaultTemplateProposalProvider{
ContextTypeIdHelper helper;
@Inject
public MyTemplateProposalProvider(TemplateStore templateStore,
ContextTypeRegistry registry, ContextTypeIdHelper helper) {
super(templateStore, registry, helper);
this.helper=helper;
}
@Inject
EditorSqlGrammarAccess grammaraccess;
@Override
protected void createTemplates(TemplateContext templateContext,
ContentAssistContext context, ITemplateAcceptor acceptor) {
super.createTemplates(templateContext, context, acceptor);
String id=helper.getId(grammaraccess.getHashFunctionRule());
Template template=new Template("TemplateProva","proviamo se funziona","11111","${t},${v},${yu},${ke}",false);
if(templateContext.getContextType().getName().equals(id)){
TemplateProposal tp= createProposal(template, templateContext, context, getImage(template), getRelevance(template));
acceptor.accept(tp);
}
}
The problem is that after I write HASH with Ctrl-space I is proposed Template!
Can anyone tell me how?
|
|
|
Powered by
FUDForum. Page generated in 0.03897 seconds