Skip to content

Commit

Permalink
use new methods that are in FCS to do walk (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored Feb 19, 2024
1 parent 6f9cf86 commit a5ad3c0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ open System.Threading.Tasks
open FsAutoComplete.FCSPatches
open FsAutoComplete.Lsp
open FsAutoComplete.Lsp.Helpers
open FSharp.Compiler.Syntax


[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -354,7 +355,23 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac
use progress = new ServerProgressReport(lspClient)
do! progress.Begin($"Checking for unnecessary parentheses {fileName}...", message = filePathUntag)

let! unnecessaryParentheses = UnnecessaryParentheses.getUnnecessaryParentheses getSourceLine tyRes.GetAST
let unnecessaryParentheses =
(System.Collections.Generic.HashSet(comparer = Range.comparer), tyRes.GetAST)
||> ParsedInput.fold (fun ranges path node ->
match node with
| SyntaxNode.SynExpr(SynExpr.Paren(expr = inner; rightParenRange = Some _; range = range)) when
not (SynExpr.shouldBeParenthesizedInContext getSourceLine path inner)
->
ignore (ranges.Add range)
ranges

| SyntaxNode.SynPat(SynPat.Paren(inner, range)) when
not (SynPat.shouldBeParenthesizedInContext path inner)
->
ignore (ranges.Add range)
ranges

| _ -> ranges)

let! ct = Async.CancellationToken

Expand Down Expand Up @@ -1594,8 +1611,6 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac
allFilesToDeclarations
|> AMapAsync.tryFindAndFlattenR $"Could not find getDeclarations for {filename}" filename



let codeGenServer =
{ new ICodeGenerationService with
member x.TokenizeLine(file, i) =
Expand Down

0 comments on commit a5ad3c0

Please sign in to comment.