Proposal depending on cursor position [message #1065127] |
Mon, 24 June 2013 13:09 |
Vincent De Bry Messages: 55 Registered: May 2013 |
Member |
|
|
Hi
Based on the following part of grammar, I am developing my own proposal provider method "complete_GENERIC_PARAM":
My_Command: {My_Command} 'COMMAND' params+=GENERIC_PARAM+;
GENERIC_PARAM : ID;
If I have already typed
and I would like to insert a value between 'COMMAND' and 'param2', how could I know the number of parameters already set before and after the cursor in the context of my command, so that I can compute the proposal correctly ?
I tried something like that, but it does not work
int paramIndex = 0;
INode lastNode = context.getCurrentNode();
while ((lastNode != null) && (lastNode.getGrammarElement() instanceof Keyword))
{
if (!(lastNode instanceof HiddenLeafNode)) paramIndex++;
lastNode = lastNode.getPreviousSibling();
}
Thanks
[Updated on: Mon, 24 June 2013 14:06] Report message to a moderator
|
|
|
|
|
Re: Proposal depending on cursor position [message #1065276 is a reply to message #1065258] |
Tue, 25 June 2013 08:23 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
The node model carries the syntactical information, e.g. offset and
length in the textual model. NodeModelUtils helps you to find the node
for a semantic element.
So my proposal is to examine the children (params) of the context
element (of type in your case My_Command) get their respective node and
compare their offsets to the caret position.
Am 25.06.13 08:53, schrieb Vincent De Bry:
> That's a track obviously.... not obvious.
>
> Thanks though.
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.03418 seconds