Skip to content

Commit

Permalink
Merge branch 'main' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Mar 17, 2024
2 parents fe5cd3c + 6bdbbaa commit 637725c
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 34 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## Unreleased

## [0.71.0] - 2024-03-07

### Added

* [Add unnecessary parentheses analyzer & code fix](https://github.com/fsharp/FsAutoComplete/pull/1235) (thanks @brianrourkeboll)

### Fixed

* [Fix debugger regression](https://github.com/fsharp/FsAutoComplete/pull/1230/files) (thanks @baronfel)

### Changed

* [Slightly better Project Loading messages](https://github.com/fsharp/FsAutoComplete/pull/1234) (thanks @TheAngryByrd)
* [add missing keyword list and extra information](https://github.com/fsharp/FsAutoComplete/pull/1226) (thanks @jkone27)
* [Speed up project load times](https://github.com/fsharp/FsAutoComplete/pull/1245) (thanks @TheAngryByrd)

## [0.70.1] - 2024-02-13

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/AdaptiveExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ module AsyncAVal =
else
{ new AbstractVal<'a>() with
member x.Compute t =
let real = Task.FromResult(value.GetValue t)
let real = Task.Run(fun () -> value.GetValue t)
AdaptiveCancellableTask(id, real) }
:> asyncaval<_>

Expand Down
20 changes: 3 additions & 17 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,10 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
}

member self.GetProjectOptionsFromScript(file: string<LocalPath>, source, tfm) =
async {
let! (projOptions, errors) =
match tfm with
| FSIRefs.TFM.NetFx -> self.GetNetFxScriptOptions(file, source)
| FSIRefs.TFM.NetCore -> self.GetNetCoreScriptOptions(file, source)

match errors with
| [] -> ()
| errs ->
optsLogger.info (
Log.setLogLevel LogLevel.Error
>> Log.setMessage "Resolved {opts} with {errors}"
>> Log.addContextDestructured "opts" projOptions
>> Log.addContextDestructured "errors" errs
)
match tfm with
| FSIRefs.TFM.NetFx -> self.GetNetFxScriptOptions(file, source)
| FSIRefs.TFM.NetCore -> self.GetNetCoreScriptOptions(file, source)

return projOptions
}

member __.ScriptTypecheckRequirementsChanged =
scriptTypecheckRequirementsChanged.Publish
Expand Down
8 changes: 3 additions & 5 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ open System.IO
open FSharp.Compiler.CodeAnalysis
open Utils
open FSharp.Compiler.Text
open FsAutoComplete.Logging
open Ionide.ProjInfo.ProjectSystem
open FSharp.UMX
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Symbols
open Microsoft.Extensions.Caching.Memory
open System
open FsToolkit.ErrorHandling
open FSharp.Compiler.Diagnostics

type Version = int

Expand All @@ -27,7 +24,8 @@ type FSharpCompilerServiceChecker =
(FSharpProjectOptions * FSharpProjectOptions list) option

member GetProjectOptionsFromScript:
file: string<LocalPath> * source: ISourceText * tfm: FSIRefs.TFM -> Async<FSharpProjectOptions>
file: string<LocalPath> * source: ISourceText * tfm: FSIRefs.TFM ->
Async<FSharpProjectOptions * FSharpDiagnostic list>

member ScriptTypecheckRequirementsChanged: IEvent<unit>

Expand Down
36 changes: 27 additions & 9 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,22 +1203,40 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac
and! tfmConfig = tfmConfig

let! projs =
asyncOption {
asyncResult {
let cts = getOpenFileTokenOrDefault filePath
use linkedCts = CancellationTokenSource.CreateLinkedTokenSource(ctok, cts)

let! opts =
checker.GetProjectOptionsFromScript(filePath, file.Source, tfmConfig)
|> Async.withCancellation linkedCts.Token
try
let! (opts, errors) =
checker.GetProjectOptionsFromScript(filePath, file.Source, tfmConfig)
|> Async.withCancellation linkedCts.Token

opts |> scriptFileProjectOptions.Trigger
let diags = errors |> Array.ofList |> Array.map fcsErrorToDiagnostic

diagnosticCollections.SetFor(
Path.LocalPathToUri filePath,
"F# Script Project Options",
file.Version,
diags
)

opts |> scriptFileProjectOptions.Trigger
return
{ FSharpProjectOptions = opts
LanguageVersion = LanguageVersionShim.fromFSharpProjectOptions opts }
|> List.singleton
with e ->
logger.error (
Log.setMessage "Error getting project options for {filePath}"
>> Log.addContextDestructured "filePath" filePath
>> Log.addExn e
)

return
{ FSharpProjectOptions = opts
LanguageVersion = LanguageVersionShim.fromFSharpProjectOptions opts }
return! Error $"Error getting project options for {filePath} - {e.Message}"
}

return file, (Option.toList projs |> Ok)
return file, projs
else
let! projs =
sourceFileToProjectOptions
Expand Down
4 changes: 2 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/CompletionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let tests state =
do! server.TextDocumentDidOpen tdop

let! _diagnostics =
waitForParseResultsForFile "Script.fsx" events
waitForDiagnosticErrorForFile "Script.fsx" events
|> AsyncResult.bimap (fun _ -> failtest "Should have had errors") (fun e -> e)

return (server, path)
Expand Down Expand Up @@ -743,7 +743,7 @@ let autoOpenTests state =
do! server.TextDocumentDidOpen tdop

do!
waitForParseResultsForFile scriptName events
waitForDiagnosticErrorForFile scriptName events
|> AsyncResult.bimap (fun _ -> failtest "Should have had errors") id
|> Async.Ignore

Expand Down
2 changes: 2 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ let diagnosticsToResult =

let waitForParseResultsForFile file = fileDiagnostics file >> diagnosticsToResult >> Async.AwaitObservable

let waitForDiagnosticErrorForFile file = fileDiagnostics file >> Observable.choose (function | [||] -> None | diags -> Some diags) >> diagnosticsToResult >> Async.AwaitObservable

let waitForFsacDiagnosticsForFile file = fsacDiagnostics file >> diagnosticsToResult >> Async.AwaitObservable

let waitForCompilerDiagnosticsForFile file = compilerDiagnostics file >> diagnosticsToResult >> Async.AwaitObservable
Expand Down
1 change: 1 addition & 0 deletions test/FsAutoComplete.Tests.Lsp/Helpers.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ val fsacDiagnostics: file: string -> (IObservable<string * obj> -> IObservable<D
val compilerDiagnostics: file: string -> (IObservable<string * obj> -> IObservable<Diagnostic array>)
val diagnosticsToResult: (IObservable<Diagnostic array> -> IObservable<Result<unit, Diagnostic array>>)
val waitForParseResultsForFile: file: string -> (IObservable<string * obj> -> Async<Result<unit, Diagnostic array>>)
val waitForDiagnosticErrorForFile: file: string -> (IObservable<string * obj> -> Async<Result<unit, Diagnostic array>>)
val waitForFsacDiagnosticsForFile: file: string -> (IObservable<string * obj> -> Async<Result<unit, Diagnostic array>>)

val waitForCompilerDiagnosticsForFile:
Expand Down

0 comments on commit 637725c

Please sign in to comment.