Skip to content

Commit

Permalink
use tryLast
Browse files Browse the repository at this point in the history
  • Loading branch information
dawedawe committed Oct 5, 2023
1 parent 7e2ad1c commit 5c5f8af
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/FSharp.Analyzers/PartialAppAnalyzer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ module PartialAppAnalyzer =
visitExpr handler argExpr
| SynExpr.App (funcExpr = SynExpr.Ident i) -> handler (i.idText, i.idRange, 1 + depth)
| SynExpr.App (funcExpr = SynExpr.LongIdent (longDotId = longDotId) ; argExpr = argExpr) ->
let (SynIdent.SynIdent (ident = ident)) = longDotId.IdentsWithTrivia |> Seq.last
handler (ident.idText, longDotId.Range, 1 + depth)
longDotId.IdentsWithTrivia
|> Seq.tryLast
|> Option.iter (fun (SynIdent.SynIdent (ident = ident)) ->
handler (ident.idText, longDotId.Range, 1 + depth)
)

visitApp handler depth argExpr
| SynExpr.App (funcExpr = SynExpr.App _ as funcExpr ; argExpr = argExpr) ->
visitApp handler (1 + depth) funcExpr
visitApp handler depth argExpr
| SynExpr.App (funcExpr = SynExpr.TypeApp (expr = SynExpr.Ident i)) -> handler (i.idText, i.idRange, 1 + depth)
| SynExpr.App (funcExpr = SynExpr.TypeApp (expr = SynExpr.LongIdent (longDotId = longDotId))) ->
let (SynIdent.SynIdent (ident = ident)) = longDotId.IdentsWithTrivia |> Seq.last
handler (ident.idText, longDotId.Range, 1 + depth)
longDotId.IdentsWithTrivia
|> Seq.tryLast
|> Option.iter (fun (SynIdent.SynIdent (ident = ident)) ->
handler (ident.idText, longDotId.Range, 1 + depth)
)
| SynExpr.IfThenElse (ifExpr = ifExpr ; thenExpr = thenExpr ; elseExpr = elseExpr) ->
visitApp handler depth ifExpr
visitApp handler depth thenExpr
Expand Down

0 comments on commit 5c5f8af

Please sign in to comment.