fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
772 stars 194 forks source link

Trivia of ParseOak is not processed #2834

Closed nojaf closed 1 year ago

nojaf commented 1 year ago

CodeFormatter.ParseOakAsync does not do any trivia processing. This explains why the online tool is no longer showing any trivia.

#r "nuget: Fantomas.Core,6.0.0-beta-001"

open Fantomas.Core
open Fantomas.Core.SyntaxOak

CodeFormatter.ParseOakAsync(false, "let a = 0 // foo")
|> Async.RunSynchronously
|> fun result ->
    let rec hasContentAfter (node: Node) =
        node.HasContentAfter || Seq.exists hasContentAfter node.Children

    result
    |> Array.head
    |> fst
    |> hasContentAfter