Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dynamic Template Proposals in Xtext
Dynamic Template Proposals in Xtext [message #870738] Wed, 09 May 2012 13:46
Gianluca Viscomi is currently offline Gianluca ViscomiFriend
Messages: 33
Registered: April 2012
Location: Italy
Member
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?
Previous Topic:need explanation regarding assignments
Next Topic:Outline View flicker
Goto Forum:
  


Current Time: Fri Mar 29 00:04:18 GMT 2024

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

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

Back to the top