Skip to content

Add trivia to SynArgPats.NamePatPairs #14008

Description

@nojaf

Is your feature request related to a problem? Please describe.

Consider the following code:

let examineData x =
    match data with
    | OnePartData( // foo
        part1 = p1
      (* bar *) ) -> p1
    | TwoPartData(part1 = p1; part2=p2) -> p1 + p2

and relevant AST:

NamePatPairs
  ([(part1, tmp.fsx (4,14--4,15),
     Named
       (SynIdent (p1, None), false, None,
        tmp.fsx (4,16--4,18)))], tmp.fsx (4,8--5,17))

It would be nice if we had the ranges of the parentheses as trivia.

Describe the solution you'd like

Add SynArgPatsNamePatPairsTrivia that contains both ranges.
We might also want to consider updating the range of SynArgPats.NamePatPairs to include the parentheses.
Although I'm not hellbent on that specifically.

Describe alternatives you've considered

There is no real way of detecting the parentheses.

Additional context

related: #11481

Surfaced in fsprojects/fantomas#2541

//cc @dsyme, @auduchinok

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions