From 06f3b1576ffa98fff440930d8ccdd12d36d33dfc Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Mon, 21 Nov 2022 08:36:45 -0600 Subject: [PATCH] WIP F# 7 update This removes the 6.0 target while we wait for updated packages on NuGet. --- .vscode/launch.json | 26 - global.json | 9 +- paket.lock | 529 +-------- src/FsAutoComplete.Core/CodeGeneration.fs | 14 +- src/FsAutoComplete.Core/Commands.fs | 4 +- .../DocumentationFormatter.fs | 23 +- src/FsAutoComplete.Core/FCSPatches.fs | 3 + .../FsAutoComplete.Core.fsproj | 1 - src/FsAutoComplete.Core/InlayHints.fs | 9 +- .../ParseAndCheckResults.fs | 9 +- .../RecordStubGenerator.fs | 11 +- src/FsAutoComplete.Core/SignatureFormatter.fs | 24 +- src/FsAutoComplete.Core/TestAdapter.fs | 26 +- .../UnionPatternMatchCaseGenerator.fs | 9 +- src/FsAutoComplete.Core/UntypedAstUtils.fs | 40 +- .../Workaround/ServiceParseTreeWalk.fs | 1012 ----------------- .../CodeFixes/RemoveUnusedBinding.fs | 2 +- .../CodeFixes/RenameParamToMatchSignature.fs | 2 +- .../CodeFixes/ReplaceWithSuggestion.fs | 2 +- src/FsAutoComplete/CommandResponse.fs | 3 +- src/FsAutoComplete/LspHelpers.fs | 4 +- .../LspServers/AdaptiveFSharpLspServer.fs | 24 +- .../LspServers/FsAutoComplete.Lsp.fs | 20 +- .../CompletionTests.fs | 5 +- test/FsAutoComplete.Tests.Lsp/CoreTests.fs | 6 +- .../ExtensionsTests.fs | 2 +- 26 files changed, 190 insertions(+), 1629 deletions(-) delete mode 100644 src/FsAutoComplete.Core/Workaround/ServiceParseTreeWalk.fs diff --git a/.vscode/launch.json b/.vscode/launch.json index c5ba1a784..e3f6e14c3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,32 +18,6 @@ "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, - { - "name": "Specific LSP tests", - "type": "coreclr", - "request": "launch", - "program": "${workspaceFolder}/test/FsAutoComplete.Tests.Lsp/bin/Debug/net6.0/FsAutoComplete.Tests.Lsp.dll", - "cwd": "${workspaceFolder}", - "console": "integratedTerminal", - "stopAtEntry": false, - "justMyCode": false, - "symbolOptions": { - "searchPaths": [], - "searchMicrosoftSymbolServer": true, - "searchNuGetOrgSymbolServer": true - }, - "sourceLinkOptions": { - "*": { - "enabled": true - } - }, - "enableStepFiltering": false, - "args": [ - "--debug", - "--filter", - "FSAC.lsp.Ionide WorkspaceLoader.Go to definition tests.Script GoTo Tests.Go-to-definition on first char of identifier works" - ] - }, { "name": ".NET Core Attach", "type": "coreclr", diff --git a/global.json b/global.json index 163e96b8c..08585a2b3 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,5 @@ { - "sdk": { - "version": "6.0.400", - "rollForward": "latestPatch" - } -} + "sdk": { + "version": "7.0.100" + } +} \ No newline at end of file diff --git a/paket.lock b/paket.lock index 89e2382c6..56991956c 100644 --- a/paket.lock +++ b/paket.lock @@ -34,40 +34,24 @@ NUGET FSharp.Compiler.Service (>= 41.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) FSharp.Core (>= 6.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) - 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) + FSharp.Compiler.Service (42.7.101) + FSharp.Core (7.0) + Microsoft.Build.Framework (>= 17.4) + Microsoft.Build.Tasks.Core (>= 17.4) + Microsoft.Build.Utilities.Core (>= 17.4) System.Buffers (>= 4.5.1) - System.Collections.Immutable (>= 5.0) - System.Diagnostics.Process (>= 4.3) - System.Diagnostics.TraceSource (>= 4.3) - System.Linq.Expressions (>= 4.3) - System.Linq.Queryable (>= 4.3) - System.Memory (>= 4.5.4) - System.Net.Requests (>= 4.3) - System.Net.Security (>= 4.3.1) - System.Reflection.Emit (>= 4.3) - System.Reflection.Metadata (>= 5.0) - System.Reflection.TypeExtensions (>= 4.3) - System.Runtime (>= 4.3) + System.Collections.Immutable (>= 6.0) + System.Memory (>= 4.5.5) + System.Reflection.Emit (>= 4.7) + System.Reflection.Metadata (>= 6.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - System.Runtime.InteropServices (>= 4.3) - System.Runtime.Loader (>= 4.3) - System.Security.Claims (>= 4.3) - System.Security.Cryptography.Algorithms (>= 4.3) - System.Security.Principal (>= 4.3) - System.Threading.Tasks.Parallel (>= 4.3) - System.Threading.Thread (>= 4.3) - System.Threading.ThreadPool (>= 4.3) FSharp.Control.AsyncSeq (3.2.1) FSharp.Core (>= 4.7.2) Microsoft.Bcl.AsyncInterfaces (>= 5.0) - FSharp.Control.Reactive (5.0.5) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) + FSharp.Control.Reactive (5.0.5) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) FSharp.Core (>= 4.7.2) System.Reactive (>= 5.0 < 6.0) - FSharp.Core (6.0.5) - content: none + FSharp.Core (7.0) - content: none FSharp.Data.Adaptive (1.2.13) FSharp.Core (>= 4.7) System.Reflection.Emit.Lightweight (>= 4.6) @@ -148,32 +132,32 @@ NUGET System.Text.Encoding.CodePages (>= 4.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) System.Text.Json (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) System.Threading.Tasks.Dataflow (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) - Microsoft.Build.Framework (17.2) - copy_local: false - Microsoft.Win32.Registry (>= 4.3) - System.Security.Permissions (>= 4.7) + Microsoft.Build.Framework (17.4) - copy_local: false + Microsoft.Win32.Registry (>= 5.0) - restriction: || (== net6.0) (== netstandard2.0) + System.Security.Permissions (>= 6.0) Microsoft.Build.Locator (1.5.3) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) - Microsoft.Build.Tasks.Core (17.2) - copy_local: false - Microsoft.Build.Framework (>= 17.2) - Microsoft.Build.Utilities.Core (>= 17.2) - Microsoft.NET.StringTools (>= 1.0) - Microsoft.Win32.Registry (>= 4.3) - System.CodeDom (>= 4.4) - System.Collections.Immutable (>= 5.0) - System.Reflection.Metadata (>= 1.6) - System.Resources.Extensions (>= 4.6) - System.Security.Cryptography.Pkcs (>= 4.7) - System.Security.Cryptography.Xml (>= 4.7) - System.Security.Permissions (>= 4.7) + Microsoft.Build.Tasks.Core (17.4) - copy_local: false + Microsoft.Build.Framework (>= 17.4) + Microsoft.Build.Utilities.Core (>= 17.4) + Microsoft.NET.StringTools (>= 17.4) + Microsoft.Win32.Registry (>= 5.0) - restriction: || (== net6.0) (== netstandard2.0) + System.CodeDom (>= 6.0) + System.Collections.Immutable (>= 6.0) + System.Reflection.Metadata (>= 6.0) + System.Resources.Extensions (>= 6.0) + System.Security.Cryptography.Pkcs (>= 6.0.1) + System.Security.Cryptography.Xml (>= 6.0) + System.Security.Permissions (>= 6.0) System.Threading.Tasks.Dataflow (>= 6.0) Microsoft.Build.Tasks.Git (1.1.1) - copy_local: true - Microsoft.Build.Utilities.Core (17.2) - copy_local: false - Microsoft.Build.Framework (>= 17.2) - Microsoft.NET.StringTools (>= 1.0) - Microsoft.Win32.Registry (>= 4.3) - System.Collections.Immutable (>= 5.0) - System.Configuration.ConfigurationManager (>= 4.7) - System.Security.Permissions (>= 4.7) - restriction: || (&& (== net7.0) (< net6.0)) (== netstandard2.0) - System.Text.Encoding.CodePages (>= 4.0.1) - restriction: || (&& (== net7.0) (< net6.0)) (== netstandard2.0) + Microsoft.Build.Utilities.Core (17.4) - copy_local: false + Microsoft.Build.Framework (>= 17.4) + Microsoft.NET.StringTools (>= 17.4) + Microsoft.Win32.Registry (>= 5.0) - restriction: || (== net6.0) (== netstandard2.0) + System.Collections.Immutable (>= 6.0) + System.Configuration.ConfigurationManager (>= 6.0) + System.Security.Permissions (>= 6.0) - restriction: || (== net6.0) (== netstandard2.0) + System.Text.Encoding.CodePages (>= 6.0) - restriction: || (== net6.0) (== netstandard2.0) Microsoft.CodeCoverage (17.3) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net45)) (&& (== netstandard2.0) (>= netcoreapp1.0)) Microsoft.DotNet.PlatformAbstractions (3.1.6) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) Microsoft.Extensions.DependencyModel (6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) @@ -182,15 +166,15 @@ NUGET System.Runtime.CompilerServices.Unsafe (>= 6.0) System.Text.Encodings.Web (>= 6.0) System.Text.Json (>= 6.0) - Microsoft.NET.StringTools (17.3.1) - copy_local: false + Microsoft.NET.StringTools (17.4) - copy_local: false System.Memory (>= 4.5.5) System.Runtime.CompilerServices.Unsafe (>= 6.0) Microsoft.NET.Test.Sdk (17.3) Microsoft.CodeCoverage (>= 17.3) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net45)) (&& (== netstandard2.0) (>= netcoreapp1.0)) Microsoft.TestPlatform.TestHost (>= 17.3) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp1.0)) - Microsoft.NETCore.Platforms (6.0.5) - Microsoft.NETCore.Targets (5.0) Microsoft.NETFramework.ReferenceAssemblies (1.0.3) + Microsoft.NETFramework.ReferenceAssemblies.net481 (>= 1.0.3) + Microsoft.NETFramework.ReferenceAssemblies.net481 (1.0.3) Microsoft.SourceLink.AzureRepos.Git (1.1.1) - copy_local: true Microsoft.Build.Tasks.Git (>= 1.1.1) Microsoft.SourceLink.Common (>= 1.1.1) @@ -218,16 +202,12 @@ NUGET System.Threading.Tasks.Extensions (>= 4.5.4) Microsoft.VisualStudio.Threading.Analyzers (17.3.44) Microsoft.VisualStudio.Validation (17.0.64) - Microsoft.Win32.Primitives (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) Microsoft.Win32.Registry (5.0) System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monoandroid) (< netstandard1.3)) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (&& (== net7.0) (>= monoandroid) (< netstandard1.3)) (&& (== net7.0) (>= monotouch)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (>= xamarinios)) (&& (== net7.0) (>= xamarinmac)) (&& (== net7.0) (>= xamarintvos)) (&& (== net7.0) (>= xamarinwatchos)) (== netstandard2.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (>= uap10.1)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (< netcoreapp2.1)) (&& (== net7.0) (>= uap10.1)) (== netstandard2.0) System.Security.AccessControl (>= 5.0) System.Security.Principal.Windows (>= 5.0) - Microsoft.Win32.SystemEvents (6.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + Microsoft.Win32.SystemEvents (6.0.1) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) Mono.Cecil (0.11.4) Nerdbank.Streams (2.8.61) Microsoft.Bcl.AsyncInterfaces (>= 5.0) @@ -237,49 +217,6 @@ NUGET System.Runtime.CompilerServices.Unsafe (>= 5.0) Newtonsoft.Json (13.0.1) NuGet.Frameworks (6.3) - 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) - runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.fedora.27-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.fedora.28-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.native.System (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) - runtime.native.System.Net.Http (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) - runtime.native.System.Net.Security (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) - runtime.native.System.Security.Cryptography.Apple (4.3.1) - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple (>= 4.3.1) - runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - 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) - runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.fedora.27-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.fedora.28-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.opensuse.42.3-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.ubuntu.18.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.3) - runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.opensuse.42.3-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple (4.3.1) - runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - runtime.ubuntu.18.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) SemanticVersioning (2.0.2) Serilog (2.11) Serilog.Sinks.Async (1.5) @@ -300,444 +237,72 @@ NUGET System.Threading.Tasks.Dataflow (>= 6.0) System.Buffers (4.5.1) System.CodeDom (6.0) - copy_local: false - System.Collections (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Collections.Concurrent (4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Diagnostics.Tracing (>= 4.3) - System.Globalization (>= 4.3) - System.Reflection (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) System.Collections.Immutable (6.0) + System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) System.CommandLine (2.0.0-beta4.22272.1) System.Memory (>= 4.5.4) - restriction: || (&& (== net7.0) (< net6.0)) (== netstandard2.0) System.Configuration.ConfigurationManager (6.0) System.Security.Cryptography.ProtectedData (>= 6.0) System.Security.Permissions (>= 6.0) - System.Diagnostics.Debug (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) System.Diagnostics.DiagnosticSource (6.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< net5.0)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net5.0)) (== netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - System.Diagnostics.Process (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.Win32.Primitives (>= 4.3) - Microsoft.Win32.Registry (>= 4.3) - runtime.native.System (>= 4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Globalization (>= 4.3) - System.IO (>= 4.3) - System.IO.FileSystem (>= 4.3) - System.IO.FileSystem.Primitives (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Text.Encoding.Extensions (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Threading.Thread (>= 4.3) - System.Threading.ThreadPool (>= 4.3) - System.Diagnostics.TraceSource (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - runtime.native.System (>= 4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Globalization (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Threading (>= 4.3) - System.Diagnostics.Tracing (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Drawing.Common (6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Drawing.Common (6.0) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) Microsoft.Win32.SystemEvents (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) System.Formats.Asn1 (6.0) - copy_local: false System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) - System.Globalization (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Globalization.Calendars (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Globalization (>= 4.3) - System.Runtime (>= 4.3) - System.Globalization.Extensions (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - System.Globalization (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.IO (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.IO.FileSystem (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.IO (>= 4.3) - System.IO.FileSystem.Primitives (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.IO.FileSystem.Primitives (4.3) - System.Runtime (>= 4.3) System.IO.Pipelines (6.0.3) System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0) System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0) - System.Linq (4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Linq.Expressions (4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Globalization (>= 4.3) - System.IO (>= 4.3) - System.Linq (>= 4.3) - System.ObjectModel (>= 4.3) - System.Reflection (>= 4.3) - System.Reflection.Emit (>= 4.3) - System.Reflection.Emit.ILGeneration (>= 4.3) - System.Reflection.Emit.Lightweight (>= 4.3) - System.Reflection.Extensions (>= 4.3) - System.Reflection.Primitives (>= 4.3) - System.Reflection.TypeExtensions (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Threading (>= 4.3) - System.Linq.Queryable (4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Linq (>= 4.3) - System.Linq.Expressions (>= 4.3) - System.Reflection (>= 4.3) - System.Reflection.Extensions (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) System.Memory (4.5.5) System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (&& (== net7.0) (>= monotouch)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= xamarinios)) (&& (== net7.0) (>= xamarinmac)) (&& (== net7.0) (>= xamarintvos)) (&& (== net7.0) (>= xamarinwatchos)) (== netstandard2.0) System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net7.0) (< netcoreapp2.0)) (== netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (&& (== net7.0) (>= monotouch)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (< netcoreapp2.1)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= uap10.1)) (&& (== net7.0) (>= xamarinios)) (&& (== net7.0) (>= xamarinmac)) (&& (== net7.0) (>= xamarintvos)) (&& (== net7.0) (>= xamarinwatchos)) (== netstandard2.0) - System.Net.Http (4.3.4) - Microsoft.NETCore.Platforms (>= 1.1.1) - runtime.native.System (>= 4.3) - runtime.native.System.Net.Http (>= 4.3) - runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.2) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Diagnostics.DiagnosticSource (>= 4.3) - System.Diagnostics.Tracing (>= 4.3) - System.Globalization (>= 4.3) - System.Globalization.Extensions (>= 4.3) - System.IO (>= 4.3) - System.IO.FileSystem (>= 4.3) - System.Net.Primitives (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Security.Cryptography.Algorithms (>= 4.3) - System.Security.Cryptography.Encoding (>= 4.3) - System.Security.Cryptography.OpenSsl (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Security.Cryptography.X509Certificates (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Net.Primitives (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) - System.Runtime (>= 4.3.1) - System.Runtime.Handles (>= 4.3) - System.Net.Requests (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Diagnostics.Tracing (>= 4.3) - System.Globalization (>= 4.3) - System.IO (>= 4.3) - System.Net.Http (>= 4.3) - System.Net.Primitives (>= 4.3) - System.Net.WebHeaderCollection (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Net.Security (4.3.2) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.Win32.Primitives (>= 4.3) - runtime.native.System (>= 4.3) - runtime.native.System.Net.Security (>= 4.3) - runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.2) - System.Collections (>= 4.3) - System.Collections.Concurrent (>= 4.3) - System.Diagnostics.Tracing (>= 4.3) - System.Globalization (>= 4.3) - System.Globalization.Extensions (>= 4.3) - System.IO (>= 4.3) - System.Net.Primitives (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Security.Claims (>= 4.3) - System.Security.Cryptography.Algorithms (>= 4.3) - System.Security.Cryptography.Encoding (>= 4.3) - System.Security.Cryptography.OpenSsl (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Security.Cryptography.X509Certificates (>= 4.3) - System.Security.Principal (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Threading.ThreadPool (>= 4.3) - System.Net.WebHeaderCollection (4.3) - System.Collections (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) System.Numerics.Vectors (4.5) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net7.0) (< netcoreapp2.0)) (== netstandard2.0) - System.ObjectModel (4.3) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Threading (>= 4.3) - System.Reactive (5.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) - System.Reflection (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.IO (>= 4.3) - System.Reflection.Primitives (>= 4.3) - System.Runtime (>= 4.3) + System.Reactive (5.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net5.0)) System.Reflection.Emit (4.7) System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net7.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= uap10.1)) (== netstandard2.0) - System.Reflection.Emit.ILGeneration (4.7) + System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net7.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= uap10.1)) (== netstandard2.0) System.Reflection.Emit.Lightweight (4.7) System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (< portable-net45+wp8)) (&& (== net6.0) (>= uap10.1)) (&& (== net7.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (< portable-net45+wp8)) (&& (== net7.0) (>= uap10.1)) (== netstandard2.0) - System.Reflection.Extensions (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Reflection (>= 4.3) - System.Runtime (>= 4.3) System.Reflection.Metadata (6.0.1) System.Collections.Immutable (>= 6.0) - System.Reflection.Primitives (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Reflection.TypeExtensions (4.7) System.Resources.Extensions (6.0) - copy_local: false System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) - System.Resources.ResourceManager (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Globalization (>= 4.3) - System.Reflection (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) System.Runtime.CompilerServices.Unsafe (6.0) - System.Runtime.Extensions (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1.1) - Microsoft.NETCore.Targets (>= 1.1.3) - System.Runtime (>= 4.3.1) - System.Runtime.Handles (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Runtime.InteropServices (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Reflection (>= 4.3) - System.Reflection.Primitives (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.Loader (4.3) - System.IO (>= 4.3) - System.Reflection (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Numerics (4.3) - System.Globalization (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Security.AccessControl (6.0) + System.Security.AccessControl (6.0) - copy_local: false System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) - System.Security.Claims (4.3) - System.Collections (>= 4.3) - System.Globalization (>= 4.3) - System.IO (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Security.Principal (>= 4.3) - System.Security.Cryptography.Algorithms (4.3.1) - Microsoft.NETCore.Platforms (>= 1.1) - runtime.native.System.Security.Cryptography.Apple (>= 4.3.1) - runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.2) - System.Collections (>= 4.3) - System.IO (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Runtime.Numerics (>= 4.3) - System.Security.Cryptography.Encoding (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Security.Cryptography.Cng (5.0) - copy_local: false - System.Security.Cryptography.Csp (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - System.IO (>= 4.3) - System.Reflection (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Security.Cryptography.Algorithms (>= 4.3) - System.Security.Cryptography.Encoding (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading (>= 4.3) - System.Security.Cryptography.Encoding (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3) - System.Collections (>= 4.3) - System.Collections.Concurrent (>= 4.3) - System.Linq (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Security.Cryptography.OpenSsl (5.0) - System.Formats.Asn1 (>= 5.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.0)) + System.Security.Cryptography.Cng (5.0) - copy_local: false, restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (< net6.0)) (&& (== net7.0) (< netcoreapp3.1)) (&& (== net7.0) (< netstandard2.1)) (== netstandard2.0) System.Security.Cryptography.Pkcs (6.0.1) - copy_local: false System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (< netstandard2.1)) (== netstandard2.0) System.Formats.Asn1 (>= 6.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (< netstandard2.1)) (== netstandard2.0) System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (< net6.0)) (&& (== net7.0) (< netcoreapp3.1)) (&& (== net7.0) (< netstandard2.1)) (== netstandard2.0) - System.Security.Cryptography.Primitives (4.3) - System.Diagnostics.Debug (>= 4.3) - System.Globalization (>= 4.3) - System.IO (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) System.Security.Cryptography.ProtectedData (6.0) System.Memory (>= 4.5.4) - restriction: || (&& (== net7.0) (< net6.0)) (== netstandard2.0) - System.Security.Cryptography.X509Certificates (4.3.2) - Microsoft.NETCore.Platforms (>= 1.1) - runtime.native.System (>= 4.3) - runtime.native.System.Net.Http (>= 4.3) - runtime.native.System.Security.Cryptography.OpenSsl (>= 4.3.2) - System.Collections (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Globalization (>= 4.3) - System.Globalization.Calendars (>= 4.3) - System.IO (>= 4.3) - System.IO.FileSystem (>= 4.3) - System.IO.FileSystem.Primitives (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Runtime.InteropServices (>= 4.3) - System.Runtime.Numerics (>= 4.3) - System.Security.Cryptography.Algorithms (>= 4.3) - System.Security.Cryptography.Cng (>= 4.3) - System.Security.Cryptography.Csp (>= 4.3) - System.Security.Cryptography.Encoding (>= 4.3) - System.Security.Cryptography.OpenSsl (>= 4.3) - System.Security.Cryptography.Primitives (>= 4.3) - System.Text.Encoding (>= 4.3) - System.Threading (>= 4.3) System.Security.Cryptography.Xml (6.0.1) - copy_local: false System.Memory (>= 4.5.4) - restriction: || (&& (== net7.0) (< net6.0)) (== netstandard2.0) System.Security.AccessControl (>= 6.0) System.Security.Cryptography.Pkcs (>= 6.0.1) - System.Security.Permissions (6.0) + System.Security.Permissions (6.0) - copy_local: false System.Security.AccessControl (>= 6.0) System.Windows.Extensions (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) - System.Security.Principal (4.3) - System.Runtime (>= 4.3) System.Security.Principal.Windows (5.0) - copy_local: false - System.Text.Encoding (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) System.Text.Encoding.CodePages (6.0) - copy_local: false + System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - System.Text.Encoding.Extensions (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) - System.Text.Encoding (>= 4.3) System.Text.Encodings.Web (6.0) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) System.Text.Json (6.0.5) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) System.Text.Encodings.Web (>= 6.0) - System.Threading (4.3) - System.Runtime (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Threading.Tasks (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - System.Runtime (>= 4.3) System.Threading.Tasks.Dataflow (6.0) - copy_local: false System.Threading.Tasks.Extensions (4.5.4) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.1)) (&& (== net7.0) (< netstandard1.0)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= wp8)) (== netstandard2.0) - System.Threading.Tasks.Parallel (4.3) - System.Collections.Concurrent (>= 4.3) - System.Diagnostics.Debug (>= 4.3) - System.Diagnostics.Tracing (>= 4.3) - System.Resources.ResourceManager (>= 4.3) - System.Runtime (>= 4.3) - System.Runtime.Extensions (>= 4.3) - System.Threading (>= 4.3) - System.Threading.Tasks (>= 4.3) - System.Threading.Thread (4.3) - System.Runtime (>= 4.3) - System.Threading.ThreadPool (4.3) - System.Runtime (>= 4.3) - System.Runtime.Handles (>= 4.3) - System.Windows.Extensions (6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) + System.Windows.Extensions (6.0) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) System.Drawing.Common (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) YoloDev.Expecto.TestSdk (0.13.3) Expecto (>= 9.0 < 10.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) diff --git a/src/FsAutoComplete.Core/CodeGeneration.fs b/src/FsAutoComplete.Core/CodeGeneration.fs index b5e9056dd..06a16826c 100644 --- a/src/FsAutoComplete.Core/CodeGeneration.fs +++ b/src/FsAutoComplete.Core/CodeGeneration.fs @@ -640,7 +640,7 @@ module CodeGenerationUtils = let (|LongIdentPattern|_|) = function - | SynPat.LongIdent(longDotId = LongIdentWithDots (xs, _)) -> + | SynPat.LongIdent(longDotId = SynLongIdent (id = xs)) -> // let (name, range) = xs |> List.map (fun x -> x.idText, x.idRange) |> List.last let last = List.last xs Some(last.idText, last.idRange) @@ -932,7 +932,7 @@ module CodeGenerationUtils = match req with | TyparStaticReq.None -> Some("'" + s.idText) | TyparStaticReq.HeadType -> Some("^" + s.idText) - | SynType.LongIdent (LongIdentWithDots (xs, _)) -> xs |> Seq.map (fun x -> x.idText) |> String.concat "." |> Some + | SynType.LongIdent (SynLongIdent (id = xs)) -> xs |> Seq.map (fun x -> x.idText) |> String.concat "." |> Some | SynType.App (t, _, ts, _, _, isPostfix, _) -> match t, ts with | TypeIdent typeName, [] -> Some typeName @@ -952,7 +952,15 @@ module CodeGenerationUtils = debug "Unsupported case with %A and %A" t ts None | SynType.Anon _ -> Some "_" - | SynType.Tuple (_, ts, _) -> Some(ts |> Seq.choose (snd >> (|TypeIdent|_|)) |> String.concat " * ") + | SynType.Tuple (_, ts, _) -> + Some( + ts + |> Seq.choose (function + | SynTupleTypeSegment.Type name -> (|TypeIdent|_|) name + | SynTupleTypeSegment.Star _ -> Some "*" + | SynTupleTypeSegment.Slash _ -> Some "/") + |> String.concat " " + ) | SynType.Array (dimension, TypeIdent typeName, _) -> Some(sprintf "%s [%s]" typeName (String(',', dimension - 1))) | SynType.MeasurePower (TypeIdent typeName, RationalConst power, _) -> Some(sprintf "%s^%s" typeName power) | SynType.MeasureDivide (TypeIdent numerator, TypeIdent denominator, _) -> diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs index 3433211fd..05bddd1c9 100644 --- a/src/FsAutoComplete.Core/Commands.fs +++ b/src/FsAutoComplete.Core/Commands.fs @@ -1156,7 +1156,7 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers: let fillHelpTextInTheBackground decls (pos: Position) fn getLine = - let declName (d: DeclarationListItem) = d.Name + let declName (d: DeclarationListItem) = d.NameInList //Fill list of declarations synchronously to know which declarations should be in cache. for d in decls do @@ -1667,7 +1667,7 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers: match res with | Some (decls, residue, shouldKeywords) -> - let declName (d: DeclarationListItem) = d.Name + let declName (d: DeclarationListItem) = d.NameInList //Init cache for current list state.Declarations.Clear() diff --git a/src/FsAutoComplete.Core/DocumentationFormatter.fs b/src/FsAutoComplete.Core/DocumentationFormatter.fs index d9b03f2f1..352e76108 100644 --- a/src/FsAutoComplete.Core/DocumentationFormatter.fs +++ b/src/FsAutoComplete.Core/DocumentationFormatter.fs @@ -107,8 +107,7 @@ module DocumentationFormatter = formatShowDocumentationLink name xmlDocSig assemblyName else if typ.HasTypeDefinition then let name = - typ.TypeDefinition.DisplayName - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + typ.TypeDefinition.DisplayName |> FSharpKeywords.NormalizeIdentifierBackticks formatShowDocumentationLink name xmlDocSig assemblyName else @@ -131,8 +130,8 @@ module DocumentationFormatter = match c.IsProperty, PrettyNaming.TryChopPropertyName c.MemberName with | true, Some (chopped) when chopped <> c.MemberName -> chopped, true | _, _ -> - if PrettyNaming.IsMangledOpName c.MemberName then - PrettyNaming.DecompileOpName c.MemberName, false + if PrettyNaming.IsLogicalOpName c.MemberName then + PrettyNaming.ConvertValLogicalNameToDisplayNameCore c.MemberName, false else c.MemberName, false @@ -235,13 +234,13 @@ module DocumentationFormatter = match func.EnclosingEntitySafe with | Some ent -> ent.DisplayName | _ -> func.DisplayName - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + |> FSharpKeywords.NormalizeIdentifierBackticks elif func.IsOperatorOrActivePattern then func.DisplayName elif func.DisplayName.StartsWith "( " then - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.LogicalName + FSharpKeywords.NormalizeIdentifierBackticks func.LogicalName else - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.DisplayName + FSharpKeywords.NormalizeIdentifierBackticks func.DisplayName name @@ -314,7 +313,7 @@ module DocumentationFormatter = |> List.concat |> List.map (fun p -> let name = Option.defaultValue p.DisplayName p.Name - let normalisedName = FSharpKeywords.AddBackticksToIdentifierIfNeeded name + let normalisedName = FSharpKeywords.NormalizeIdentifierBackticks name normalisedName.Length) match allLengths with @@ -323,7 +322,7 @@ module DocumentationFormatter = let formatName indent padding (parameter: FSharpParameter) = let name = Option.defaultValue parameter.DisplayName parameter.Name - let normalisedName = FSharpKeywords.AddBackticksToIdentifierIfNeeded name + let normalisedName = FSharpKeywords.NormalizeIdentifierBackticks name indent + normalisedName.PadRight padding + ":" let isDelegate = @@ -412,7 +411,7 @@ module DocumentationFormatter = elif func.IsOperatorOrActivePattern then func.DisplayName elif func.DisplayName.StartsWith "( " then - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.LogicalName + FSharpKeywords.NormalizeIdentifierBackticks func.LogicalName elif func.LogicalName.StartsWith "get_" || func.LogicalName.StartsWith "set_" then PrettyNaming.TryChopPropertyName func.DisplayName |> Option.defaultValue func.DisplayName @@ -536,7 +535,7 @@ module DocumentationFormatter = v.LogicalName else v.DisplayName) - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + |> FSharpKeywords.NormalizeIdentifierBackticks let constraints = match v.FullTypeSafe with @@ -732,7 +731,7 @@ module DocumentationFormatter = let typeDisplay = let name = - let normalisedName = FSharpKeywords.AddBackticksToIdentifierIfNeeded fse.DisplayName + let normalisedName = FSharpKeywords.NormalizeIdentifierBackticks fse.DisplayName if fse.GenericParameters.Count > 0 then let paramsAndConstraints = diff --git a/src/FsAutoComplete.Core/FCSPatches.fs b/src/FsAutoComplete.Core/FCSPatches.fs index 8a4f72b78..2eb0556b4 100644 --- a/src/FsAutoComplete.Core/FCSPatches.fs +++ b/src/FsAutoComplete.Core/FCSPatches.fs @@ -380,6 +380,7 @@ module SyntaxTreeOps = | SynExpr.Null _ | SynExpr.Ident _ | SynExpr.ImplicitZero _ + | SynExpr.Typar _ | SynExpr.Const _ -> false | SynExpr.TypeTest (e, _, _) @@ -489,5 +490,7 @@ module SyntaxTreeOps = |> Option.defaultValue false | SynExpr.IndexFromEnd (expr, range) -> walkExpr expr | SynExpr.DebugPoint (innerExpr = expr) -> walkExpr expr + | SynExpr.Dynamic (funcExpr = funcExpr; argExpr = argExpr) -> walkExpr funcExpr || walkExpr argExpr + walkExpr inpExpr diff --git a/src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj b/src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj index 81ddede39..6760aba75 100644 --- a/src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj +++ b/src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj @@ -9,7 +9,6 @@ - diff --git a/src/FsAutoComplete.Core/InlayHints.fs b/src/FsAutoComplete.Core/InlayHints.fs index b6bcb6ca5..f557872f5 100644 --- a/src/FsAutoComplete.Core/InlayHints.fs +++ b/src/FsAutoComplete.Core/InlayHints.fs @@ -11,7 +11,6 @@ open System.Linq open System.Collections.Immutable open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Text.Range -open FsAutoComplete.Core.Workaround.ServiceParseTreeWalk /// `traversePat`from `SyntaxTraversal.Traverse` /// @@ -556,7 +555,7 @@ let rec private getParensForPatternWithIdent (patternRange: Range) (identStart: let private rangeOfNamedPat (text: NamedText) (pat: SynPat) = match pat with | SynPat.Named(accessibility = None) -> pat.Range - | SynPat.Named (ident = ident; accessibility = Some (access)) -> + | SynPat.Named (ident = SynIdent (ident = ident); accessibility = Some (access)) -> maybe { let start = ident.idRange.Start let! line = text.GetLine start @@ -588,7 +587,7 @@ let private rangeOfNamedPat (text: NamedText) (pat: SynPat) = /// Note: (deliberately) fails when `pat` is neither `Named` nor `OptionalVal` let rec private getParensForIdentPat (text: NamedText) (pat: SynPat) (path: SyntaxVisitorPath) = match pat with - | SynPat.Named (ident = ident) -> + | SynPat.Named(ident = SynIdent (ident = ident)) -> // neither `range`, not `pat.Range` includes `accessibility`... // `let private (a: int)` is not valid, must include private: `let (private a: int)` let patternRange = rangeOfNamedPat text pat @@ -658,11 +657,11 @@ let tryGetExplicitTypeInfo (text: NamedText, ast: ParsedInput) (pos: Position) : // no simple way out: Range for `SynPat.LongIdent` doesn't cover full pats (just ident) // see dotnet/fsharp#13115 // | _ when not (rangeContainsPos pat.Range pos) -> None - | SynPat.Named (ident = ident) when + | SynPat.Named(ident = SynIdent (ident = ident)) when rangeContainsPos ident.idRange pos && invalidPositionForTypeAnnotation pos path -> ExplicitType.Invalid |> Some - | SynPat.Named (ident = ident; isThisVal = false) when rangeContainsPos ident.idRange pos -> + | SynPat.Named (ident = SynIdent (ident = ident); isThisVal = false) when rangeContainsPos ident.idRange pos -> let typed = isDirectlyTyped ident.idRange.Start path if typed then diff --git a/src/FsAutoComplete.Core/ParseAndCheckResults.fs b/src/FsAutoComplete.Core/ParseAndCheckResults.fs index fbf6d1a0d..2978840ed 100644 --- a/src/FsAutoComplete.Core/ParseAndCheckResults.fs +++ b/src/FsAutoComplete.Core/ParseAndCheckResults.fs @@ -583,7 +583,7 @@ type ParseAndCheckResults | _ -> let results = - checkResults.GetDeclarationListInfo(Some parseResults, pos.Line, lineStr, longName, getAllSymbols) + checkResults.GetDeclarationListInfo(Some parseResults, pos.Line, lineStr, longName, getSymbols) let getKindPriority = function @@ -600,10 +600,11 @@ type ParseAndCheckResults match filter with | Some "StartsWith" -> results.Items - |> Array.filter (fun d -> d.Name.StartsWith(residue, StringComparison.InvariantCultureIgnoreCase)) + |> Array.filter (fun d -> d.NameInList.StartsWith(residue, StringComparison.InvariantCultureIgnoreCase)) | Some "Contains" -> results.Items - |> Array.filter (fun d -> d.Name.IndexOf(residue, StringComparison.InvariantCultureIgnoreCase) >= 0) + |> Array.filter (fun d -> + d.NameInList.IndexOf(residue, StringComparison.InvariantCultureIgnoreCase) >= 0) | _ -> results.Items let sortedDecls = @@ -634,7 +635,7 @@ type ParseAndCheckResults if n <> 0 then n else - n <- StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name) + n <- StringComparer.OrdinalIgnoreCase.Compare(x.NameInList, y.NameInList) if n <> 0 then n diff --git a/src/FsAutoComplete.Core/RecordStubGenerator.fs b/src/FsAutoComplete.Core/RecordStubGenerator.fs index 9ad3dcf66..c771a241e 100644 --- a/src/FsAutoComplete.Core/RecordStubGenerator.fs +++ b/src/FsAutoComplete.Core/RecordStubGenerator.fs @@ -65,7 +65,7 @@ type RecordStubsInsertionParams = expr.FieldExprList |> List.choose (fun fieldInfo -> match fieldInfo with - | SynExprRecordField (fieldName = (LongIdentWithDots (identHead :: _, _), true)) -> + | SynExprRecordField (fieldName = (SynLongIdent(id = identHead :: _), true)) -> let fieldLine = identHead.idRange.StartLine let indentColumn = identHead.idRange.StartColumn Some(fieldInfo, indentColumn, fieldLine) @@ -89,7 +89,7 @@ type RecordStubsInsertionParams = return! match lastFieldInfo with | SynExprRecordField(expr = None) -> None - | SynExprRecordField (fieldName = (LongIdentWithDots (_ :: _, _), true) + | SynExprRecordField (fieldName = (SynLongIdent(id = _ :: _), true) expr = Some expr blockSeparator = semiColonOpt) -> match semiColonOpt with @@ -152,12 +152,9 @@ let formatRecord let fieldsWritten = fieldsWritten |> List.collect (function - | SynExprRecordField (fieldName = (fieldName, _)) -> + | SynExprRecordField (fieldName = (SynLongIdent (id = id), _)) -> // Extract in qualified identifiers: A.B. = ... - if fieldName.Lid.Length > 0 then - [ (fieldName.Lid.Item(fieldName.Lid.Length - 1)).idText ] - else - []) + if id.Length > 0 then [ (List.last id).idText ] else []) |> Set.ofList let fieldsToWrite = diff --git a/src/FsAutoComplete.Core/SignatureFormatter.fs b/src/FsAutoComplete.Core/SignatureFormatter.fs index fac2d908b..5e63f542a 100644 --- a/src/FsAutoComplete.Core/SignatureFormatter.fs +++ b/src/FsAutoComplete.Core/SignatureFormatter.fs @@ -79,9 +79,9 @@ module SignatureFormatter = elif isMeasureType typeDef then typ.Format context else - sprintf "%s<%s>" (FSharpKeywords.AddBackticksToIdentifierIfNeeded typeDef.DisplayName) genericArgs + sprintf "%s<%s>" (FSharpKeywords.NormalizeIdentifierBackticks typeDef.DisplayName) genericArgs else if typ.HasTypeDefinition then - FSharpKeywords.AddBackticksToIdentifierIfNeeded typ.TypeDefinition.DisplayName + FSharpKeywords.NormalizeIdentifierBackticks typ.TypeDefinition.DisplayName else typ.Format context with _ -> @@ -100,8 +100,8 @@ module SignatureFormatter = match c.IsProperty, PrettyNaming.TryChopPropertyName c.MemberName with | true, Some (chopped) when chopped <> c.MemberName -> chopped, true | _, _ -> - if PrettyNaming.IsMangledOpName c.MemberName then - $"( {PrettyNaming.DecompileOpName c.MemberName} )", false + if PrettyNaming.IsLogicalOpName c.MemberName then + $"( {PrettyNaming.ConvertValLogicalNameToDisplayNameCore c.MemberName} )", false else c.MemberName, false @@ -195,13 +195,13 @@ module SignatureFormatter = match func.EnclosingEntitySafe with | Some ent -> ent.DisplayName | _ -> func.DisplayName - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + |> FSharpKeywords.NormalizeIdentifierBackticks elif func.IsOperatorOrActivePattern then $"( {func.DisplayNameCore} )" elif func.DisplayName.StartsWith "( " then - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.LogicalName + FSharpKeywords.NormalizeIdentifierBackticks func.LogicalName else - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.DisplayName + FSharpKeywords.NormalizeIdentifierBackticks func.DisplayName name @@ -271,7 +271,7 @@ module SignatureFormatter = let safeParameterName (p: FSharpParameter) = match Option.defaultValue p.DisplayNameCore p.Name with | "" -> "" - | name -> FSharpKeywords.AddBackticksToIdentifierIfNeeded name + | name -> FSharpKeywords.NormalizeIdentifierBackticks name let padLength = let allLengths = @@ -383,7 +383,7 @@ module SignatureFormatter = elif func.IsOperatorOrActivePattern then func.DisplayName elif func.DisplayName.StartsWith "( " then - FSharpKeywords.AddBackticksToIdentifierIfNeeded func.LogicalName + FSharpKeywords.NormalizeIdentifierBackticks func.LogicalName elif func.LogicalName.StartsWith "get_" || func.LogicalName.StartsWith "set_" then PrettyNaming.TryChopPropertyName func.DisplayName |> Option.defaultValue func.DisplayName @@ -436,7 +436,7 @@ module SignatureFormatter = match func.EnclosingEntitySafe with | Some ent -> ent.DisplayName | _ -> func.DisplayName - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + |> FSharpKeywords.NormalizeIdentifierBackticks else formatFSharpType displayContext func.ReturnParameter.Type with _ex -> @@ -525,7 +525,7 @@ module SignatureFormatter = v.LogicalName else v.DisplayName) - |> FSharpKeywords.AddBackticksToIdentifierIfNeeded + |> FSharpKeywords.NormalizeIdentifierBackticks let constraints = match v.FullTypeSafe with @@ -679,7 +679,7 @@ module SignatureFormatter = let typeDisplay = let name = - let normalisedName = FSharpKeywords.AddBackticksToIdentifierIfNeeded fse.DisplayName + let normalisedName = FSharpKeywords.NormalizeIdentifierBackticks fse.DisplayName if fse.GenericParameters.Count > 0 then let paramsAndConstraints = diff --git a/src/FsAutoComplete.Core/TestAdapter.fs b/src/FsAutoComplete.Core/TestAdapter.fs index 8fe8a0e80..7cd27012b 100644 --- a/src/FsAutoComplete.Core/TestAdapter.fs +++ b/src/FsAutoComplete.Core/TestAdapter.fs @@ -64,7 +64,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry list = if isExpectoName i.idText then Case elif isExpectoListName i.idText then List else NotExpecto - | SynExpr.LongIdent (_, LongIdentWithDots (lst, _), _, _) -> + | SynExpr.LongIdent (_, SynLongIdent (id = lst), _, _) -> let i = lst |> List.last if isExpectoName i.idText then Case @@ -200,7 +200,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry list = | _ -> () let visitModulesAndNamespaces prefix modulesOrNss = - Seq.iter (fun (SynModuleOrNamespace (_, _, _, decls, _, _, _, _)) -> visitDeclarations prefix decls) modulesOrNss + Seq.iter (fun (SynModuleOrNamespace (decls = decls)) -> visitDeclarations prefix decls) modulesOrNss let allTests = { Name = "" @@ -211,7 +211,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry list = Type = "" } match ast with - | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> visitModulesAndNamespaces allTests modules + | ParsedInput.ImplFile (ParsedImplFileInput (contents = modules)) -> visitModulesAndNamespaces allTests modules | _ -> () List.ofSeq allTests.Childs @@ -224,7 +224,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = attrs |> List.collect (fun (attr: SynAttributeList) -> attr.Attributes) |> List.exists (fun a -> - let str = a.TypeName.Lid |> List.last + let str = a.TypeName.LongIdent |> List.last str.idText.EndsWith "Test" || str.idText.EndsWith "TestAttribute" @@ -239,8 +239,8 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = let getName = function - | SynPat.Named (ident = name) -> name.idText - | SynPat.LongIdent(longDotId = LongIdentWithDots (ident, _)) -> ident |> List.last |> (fun n -> n.idText) + | SynPat.Named(ident = SynIdent (ident = name)) -> name.idText + | SynPat.LongIdent(longDotId = SynLongIdent (id = ident)) -> ident |> List.last |> (fun n -> n.idText) | _ -> "" let rec visitMember (parent: TestAdapterEntry) = @@ -327,7 +327,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = let visitModulesAndNamespaces parent modulesOrNss = Seq.iter - (fun (SynModuleOrNamespace (ids, _, _, decls, _, _, _, r)) -> + (fun (SynModuleOrNamespace (longId = ids; decls = decls; range = r)) -> let name = String.concat "." [ for i in ids -> i.idText ] ident <- ident + 1 @@ -355,7 +355,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = Type = "" } match ast with - | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> visitModulesAndNamespaces allTests modules + | ParsedInput.ImplFile (ParsedImplFileInput (contents = modules)) -> visitModulesAndNamespaces allTests modules | _ -> () List.ofSeq allTests.Childs @@ -367,7 +367,7 @@ let getXUnitTest ast : TestAdapterEntry list = attrs |> List.collect (fun (attr: SynAttributeList) -> attr.Attributes) |> List.exists (fun a -> - let str = a.TypeName.Lid |> List.last + let str = a.TypeName.LongIdent |> List.last str.idText.EndsWith "Fact" || str.idText.EndsWith "FactAttribute" @@ -378,8 +378,8 @@ let getXUnitTest ast : TestAdapterEntry list = let getName = function - | SynPat.Named (ident = name) -> name.idText - | SynPat.LongIdent(longDotId = LongIdentWithDots (ident, _)) -> ident |> List.last |> (fun n -> n.idText) + | SynPat.Named(ident = SynIdent (ident = name)) -> name.idText + | SynPat.LongIdent(longDotId = SynLongIdent (id = ident)) -> ident |> List.last |> (fun n -> n.idText) | _ -> "" let rec visitMember (parent: TestAdapterEntry) = @@ -468,7 +468,7 @@ let getXUnitTest ast : TestAdapterEntry list = let visitModulesAndNamespaces parent modulesOrNss = Seq.iter - (fun (SynModuleOrNamespace (ids, _, _, decls, _, _, _, r)) -> + (fun (SynModuleOrNamespace (longId = ids; decls = decls; range = r)) -> let name = String.concat "." [ for i in ids -> i.idText ] ident <- ident + 1 @@ -496,7 +496,7 @@ let getXUnitTest ast : TestAdapterEntry list = Type = "" } match ast with - | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> visitModulesAndNamespaces allTests modules + | ParsedInput.ImplFile (ParsedImplFileInput (contents = modules)) -> visitModulesAndNamespaces allTests modules | _ -> () List.ofSeq allTests.Childs diff --git a/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs b/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs index 457e8217e..033a818e9 100644 --- a/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs +++ b/src/FsAutoComplete.Core/UnionPatternMatchCaseGenerator.fs @@ -47,7 +47,7 @@ let private clauseIsCandidateForCodeGen (cursorPos: Position) (SynMatchClause (p | SynPat.Or (lhsPat = leftPat; rhsPat = rightPat) -> patIsCandidate leftPat || patIsCandidate rightPat | SynPat.Ands (innerPatList, _) -> List.exists patIsCandidate innerPatList // This is the 'hd :: tail -> ...' pattern - | SynPat.LongIdent(longDotId = LongIdentWithDots ([ ident ], [])) when ident.idText = "op_ColonColon" -> false + | SynPat.LongIdent(longDotId = SynLongIdent(id = [ ident ])) when ident.idText = "op_ColonColon" -> false | SynPat.LongIdent (argPats = ConstructorPats nestedPats; range = r) -> // The cursor should not be in the nested patterns Range.rangeContainsPos r cursorPos @@ -77,10 +77,10 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P let inline getIfPosInRange range f = if Range.rangeContainsPos range pos then f () else None - let rec walkImplFileInput (ParsedImplFileInput (modules = moduleOrNamespaceList)) = + let rec walkImplFileInput (ParsedImplFileInput (contents = moduleOrNamespaceList)) = List.tryPick walkSynModuleOrNamespace moduleOrNamespaceList - and walkSynModuleOrNamespace (SynModuleOrNamespace (_, _, _, decls, _, _, _, range)) = + and walkSynModuleOrNamespace (SynModuleOrNamespace (decls = decls; range = range)) = getIfPosInRange range (fun () -> List.tryPick walkSynModuleDecl decls) and walkSynModuleDecl (decl: SynModuleDecl) = @@ -123,6 +123,7 @@ let private tryFindPatternMatchExprInParsedInput (pos: Position) (parsedInput: P | SynMemberDefn.NestedType (typeDef, _access, _range) -> walkSynTypeDefn typeDef | SynMemberDefn.ValField (_field, _range) -> None | SynMemberDefn.LetBindings (bindings, _isStatic, _isRec, _range) -> List.tryPick walkBinding bindings + | SynMemberDefn.GetSetMember (_get, _set, _range, trivia) -> None | SynMemberDefn.Open _ | SynMemberDefn.ImplicitInherit _ | SynMemberDefn.Inherit _ @@ -340,7 +341,7 @@ let getWrittenCases (patMatchExpr: PatternMatchExpr) = let rec getCasesInPattern (pat: SynPat) = match pat with - | SynPat.LongIdent (longDotId = LongIdentWithDots (unionCaseLongIdent, _); argPats = constructorArgs) -> + | SynPat.LongIdent (longDotId = SynLongIdent (id = unionCaseLongIdent); argPats = constructorArgs) -> // Get list of qualifiers, this can be checked for length later. let reversedIdents = unionCaseLongIdent |> List.map (fun id -> id.idText) |> List.rev diff --git a/src/FsAutoComplete.Core/UntypedAstUtils.fs b/src/FsAutoComplete.Core/UntypedAstUtils.fs index e0d6f513f..ac7348efc 100644 --- a/src/FsAutoComplete.Core/UntypedAstUtils.fs +++ b/src/FsAutoComplete.Core/UntypedAstUtils.fs @@ -5,6 +5,7 @@ open FSharp.Compiler.Syntax open System.Collections.Generic open FSharp.Compiler open FSharp.Compiler.Text +open FSharp.Control.Reactive.Observable type Range with @@ -69,10 +70,10 @@ let internal getRangesAtPosition input (r: Position) : Range list = - let rec walkImplFileInput (ParsedImplFileInput (modules = moduleOrNamespaceList)) = + let rec walkImplFileInput (ParsedImplFileInput (contents = moduleOrNamespaceList)) = List.iter walkSynModuleOrNamespace moduleOrNamespaceList - and walkSynModuleOrNamespace (SynModuleOrNamespace (_, _, _, decls, _, AllAttrs attrs, _, r)) = + and walkSynModuleOrNamespace (SynModuleOrNamespace (decls = decls; attribs = AllAttrs attrs; range = r)) = addIfInside r List.iter walkAttribute attrs List.iter walkSynModuleDecl decls @@ -115,6 +116,9 @@ let internal getRangesAtPosition input (r: Position) : Range list = addIfInside r List.iter walkType ts walkMemberSig sign + | SynTypeConstraint.WhereSelfConstrained (t, r) -> + addIfInside r + walkType t and walkPat = function @@ -135,7 +139,7 @@ let internal getRangesAtPosition input (r: Position) : Range list = | SynPat.Or (pat1, pat2, r, _) -> addIfInside r List.iter walkPat [ pat1; pat2 ] - | SynPat.LongIdent (ident, _, _, typars, ConstructorPats pats, _, r) -> + | SynPat.LongIdent (typarDecls = typars; argPats = ConstructorPats pats; range = r) -> addIfInside r Option.iter walkSynValTyparDecls typars List.iter walkPat pats @@ -187,7 +191,7 @@ let internal getRangesAtPosition input (r: Position) : Range list = | SynType.MeasurePower (t, _, r) -> addIfInside r walkType t - | SynType.Fun (t1, t2, r) + | SynType.Fun (t1, t2, r, _) | SynType.MeasureDivide (t1, t2, r) -> addIfInside r walkType t1 @@ -201,7 +205,11 @@ let internal getRangesAtPosition input (r: Position) : Range list = List.iter walkType types | SynType.Tuple (_, ts, r) -> addIfInside r - ts |> List.iter (fun (_, t) -> walkType t) + + ts + |> List.iter (function + | SynTupleTypeSegment.Type t -> walkType t + | _ -> ()) | SynType.WithGlobalConstraints (t, typeConstraints, r) -> addIfInside r walkType t @@ -216,7 +224,9 @@ let internal getRangesAtPosition input (r: Position) : Range list = | SynType.Paren (innerType, r) -> addIfInside r walkType innerType - + | SynType.SignatureParameter (usedType = t; range = r) -> + addIfInside r + walkType t and walkClause (SynMatchClause (pat, e1, e2, r, _, _)) = addIfInside r @@ -311,7 +321,7 @@ let internal getRangesAtPosition input (r: Position) : Range list = | SynExpr.MatchLambda (_, _, synMatchClauseList, _, r) -> addIfInside r List.iter walkClause synMatchClauseList - | SynExpr.Match (_, _, e, _, synMatchClauseList, r) -> + | SynExpr.Match (expr = e; clauses = synMatchClauseList; range = r) -> addIfInside r walkExpr e List.iter walkClause synMatchClauseList @@ -371,7 +381,7 @@ let internal getRangesAtPosition input (r: Position) : Range list = walkExpr e2 | SynExpr.TraitCall (ts, sign, e, r) -> addIfInside r - List.iter walkTypar ts + List.iter walkType ts walkMemberSig sign walkExpr e | SynExpr.Const (SynConst.Measure (_, _, m), r) -> @@ -407,6 +417,13 @@ let internal getRangesAtPosition input (r: Position) : Range list = Option.iter walkExpr e1 Option.iter walkExpr e2 | SynExpr.DebugPoint (innerExpr = expr) -> walkExpr expr + | SynExpr.Dynamic (funcExpr = e1; argExpr = e2; range = range) -> + addIfInside range + walkExpr e1 + walkExpr e2 + | SynExpr.Typar (t, r) -> + addIfInside r + walkTypar t and walkMeasure = function @@ -425,6 +442,9 @@ let internal getRangesAtPosition input (r: Position) : Range list = | SynMeasure.Var (ty, r) -> addIfInside r walkTypar ty + | SynMeasure.Paren (m, r) -> + addIfInside r + walkMeasure m | SynMeasure.One | SynMeasure.Anon _ -> () @@ -521,6 +541,10 @@ let internal getRangesAtPosition input (r: Position) : Range list = Option.iter walkType t walkExpr e | SynMemberDefn.Open (longId, r) -> addIfInside r + | SynMemberDefn.GetSetMember (memberDefnForGet = getter; memberDefnForSet = setter; range = range) -> + addIfInside range + Option.iter walkBinding getter + Option.iter walkBinding setter and walkEnumCase (SynEnumCase (attributes = AllAttrs attrs; range = r)) = addIfInside r diff --git a/src/FsAutoComplete.Core/Workaround/ServiceParseTreeWalk.fs b/src/FsAutoComplete.Core/Workaround/ServiceParseTreeWalk.fs deleted file mode 100644 index 28ee177dc..000000000 --- a/src/FsAutoComplete.Core/Workaround/ServiceParseTreeWalk.fs +++ /dev/null @@ -1,1012 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -//---------------------------------------------------------------------------- -// Open up the compiler as an incremental service for parsing, -// type checking and intellisense-like environment-reporting. -//-------------------------------------------------------------------------- - -/// Current (and older) FCS Visitors don't walk into into `SynMatchClause`s in `SynExpr.Match` (at least not into their patterns) -/// -> Cannot walk to `SynPat.Named` inside Match Case -/// -/// That's fixed in `main` FCS -/// -> This here is a copy of [`ServiceParseTreeWalk.fs`@`0155fd5`](https://github.com/dotnet/fsharp/blob/a65ace7698c159c34bd00f6408c7d4beb89b687d/src/Compiler/Service/ServiceParseTreeWalk.fs) with slight adjustments so it compiles -/// -/// **Remove once it's available as nuget package and updated here in FSAC** -module internal FsAutoComplete.Core.Workaround.ServiceParseTreeWalk -//TOOD: Use new FCS one available - -open FSharp.Compiler.Syntax -open FSharp.Compiler.Text -open FSharp.Compiler.Text.Position -open FSharp.Compiler.Text.Range - -// Adjustments to compile with older FCS version -type SynLongIdent = LongIdentWithDots -let SynLongIdent (id, r, _) = LongIdentWithDots(id, r) - -type LongIdentWithDots with - - member lid.LongIdent = lid.Lid - -type private Range with - - member m.ToShortString() = - sprintf "(%d,%d--%d,%d)" m.StartLine m.StartColumn m.EndLine m.EndColumn - -let unionBindingAndMembers (bindings: SynBinding list) (members: SynMemberDefn list) : SynBinding list = - [ yield! bindings - yield! - List.choose - (function - | SynMemberDefn.Member (b, _) -> Some b - | _ -> None) - members ] - -let rec private stripParenTypes synType = - match synType with - | SynType.Paren (innerType, _) -> stripParenTypes innerType - | _ -> synType - -let private (|StripParenTypes|) synType = stripParenTypes synType - - -// copied ServiceParseTreeWalk - -// /// used to track route during traversal AST -// [] -// type SyntaxNode = -// | SynPat of SynPat -// | SynType of SynType -// | SynExpr of SynExpr -// | SynModule of SynModuleDecl -// | SynModuleOrNamespace of SynModuleOrNamespace -// | SynTypeDefn of SynTypeDefn -// | SynMemberDefn of SynMemberDefn -// | SynMatchClause of SynMatchClause -// | SynBinding of SynBinding - -// type SyntaxVisitorPath = SyntaxNode list - -[] -type SyntaxVisitorBase<'T>() = - abstract VisitExpr: - path: SyntaxVisitorPath * - traverseSynExpr: (SynExpr -> 'T option) * - defaultTraverse: (SynExpr -> 'T option) * - synExpr: SynExpr -> - 'T option - - default _.VisitExpr - ( - path: SyntaxVisitorPath, - traverseSynExpr: SynExpr -> 'T option, - defaultTraverse: SynExpr -> 'T option, - synExpr: SynExpr - ) = - ignore (path, traverseSynExpr, defaultTraverse, synExpr) - None - - /// VisitTypeAbbrev(ty,m), defaults to ignoring this leaf of the AST - abstract VisitTypeAbbrev: path: SyntaxVisitorPath * synType: SynType * range: range -> 'T option - - default _.VisitTypeAbbrev(path, synType, range) = - ignore (path, synType, range) - None - - /// VisitImplicitInherit(defaultTraverse,ty,expr,m), defaults to just visiting expr - abstract VisitImplicitInherit: - path: SyntaxVisitorPath * - defaultTraverse: (SynExpr -> 'T option) * - inheritedType: SynType * - synArgs: SynExpr * - range: range -> - 'T option - - default _.VisitImplicitInherit(path, defaultTraverse, inheritedType, synArgs, range) = - ignore (path, inheritedType, range) - defaultTraverse synArgs - - /// VisitModuleDecl allows overriding module declaration behavior - abstract VisitModuleDecl: - path: SyntaxVisitorPath * defaultTraverse: (SynModuleDecl -> 'T option) * synModuleDecl: SynModuleDecl -> 'T option - - default _.VisitModuleDecl(path, defaultTraverse, synModuleDecl) = - ignore path - defaultTraverse synModuleDecl - - /// VisitBinding allows overriding binding behavior (note: by default it would defaultTraverse expression) - abstract VisitBinding: - path: SyntaxVisitorPath * defaultTraverse: (SynBinding -> 'T option) * synBinding: SynBinding -> 'T option - - default _.VisitBinding(path, defaultTraverse, synBinding) = - ignore path - defaultTraverse synBinding - - /// VisitMatchClause allows overriding clause behavior (note: by default it would defaultTraverse expression) - abstract VisitMatchClause: - path: SyntaxVisitorPath * defaultTraverse: (SynMatchClause -> 'T option) * matchClause: SynMatchClause -> 'T option - - default _.VisitMatchClause(path, defaultTraverse, matchClause) = - ignore path - defaultTraverse matchClause - - /// VisitInheritSynMemberDefn allows overriding inherit behavior (by default do nothing) - abstract VisitInheritSynMemberDefn: - path: SyntaxVisitorPath * - componentInfo: SynComponentInfo * - typeDefnKind: SynTypeDefnKind * - SynType * - SynMemberDefns * - range -> - 'T option - - default _.VisitInheritSynMemberDefn(path, componentInfo, typeDefnKind, synType, members, range) = - ignore (path, componentInfo, typeDefnKind, synType, members, range) - None - - /// VisitRecordDefn allows overriding behavior when visiting record definitions (by default do nothing) - abstract VisitRecordDefn: path: SyntaxVisitorPath * fields: SynField list * range -> 'T option - - default _.VisitRecordDefn(path, fields, range) = - ignore (path, fields, range) - None - - /// VisitUnionDefn allows overriding behavior when visiting union definitions (by default do nothing) - abstract VisitUnionDefn: path: SyntaxVisitorPath * cases: SynUnionCase list * range -> 'T option - - default _.VisitUnionDefn(path, cases, range) = - ignore (path, cases, range) - None - - /// VisitEnumDefn allows overriding behavior when visiting enum definitions (by default do nothing) - abstract VisitEnumDefn: path: SyntaxVisitorPath * cases: SynEnumCase list * range -> 'T option - - default _.VisitEnumDefn(path, cases, range) = - ignore (path, cases, range) - None - - /// VisitInterfaceSynMemberDefnType allows overriding behavior for visiting interface member in types (by default - do nothing) - abstract VisitInterfaceSynMemberDefnType: path: SyntaxVisitorPath * synType: SynType -> 'T option - - default _.VisitInterfaceSynMemberDefnType(path, synType) = - ignore (path, synType) - None - - /// VisitRecordField allows overriding behavior when visiting l.h.s. of constructed record instances - abstract VisitRecordField: - path: SyntaxVisitorPath * copyOpt: SynExpr option * recordField: SynLongIdent option -> 'T option - - default _.VisitRecordField(path, copyOpt, recordField) = - ignore (path, copyOpt, recordField) - None - - /// VisitHashDirective allows overriding behavior when visiting hash directives in FSX scripts, like #r, #load and #I. - abstract VisitHashDirective: path: SyntaxVisitorPath * hashDirective: ParsedHashDirective * range: range -> 'T option - - default _.VisitHashDirective(path, hashDirective, range) = - ignore (path, hashDirective, range) - None - - /// VisitModuleOrNamespace allows overriding behavior when visiting module or namespaces - abstract VisitModuleOrNamespace: path: SyntaxVisitorPath * synModuleOrNamespace: SynModuleOrNamespace -> 'T option - - default _.VisitModuleOrNamespace(path, synModuleOrNamespace) = - ignore (path, synModuleOrNamespace) - None - - /// VisitComponentInfo allows overriding behavior when visiting type component infos - abstract VisitComponentInfo: path: SyntaxVisitorPath * synComponentInfo: SynComponentInfo -> 'T option - - default _.VisitComponentInfo(path, synComponentInfo) = - ignore (path, synComponentInfo) - None - - /// VisitLetOrUse allows overriding behavior when visiting module or local let or use bindings - abstract VisitLetOrUse: - path: SyntaxVisitorPath * - isRecursive: bool * - defaultTraverse: (SynBinding -> 'T option) * - bindings: SynBinding list * - range: range -> - 'T option - - default _.VisitLetOrUse(path, isRecursive, defaultTraverse, bindings, range) = - ignore (path, isRecursive, defaultTraverse, bindings, range) - None - - /// VisitType allows overriding behavior when visiting simple pats - abstract VisitSimplePats: path: SyntaxVisitorPath * synPats: SynSimplePat list -> 'T option - - default _.VisitSimplePats(path, synPats) = - ignore (path, synPats) - None - - /// VisitPat allows overriding behavior when visiting patterns - abstract VisitPat: path: SyntaxVisitorPath * defaultTraverse: (SynPat -> 'T option) * synPat: SynPat -> 'T option - - default _.VisitPat(path, defaultTraverse, synPat) = - ignore path - defaultTraverse synPat - - /// VisitType allows overriding behavior when visiting type hints (x: ..., etc.) - abstract VisitType: path: SyntaxVisitorPath * defaultTraverse: (SynType -> 'T option) * synType: SynType -> 'T option - - default _.VisitType(path, defaultTraverse, synType) = - ignore path - defaultTraverse synType - -/// A range of utility functions to assist with traversing an AST -module SyntaxTraversal = - - // treat ranges as though they are half-open: [,) - let rangeContainsPosLeftEdgeInclusive (m1: range) p = - if posEq m1.Start m1.End then - // the parser doesn't produce zero-width ranges, except in one case, for e.g. a block of lets that lacks a body - // we treat the range [n,n) as containing position n - posGeq p m1.Start && posGeq m1.End p - else - posGeq p m1.Start - && // [ - posGt m1.End p // ) - - // treat ranges as though they are fully open: (,) - let rangeContainsPosEdgesExclusive (m1: range) p = posGt p m1.Start && posGt m1.End p - - let rangeContainsPosLeftEdgeExclusiveAndRightEdgeInclusive (m1: range) p = posGt p m1.Start && posGeq m1.End p - - let dive node range project = range, (fun () -> project node) - - let pick pos (outerRange: range) (debugObj: obj) (diveResults: (range * _) list) = - match diveResults with - | [] -> None - | _ -> - let isOrdered = -#if DEBUG - // ranges in a dive-and-pick group should be ordered - diveResults - |> Seq.pairwise - |> Seq.forall (fun ((r1, _), (r2, _)) -> posGeq r2.Start r1.End) -#else - true -#endif - if not isOrdered then - let s = - sprintf "ServiceParseTreeWalk: not isOrdered: %A" (diveResults |> List.map (fun (r, _) -> r.ToShortString())) - - ignore s - //System.Diagnostics.Debug.Assert(false, s) - let outerContainsInner = -#if DEBUG - // ranges in a dive-and-pick group should be "under" the thing that contains them - let innerTotalRange = diveResults |> List.map fst |> List.reduce unionRanges - - rangeContainsRange outerRange innerTotalRange -#else - ignore (outerRange) - true -#endif - if not outerContainsInner then - let s = - sprintf - "ServiceParseTreeWalk: not outerContainsInner: %A : %A" - (outerRange.ToShortString()) - (diveResults |> List.map (fun (r, _) -> r.ToShortString())) - - ignore s - //System.Diagnostics.Debug.Assert(false, s) - let isZeroWidth (r: range) = posEq r.Start r.End // the parser inserts some zero-width elements to represent the completions of incomplete constructs, but we should never 'dive' into them, since they don't represent actual user code - - match - List.choose - (fun (r, f) -> - if rangeContainsPosLeftEdgeInclusive r pos && not (isZeroWidth r) then - Some(f) - else - None) - diveResults - with - | [] -> - // No entity's range contained the desired position. However the ranges in the parse tree only span actual characters present in the file. - // The cursor may be at whitespace between entities or after everything, so find the nearest entity with the range left of the position. - let mutable e = diveResults.Head - - for r in diveResults do - if posGt pos (fst r).Start then - e <- r - - snd (e) () - | [ x ] -> x () - | _ -> -#if DEBUG - assert false - failwithf "multiple disjoint AST node ranges claimed to contain (%A) from %+A" pos debugObj -#else - ignore debugObj - None -#endif - - /// traverse an implementation file walking all the way down to SynExpr or TypeAbbrev at a particular location - /// - let Traverse (pos: pos, parseTree, visitor: SyntaxVisitorBase<'T>) = - let pick x = pick pos x - - let rec traverseSynModuleDecl origPath (decl: SynModuleDecl) = - let pick = pick decl.Range - - let defaultTraverse m = - let path = SyntaxNode.SynModule m :: origPath - - match m with - | SynModuleDecl.ModuleAbbrev (_ident, _longIdent, _range) -> None - | SynModuleDecl.NestedModule (decls = synModuleDecls) -> - synModuleDecls - |> List.map (fun x -> dive x x.Range (traverseSynModuleDecl path)) - |> pick decl - | SynModuleDecl.Let (isRecursive, synBindingList, range) -> - match visitor.VisitLetOrUse(path, isRecursive, traverseSynBinding path, synBindingList, range) with - | Some x -> Some x - | None -> - synBindingList - |> List.map (fun x -> dive x x.RangeOfBindingWithRhs (traverseSynBinding path)) - |> pick decl - | SynModuleDecl.Expr (synExpr, _range) -> traverseSynExpr path synExpr - | SynModuleDecl.Types (synTypeDefnList, _range) -> - synTypeDefnList - |> List.map (fun x -> dive x x.Range (traverseSynTypeDefn path)) - |> pick decl - | SynModuleDecl.Exception (_synExceptionDefn, _range) -> None - | SynModuleDecl.Open (_target, _range) -> None - | SynModuleDecl.Attributes (_synAttributes, _range) -> None - | SynModuleDecl.HashDirective (parsedHashDirective, range) -> - visitor.VisitHashDirective(path, parsedHashDirective, range) - | SynModuleDecl.NamespaceFragment (synModuleOrNamespace) -> - traverseSynModuleOrNamespace path synModuleOrNamespace - - visitor.VisitModuleDecl(origPath, defaultTraverse, decl) - - and traverseSynModuleOrNamespace origPath (SynModuleOrNamespace (decls = synModuleDecls; range = range) as mors) = - match visitor.VisitModuleOrNamespace(origPath, mors) with - | Some x -> Some x - | None -> - let path = SyntaxNode.SynModuleOrNamespace mors :: origPath - - synModuleDecls - |> List.map (fun x -> dive x x.Range (traverseSynModuleDecl path)) - |> pick range mors - - and traverseSynExpr origPath (expr: SynExpr) = - let pick = pick expr.Range - - let defaultTraverse e = - let path = SyntaxNode.SynExpr e :: origPath - let traverseSynExpr = traverseSynExpr path - let traverseSynType = traverseSynType path - let traversePat = traversePat path - - match e with - - | SynExpr.Paren (synExpr, _, _, _parenRange) -> traverseSynExpr synExpr - - | SynExpr.Quote (_synExpr, _, synExpr2, _, _range) -> - [ //dive synExpr synExpr.Range traverseSynExpr // TODO, what is this? - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.Const (_synConst, _range) -> None - - | SynExpr.InterpolatedString (parts, _, _) -> - [ for part in parts do - match part with - | SynInterpolatedStringPart.String _ -> () - | SynInterpolatedStringPart.FillExpr (fillExpr, _) -> yield dive fillExpr fillExpr.Range traverseSynExpr ] - |> pick expr - - | SynExpr.Typed (synExpr, synType, _range) -> - match traverseSynExpr synExpr with - | None -> traverseSynType synType - | x -> x - - | SynExpr.Tuple (_, synExprList, _, _range) - | SynExpr.ArrayOrList (_, synExprList, _range) -> - synExprList |> List.map (fun x -> dive x x.Range traverseSynExpr) |> pick expr - - | SynExpr.AnonRecd (_isStruct, copyOpt, synExprList, _range) -> - [ match copyOpt with - | Some (expr, (withRange, _)) -> - yield dive expr expr.Range traverseSynExpr - - yield - dive () withRange (fun () -> - if posGeq pos withRange.End then - // special case: caret is after WITH - // { x with $ } - visitor.VisitRecordField(path, Some expr, None) - else - None) - | _ -> () - for _, _, x in synExprList do - yield dive x x.Range traverseSynExpr ] - |> pick expr - - | SynExpr.Record (inheritOpt, copyOpt, fields, _range) -> - [ let diveIntoSeparator offsideColumn scPosOpt copyOpt = - match scPosOpt with - | Some scPos -> - if posGeq pos scPos then - visitor.VisitRecordField(path, copyOpt, None) // empty field after the inherits - else - None - | None -> - //semicolon position is not available - use offside rule - if pos.Column = offsideColumn then - visitor.VisitRecordField(path, copyOpt, None) // empty field after the inherits - else - None - - match inheritOpt with - | Some (_ty, expr, _range, sepOpt, inheritRange) -> - // dive into argument - yield - dive expr expr.Range (fun expr -> - // special-case:caret is located in the offside position below inherit - // inherit A() - // $ - if - not (rangeContainsPos expr.Range pos) - && sepOpt.IsNone - && pos.Column = inheritRange.StartColumn - then - visitor.VisitRecordField(path, None, None) - else - traverseSynExpr expr) - - match sepOpt with - | Some (sep, scPosOpt) -> - yield - dive () sep (fun () -> - // special case: caret is below 'inherit' + one or more fields are already defined - // inherit A() - // $ - // field1 = 5 - diveIntoSeparator inheritRange.StartColumn scPosOpt None) - | None -> () - | _ -> () - - match copyOpt with - | Some (expr, (withRange, _)) -> - yield dive expr expr.Range traverseSynExpr - - yield - dive () withRange (fun () -> - if posGeq pos withRange.End then - // special case: caret is after WITH - // { x with $ } - visitor.VisitRecordField(path, Some expr, None) - else - None) - | _ -> () - - let copyOpt = Option.map fst copyOpt - - for SynExprRecordField (fieldName = (field, _); expr = e; blockSeparator = sepOpt) in fields do - yield - dive (path, copyOpt, Some field) field.Range (fun r -> - if rangeContainsPos field.Range pos then - visitor.VisitRecordField r - else - None) - - let offsideColumn = - match inheritOpt with - | Some (_, _, _, _, inheritRange) -> inheritRange.StartColumn - | None -> field.Range.StartColumn - - match e with - | Some e -> - yield - dive e e.Range (fun expr -> - // special case: caret is below field binding - // field x = 5 - // $ - if - not (rangeContainsPos e.Range pos) - && sepOpt.IsNone - && pos.Column = offsideColumn - then - visitor.VisitRecordField(path, copyOpt, None) - else - traverseSynExpr expr) - | None -> () - - match sepOpt with - | Some (sep, scPosOpt) -> - yield - dive () sep (fun () -> - // special case: caret is between field bindings - // field1 = 5 - // $ - // field2 = 5 - diveIntoSeparator offsideColumn scPosOpt copyOpt) - | _ -> () - - ] - |> pick expr - - | SynExpr.New (_, _synType, synExpr, _range) -> traverseSynExpr synExpr - | SynExpr.ObjExpr (objType = ty; argOptions = baseCallOpt; bindings = binds; members = ms; extraImpls = ifaces) -> - let binds = unionBindingAndMembers binds ms - - let result = - ifaces - |> Seq.map (fun (SynInterfaceImpl (interfaceTy = ty)) -> ty) - |> Seq.tryPick (fun ty -> visitor.VisitInterfaceSynMemberDefnType(path, ty)) - - if result.IsSome then - result - else - [ match baseCallOpt with - | Some (expr, _) -> - // this is like a call to 'new', so mock up a 'new' so we can recurse and use that existing logic - let newCall = SynExpr.New(false, ty, expr, unionRanges ty.Range expr.Range) - yield dive newCall newCall.Range traverseSynExpr - | _ -> () - for b in binds do - yield dive b b.RangeOfBindingWithRhs (traverseSynBinding path) - for SynInterfaceImpl (bindings = binds) in ifaces do - for b in binds do - yield dive b b.RangeOfBindingWithRhs (traverseSynBinding path) ] - |> pick expr - - | SynExpr.While (_spWhile, synExpr, synExpr2, _range) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.For (identBody = synExpr; toBody = synExpr2; doBody = synExpr3) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr - dive synExpr3 synExpr3.Range traverseSynExpr ] - |> pick expr - - | SynExpr.ForEach (_spFor, _spIn, _seqExprOnly, _isFromSource, synPat, synExpr, synExpr2, _range) -> - [ dive synPat synPat.Range traversePat - dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.ArrayOrListComputed (_, synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.ComputationExpr (_, synExpr, _range) -> - // now parser treats this syntactic expression as computation expression - // { identifier } - // here we detect this situation and treat ComputationExpr { Identifier } as attempt to create record - // note: sequence expressions use SynExpr.ComputationExpr too - they need to be filtered out - let isPartOfArrayOrList = - match origPath with - | SyntaxNode.SynExpr (SynExpr.ArrayOrListComputed _) :: _ -> true - | _ -> false - - let ok = - match isPartOfArrayOrList, synExpr with - | false, SynExpr.Ident ident -> - visitor.VisitRecordField(path, None, Some(SynLongIdent([ ident ], [], [ None ]))) - | false, SynExpr.LongIdent (false, lidwd, _, _) -> visitor.VisitRecordField(path, None, Some lidwd) - | _ -> None - - if ok.IsSome then ok else traverseSynExpr synExpr - - | SynExpr.Lambda (args = synSimplePats; body = synExpr) -> - match synSimplePats with - | SynSimplePats.SimplePats (pats, _) -> - match visitor.VisitSimplePats(path, pats) with - | None -> traverseSynExpr synExpr - | x -> x - | _ -> traverseSynExpr synExpr - - | SynExpr.MatchLambda (_isExnMatch, _argm, synMatchClauseList, _spBind, _wholem) -> - synMatchClauseList - |> List.map (fun x -> dive x x.Range (traverseSynMatchClause path)) - |> pick expr - - | SynExpr.Match (expr = synExpr; clauses = synMatchClauseList) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield! - synMatchClauseList - |> List.map (fun x -> dive x x.Range (traverseSynMatchClause path)) ] - |> pick expr - - | SynExpr.Do (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.Assert (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.Fixed (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.DebugPoint (_, _, synExpr) -> traverseSynExpr synExpr - - // | SynExpr.Dynamic _ -> None - - | SynExpr.App (_exprAtomicFlag, isInfix, synExpr, synExpr2, _range) -> - if isInfix then - [ dive synExpr2 synExpr2.Range traverseSynExpr - dive synExpr synExpr.Range traverseSynExpr ] // reverse the args - |> pick expr - else - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.TypeApp (synExpr, _, _synTypeList, _commas, _, _, _range) -> traverseSynExpr synExpr - - | SynExpr.LetOrUse (_, isRecursive, synBindingList, synExpr, range, _) -> - match visitor.VisitLetOrUse(path, isRecursive, traverseSynBinding path, synBindingList, range) with - | None -> - [ yield! - synBindingList - |> List.map (fun x -> dive x x.RangeOfBindingWithRhs (traverseSynBinding path)) - yield dive synExpr synExpr.Range traverseSynExpr ] - |> pick expr - | x -> x - - | SynExpr.TryWith (tryExpr = synExpr; withCases = synMatchClauseList) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield! - synMatchClauseList - |> List.map (fun x -> dive x x.Range (traverseSynMatchClause path)) ] - |> pick expr - - | SynExpr.TryFinally (tryExpr = synExpr; finallyExpr = synExpr2) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.Lazy (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.SequentialOrImplicitYield (_sequencePointInfoForSequential, synExpr, synExpr2, _, _range) - - | SynExpr.Sequential (_sequencePointInfoForSequential, _, synExpr, synExpr2, _range) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.IfThenElse (ifExpr = synExpr; thenExpr = synExpr2; elseExpr = synExprOpt) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield dive synExpr2 synExpr2.Range traverseSynExpr - match synExprOpt with - | None -> () - | Some x -> yield dive x x.Range traverseSynExpr ] - |> pick expr - - | SynExpr.Ident _ident -> None - - | SynExpr.LongIdent (_, _longIdent, _altNameRefCell, _range) -> None - - | SynExpr.LongIdentSet (_longIdent, synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.DotGet (synExpr, _dotm, _longIdent, _range) -> traverseSynExpr synExpr - - | SynExpr.Set (synExpr, synExpr2, _) - - | SynExpr.DotSet (synExpr, _, synExpr2, _) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.IndexRange (expr1, _, expr2, _, _, _) -> - [ match expr1 with - | Some e -> dive e e.Range traverseSynExpr - | None -> () - match expr2 with - | Some e -> dive e e.Range traverseSynExpr - | None -> () ] - |> pick expr - - | SynExpr.IndexFromEnd (e, _) -> traverseSynExpr e - - | SynExpr.DotIndexedGet (synExpr, indexArgs, _range, _range2) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield dive indexArgs indexArgs.Range traverseSynExpr ] - |> pick expr - - | SynExpr.DotIndexedSet (synExpr, indexArgs, synExpr2, _, _range, _range2) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield dive indexArgs indexArgs.Range traverseSynExpr - yield dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.JoinIn (synExpr1, _range, synExpr2, _range2) -> - [ dive synExpr1 synExpr1.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.NamedIndexedPropertySet (_longIdent, synExpr, synExpr2, _range) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.DotNamedIndexedPropertySet (synExpr, _longIdent, synExpr2, synExpr3, _range) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synExpr2 synExpr2.Range traverseSynExpr - dive synExpr3 synExpr3.Range traverseSynExpr ] - |> pick expr - - | SynExpr.TypeTest (synExpr, synType, _range) - - | SynExpr.Upcast (synExpr, synType, _range) - - | SynExpr.Downcast (synExpr, synType, _range) -> - [ dive synExpr synExpr.Range traverseSynExpr - dive synType synType.Range traverseSynType ] - |> pick expr - - | SynExpr.InferredUpcast (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.InferredDowncast (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.Null _range -> None - - | SynExpr.AddressOf (_, synExpr, _range, _range2) -> traverseSynExpr synExpr - - | SynExpr.TraitCall (_synTyparList, _synMemberSig, synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.ImplicitZero _range -> None - - | SynExpr.YieldOrReturn (_, synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.YieldOrReturnFrom (_, synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.LetOrUseBang (pat = synPat; rhs = synExpr; andBangs = andBangSynExprs; body = synExpr2) -> - [ yield dive synPat synPat.Range traversePat - yield dive synExpr synExpr.Range traverseSynExpr - yield! - [ for SynExprAndBang (pat = andBangSynPat; body = andBangSynExpr) in andBangSynExprs do - yield (dive andBangSynPat andBangSynPat.Range traversePat) - yield (dive andBangSynExpr andBangSynExpr.Range traverseSynExpr) ] - yield dive synExpr2 synExpr2.Range traverseSynExpr ] - |> pick expr - - | SynExpr.MatchBang (expr = synExpr; clauses = synMatchClauseList) -> - [ yield dive synExpr synExpr.Range traverseSynExpr - yield! - synMatchClauseList - |> List.map (fun x -> dive x x.Range (traverseSynMatchClause path)) ] - |> pick expr - - | SynExpr.DoBang (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.LibraryOnlyILAssembly _ -> None - - | SynExpr.LibraryOnlyStaticOptimization _ -> None - - | SynExpr.LibraryOnlyUnionCaseFieldGet _ -> None - - | SynExpr.LibraryOnlyUnionCaseFieldSet _ -> None - - | SynExpr.ArbitraryAfterError (_debugStr, _range) -> None - - | SynExpr.FromParseError (synExpr, _range) -> traverseSynExpr synExpr - - | SynExpr.DiscardAfterMissingQualificationAfterDot (synExpr, _range) -> traverseSynExpr synExpr - - visitor.VisitExpr(origPath, traverseSynExpr origPath, defaultTraverse, expr) - - and traversePat origPath (pat: SynPat) = - let defaultTraverse p = - let path = SyntaxNode.SynPat p :: origPath - - match p with - | SynPat.Paren (p, _) -> traversePat path p - | SynPat.As (p1, p2, _) - | SynPat.Or (p1, p2, _, _) -> [ p1; p2 ] |> List.tryPick (traversePat path) - | SynPat.Ands (ps, _) - | SynPat.Tuple (_, ps, _) - | SynPat.ArrayOrList (_, ps, _) -> ps |> List.tryPick (traversePat path) - | SynPat.Attrib (p, _, _) -> traversePat path p - | SynPat.LongIdent (argPats = args) -> - match args with - | SynArgPats.Pats ps -> ps |> List.tryPick (traversePat path) - | SynArgPats.NamePatPairs (ps, _) -> - ps |> List.map (fun (_, _, pat) -> pat) |> List.tryPick (traversePat path) - | SynPat.Typed (p, ty, _) -> - match traversePat path p with - | None -> traverseSynType path ty - | x -> x - | _ -> None - - visitor.VisitPat(origPath, defaultTraverse, pat) - - and traverseSynType origPath (StripParenTypes ty) = - let defaultTraverse ty = - let path = SyntaxNode.SynType ty :: origPath - - match ty with - | SynType.App (typeName, _, typeArgs, _, _, _, _) - | SynType.LongIdentApp (typeName, _, _, typeArgs, _, _, _) -> - [ yield typeName; yield! typeArgs ] |> List.tryPick (traverseSynType path) - | SynType.Fun (ty1, ty2, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) - | SynType.MeasurePower (ty, _, _) - | SynType.HashConstraint (ty, _) - | SynType.WithGlobalConstraints (ty, _, _) - | SynType.Array (_, ty, _) -> traverseSynType path ty - | SynType.StaticConstantNamed (ty1, ty2, _) - | SynType.MeasureDivide (ty1, ty2, _) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path) - | SynType.Tuple (_, tys, _) -> tys |> List.map snd |> List.tryPick (traverseSynType path) - | SynType.StaticConstantExpr (expr, _) -> traverseSynExpr [] expr - | SynType.Anon _ -> None - | _ -> None - - visitor.VisitType(origPath, defaultTraverse, ty) - - and normalizeMembersToDealWithPeculiaritiesOfGettersAndSetters - path - traverseInherit - (synMemberDefns: SynMemberDefns) - = - synMemberDefns - // property getters are setters are two members that can have the same range, so do some somersaults to deal with this - |> Seq.groupBy (fun x -> x.Range) - |> Seq.choose (fun (r, mems) -> - match mems |> Seq.toList with - | [ mem ] -> // the typical case, a single member has this range 'r' - Some(dive mem r (traverseSynMemberDefn path traverseInherit)) - | [ SynMemberDefn.Member(memberDefn = SynBinding(headPat = SynPat.LongIdent (longDotId = lid1 - extraId = Some (info1)))) as mem1 - SynMemberDefn.Member(memberDefn = SynBinding(headPat = SynPat.LongIdent (longDotId = lid2 - extraId = Some (info2)))) as mem2 ] -> // can happen if one is a getter and one is a setter - // ensure same long id - assert - ((lid1.LongIdent, lid2.LongIdent) - ||> List.forall2 (fun x y -> x.idText = y.idText)) - // ensure one is getter, other is setter - assert - ((info1.idText = "set" && info2.idText = "get") - || (info2.idText = "set" && info1.idText = "get")) - - Some( - r, - (fun () -> - // both mem1 and mem2 have same range, would violate dive-and-pick assertions, so just try the first one, else try the second one: - match traverseSynMemberDefn path (fun _ -> None) mem1 with - | Some _ as x -> x - | _ -> traverseSynMemberDefn path (fun _ -> None) mem2) - ) - | [] -> -#if DEBUG - assert false - failwith "impossible, Seq.groupBy never returns empty results" -#else - // swallow AST error and recover silently - None -#endif - | _ -> -#if DEBUG - assert false // more than 2 members claim to have the same range, this indicates a bug in the AST - failwith "bug in AST" -#else - // swallow AST error and recover silently - None -#endif - ) - - and traverseSynTypeDefn - origPath - (SynTypeDefn (synComponentInfo, synTypeDefnRepr, synMemberDefns, _, tRange, _) as tydef) - = - let path = SyntaxNode.SynTypeDefn tydef :: origPath - - match visitor.VisitComponentInfo(origPath, synComponentInfo) with - | Some x -> Some x - | None -> - [ match synTypeDefnRepr with - | SynTypeDefnRepr.Exception _ -> - // This node is generated in CheckExpressions.fs, not in the AST. - // But note exception declarations are missing from this tree walk. - () - | SynTypeDefnRepr.ObjectModel (synTypeDefnKind, synMemberDefns, _oRange) -> - // traverse inherit function is used to capture type specific data required for processing Inherit part - let traverseInherit (synType: SynType, range: range) = - visitor.VisitInheritSynMemberDefn(path, synComponentInfo, synTypeDefnKind, synType, synMemberDefns, range) - - yield! - synMemberDefns - |> normalizeMembersToDealWithPeculiaritiesOfGettersAndSetters path traverseInherit - | SynTypeDefnRepr.Simple (synTypeDefnSimpleRepr, _range) -> - match synTypeDefnSimpleRepr with - | SynTypeDefnSimpleRepr.Record (_synAccessOption, fields, m) -> - yield dive () synTypeDefnRepr.Range (fun () -> visitor.VisitRecordDefn(path, fields, m)) - | SynTypeDefnSimpleRepr.Union (_synAccessOption, cases, m) -> - yield dive () synTypeDefnRepr.Range (fun () -> visitor.VisitUnionDefn(path, cases, m)) - | SynTypeDefnSimpleRepr.Enum (cases, m) -> - yield dive () synTypeDefnRepr.Range (fun () -> visitor.VisitEnumDefn(path, cases, m)) - | SynTypeDefnSimpleRepr.TypeAbbrev (_, synType, m) -> - yield dive synTypeDefnRepr synTypeDefnRepr.Range (fun _ -> visitor.VisitTypeAbbrev(path, synType, m)) - | _ -> () - yield! - synMemberDefns - |> normalizeMembersToDealWithPeculiaritiesOfGettersAndSetters path (fun _ -> None) ] - |> pick tRange tydef - - and traverseSynMemberDefn path traverseInherit (m: SynMemberDefn) = - let pick (debugObj: obj) = pick m.Range debugObj - let path = SyntaxNode.SynMemberDefn m :: path - - match m with - | SynMemberDefn.Open (_longIdent, _range) -> None - | SynMemberDefn.Member (synBinding, _range) -> traverseSynBinding path synBinding - | SynMemberDefn.ImplicitCtor (_synAccessOption, _synAttributes, simplePats, _identOption, _doc, _range) -> - match simplePats with - | SynSimplePats.SimplePats (simplePats, _) -> visitor.VisitSimplePats(path, simplePats) - | _ -> None - | SynMemberDefn.ImplicitInherit (synType, synExpr, _identOption, range) -> - [ dive () synType.Range (fun () -> - match traverseInherit (synType, range) with - | None -> visitor.VisitImplicitInherit(path, traverseSynExpr path, synType, synExpr, range) - | x -> x) - dive () synExpr.Range (fun () -> - visitor.VisitImplicitInherit(path, traverseSynExpr path, synType, synExpr, range)) ] - |> pick m - | SynMemberDefn.AutoProperty (synExpr = synExpr) -> traverseSynExpr path synExpr - | SynMemberDefn.LetBindings (synBindingList, isRecursive, _, range) -> - match visitor.VisitLetOrUse(path, isRecursive, traverseSynBinding path, synBindingList, range) with - | Some x -> Some x - | None -> - synBindingList - |> List.map (fun x -> dive x x.RangeOfBindingWithRhs (traverseSynBinding path)) - |> pick m - | SynMemberDefn.AbstractSlot (_synValSig, _memberFlags, _range) -> None - | SynMemberDefn.Interface (interfaceType = synType; members = synMemberDefnsOption) -> - match visitor.VisitInterfaceSynMemberDefnType(path, synType) with - | None -> - match synMemberDefnsOption with - | None -> None - | Some (x) -> - [ yield! - x - |> normalizeMembersToDealWithPeculiaritiesOfGettersAndSetters path (fun _ -> None) ] - |> pick x - | ok -> ok - | SynMemberDefn.Inherit (synType, _identOption, range) -> traverseInherit (synType, range) - | SynMemberDefn.ValField (_synField, _range) -> None - | SynMemberDefn.NestedType (synTypeDefn, _synAccessOption, _range) -> traverseSynTypeDefn path synTypeDefn - - and traverseSynMatchClause origPath mc = - let defaultTraverse mc = - let path = SyntaxNode.SynMatchClause mc :: origPath - - match mc with - | SynMatchClause (pat = synPat; whenExpr = synExprOption; resultExpr = synExpr) as all -> - [ dive synPat synPat.Range (traversePat path) ] - @ ([ match synExprOption with - | None -> () - | Some guard -> yield guard - yield synExpr ] - |> List.map (fun x -> dive x x.Range (traverseSynExpr path))) - |> pick all.Range all - - visitor.VisitMatchClause(origPath, defaultTraverse, mc) - - and traverseSynBinding origPath b = - let defaultTraverse b = - let path = SyntaxNode.SynBinding b :: origPath - - match b with - | SynBinding (headPat = synPat; expr = synExpr) -> - match traversePat path synPat with - | None -> traverseSynExpr path synExpr - | x -> x - - visitor.VisitBinding(origPath, defaultTraverse, b) - - match parseTree with - | ParsedInput.ImplFile (ParsedImplFileInput (modules = l)) -> - let fileRange = -#if DEBUG - match l with - | [] -> range0 - | _ -> l |> List.map (fun x -> x.Range) |> List.reduce unionRanges -#else - range0 // only used for asserting, does not matter in non-debug -#endif - l - |> List.map (fun x -> dive x x.Range (traverseSynModuleOrNamespace [])) - |> pick fileRange l - | ParsedInput.SigFile _sigFile -> None diff --git a/src/FsAutoComplete/CodeFixes/RemoveUnusedBinding.fs b/src/FsAutoComplete/CodeFixes/RemoveUnusedBinding.fs index 5ceed6dee..586996940 100644 --- a/src/FsAutoComplete/CodeFixes/RemoveUnusedBinding.fs +++ b/src/FsAutoComplete/CodeFixes/RemoveUnusedBinding.fs @@ -62,7 +62,7 @@ type FSharpParseFileResults with else // Check if it's an operator match pat with - | SynPat.LongIdent(longDotId = LongIdentWithDots ([ id ], _)) when id.idText.StartsWith("op_") -> + | SynPat.LongIdent(longDotId = SynLongIdent(id = [ id ])) when id.idText.StartsWith("op_") -> if Range.rangeContainsRange id.idRange diagnosticRange then Some(FullBinding binding.RangeOfBindingWithRhs) else diff --git a/src/FsAutoComplete/CodeFixes/RenameParamToMatchSignature.fs b/src/FsAutoComplete/CodeFixes/RenameParamToMatchSignature.fs index 4cf88b0f3..1a724702e 100644 --- a/src/FsAutoComplete/CodeFixes/RenameParamToMatchSignature.fs +++ b/src/FsAutoComplete/CodeFixes/RenameParamToMatchSignature.fs @@ -52,7 +52,7 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix = match tryGetSigName diagnostic.Message with | None -> return [] | Some sigName -> - let sigName = sigName |> PrettyNaming.AddBackticksToIdentifierIfNeeded + let sigName = sigName |> PrettyNaming.NormalizeIdentifierBackticks // replace usages of parameter with new name let fileName = codeActionParams.TextDocument.GetFilePath() |> Utils.normalizePath diff --git a/src/FsAutoComplete/CodeFixes/ReplaceWithSuggestion.fs b/src/FsAutoComplete/CodeFixes/ReplaceWithSuggestion.fs index 2f734b94d..afe8615e8 100644 --- a/src/FsAutoComplete/CodeFixes/ReplaceWithSuggestion.fs +++ b/src/FsAutoComplete/CodeFixes/ReplaceWithSuggestion.fs @@ -13,7 +13,7 @@ let fix = Run.ifDiagnosticByMessage "Maybe you want one of the following:" (fun diagnostic codeActionParams -> diagnostic.Message.Split('\n').[1..] |> Array.map (fun suggestion -> - let suggestion = suggestion.Trim() |> PrettyNaming.AddBackticksToIdentifierIfNeeded + let suggestion = suggestion.Trim() |> PrettyNaming.NormalizeIdentifierBackticks { Edits = [| { Range = diagnostic.Range diff --git a/src/FsAutoComplete/CommandResponse.fs b/src/FsAutoComplete/CommandResponse.fs index e0f856c90..10adda4f0 100644 --- a/src/FsAutoComplete/CommandResponse.fs +++ b/src/FsAutoComplete/CommandResponse.fs @@ -33,6 +33,7 @@ module internal CompletionUtils = | FSharpGlyph.Variable -> ("Variable", "V") | FSharpGlyph.ExtensionMethod -> ("Extension Method", "M") | FSharpGlyph.Error -> ("Error", "E") + | FSharpGlyph.TypeParameter -> ("Type", "T") let getEnclosingEntityChar = @@ -226,7 +227,7 @@ module CommandResponse = let (glyph, glyphChar) = CompletionUtils.getIcon e.Glyph { UniqueName = e.UniqueName - Name = e.Name + Name = e.LogicalName Glyph = glyph GlyphChar = glyphChar IsTopLevel = e.IsSingleTopLevel diff --git a/src/FsAutoComplete/LspHelpers.fs b/src/FsAutoComplete/LspHelpers.fs index 222a30f93..01d0abfbb 100644 --- a/src/FsAutoComplete/LspHelpers.fs +++ b/src/FsAutoComplete/LspHelpers.fs @@ -126,7 +126,7 @@ module Conversions = Range = fcsRangeToLsp decl.Range } let sym = - { SymbolInformation.Name = decl.Name + { SymbolInformation.Name = decl.LogicalName Kind = kind Location = location ContainerName = container } @@ -134,7 +134,7 @@ module Conversions = if symbolFilter sym then Some sym else None [| yield! inner None topLevel.Declaration |> Option.toArray - yield! topLevel.Nested |> Array.choose (inner (Some topLevel.Declaration.Name)) |] + yield! topLevel.Nested |> Array.choose (inner (Some topLevel.Declaration.LogicalName)) |] let applyQuery (query: string) (info: SymbolInformation) = match query.Split([| '.' |], StringSplitOptions.RemoveEmptyEntries) with diff --git a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs index 94e7ca004..0dacc5b68 100644 --- a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs +++ b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs @@ -1738,7 +1738,7 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar transact (fun () -> HashMap.OfList( [ for d in decls do - d.Name, (d, pos, filePath, namedText.Lines.GetLine, typeCheckResults.GetAST) ] + d.NameInList, (d, pos, filePath, namedText.Lines.GetLine, typeCheckResults.GetAST) ] ) |> autoCompleteItems.UpdateTo) |> ignore @@ -1749,23 +1749,26 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar decls |> Array.mapi (fun id d -> let code = - if System.Text.RegularExpressions.Regex.IsMatch(d.Name, """^[a-zA-Z][a-zA-Z0-9']+$""") then - d.Name + if + System.Text.RegularExpressions.Regex.IsMatch(d.NameInList, """^[a-zA-Z][a-zA-Z0-9']+$""") + then + d.NameInList elif d.NamespaceToOpen.IsSome then - d.Name + d.NameInList else - FSharpKeywords.AddBackticksToIdentifierIfNeeded d.Name + FSharpKeywords.NormalizeIdentifierBackticks d.NameInList let label = match d.NamespaceToOpen with - | Some no -> sprintf "%s (open %s)" d.Name no - | None -> d.Name + | Some no -> sprintf "%s (open %s)" d.NameInList no + | None -> d.NameInList - { CompletionItem.Create(d.Name) with + { CompletionItem.Create(d.NameInList) with Kind = (AVal.force glyphToCompletionKind) d.Glyph InsertText = Some code SortText = Some(sprintf "%06d" id) - FilterText = Some d.Name }) + FilterText = Some d.NameInList + Label = label }) let its = if not includeKeywords then @@ -2036,8 +2039,7 @@ type AdaptiveFSharpLspServer(workspaceLoader: IWorkspaceLoader, lspClient: FShar |> Seq.map (fun (namedText, symbols) -> let edits = let newName = - p.NewName - |> FSharp.Compiler.Syntax.PrettyNaming.AddBackticksToIdentifierIfNeeded + p.NewName |> FSharp.Compiler.Syntax.PrettyNaming.NormalizeIdentifierBackticks symbols |> Seq.map (fun sym -> diff --git a/src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs b/src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs index b00656566..c037a061b 100644 --- a/src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs +++ b/src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs @@ -1432,23 +1432,24 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) = decls |> Array.mapi (fun id d -> let code = - if System.Text.RegularExpressions.Regex.IsMatch(d.Name, """^[a-zA-Z][a-zA-Z0-9']+$""") then - d.Name + if System.Text.RegularExpressions.Regex.IsMatch(d.NameInList, """^[a-zA-Z][a-zA-Z0-9']+$""") then + d.NameInList elif d.NamespaceToOpen.IsSome then - d.Name + d.NameInList else - FSharpKeywords.AddBackticksToIdentifierIfNeeded d.Name + FSharpKeywords.NormalizeIdentifierBackticks d.NameInList let label = match d.NamespaceToOpen with - | Some no -> sprintf "%s (open %s)" d.Name no - | None -> d.Name + | Some no -> sprintf "%s (open %s)" d.NameInList no + | None -> d.NameInList - { CompletionItem.Create(d.Name) with + { CompletionItem.Create(d.NameInList) with Kind = glyphToCompletionKind d.Glyph InsertText = Some code SortText = Some(sprintf "%06d" id) - FilterText = Some d.Name }) + FilterText = Some d.NameInList + Label = label }) let its = if not keywords then @@ -1637,8 +1638,7 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) = |> Seq.map (fun (namedText, symbols) -> let edits = let newName = - p.NewName - |> FSharp.Compiler.Syntax.PrettyNaming.AddBackticksToIdentifierIfNeeded + p.NewName |> FSharp.Compiler.Syntax.PrettyNaming.NormalizeIdentifierBackticks symbols |> Seq.map (fun sym -> diff --git a/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs b/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs index 929b66a0a..8a6260d42 100644 --- a/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CompletionTests.fs @@ -497,10 +497,11 @@ let autoOpenTests state = | Ok None -> failtest "Request none" | Ok (Some res) -> Expect.isFalse res.IsIncomplete "Result is incomplete" - let ci = res.Items |> Array.find (fun c -> c.Label = word) + let ci = res.Items |> Array.tryFind (fun c -> c.Label = word) + if ci = None then failwithf $"Couldn't find completion item for `{word}` among the items %A{res.Items |> Array.map (fun i -> i.Label)}" |> ignore // now get details: `completionItem/resolve` (previous request was `textDocument/completion` -> List of all completions, but without details) - match! server.CompletionItemResolve ci with + match! server.CompletionItemResolve ci.Value with | Error e -> failtestf "Request failed: %A" e | Ok ci -> Expect.equal ci.Label $"{word} (open {ns})" $"Should be unopened {word}" diff --git a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs index 26b6b7560..7cce0791b 100644 --- a/test/FsAutoComplete.Tests.Lsp/CoreTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CoreTests.fs @@ -330,9 +330,9 @@ let tooltipTests state = 13 (concatLines [ "val inline add:" - " x: ^a (requires static member ( + ) ) ->" - " y: ^b (requires static member ( + ) )" - " -> ^c" ]) + " x: 'a (requires static member ( + ) ) ->" + " y: 'b (requires static member ( + ) )" + " -> 'c" ]) // verify rendering of solved generic constraints in tooltips for members where they are solved verifyDescription 45 diff --git a/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs b/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs index 735d8be0e..2c04006d8 100644 --- a/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/ExtensionsTests.fs @@ -406,6 +406,6 @@ let signatureTests state = "signature evaluation" [ testList "tests" - [ verifySignature 0 (4, 16) "val arrayOfTuples: (int * int)[]" + [ verifySignature 0 (4, 16) "val arrayOfTuples: (int * int) array" verifySignature 1 (4, 15) "val listOfTuples: (int * int) list" verifySignature 2 (4, 15) "val someFunction: a: 'a -> unit" ] ]