Skip to content

The tree adapter is not used for updating the end location of an element #314

@DMartens

Description

@DMartens

Hi,
I am currently writing a custom tree adapter restructuring the source code location:

{
	start: { offset: 0, line: 1, column: 1 },
	end:   { offset: 0, line: 1, column: 1 },
}

The problem is that elements closing tag are not correctly handled in the parser mixin.
The location is retrieved using the tree adapter but the end location is set directly on the retrieved location, not using the tree adapter.
Therefore the result after parsing is:

{
	start: { offset: 0, line: 1, column: 1 },
	end:   { offset: 0, line: 1, column: 1 },
	endTag: ...,
    endLine: 1,
	endCol: 10,
	endOffset: 9,
}

I think there are three possible solutions:

  1. Call the setSourceCodeLocation only after the closing tag is parsed
  2. Call the setSourceCodeLocation twice (once after the opening tag and once for the closing tag)
  3. Introduce a new method updateSourceCodeLocation for this purpose

Personally I would prefer the last option.
If this change is approved, I gladly submit a PR for the proposed solution.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions