Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » AbstractMyDslProposalProvider(About creating AbstractMyDslProposalProvider)
icon12.gif  AbstractMyDslProposalProvider [message #1720422] Mon, 18 January 2016 14:55 Go to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Rolling Eyes I have read that :

"Xtext gives us a class for this purpose, a ProposalProvider (MyDslProposalProvider), that extends AbstractMyDslProposalProvider"

However, In my project

both MyDslProposalProvider and AbstractMyDslProposalProvider is not created . Do I need to configure it . Should it automatically be created when I build my project.

Should I create it manually.

Any help on this will be much appreciated.

[Updated on: Mon, 18 January 2016 14:56]

Report message to a moderator

Re: AbstractMyDslProposalProvider [message #1720423 is a reply to message #1720422] Mon, 18 January 2016 15:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you remove the fragment for content assist from your workflow

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720425 is a reply to message #1720423] Mon, 18 January 2016 15:11 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thanks for your message .No. I have created a sample project from Intellij. Which file should I check to find whether it needs to be there?
Re: AbstractMyDslProposalProvider [message #1720431 is a reply to message #1720425] Mon, 18 January 2016 15:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
this is the hook for eclipse.
the hook for intellij is MyDslCompletionContributor


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720511 is a reply to message #1720431] Tue, 19 January 2016 06:29 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok Thank You for your message. I am particularly interested in Web editor . The class MyDslCompletionContributor is in idea.completion . I would like to understand how can I configure web editor. Are there any examples?
Re: AbstractMyDslProposalProvider [message #1720514 is a reply to message #1720511] Tue, 19 January 2016 06:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi dont know any complex examples. only this one
https://github.com/eclipse/xtext/blob/6f36b135c9643d4c2e9e4cd60104e1e93491d944/web/org.eclipse.xtext.web.example.statemachine.ide/src/org/eclipse/xtext/web/example/statemachine/ide/StatemachineWebContentProposalProvider.xtend
https://github.com/eclipse/xtext/blob/6c294a666b26c3df0e4b68694162dea49a8b9584/web/org.eclipse.xtext.web.example.jetty/src/main/java/org/eclipse/xtext/web/example/jetty/StatemachineWebModule.xtend


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720523 is a reply to message #1720514] Tue, 19 January 2016 08:03 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Razz This is very useful Christian.
I would like to know whether I need to override both the methods "createProposals". I am just trying to use it like , if I am expecting an Employee type as the next word I should fetch few names from database .

So my rule says ,

Greeting Employee

"Hello " should assist me the names of Employee when Employee Rule is fired.

Am I correct to implement the above using the way you shared. Please suggest
Re: AbstractMyDslProposalProvider [message #1720528 is a reply to message #1720523] Tue, 19 January 2016 08:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
In the Hello World Example you have

Greeting: "Hello" name=ID;

=>

Greeting is a rulecall
name= is an assignment
ID is a rulecall

=> you have to pick what fits best


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720537 is a reply to message #1720528] Tue, 19 January 2016 08:43 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thank You Christian . Please have a look at the following.

I have added these classes based on the examples.

public class StatemachineWebModule extends AbstractMyDslWebModule {
public StatemachineWebModule(final Provider<ExecutorService> executorServiceProvider) {
super(executorServiceProvider);
}

public Class<? extends StatemachineWebContentProposalProvider> bindIdeContentProposalProvider() {
return StatemachineWebContentProposalProvider.class;
}
}


and


class StatemachineWebContentProposalProvider extends IdeContentProposalProvider {

@Inject extension MyDslGrammarAccess

override dispatch createProposals(RuleCall ruleCall, ContentAssistContext context,
IIdeContentProposalAcceptor acceptor) {
switch (ruleCall.rule) {

case getIDRule: {

if ('abc'.startsWith(context.prefix)) {
val trueEntry = new ContentAssistEntry => [
prefix = context.prefix
proposal = 'pqr'
]
acceptor.accept(trueEntry, proposalPriorities.getDefaultPriority(trueEntry))
}

}

default:
super._createProposals(ruleCall, context, acceptor)
}
}

}




I am trying to say that if my there is an ID which is 'abc' suggest 'pqr'

I am not getting content assist in the web ui editor.Does it look Ok.?

Re: AbstractMyDslProposalProvider [message #1720540 is a reply to message #1720537] Tue, 19 January 2016 08:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you share your complete grammar?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720542 is a reply to message #1720540] Tue, 19 January 2016 08:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
this looks ok beside the if is the wrong way 'abc'.startsWith(context.prefix)
=> if the prefix is empty this always will be true

=> you get pqr suggested


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720543 is a reply to message #1720542] Tue, 19 January 2016 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s. the binding is wrong

public Class<? extends IdeContentProposalProvider> bindIdeContentProposalProvider() {
return StatemachineWebContentProposalProvider.class;
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720544 is a reply to message #1720540] Tue, 19 January 2016 08:58 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member

Model:
greetings=Query;

Query:
(key=QTypekeyWord)? person=Person


QTypekeyWord:
plot='hello'
;

Person:
per=ID
;

Re: AbstractMyDslProposalProvider [message #1720548 is a reply to message #1720544] Tue, 19 January 2016 09:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
see answers above

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720628 is a reply to message #1720548] Wed, 20 January 2016 03:17 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thanks for the reply. Could you guide me whats wrong with the binding.
Also ,I have corrected the equality match. But I am unable to get any content assist.

def Class<? extends IdeContentProposalProvider> bindIdeContentProposalProvider() {
return StatemachineWebContentProposalProvider
}
Re: AbstractMyDslProposalProvider [message #1720629 is a reply to message #1720628] Wed, 20 January 2016 03:22 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
https://www.evernote.com/l/AHs5BNB5n5pFyqIj7cpC2aQ0pN2w5CQb6xs



This is the place where I have put the two files.(in the web module)

[Updated on: Wed, 20 January 2016 03:26]

Report message to a moderator

Re: AbstractMyDslProposalProvider [message #1720632 is a reply to message #1720629] Wed, 20 January 2016 05:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the webmodule is pregenerated you simply have to add the binding method there. you can pleace the StatemachineWebContentProposalProvider right next to it.
you can use remote debugging to see if your or the superclasses code is called.
of course you have to enable (is by default) and call content assist (space). this seems to work only if you type at least on char (if the document is empty)

p.s. you link seems not to work


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720649 is a reply to message #1720632] Wed, 20 January 2016 08:07 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thank You. It works Smile . While debugging I found that the proposal is added but it is not displayed on the screen . The below code executes on the rule match and "trueEntry" is created ,but I do not see the proposal on the screen. Please let me know if I am missing something.

This is my code.
override dispatch createProposals(RuleCall ruleCall, ContentAssistContext context,
IIdeContentProposalAcceptor acceptor) {
switch (ruleCall.rule) {

case getQTypekeyWordRule: {


if (context.prefix.startsWith('abc') ){
val trueEntry = new ContentAssistEntry => [
prefix = context.prefix
proposal = 'pqr'
]
acceptor.accept(trueEntry, proposalPriorities.getDefaultPriority(trueEntry))
}


}

default:super._createProposals(ruleCall, context, acceptor)
}
}
Re: AbstractMyDslProposalProvider [message #1720650 is a reply to message #1720649] Wed, 20 January 2016 08:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sry have no idea on this
Did you debug the ace / xtext JavaScript code?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720651 is a reply to message #1720650] Wed, 20 January 2016 08:13 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
No I have not debugged the java script code. This code looks ok right ? Is there a chance of being overwritten later in the execution? What do you suggest?
Re: AbstractMyDslProposalProvider [message #1720654 is a reply to message #1720651] Wed, 20 January 2016 08:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
You should return prefix+"par"

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720657 is a reply to message #1720654] Wed, 20 January 2016 08:29 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Ok. I see that Acceptor has the prosposal I want. But I dont see it in the screen Sad
Re: AbstractMyDslProposalProvider [message #1720659 is a reply to message #1720657] Wed, 20 January 2016 08:34 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
My resultant JSON in XTextServlet But ,only one word is displayed.
ContentAssistResult[
stateId = "-7fffffff"
entries = ArrayList(
ContentAssistEntry[
prefix = "pl"
proposal = "falslke"
textReplacements = ArrayList() editPositions = ArrayList()
],
ContentAssistEntry[
prefix = "pl"
proposal = "plot"
textReplacements = ArrayList() editPositions = ArrayList()
]
)
]

[Updated on: Wed, 20 January 2016 08:35]

Report message to a moderator

Re: AbstractMyDslProposalProvider [message #1720663 is a reply to message #1720659] Wed, 20 January 2016 08:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
falslke
Does not start with pl
You should return plfalslke


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: AbstractMyDslProposalProvider [message #1720664 is a reply to message #1720659] Wed, 20 January 2016 08:41 Go to previous message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
doing prefix+"par" solved the issue . Thanks a lot . Smile Now I can see the assist working Smile Smile Smile Smile Smile
Previous Topic:web editor with code generation
Next Topic:Primitive void cannot be a dependency.
Goto Forum:
  


Current Time: Wed Apr 24 17:56:51 GMT 2024

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

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

Back to the top