Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Different prefix for Special Character in RuleCall
Different prefix for Special Character in RuleCall [message #1725260] Wed, 02 March 2016 08:10 Go to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
MY Grammar has definition of string as

Model:
	greetings=Query;

Query:
	(key=QTypekeyWord)? (aggregation=Aggregation)?(measure=MeasureList);

QTypekeyWord:
	qKeyword='plot'
;

MeasureList : names+=Measure ("and" names+=Measure)*;


EinString:ID |SPECIAL;

SPECIAL:
	('/' | ';' | ',' | '!' | '§' | '%' | '&' | '(' | ')' | '?' | '*' | '+' | '.' | '-' | '|' | '[' | ']' | '#' | '@' |'{'|'}' |'$' |'^' |'~' |INT |':');

Measure:EinString+;



the value of prefix is different .

For
plot profit a --->prefix ="profit a"

for

plot profit # ----> preifix =""



For the second case ,I expect the prefix to be "profit #" and not "".Please suggest if I am missing something.


At these places I am checking prefix value.
override protected def dispatch void createProposals(Keyword keyword, ContentAssistContext context,
    IIdeContentProposalAcceptor acceptor) {
        if(filterKeyword(keyword, context)) {
            var userTypedText= context.getRootNode.getText
            var prefix=context.prefix

and
override dispatch createProposals(RuleCall ruleCall, ContentAssistContext context,
    IIdeContentProposalAcceptor acceptor) {

       [b] val prefix= context.prefix[/b]


[Updated on: Wed, 02 March 2016 08:12]

Report message to a moderator

Re: Different prefix for Special Character in RuleCall [message #1725265 is a reply to message #1725260] Wed, 02 March 2016 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
where do you call this code from? javascript client?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725275 is a reply to message #1725265] Wed, 02 March 2016 08:52 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I call from java scriptclient. But for both the scenarios. I am receiving correct prefix /input
Re: Different prefix for Special Character in RuleCall [message #1725276 is a reply to message #1725275] Wed, 02 March 2016 08:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
i dont understand your question

i get as prefix

!!!!!!!!!!!!
!!!!!!!!!!!!profit #
!!!!!!!!!!!!profit #

for the 3 contexts


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725286 is a reply to message #1725276] Wed, 02 March 2016 09:28 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
My question is for prefix values in over ridden methods.I am getting different prefix values for "plot profit d" and "plot profit #" . I am wondering why my "context.prefix" values are "profit d" for first and "" for the second.while it should be "profit #" . Also ,what is the significance of many contexts here ?
Re: Different prefix for Special Character in RuleCall [message #1725287 is a reply to message #1725286] Wed, 02 March 2016 09:34 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
I am extending IdeContentProposalProvider
Re: Different prefix for Special Character in RuleCall [message #1725295 is a reply to message #1725287] Wed, 02 March 2016 10:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi i still do not get your question

please use in your code the following code and debug

class MyDslProposalProvider extends IdeContentProposalProvider {

override createProposals(Collection<ContentAssistContext> contexts, IIdeContentProposalAcceptor acceptor) {
for (c : contexts) {
for (element : c.firstSetGrammarElements) {
println("!!!!"+c.prefix+" " + element)
}

}
super.createProposals(contexts, acceptor)
}

}

you have many contexts since your grammar allows multiple stuff


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725315 is a reply to message #1725295] Wed, 02 March 2016 13:38 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
index.php/fa/25160/0/
Could you verify this for this method as well.For the one you shared I get "profit #" .My input is "plot profit #"
  override dispatch createProposals(RuleCall ruleCall, ContentAssistContext context,
    IIdeContentProposalAcceptor acceptor) {

        val prefix= context.prefix

}


[Updated on: Wed, 02 March 2016 13:44]

Report message to a moderator

Re: Different prefix for Special Character in RuleCall [message #1725319 is a reply to message #1725315] Wed, 02 March 2016 13:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
yes, but
override protected _createProposals(RuleCall ruleCall, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) {
println("%%%%%%" + ruleCall.rule?.name + " " + context.prefix)
super._createProposals(ruleCall, context, acceptor)
}

%%%%%%Query
%%%%%%QTypekeyWord
%%%%%%MeasureList
%%%%%%Measure
%%%%%%Query

so what is your actual question problem?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725332 is a reply to message #1725319] Wed, 02 March 2016 15:30 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
My Question is should I expect "profit #" as the value of context.prefix .because when I type the question "plot profit p" I get "profit p" as prefix . So why not "profit #" when my input is "plot profit #"
Re: Different prefix for Special Character in RuleCall [message #1725333 is a reply to message #1725332] Wed, 02 March 2016 15:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
but i get 'profit #' as prefix ?!?

(i have to adapt the grammar since it is incomplete)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725335 is a reply to message #1725333] Wed, 02 March 2016 15:46 Go to previous messageGo to next message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
This is my aggregation.
Aggregation:
agg=('average'|'number of'|'total')
;

So , you are getting "profit #" as prefix. Strange !Sad
Re: Different prefix for Special Character in RuleCall [message #1725337 is a reply to message #1725335] Wed, 02 March 2016 15:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
yes but i still have adopted

org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider.isAcceptable(ContentAssistContext)


which insists of the last thing to be a character.
you have to adaopt this as well

p.s.

once more using a debugger might help


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Different prefix for Special Character in RuleCall [message #1725835 is a reply to message #1725337] Tue, 08 March 2016 03:57 Go to previous message
pranay roy is currently offline pranay royFriend
Messages: 196
Registered: January 2016
Senior Member
Thanks Christian. This solved my issue
Previous Topic:Call functions from other files
Next Topic:[SOLVED] Resolve cross references from a different DSL during Maven build
Goto Forum:
  


Current Time: Fri Mar 29 13:51:49 GMT 2024

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

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

Back to the top