From 546762652a58a1efe28490db9d4eb8df3efb84f4 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Sun, 13 Apr 2025 21:08:16 +0100 Subject: [PATCH] Add SynField.withMutability (#31) --- WoofWare.Whippet.Fantomas/SurfaceBaseline.txt | 1 + WoofWare.Whippet.Fantomas/SynField.fs | 7 +++++++ WoofWare.Whippet.Fantomas/version.json | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/WoofWare.Whippet.Fantomas/SurfaceBaseline.txt b/WoofWare.Whippet.Fantomas/SurfaceBaseline.txt index 9475898..9c63951 100644 --- a/WoofWare.Whippet.Fantomas/SurfaceBaseline.txt +++ b/WoofWare.Whippet.Fantomas/SurfaceBaseline.txt @@ -271,6 +271,7 @@ WoofWare.Whippet.Fantomas.SynField.extractWithIdent [static method]: Fantomas.FC WoofWare.Whippet.Fantomas.SynField.make [static method]: Fantomas.FCS.Syntax.Ident option WoofWare.Whippet.Fantomas.SynFieldData -> Fantomas.FCS.Syntax.SynField WoofWare.Whippet.Fantomas.SynField.mapIdent [static method]: ('a -> 'b) -> 'a WoofWare.Whippet.Fantomas.SynFieldData -> 'b WoofWare.Whippet.Fantomas.SynFieldData WoofWare.Whippet.Fantomas.SynField.withDocString [static method]: Fantomas.FCS.Xml.PreXmlDoc -> Fantomas.FCS.Syntax.SynField -> Fantomas.FCS.Syntax.SynField +WoofWare.Whippet.Fantomas.SynField.withMutability [static method]: bool -> Fantomas.FCS.Syntax.SynField -> Fantomas.FCS.Syntax.SynField WoofWare.Whippet.Fantomas.SynFieldData`1 inherit obj WoofWare.Whippet.Fantomas.SynFieldData`1..ctor [constructor]: (Fantomas.FCS.Syntax.SynAttribute list, 'Ident, Fantomas.FCS.Syntax.SynType) WoofWare.Whippet.Fantomas.SynFieldData`1.Attrs [property]: [read-only] Fantomas.FCS.Syntax.SynAttribute list diff --git a/WoofWare.Whippet.Fantomas/SynField.fs b/WoofWare.Whippet.Fantomas/SynField.fs index 4c927d1..eccfaaa 100644 --- a/WoofWare.Whippet.Fantomas/SynField.fs +++ b/WoofWare.Whippet.Fantomas/SynField.fs @@ -78,3 +78,10 @@ module SynField = match f with | SynField (attributes, isStatic, idOpt, fieldType, isMutable, _, accessibility, range, trivia) -> SynField (attributes, isStatic, idOpt, fieldType, isMutable, doc, accessibility, range, trivia) + + /// Set the mutability of this `SynField`. + /// For example, `{ mutable Foo : int }` is a record with one mutable field. + let withMutability (isMutable : bool) (f : SynField) : SynField = + match f with + | SynField (attributes, isStatic, idOpt, fieldType, _, doc, accessibility, range, trivia) -> + SynField (attributes, isStatic, idOpt, fieldType, isMutable, doc, accessibility, range, trivia) diff --git a/WoofWare.Whippet.Fantomas/version.json b/WoofWare.Whippet.Fantomas/version.json index a6bbf9b..59bb1bf 100644 --- a/WoofWare.Whippet.Fantomas/version.json +++ b/WoofWare.Whippet.Fantomas/version.json @@ -1,5 +1,5 @@ { - "version": "0.4", + "version": "0.5", "publicReleaseRefSpec": [ "^refs/heads/main$" ], @@ -9,4 +9,4 @@ ":/global.json", ":/Directory.Build.props" ] -} +} \ No newline at end of file