Skip to content

Commit

Permalink
Initial FCS update
Browse files Browse the repository at this point in the history
todo: open type
  • Loading branch information
auduchinok committed Oct 22, 2020
1 parent b022ffd commit b584aff
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@

<Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(PaketIntermediateOutputPath)/$(MSBuildProjectFile).references')" >
<PropertyGroup>
<ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
<!-- <ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec> -->
</PropertyGroup>
</Target>

Expand Down
6 changes: 3 additions & 3 deletions src/Fantomas.Tests/FormattingPropertyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ and generateSynExpr size =
Gen.map2 (fun b clauses -> SynExpr.MatchLambda(b, zero, clauses, NoDebugPointAtDoBinding, zero))
Arb.generate<_> genSubSynMatchClauseList
2,
Gen.map3 (fun b pat expr -> SynExpr.Lambda(b, false, pat, expr, zero)) Arb.generate<_>
Gen.map3 (fun b pat expr -> SynExpr.Lambda(b, false, pat, expr, None, zero)) Arb.generate<_>
genSubSynSimplePats genSubSynExpr
2,
Gen.map5 (fun b expr1 expr2 expr3 s ->
Expand Down Expand Up @@ -419,7 +419,7 @@ and generateDeclExpr size =
Gen.map2 (fun b clauses -> SynExpr.MatchLambda(b, zero, clauses, NoDebugPointAtDoBinding, zero))
Arb.generate<_> genSubSynMatchClauseList //
4,
Gen.map3 (fun b pat expr -> SynExpr.Lambda(b, false, pat, expr, zero)) Arb.generate<_>
Gen.map3 (fun b pat expr -> SynExpr.Lambda(b, false, pat, expr, None, zero)) Arb.generate<_>
genSubSynSimplePats genSubDeclExpr //
1,
Gen.map2 (fun expr1 expr2 ->
Expand Down Expand Up @@ -574,7 +574,7 @@ let rec shrinkSynExpr =
| SynExpr.TypeApp (expr, _, _, _, _, _, _)
| SynExpr.Do (expr, _)
| SynExpr.Assert (expr, _)
| SynExpr.Lambda (_, _, _, expr, _)
| SynExpr.Lambda (_, _, _, expr, _, _)
| SynExpr.CompExpr (_, _, expr, _)
| SynExpr.ArrayOrListOfSeqExpr (_, expr, _)
| SynExpr.New (_, _, expr, _)
Expand Down
19 changes: 11 additions & 8 deletions src/Fantomas/AstTransformer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ module private Ast =
Properties = p []
FsAstNode = ast
Childs = [ visitSynExceptionDefn exceptionDef ] }
| SynModuleDecl.Open (longDotId, range) ->
| SynModuleDecl.Open (SynOpenDeclTarget.ModuleOrNamespace(s, _), range) -> // todo: types
{ Type = SynModuleDecl_Open
Range = r range
Properties = p [ "longIdent" ==> lid longDotId ]
Properties = p [ "longIdent" ==> s ]
FsAstNode = ast
Childs = [] }
| SynModuleDecl.Attributes (attrs, range) ->
Expand All @@ -147,6 +147,7 @@ module private Ast =
Properties = p []
FsAstNode = ast
Childs = [ visitSynModuleOrNamespace moduleOrNamespace ] }
| _ -> failwith "todo" // todo: open types

and visitSynExpr (synExpr: SynExpr): Node =
match synExpr with
Expand Down Expand Up @@ -269,7 +270,7 @@ module private Ast =
"isNotNakedRefCell" ==> isNotNakedRefCell ]
FsAstNode = synExpr
Childs = [ yield visitSynExpr expr ] }
| SynExpr.Lambda (fromMethod, inLambdaSeq, args, body, range) ->
| SynExpr.Lambda (fromMethod, inLambdaSeq, args, body, _, range) ->
{ Type = SynExpr_Lambda
Range = r range
Properties =
Expand Down Expand Up @@ -832,10 +833,10 @@ module private Ast =

and visitSynMemberDefn (mbrDef: SynMemberDefn): Node =
match mbrDef with
| SynMemberDefn.Open (longIdent, range) ->
| SynMemberDefn.Open (SynOpenDeclTarget.ModuleOrNamespace(s, _), range) -> // todo: types
{ Type = SynMemberDefn_Open
Range = r range
Properties = p [ "longIdent" ==> li longIdent ]
Properties = p [ "longIdent" ==> li s ]
FsAstNode = mbrDef
Childs = [] }
| SynMemberDefn.Member (memberDefn, range) ->
Expand All @@ -844,7 +845,7 @@ module private Ast =
Properties = p []
FsAstNode = mbrDef
Childs = [ yield visitSynBinding memberDefn ] }
| SynMemberDefn.ImplicitCtor (access, attrs, ctorArgs, selfIdentifier, range) ->
| SynMemberDefn.ImplicitCtor (access, attrs, ctorArgs, selfIdentifier, _, range) ->
{ Type = SynMemberDefn_ImplicitCtor
Range = r range
Properties =
Expand Down Expand Up @@ -935,6 +936,7 @@ module private Ast =
[ yield! (visitSynAttributeLists range attrs)
if typeOpt.IsSome then yield visitSynType typeOpt.Value
yield visitSynExpr synExpr ] }
| _ -> failwith "todo" // todo: open types

and visitSynSimplePat (sp: SynSimplePat): Node =
match sp with
Expand Down Expand Up @@ -1765,10 +1767,10 @@ module private Ast =
Properties = p []
FsAstNode = ast
Childs = typeDefs |> List.map visitSynTypeDefnSig }
| SynModuleSigDecl.Open (longId, range) ->
| SynModuleSigDecl.Open (SynOpenDeclTarget.ModuleOrNamespace(s, _), range) -> // todo: types
{ Type = SynModuleSigDecl_Open
Range = r range
Properties = p [ "longIdent" ==> li longId ]
Properties = p [ "longIdent" ==> li s ]
FsAstNode = ast
Childs = [] }
| SynModuleSigDecl.HashDirective (hash, range) ->
Expand All @@ -1789,6 +1791,7 @@ module private Ast =
Properties = p []
FsAstNode = ast
Childs = [ visitSynExceptionSig synExceptionSig ] }
| _ -> failwith "todo" // todo: open types

and visitSynExceptionSig (exceptionDef: SynExceptionSig): Node =
match exceptionDef with
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas/CodeFormatterImpl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ let isValidAST ast =

| SynExpr.ArrayOrListOfSeqExpr (_, synExpr, _range) -> validateExpr synExpr
| SynExpr.CompExpr (_, _, synExpr, _range) -> validateExpr synExpr
| SynExpr.Lambda (_, _, _synSimplePats, synExpr, _range) -> validateExpr synExpr
| SynExpr.Lambda (_, _, _synSimplePats, synExpr, _, _range) -> validateExpr synExpr

| SynExpr.MatchLambda (_isExnMatch, _argm, synMatchClauseList, _spBind, _wholem) ->
List.forall validateClause synMatchClauseList
Expand Down
15 changes: 7 additions & 8 deletions src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,12 @@ let (|Access|) =
| SynAccess.Private -> "private"

let (|PreXmlDoc|) (px: PreXmlDoc) =
match px.ToXmlDoc() with
| XmlDoc lines -> lines
px.ToXmlDoc(false, None).UnprocessedLines

// Module declarations (10 cases)
let (|Open|_|) =
function
| SynModuleDecl.Open (LongIdentWithDots s, _) -> Some s
| SynModuleDecl.Open (SynOpenDeclTarget.ModuleOrNamespace(LongIdent s, _), _) -> Some s // todo: types
| _ -> None

let (|ModuleAbbrev|_|) =
Expand Down Expand Up @@ -362,7 +361,7 @@ let (|Exception|_|) =

let (|SigOpen|_|) =
function
| SynModuleSigDecl.Open (LongIdent s, _) -> Some s
| SynModuleSigDecl.Open (SynOpenDeclTarget.ModuleOrNamespace(LongIdent s, _), _) -> Some s // todo: types
| _ -> None

let (|SigModuleAbbrev|_|) =
Expand Down Expand Up @@ -448,7 +447,7 @@ let (|MDNestedType|_|) =

let (|MDOpen|_|) =
function
| SynMemberDefn.Open (LongIdent s, _) -> Some s
| SynMemberDefn.Open (SynOpenDeclTarget.ModuleOrNamespace(LongIdent s, _), _) -> Some s // todo: types
| _ -> None

let (|MDImplicitInherit|_|) =
Expand All @@ -468,7 +467,7 @@ let (|MDValField|_|) =

let (|MDImplicitCtor|_|) =
function
| SynMemberDefn.ImplicitCtor (ao, ats, ps, ido, _) -> Some(ats, ao, ps, Option.map (|Ident|) ido)
| SynMemberDefn.ImplicitCtor (ao, ats, ps, ido, _, _) -> Some(ats, ao, ps, Option.map (|Ident|) ido)
| _ -> None

let (|MDMember|_|) =
Expand Down Expand Up @@ -852,8 +851,8 @@ let (|AppWithMultilineArgument|_|) e =
/// Gather all arguments in lambda
let rec (|Lambda|_|) =
function
| SynExpr.Lambda (_, _, pats, Lambda (e, patss), _) -> Some(e, pats :: patss)
| SynExpr.Lambda (_, _, pats, e, _) -> Some(e, [ pats ])
| SynExpr.Lambda (_, _, pats, Lambda (e, patss), _, _) -> Some(e, pats :: patss)
| SynExpr.Lambda (_, _, pats, e, _, _) -> Some(e, [ pats ])
| _ -> None

let (|MatchLambda|_|) =
Expand Down

0 comments on commit b584aff

Please sign in to comment.