Skip to content

Commit

Permalink
Refactor FieldsGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
7sharp9 committed Oct 11, 2021
1 parent f2a85cb commit eedd9ef
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Myriad.Plugins/FieldsGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ module internal Create =
LongIdentWithDots.Create (parent |> List.map (fun i -> i.idText))
|> SynType.CreateLongIdent

let camelCaseIdent (ident: Ident) =
Ident.Create(ident.idText.Substring(0, 1).ToLowerInvariant() + ident.idText.Substring(1))

let pattern =
let arguments =
fields
|> List.map (fun f -> let field = f.ToRcd
let name = SynPatRcd.CreateNamed(camelCaseIdent field.Id.Value, SynPatRcd.CreateWild)
let name = SynPatRcd.CreateNamed(Ast.Ident.asCamelCase field.Id.Value, SynPatRcd.CreateWild)
SynPatRcd.CreateTyped(name, field.Type) |> SynPatRcd.CreateParen)

SynPatRcd.CreateLongIdent(varIdent, arguments)
Expand All @@ -64,7 +61,7 @@ module internal Create =
|> List.map (fun f -> let field = f.ToRcd
let fieldIdent = match field.Id with None -> failwith "no field name" | Some f -> f
let name = LongIdentWithDots.Create([fieldIdent.idText])
let ident = SynExpr.CreateIdent(camelCaseIdent fieldIdent)
let ident = SynExpr.CreateIdent(Ast.Ident.asCamelCase fieldIdent)
RecordFieldName(name, true), Some ident, None)

let newRecord = SynExpr.Record(None, None, fields, range.Zero )
Expand Down

0 comments on commit eedd9ef

Please sign in to comment.