Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Ionide.LanguageServerProtocol #954

Merged
merged 4 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
strategy:
matrix:
os: [windows-2022, macos-11, ubuntu-20.04]
dotnet: [6.0.200]
fail-fast: false # we have timing issues on some OS, so we want them all to run

runs-on: ${{ matrix.os }}
Expand All @@ -21,9 +20,7 @@ jobs:
uses: al-cheb/configure-pagefile-action@v1.2
if: ${{ matrix.os == 'windows-2019' }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet }}
uses: actions/setup-dotnet@v2
- name: Restore tools
run: dotnet tool restore
- name: Run Build
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@ on:

jobs:
release:
strategy:
matrix:
dotnet: [6.0.200]

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet }}
uses: actions/setup-dotnet@v2

- name: Restore tools
run: dotnet tool restore
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.200",
"version": "6.0.301",
"rollForward": "major"
}
}
41 changes: 20 additions & 21 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ STORAGE: NONE
RESTRICTION: || (== net6.0) (== netstandard2.0)
NUGET
remote: https://api.nuget.org/v3/index.json
altcover (8.2.837)
altcover (8.3.838)
CliWrap (3.4.4)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
Expand All @@ -26,7 +26,7 @@ NUGET
DiffPlex (>= 1.6.3)
Expecto (>= 9.0.4)
FSharp.Core (>= 4.6)
Fantomas.Client (0.5.4)
Fantomas.Client (0.6)
FSharp.Core (>= 5.0.1)
SemanticVersioning (>= 2.0.2)
StreamJsonRpc (>= 2.8.28)
Expand All @@ -36,8 +36,8 @@ NUGET
FSharp.Compiler.Service (>= 41.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net5.0))
FSharp.Core (>= 6.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net5.0))
McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net5.0))
FSharp.Compiler.Service (41.0.4)
FSharp.Core (6.0.4)
FSharp.Compiler.Service (41.0.5)
FSharp.Core (6.0.5)
Microsoft.Build.Framework (>= 17.0)
Microsoft.Build.Tasks.Core (>= 17.0)
Microsoft.Build.Utilities.Core (>= 17.0)
Expand Down Expand Up @@ -69,7 +69,7 @@ NUGET
FSharp.Control.Reactive (5.0.5) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0))
FSharp.Core (>= 4.7.2)
System.Reactive (>= 5.0 < 6.0)
FSharp.Core (6.0.4) - content: none
FSharp.Core (6.0.5) - content: none
FSharp.Formatting (14.0.1)
FSharp.Compiler.Service (>= 40.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netstandard2.1))
FSharp.UMX (1.1)
Expand All @@ -92,14 +92,14 @@ NUGET
FSharp.Core (>= 4.6.2)
FsToolkit.ErrorHandling (2.13)
FSharp.Core (>= 4.7.2)
GitHubActionsTestLogger (2.0)
GitHubActionsTestLogger (2.0.1)
Microsoft.TestPlatform.ObjectModel (>= 17.2)
ICSharpCode.Decompiler (7.2.1.6856)
Microsoft.Win32.Registry (>= 5.0)
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (>= 5.0)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.4.3)
Ionide.LanguageServerProtocol (0.4.4)
FSharp.Core (>= 6.0)
Newtonsoft.Json (>= 13.0.1)
StreamJsonRpc (>= 2.10.44)
Expand All @@ -125,16 +125,15 @@ NUGET
McMaster.NETCore.Plugins (1.4) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net5.0))
Microsoft.DotNet.PlatformAbstractions (>= 3.1.6) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp2.1))
Microsoft.Extensions.DependencyModel (>= 5.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp2.1))
MessagePack (2.3.85)
MessagePack.Annotations (>= 2.3.85)
Microsoft.Bcl.AsyncInterfaces (>= 1.0) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Collections.Immutable (>= 1.5) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Memory (>= 4.5.3) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Reflection.Emit (>= 4.6) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Reflection.Emit.Lightweight (>= 4.6) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.2) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.3) - restriction: || (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
MessagePack.Annotations (2.3.85)
MessagePack (2.4.35)
MessagePack.Annotations (>= 2.4.35)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
Microsoft.NET.StringTools (>= 1.0)
System.Collections.Immutable (>= 1.7.1) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Reflection.Emit (>= 4.7) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Reflection.Emit.Lightweight (>= 4.7) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
MessagePack.Annotations (2.4.35)
Microsoft.Bcl.AsyncInterfaces (6.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.Build (17.2) - copy_local: false
Expand Down Expand Up @@ -193,7 +192,7 @@ NUGET
Microsoft.NET.Test.Sdk (17.2)
Microsoft.CodeCoverage (>= 17.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net45)) (&& (== netstandard2.0) (>= netcoreapp1.0))
Microsoft.TestPlatform.TestHost (>= 17.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp1.0))
Microsoft.NETCore.Platforms (6.0.3)
Microsoft.NETCore.Platforms (6.0.4)
Microsoft.NETCore.Targets (5.0)
Microsoft.NETFramework.ReferenceAssemblies (1.0.2)
Microsoft.SourceLink.AzureRepos.Git (1.1.1) - copy_local: true
Expand Down Expand Up @@ -234,7 +233,7 @@ NUGET
System.Security.Principal.Windows (>= 5.0)
Microsoft.Win32.SystemEvents (6.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
Mono.Cecil (0.11.4)
Nerdbank.Streams (2.8.57)
Nerdbank.Streams (2.8.61)
Microsoft.Bcl.AsyncInterfaces (>= 5.0)
Microsoft.VisualStudio.Threading (>= 16.10.56)
Microsoft.VisualStudio.Validation (>= 16.10.26)
Expand All @@ -243,7 +242,7 @@ NUGET
NETStandard.Library (2.0.3)
Microsoft.NETCore.Platforms (>= 1.1)
Newtonsoft.Json (13.0.1)
NuGet.Frameworks (6.2)
NuGet.Frameworks (6.2.1)
runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
Expand Down Expand Up @@ -732,7 +731,7 @@ NUGET
System.Text.Encoding (>= 4.3)
System.Text.Encodings.Web (6.0) - copy_local: false, restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
System.Runtime.CompilerServices.Unsafe (>= 6.0)
System.Text.Json (6.0.4) - copy_local: false, restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
System.Text.Json (6.0.5) - copy_local: false, restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
System.Runtime.CompilerServices.Unsafe (>= 6.0)
System.Text.Encodings.Web (>= 6.0)
System.Threading (4.3)
Expand Down
2 changes: 0 additions & 2 deletions src/FsAutoComplete/CodeFixes/ConvertPositionalDUToNamed.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ type ParseAndCheckResults with
Some(ident, [ singleDUFieldPattern ], parenRange)
| SynPat.Paren(pat = UnionNameAndPatterns (ident, duFieldPatterns, parenRange)) ->
Some(ident, duFieldPatterns, parenRange)
| SynPat.Paren(pat = UnionNameAndPatterns (ident, duFieldPatterns, parenRange)) ->
Some(ident, duFieldPatterns, parenRange)
| _ -> None

let visitor =
Expand Down
9 changes: 8 additions & 1 deletion src/FsAutoComplete/CodeFixes/ExternalSystemDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ open FsAutoComplete.CodeFix
open FsAutoComplete.CodeFix.Types
open Ionide.LanguageServerProtocol.Types
open FsAutoComplete
open Newtonsoft.Json.Linq

let private (|Payload|_|) (tok: JToken) : 't option =
try
Some(Ionide.LanguageServerProtocol.Server.deserialize tok: 't)
with e ->
None

let private mapExternalDiagnostic diagnosticType =
Run.ifDiagnosticByType diagnosticType (fun diagnostic codeActionParams ->
match diagnostic.Data with
| None -> AsyncResult.retn []
| Some fixes ->
match fixes with
| :? list<TextEdit> as fixes ->
| Payload (fixes: list<TextEdit>) ->
AsyncResult.retn
[ { SourceDiagnostic = Some diagnostic
File = codeActionParams.TextDocument
Expand Down
10 changes: 6 additions & 4 deletions src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =
|> List.map (fun fix ->
{ Range = fcsRangeToLsp fix.FromRange
NewText = fix.ToText })
|> box
|> Ionide.LanguageServerProtocol.Server.serialize
|> Some

{ Range = range
Expand Down Expand Up @@ -991,7 +991,7 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =
Some
{ Legend =
createTokenLegend<ClassificationUtils.SemanticTokenTypes, ClassificationUtils.SemanticTokenModifier>
Range = Some(U2.First true)
Range = Some true
Full = Some(U2.First true) }
InlayHintProvider = Some { ResolveProvider = Some false } } }
|> success
Expand Down Expand Up @@ -1719,9 +1719,11 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =
| actions ->
return
actions
|> List.map (CodeAction.OfFix commands.TryGetFileVersion clientCapabilities.Value)
|> List.map (
CodeAction.OfFix commands.TryGetFileVersion clientCapabilities.Value
>> U2.Second
)
|> List.toArray
|> TextDocumentCodeActionResult.CodeActions
|> Some
}

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 @@ -147,7 +147,7 @@ let tests state =
| Ok None -> failtest "Should have gotten some completion items"
| Error e -> failtestf "Got an error while retrieving completions: %A" e
})

testCaseAsync "completion before first character of expression" (async {
let! server, path = server
let completionParams : CompletionParams =
Expand Down Expand Up @@ -423,7 +423,7 @@ let autoOpenTests state =
match! server.TextDocumentCodeAction p with
| Error e -> return failtestf "Quick fix Request failed: %A" e
| Ok None -> return failtest "Quick fix Request none"
| Ok (Some (TextDocumentCodeActionResult.CodeActions (ContainsOpenAction quickfix))) ->
| Ok (Some (CodeActions (ContainsOpenAction quickfix))) ->
let ns = quickfix.Title.Substring("open ".Length)

let edit =
Expand Down
4 changes: 2 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ let linterTests state =
|> Array.map (fun (diag, text) ->
{ diag with
CodeDescription = urlFor diag.Code
Data = Some(box [ { Range = diag.Range; NewText = text } ]) })
Data = Some(Ionide.LanguageServerProtocol.Server.serialize [ { Range = diag.Range; NewText = text } ]) })

testList
"Linter Test"
Expand Down Expand Up @@ -278,7 +278,7 @@ let formattingTests state =
match!
server.TextDocumentFormatting
{ TextDocument = { Uri = Path.FilePathToUri sourceFile }
Options = FormattingOptions(TabSize = 4, InsertSpaces = true) }
Options = {TabSize = 4; InsertSpaces = true; TrimTrailingWhitespace = None; InsertFinalNewline = None; TrimFinalNewlines = None; AdditionalData = System.Collections.Generic.Dictionary<_,_>() } }
with
| Ok (Some [| edit |]) ->
let normalized = { edit with NewText = normalizeLineEndings edit.NewText }
Expand Down
12 changes: 10 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ let clientCaps: ClientCapabilities =
WillSaveWaitUntil = Some true
DidSave = Some true }

let diagCaps: PublishDiagnosticsCapabilites =
let diagCaps: PublishDiagnosticsCapabilities =
let diagnosticTags: DiagnosticTagSupport = { ValueSet = [||] }

{ RelatedInformation = Some true
Expand Down Expand Up @@ -289,7 +289,7 @@ let clientCaps: ClientCapabilities =
let semanticTokensCaps: SemanticTokensClientCapabilities =
{ DynamicRegistration = Some true
Requests =
{ Range = Some(U2.First true)
{ Range = Some true
Full = Some(U2.First true) }
TokenTypes = [||]
TokenModifiers = [||]
Expand Down Expand Up @@ -624,3 +624,11 @@ let (|As|_|) (m: PlainNotification) : 't option =
match trySerialize m.Content with
| Some (r: FsAutoComplete.CommandResponse.ResponseMsg<'t>) -> Some r.Data
| None -> None

let (|CodeActions|_|) (t: TextDocumentCodeActionResult) =
let actions =
t
|> Array.choose (function U2.Second action -> Some action | _ -> None)
match actions with
| [||] -> None
| actions -> Some actions
Loading