Rename fails if cursor is behind identifier [message #1838275] |
Sat, 20 February 2021 06:12  |
Frank Benoit Messages: 174 Registered: July 2009 |
Senior Member |
|
|
Hi
I have a grammar for variable declaration like this (stripped):
VariableList:
'var' Variable (',' Variable)* ";"
;
Variable:
name ('=' Expression )?
;
Example texts
var a;
var b = 1.0;
var a = 2.3, b;
Now a problem occurs during renaming:
If the cursor is directly behind the variable name (var a|;), then the IRenameContext targetElement is the VariableList, not the Variable. Hence in this case, the rename is not working.
I guess the selection is seen as the character after the cursor, and in that case this might be the semicolon or the comma.
There is the solution to customize the RenameContextFactory, detect there the VariableList and change the targetElement to the right Variable.
My question:'
Is there a better way? Can this be done without the customized context factory?
Is there a way to make clear that the cursor position behind the variable name (identifier) belong to it?
Frank
[Updated on: Sat, 20 February 2021 06:36] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02068 seconds