Skip to content

Commit

Permalink
Type.LongIdentApp
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Nov 25, 2022
1 parent 65716da commit a7cd66e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Fantomas.Core.Tests/DallasTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,3 +1623,18 @@ and [<Sealed>] MapDebugView<'Key, 'Value when 'Key: comparison>(v: Map<'Key, 'Va
member x.Items =
v |> Seq.truncate 10000 |> Seq.map KeyValuePairDebugFriendly |> Seq.toArray
"""

[<Test>]
let ``long ident app type`` () =
formatSourceString
false
"""
let create size : ImmutableArray<'T>.Builder = ImmutableArray.CreateBuilder(size)
"""
config
|> prepend newline
|> should
equal
"""
let create size : ImmutableArray<'T>.Builder = ImmutableArray.CreateBuilder(size)
"""
3 changes: 3 additions & 0 deletions src/Fantomas.Core/CodePrinter2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3088,6 +3088,9 @@ let genType (t: Type) =
+> sepSpace
+> genType node.RightHandSide
|> genNode node
| Type.LongIdentApp node ->
genType node.AppType +> sepDot +> genIdentListNode node.LongIdent
|> genNode node

let genSynTupleTypeSegments (path: Choice<Type, SingleTextNode> list) =
let genTs addNewline =
Expand Down
3 changes: 3 additions & 0 deletions src/Fantomas.Core/Fangorn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,9 @@ let mkType (creationAide: CreationAide) (t: SynType) : Type =
typeRange
)
|> Type.AppPrefix
| SynType.LongIdentApp(t, lid, None, [], _, None, _) ->
TypeLongIdentAppNode(mkType creationAide t, mkSynLongIdent lid, typeRange)
|> Type.LongIdentApp
| SynType.WithGlobalConstraints(SynType.Var _, [ SynTypeConstraint.WhereTyparSubtypeOfType _ as tc ], _) ->
mkSynTypeConstraint creationAide tc |> Type.WithSubTypeConstraint
| SynType.WithGlobalConstraints(t, tcs, _) ->
Expand Down
8 changes: 8 additions & 0 deletions src/Fantomas.Core/SyntaxOak.fs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ type TypeOrNode(lhs: Type, orNode: SingleTextNode, rhs: Type, range) =
member x.Or = orNode
member x.RightHandSide = rhs

type TypeLongIdentAppNode(appType: Type, longIdent: IdentListNode, range) =
inherit NodeBase(range)
override this.Children = [| yield Type.Node appType; yield longIdent |]
member x.AppType = appType
member x.LongIdent = longIdent

[<RequireQualifiedAccess; NoEquality; NoComparison>]
type Type =
| Funs of TypeFunsNode
Expand All @@ -343,6 +349,7 @@ type Type =
| Paren of TypeParenNode
| SignatureParameter of TypeSignatureParameterNode
| Or of TypeOrNode
| LongIdentApp of TypeLongIdentAppNode

static member Node(x: Type) : Node =
match x with
Expand All @@ -366,6 +373,7 @@ type Type =
| Paren n -> n
| SignatureParameter n -> n
| Or n -> n
| LongIdentApp n -> n

type PatAttribNode(attrs: MultipleAttributeListNode option, pat: Pattern, range) =
inherit NodeBase(range)
Expand Down

0 comments on commit a7cd66e

Please sign in to comment.