Replies: 2 comments 1 reply
-
I think introducing the new API would be the ideal solution in this case, since the existing API's usage is intended to honour the left to write writing pattern. If we are to use the same API with modifications for the position inputs we might need to calculate the positions and ranges which will not suit all the cases and the changes will scatter. Therefore I think API addition would be a better option here |
Beta Was this translation helpful? Give feedback.
-
I overloaded the Now the |
Beta Was this translation helpful? Give feedback.
-
In the current
NonTerminalNode.findChildNode()
implementation, the start offset of a text range is excluded purposefully.Based on a discussion had with @nadeeshaan and @rasika it was made clear that this was to support the left to right writing pattern. However, this causes an issue when working with VSCode client.
That is, consider the
create function code action
. Suppose we have the following ballerina code:When the user has the cursor on
getStr()
method, the VSCode client sends the cursor position as<cursor>getStr()
which is the start position of the diagnostic location. Therefore, when we search for the node at the cursor, what we always get is theLetVariableDeclarationNode
instead of theFunctionCallExpression
.Due to this limitation, we have to identify the function call expressions based on the node type returned. For example, this is what we use currently to get the
function call expression
out of different node types.This approach is ok for simple scenarios as above. But,
Create Function Code Action
implementation, but we will face the same issue for other code actions as well.All the above issues could be solved, if we can add a new API to
NonTerminalNode
to search for child nodes while including the starting offset. @nadeeshaan @rasika WDYT?Beta Was this translation helpful? Give feedback.
All reactions