Skip to content

Review trivia which can't be inferred from their node kind #223

@c42f

Description

@c42f

Some tokens becomes trivia after parsing has done its work. For example, parentheses in both f(x) and (x) only appear in the green tree as trivia. For the function call, the presence of parentheses can be inferred from the tree (call f x) because there's only one type of function call syntax. That is, we can reconstruct the trivia which isn't whitespace or comments.

In contrast, this is not the case for (x), until #222 is merged because the green tree didn't represent grouping parentheses (these ended up as trivia on the parent node instead).

In general, it seems that a nice invariant for the green tree to have would be that

Every piece of syntax can be inferred from the kind, flags, and list of nontrivia children, other than whitespace and comments.

Presumably there's cases other than #222 to fix - would be good to review all cases of bump used together with TRIVIA_FLAG.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions