-
Notifications
You must be signed in to change notification settings - Fork 832
Description
Is your feature request related to a problem? Please describe.
In order to have better results in Fantomas, we require more information in the syntax tree about certain specifics.
Examples are locations of certain tokens or keywords.
Describe the solution you'd like
In the past, we added this information directly to the syntax tree nodes.
However, this can lead to a lot of overhead as discussed in #12400.
As a compromise, we could instantiate a new object/record/structure per syntax tree node to bundle these.
The proposal would be to have them as the last item in a DU case.
Example:
SyntaxTrivia.fs:
namespace FSharp.Compiler.Syntax.Trivia // or SyntaxTrivia ?
type SynTryWithTrivia =
{ TryKeyword: Range
WithKeyword: Range }SyntaxTree.fs:
type SynExpr =
| TryWith of
tryExpr: SynExpr *
tryRange: range *
withCases: SynMatchClause list *
withRange: range *
tryDebugPoint: DebugPointAtTry *
withDebugPoint: DebugPointAtWith
range: range *
trivia: SynTryWithTrivia Describe alternatives you've considered
The alternative is to have all extra information unbundled in the Syntax tree.
Additional context
related: #11481
I'm not really fixed on the appendix name, I would like to avoid using any trivia terminology.
Trivia is used as a concept in Fantomas to add additional information found in the tokens to the tree.
In this case, we really are enriching the tree. So to avoid any confusion I would go with a different name.
Let me know what you think.
//cc @dsyme @auduchinok @baronfel