langium icon indicating copy to clipboard operation
langium copied to clipboard

Range of CST nodes after repeated tree rewriting

Open lars-reimann opened this issue 1 year ago • 1 comments

Langium version: 2.0.2 Package name: langium

Steps To Reproduce

  1. Clone the repo linked below. It contains a slightly altered hello-world project that allows writing chained member accesses like A.B or A.B.C. For the member access directly below the root, a warning is issued.
  2. Generate, build, and run the extension.
  3. Create a new file with the .hello extension.
  4. Type A.B into the file.
  5. 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:

image

In step 5, however, only the part starting at the dot gets highlighted. The computed range of the CST node is also too short:

image

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.

lars-reimann avatar Oct 07 '23 21:10 lars-reimann

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.

msujew avatar Oct 08 '23 10:10 msujew