Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to know where content assist is invoked?
How to know where content assist is invoked? [message #998640] Thu, 10 January 2013 12:01 Go to next message
Latha Shankara is currently offline Latha ShankaraFriend
Messages: 33
Registered: June 2012
Member
Hi,

I have a issue with content assist where in I want to know where exactly the content assist is invoked.
I have a model which has an element which has 4 different attributes, eg:

addData{

numberA = a+e;
numberB = b-f*h;
numberC = c;
numberD = d;

}

a, b, c, d, f, h are constants with some values.
addData is the element, having numberA, numberB, numberC, numberD as its attributes.

I have to make sure that the first element is not negative for numberA and numberB attributes. I have overridden the appropriate method to filter the proposals. But how do I get to know for which attribute content assist was invoked for me to provide correct proposals? Is there a way to get this info?

Thanks in advance,
Latha
Re: How to know where content assist is invoked? [message #998660 is a reply to message #998640] Thu, 10 January 2013 13:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

how does your grammar look like. you can find stuff like the node model, the ast etc in the contentassistcontext. you may have to trick somehow depending on the grammar


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to know where content assist is invoked? [message #999000 is a reply to message #998660] Fri, 11 January 2013 06:07 Go to previous messageGo to next message
Latha Shankara is currently offline Latha ShankaraFriend
Messages: 33
Registered: June 2012
Member
Hi Christian,

I found that I can get to know the attribute of the element where content assist was invoked by getting the previous nodes of the lastcompleteNode of the context.

I get the last completed node by using,

INode node = contentAssistContext.getLastCompleteNode();


But how do I get the previous node of lastCompleteNode?

While debugging, the lastCompleteNode has properties like prev, next and so on.. Is there a way to get the prev property? I was not able to find any method to get the same.

Thanks,
Latha
Re: How to know where content assist is invoked? [message #999033 is a reply to message #999000] Fri, 11 January 2013 07:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
You can ask the node for its grammar element. (You may have to
downcast)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to know where content assist is invoked? [message #999045 is a reply to message #999033] Fri, 11 January 2013 08:13 Go to previous messageGo to next message
Latha Shankara is currently offline Latha ShankaraFriend
Messages: 33
Registered: June 2012
Member
Yes, I can get the grammar element. But my requirement is different.

If I have code like below,

addData{

numberA = <Ctrl+Space>

}



Then, the current node is hidden leaf node which is a space, last complete node is "=" which is a keyword. The prev property of the last complete node would be the keyword numberA which I am in need of. By the grammar element of the last complete node I get "=" and not "numberA". How do I get previous node to lastCompleteNode?

Thanks,
Latha
Re: How to know where content assist is invoked? [message #999055 is a reply to message #999045] Fri, 11 January 2013 08:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi can't you ask the node for its previous. BTW posting a grammar
(simplyfied) would make it much easier to help

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to know where content assist is invoked? [message #999081 is a reply to message #999055] Fri, 11 January 2013 09:49 Go to previous message
Latha Shankara is currently offline Latha ShankaraFriend
Messages: 33
Registered: June 2012
Member
Hi,

Yes, the prev node could be obtained by invoking getPreviousSibling() method on the node.

Thanks for your great help Christian,
Latha
Previous Topic:Problems running Xtext project.
Next Topic:Installing multiple versions of a DSL
Goto Forum:
  


Current Time: Thu Apr 25 22:08:51 GMT 2024

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

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

Back to the top