langium
langium copied to clipboard
Range of CST nodes after repeated tree rewriting
Langium version: 2.0.2 Package name: langium
Steps To Reproduce
- Clone the repo linked below. It contains a slightly altered hello-world project that allows writing chained member accesses like
A.B
orA.B.C
. For the member access directly below the root, a warning is issued. - Generate, build, and run the extension.
- Create a new file with the
.hello
extension. - Type
A.B
into the file. - Type
A.B.C
into the file.
Link to code example: https://github.com/lars-reimann/langium-cst-range
The current behavior
In step 4, the entire expression gets highlighted correctly:
In step 5, however, only the part starting at the dot gets highlighted. The computed range of the CST node is also too short:
The playground (or a debugging session) shows that the AST is built properly:
{
$type: "Module",
expression:
{
$type: "MemberAccess",
receiver:
{
$type: "MemberAccess",
receiver:
{
$type: "Reference",
name: "A"
},
member:
{
$type: "Reference",
name: "B"
}
},
member:
{
$type: "Reference",
name: "C"
}
}
}
The expected behavior
The warning should be shown for the entire expression A.B.C
in step 5. Likewise, the range of the CST node should be 0:0--0:5.
Might be related to the issue that https://github.com/eclipse-langium/langium/pull/932 attempts to fix. I'll probably take a look at that soon.