Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext custom content assist problem(Xtext custom content assist problem)
Xtext custom content assist problem [message #1735183] Thu, 16 June 2016 07:48 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

I have below grammar

Annotation: {Annotation} ('@app()->') (appExp+=Expression);

Widget: {Widget} '@widget' (widgetExp+=Expression)+ ('->'widgetExp+=Expression)?;

ScreenNum : {ScreenNum} ('@screen_num'|'@screen')(screenExp+=Expression) ('!@widget'(screenExp+=Expression))? ('->'screenExp+=Expression)?;

FieldNum: {FieldNum} ('@field_num')(fieldExp+=Expression) (fieldExp+=Expression)? ('->'fieldExp+=Expression)?;

I want auto content assist when I click on '->'.

I have added below code in proposal provider class as

class JPLEditorUiModule extends AbstractJPLEditorUiModule {
override configure(Binder binder) {
super.configure(binder);
binder.bind(String).annotatedWith(Names.named((XtextContentAssistProcessor.COMPLETION_AUTO_ACTIVATION_CHARS))).toInstance(">");
}
def Class<? extends AbstractAntlrTokenToAttributeIdMapper> bindAbstractAntlrTokenToAttributeIdMapper() {
JPLAntlrTokenToAttributeIdMapper
}
}

But when I writing @app()-> the contents belongs to @app are coming. But when I write @widget, @screen_num, @field_num it is showing all contents.

Re: Xtext custom content assist problem [message #1735184 is a reply to message #1735183] Thu, 16 June 2016 07:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
i dont see what this has to do with auto activation.
does it work if you incoke ca manually?

thus i assume this has to do with your amiguity hell regarding the expressions as well


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext custom content assist problem [message #1735190 is a reply to message #1735184] Thu, 16 June 2016 08:45 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
I have written content assist for the grammar rules defined as :

override completeAnnotation_AppExp(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
for(String app : appSet) {
acceptor.accept(createCompletionProposal(app, app,null /*getBlackImage()*/, context));
}
}
override completeWidget_WidgetExp(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor){
println("Inside Widget:::::::")
for(String widget : widgetSet) {
acceptor.accept(createCompletionProposal(widget, widget,null /*getBlackImage()*/, context));
}
}
override completeScreenNum_ScreenExp(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor){
println("Inside Screen:::::::")
for(String screenNum : screenNumSet) {
acceptor.accept(createCompletionProposal(screenNum, screenNum,null /*getBlackImage()*/, context));
}
}
override completeIdObject_IdExp(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor){
println("Inside idset:::::::")
for(String id : idSet) {
acceptor.accept(createCompletionProposal(id, id,null /*getBlackImage()*/, context));
}
}
override completeTpReq_TpreqExp(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor){
println("Inside tpReqSet:::::::")
for(String tpReq : tpReqSet) {
acceptor.accept(createCompletionProposal(tpReq, tpReq,null /*getBlackImage()*/, context));
}
}
Re: Xtext custom content assist problem [message #1735192 is a reply to message #1735190] Thu, 16 June 2016 09:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
yes but as said: depending on the grammar xtext may not know that is is inside these contexts.
thus these methods may or may not be executed


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext custom content assist problem [message #1735193 is a reply to message #1735192] Thu, 16 June 2016 09:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
can you please give this a try with a minimal grammar e.g.

Expression:
value=INT
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext custom content assist problem [message #1735207 is a reply to message #1735193] Thu, 16 June 2016 10:47 Go to previous message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Thank you
Previous Topic:Xtext, Idea multiple output configuration
Next Topic:Xtext unknown error
Goto Forum:
  


Current Time: Sun Feb 25 02:42:31 GMT 2024

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

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

Back to the top