Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to FCS 40 #37

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source https://api.nuget.org/v3/index.json
storage: none
framework: netstandard2.0, netcoreapp3.1

nuget FSharp.Compiler.Service ~> 39
nuget Fantomas

nuget Microsoft.SourceLink.GitHub copy_local: true
nuget Microsoft.SourceLink.GitHub copy_local: true
nuget FSharp.Compiler.Service ~> 40
nuget Fantomas
12 changes: 6 additions & 6 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ NUGET
Fantomas (4.5.1)
FSharp.Compiler.Service (>= 39.0)
FSharp.Core (>= 5.0.1)
FSharp.Compiler.Service (39.0)
FSharp.Core (5.0.1)
Microsoft.Build.Framework (>= 16.6)
Microsoft.Build.Tasks.Core (>= 16.6)
Microsoft.Build.Utilities.Core (>= 16.6)
FSharp.Compiler.Service (40.0)
FSharp.Core (5.0.2)
Microsoft.Build.Framework (>= 16.9)
Microsoft.Build.Tasks.Core (>= 16.9)
Microsoft.Build.Utilities.Core (>= 16.9)
System.Buffers (>= 4.5.1)
System.Collections.Immutable (>= 5.0)
System.Diagnostics.Process (>= 4.3)
Expand All @@ -31,7 +31,7 @@ NUGET
System.Threading.Tasks.Parallel (>= 4.3)
System.Threading.Thread (>= 4.3)
System.Threading.ThreadPool (>= 4.3)
FSharp.Core (5.0.1)
FSharp.Core (5.0.2)
Microsoft.Build.Framework (16.10)
System.Security.Permissions (>= 4.7)
Microsoft.Build.Tasks.Core (16.10)
Expand Down
4 changes: 2 additions & 2 deletions sample/CreateAst.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module FsAst.CreateAst

open System
open Fantomas
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open Microsoft.FSharp.Quotations
open FSharp.Compiler.XmlDoc
open FSharp.Compiler.Xml

let createBasicClass() =
async {
Expand Down
3 changes: 2 additions & 1 deletion sample/FormatFs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module FsAst.FormatFs

open System.IO
open Fantomas
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.CodeAnalysis


let formatAst ast =
let cfg = { FormatConfig.FormatConfig.Default with StrictMode = true } // do not format comments
Expand Down
10 changes: 5 additions & 5 deletions sample/PrintAstInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module FsAst.PrintAstInfo

open System.IO
open Fantomas
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Syntax
open FSharp.Compiler.CodeAnalysis

let rec printType indent typ =
match typ with
Expand All @@ -22,7 +22,7 @@ let rec printExpr indent expr =
| SynExpr.Const(c,_) ->
match c with
| SynConst.Int32 i -> printfn "%*sConst Int32: %d" indent "" i
| SynConst.String (s,_) -> printfn "%*sConst String: %s" indent "" s
| SynConst.String (s, _, _) -> printfn "%*sConst String: %s" indent "" s
| cnst -> printfn "%*scnst not matched: %A" indent "" cnst
| SynExpr.Paren(innerExpr, _, _, _) ->
printfn "%*sParen expr" indent ""
Expand Down Expand Up @@ -78,7 +78,7 @@ let rec printPattern indent pat =
let printAstInfo filename checker =
async {
let s = File.ReadAllText filename
let parsOpt = {FSharpParsingOptions.Default with SourceFiles = [|filename|]}
let parsOpt = { FSharpParsingOptions.Default with SourceFiles = [|filename|]}
let! res = CodeFormatter.ParseAsync(filename, SourceOrigin.SourceString s, parsOpt, checker)
for (ast,_) in res do
match ast with
Expand Down Expand Up @@ -114,7 +114,7 @@ let printAstInfo filename checker =
| SynTypeDefnSimpleReprRcd.Record record ->
for field in record.Fields do
match field with
| SynField.Field(attribs, isstatic, ident, typ, e, prexmldoc, access, range) ->
| SynField(attribs, isstatic, ident, typ, e, prexmldoc, access, range) ->
printfn "%s:"
(match ident with
| Some i -> i.idText
Expand Down
67 changes: 37 additions & 30 deletions src/AstCreate.fs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[<AutoOpen>]
module FsAst.AstCreate
open System
open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FSharp.Compiler.Text.Range
open FSharp.Compiler.Text.Pos
open FSharp.Compiler.XmlDoc
open FSharp.Compiler.Text.Position
open FSharp.Compiler.Xml

type Ident with
static member Create text =
Expand Down Expand Up @@ -57,15 +57,19 @@ type QualifiedNameOfFile with
static member Create name =
QualifiedNameOfFile(Ident.Create name)

type MemberFlags with
static member InstanceMember =
{ IsInstance = true; MemberKind = MemberKind.Member; IsDispatchSlot = false; IsOverrideOrExplicitImpl = false; IsFinal = false }
static member StaticMember =
{ MemberFlags.InstanceMember with IsInstance = false }
type SynMemberFlags with
static member InstanceMember: SynMemberFlags =
{ IsInstance = true; MemberKind = SynMemberKind.Member; IsDispatchSlot = false; IsOverrideOrExplicitImpl = false; IsFinal = false }
static member StaticMember: SynMemberFlags =
{ SynMemberFlags.InstanceMember with IsInstance = false }

type SynConst with
static member CreateString s =
SynConst.String(s, range.Zero)
SynConst.String(s, SynStringKind.Regular, range.Zero)
static member CreateVerbatimString s =
SynConst.String(s, SynStringKind.Verbatim, range.Zero)
static member CreateTripleQuoteString s =
SynConst.String(s, SynStringKind.TripleQuote, range.Zero)

type SynExpr with
static member CreateConst cnst =
Expand Down Expand Up @@ -114,7 +118,7 @@ type SynExpr with
/// | clauseN
/// ```
static member CreateMatch(matchExpr, clauses) =
SynExpr.Match(DebugPointForBinding.DebugPointAtBinding range0, matchExpr, clauses, range0)
SynExpr.Match(DebugPointAtBinding.Yes range0, matchExpr, clauses, range0)
/// Creates : `instanceAndMethod(args)`
static member CreateInstanceMethodCall(instanceAndMethod : LongIdentWithDots, args) =
let valueExpr = SynExpr.CreateLongIdent instanceAndMethod
Expand Down Expand Up @@ -358,17 +362,17 @@ type SynBindingReturnInfoRcd with
type SynBindingRcd with
static member Null =
{ Access = None
Kind = SynBindingKind.NormalBinding
Kind = SynBindingKind.Normal
IsInline = false
IsMutable = false
Attributes = SynAttributes.Empty
XmlDoc = PreXmlDoc.Empty
ValData = SynValData(Some MemberFlags.InstanceMember, SynValInfo.Empty, None)
ValData = SynValData(Some SynMemberFlags.InstanceMember, SynValInfo.Empty, None)
Pattern = SynPatRcd.CreateNull
ReturnInfo = None
Expr = SynExpr.Null range.Zero
Range = range.Zero
Bind = DebugPointForBinding.NoDebugPointAtInvisibleBinding
Bind = DebugPointAtBinding.NoneAtInvisible
}
static member Let =
{ SynBindingRcd.Null with
Expand Down Expand Up @@ -407,13 +411,13 @@ type SynMemberDefn with
/// </summary>
static member CreateStaticMember(binding:SynBindingRcd) =
let (SynValData(usedMemberFlags, valInfo, identifier)) = binding.ValData
let staticMemberFlags = Some {
let staticMemberFlags: SynMemberFlags option = Some {
// this means the member is static
IsInstance = false;
IsOverrideOrExplicitImpl = false
IsDispatchSlot = false;
IsFinal = false
MemberKind = MemberKind.Member
MemberKind = SynMemberKind.Member
}
let staticBinding = { binding with ValData = SynValData.SynValData(staticMemberFlags, valInfo, identifier) }
SynMemberDefn.Member(staticBinding.FromRcd, range.Zero)
Expand All @@ -424,12 +428,12 @@ type SynMemberDefn with
/// </summary>
static member CreateOverrideMember(binding:SynBindingRcd) =
let (SynValData(usedMemberFlags, valInfo, identifier)) = binding.ValData
let overrideMemberFlags = Some {
let overrideMemberFlags: SynMemberFlags option = Some {
IsInstance = true;
IsOverrideOrExplicitImpl = true
IsDispatchSlot = false;
IsFinal = false
MemberKind = MemberKind.Member
MemberKind = SynMemberKind.Member
}
let overrideBinding = { binding with ValData = SynValData.SynValData(overrideMemberFlags, valInfo, identifier) }
SynMemberDefn.Member(overrideBinding.FromRcd, range.Zero)
Expand All @@ -439,23 +443,25 @@ type SynMemberDefn with

type SynTypeDefnReprObjectModelRcd with
static member Create members =
{ //Kind = SynTypeDefnKind.TyconClass
Kind = SynTypeDefnKind.TyconUnspecified
{
Kind = SynTypeDefnKind.Unspecified
Members = members
Range = range.Zero
}

type SynTypeDefnRcd with
static member Create (info: SynComponentInfoRcd, members) =
static member Create (info: SynComponentInfoRcd, members, ?implicitCtor) =
{ Info = info
Repr = SynTypeDefnReprObjectModelRcd.Create(members).FromRcd
Members = []
ImplicitConstructor = implicitCtor
Range = range.Zero
}
static member CreateSimple (info: SynComponentInfoRcd, simple: SynTypeDefnSimpleRepr, ?members) =
static member CreateSimple (info: SynComponentInfoRcd, simple: SynTypeDefnSimpleRepr, ?members, ?implicitCtor) =
{ Info = info
Repr = SynTypeDefnRepr.Simple(simple, range.Zero)
Members = Option.defaultValue [] members
ImplicitConstructor = implicitCtor
Range = range.Zero
}

Expand Down Expand Up @@ -549,25 +555,26 @@ type SynTypeDefnSimpleReprUnionRcd with
Range = range.Zero }

type SynUnionCaseRcd with
static member Create(id, typ) : SynUnionCaseRcd =
static member Create(id, kind) : SynUnionCaseRcd =
{ Attributes = SynAttributes.Empty
Id = id
Type = typ
Kind = kind
XmlDoc = PreXmlDoc.Empty
Access = None
Range = range.Zero }

type SynUnionCaseType with
type SynUnionCaseKind with
static member Create(synFieldList : SynFieldRcd list) =
SynUnionCaseType.UnionCaseFields(synFieldList |> List.map (fun sf -> sf.FromRcd ))
SynUnionCaseKind.Fields (synFieldList |> List.map (fun sf -> sf.FromRcd ))

type SynEnumCaseRcd with
static member Create (id, cnst) =
{ Attributes = SynAttributes.Empty
Id = id
Constant = cnst
ConstantRange = range0
XmlDoc = PreXmlDoc.Empty
Range = range.Zero
Range = range0
}

type SynFieldRcd with
Expand Down Expand Up @@ -610,19 +617,19 @@ type SynFieldRcd with
SynFieldRcd.Create(Ident.Create id, SynType.CreateApp(SynType.CreateLongIdent typ, args |> List.map (SynType.CreateLongIdent)))

type SynAttributeList with
static member Create(attrs) =
static member Create(attrs): SynAttributeList =
{
Attributes = attrs
Range = range0
}

static member Create(attr) =
static member Create(attr): SynAttributeList =
{
Attributes = [ attr ]
Range = range0
}

static member Create([<ParamArray>] attrs) =
static member Create([<ParamArray>] attrs): SynAttributeList =
{
Attributes = List.ofArray attrs
Range = range0
Expand All @@ -641,7 +648,7 @@ type SynAttribute with
static member Create(name: string, argument: string) : SynAttribute =
{
AppliesToGetterAndSetter = false
ArgExpr = SynExpr.Const (SynConst.String(argument, range0), range0)
ArgExpr = SynExpr.Const (SynConst.CreateString argument, range0)
Range = range0
Target = None
TypeName = LongIdentWithDots([ Ident.Create name ], [ ])
Expand Down
Loading