[C2Fx] [Nl2Fx] Consider Comment Positions for Nl2Fx To Allow Adding inner Formula Scopes Specific Context (With() scopes)
Comments 2 Fx variation of Nl2Fx supports converting comments into code suggestions. Comments could be anywhere in the formula. A formula can have inner scopes due to the use of With() functions. A comment inside a With() call can be thought of being scoped to that With() call. If we can know which scope comment overlaps with we can add more context to the Nl2Fx payload to get better suggestions. This could be achieved by extending Nl2Fx handling in LSP to take in position of the comment along with the comment text and then using that position to compute the chain of scopes above that comment and adding more stuff to the context for Nl2Fx model
See an example below, I have two variables "VarInComp"with the same name but in different scopes. Currently, i only pass in global VarInComp and that's why suggestion for my comment inside With() converts VarInComp to text from a number to get its length. This is not accurate as my comment is inside With() scope and it has its own VarInComp which is already a text/string
Currently the Nl2FxPayload looks like this {sentence, context, textDocument}. We can add a position of type integer in the payload making it {sentence: string, context: string, textDocument: {uri:string}, position: number}. Position is a 0 based index into the formula string. Now we would also need a formula in the Nl2FxPayload so we would also need to accomodate that in the payload. we might need to add that as well.