From 070be18c44e9f48118666a85703b65a3419f1aab Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Sun, 26 May 2019 21:16:13 -0700 Subject: [PATCH 1/4] Unify fsharpqa comparer.fsx (#6875) --- .../fsc/gccerrors/comparer.fsx | 21 --------- .../CompilerOptions/fsc/gccerrors/env.lst | 4 +- .../CompilerOptions/fsc/help/comparer.fsx | 32 -------------- .../Source/CompilerOptions/fsc/help/env.lst | 6 +-- .../CompilerOptions/fsc/nologo/comparer.fsx | 33 -------------- .../Source/CompilerOptions/fsc/nologo/env.lst | 4 +- .../CompilerOptions/fsi/exename/comparer.fsx | 21 --------- .../CompilerOptions/fsi/exename/env.lst | 2 +- .../CompilerOptions/fsi/help/comparer.fsx | 36 --------------- .../Source/CompilerOptions/fsi/help/env.lst | 8 ++-- tests/fsharpqa/Source/comparer.fsx | 44 +++++++++++++++++++ 11 files changed, 55 insertions(+), 156 deletions(-) delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/comparer.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/help/comparer.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsc/nologo/comparer.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/exename/comparer.fsx delete mode 100644 tests/fsharpqa/Source/CompilerOptions/fsi/help/comparer.fsx create mode 100644 tests/fsharpqa/Source/comparer.fsx diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/comparer.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/comparer.fsx deleted file mode 100644 index dfc716408b9..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/comparer.fsx +++ /dev/null @@ -1,21 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -let fn1 = fsi.CommandLineArgs.[1] -let fn2 = fsi.CommandLineArgs.[2] -// Read file into an array -let File2List(filename : string) = System.IO.File.ReadAllLines filename |> Array.toList -let f1 = File2List fn1 -let f2 = File2List fn2 -let mutable i = 0 - -let compare f1 f2 = - (f1, f2) ||> List.forall2 (fun (a : string) (b : string) -> - i <- i + 1 - if (a = b) then true - else - printfn "Files differ at line %d:" i - printfn "\t>> %s" a - printfn "\t<< %s" b - false) - -exit (if (f1.Length = f2.Length && compare f1 f2) then 0 - else 1) diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/env.lst index e7cc45cb1e0..e45bfc18344 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/env.lst +++ b/tests/fsharpqa/Source/CompilerOptions/fsc/gccerrors/env.lst @@ -1,3 +1 @@ -ReqENU SOURCE=gccerrors01.fs COMPILE_ONLY=1 SCFLAGS="--gccerrors --nologo gccerrors01.fs >gccerrors01.txt" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx gccerrors01.txt gccerrors01.bsl" - - +ReqENU SOURCE=gccerrors01.fs COMPILE_ONLY=1 SCFLAGS="--gccerrors --nologo gccerrors01.fs >gccerrors01.txt" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx gccerrors01.txt gccerrors01.bsl" diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/help/comparer.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/help/comparer.fsx deleted file mode 100644 index 38adec6afd1..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/help/comparer.fsx +++ /dev/null @@ -1,32 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -#light - -let arg0 = System.Environment.GetCommandLineArgs().[0] -let path = System.Environment.GetEnvironmentVariable("PATH") -let fn1 = fsi.CommandLineArgs.[1] -let fn2 = fsi.CommandLineArgs.[2] - -// Read file into an array -let File2List (filename:string) = System.IO.File.ReadAllLines(filename) - -let f1 = File2List fn1 -let f2 = File2List fn2 - -let mutable i = 0 -let compare (f1:string[]) (f2:string[]) = - if f1.Length <> f2.Length then failwithf "Help text did not match. f1.Length = %d, f2.Length = %d. Check you have fsc on path, arg0 = %s, PATH=%s" f1.Length f2.Length arg0 path - (f1, f2) ||> Array.forall2 (fun (a:string) (b:string) -> - let aa = System.Text.RegularExpressions.Regex.Replace(a, @"F# Compiler version .+", "F# Compiler") - let bb = System.Text.RegularExpressions.Regex.Replace(b, @"F# Compiler version .+", "F# Compiler") - i <- i+1 - if (aa = bb) then - true - else - printfn "Files differ at line %d:" i - printfn "\t>> %s" a - printfn "\t<< %s" b - false - ) - -exit (if compare f1 f2 then 0 else 1) - diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/help/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/help/env.lst index 2deb1bea39a..d6e7a56c5cd 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/help/env.lst +++ b/tests/fsharpqa/Source/CompilerOptions/fsc/help/env.lst @@ -1,6 +1,6 @@ # ReqENU means that the test is non-localized -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help40.txt help40.437.1033.bsl" # -? -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help40.txt help40.437.1033.bsl" # --help -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help40.txt help40.437.1033.bsl" # /? +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # -? +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # --help +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >help40.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help40.txt help40.437.1033.bsl" # /? diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/comparer.fsx b/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/comparer.fsx deleted file mode 100644 index 9f4ea4aab69..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/comparer.fsx +++ /dev/null @@ -1,33 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -#light - -let fn1 = fsi.CommandLineArgs.[1] -let fn2 = fsi.CommandLineArgs.[2] - -// Read file into an array -let File2List (filename:string) = - use s = new System.IO.StreamReader(filename) - let mutable l = [] - while not s.EndOfStream do - l <- List.append l ( s.ReadLine() :: []) - l - -let f1 = File2List fn1 -let f2 = File2List fn2 - -let mutable i = 0 -let compare (f1:string list) (f2:string list) = List.forall2 (fun (a:string) (b:string) -> - let aa = System.Text.RegularExpressions.Regex.Replace(a, @"F# Compiler version .+", "F# Compiler version") - let bb = System.Text.RegularExpressions.Regex.Replace(b, @"F# Compiler version .+", "F# Compiler version") - - i <- i+1 - if (aa = bb) then - true - else - printfn "Files differ at line %d:" i - printfn "\t>> %s" a - printfn "\t<< %s" b - false - ) f1 f2 - -exit (if compare f1 f2 then 0 else 1) diff --git a/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/env.lst index b4d4335cbff..179f4ddb7f0 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/env.lst +++ b/tests/fsharpqa/Source/CompilerOptions/fsc/nologo/env.lst @@ -1,7 +1,7 @@ # Not really related to the --nologo option -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >logo.txt 2>&1 || time /t" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx logo.txt logo.437.1033.bsl" # fsc -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >nologo.txt --nologo 2>&1 || time /t" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx nologo.txt nologo.437.1033.bsl" # fsc --nologo +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >logo.txt 2>&1 || time /t" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx logo.txt logo.437.1033.bsl" # fsc +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 PRECMD="\$FSC_PIPE >nologo.txt --nologo 2>&1 || time /t" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx nologo.txt nologo.437.1033.bsl" # fsc --nologo diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/comparer.fsx b/tests/fsharpqa/Source/CompilerOptions/fsi/exename/comparer.fsx deleted file mode 100644 index dd10fa3f16c..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/comparer.fsx +++ /dev/null @@ -1,21 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -let fn1 = fsi.CommandLineArgs.[1] -let fn2 = fsi.CommandLineArgs.[2] -let File2List(filename : string) = System.IO.File.ReadAllLines filename |> Array.toList -let f1 = File2List fn1 -let f2 = File2List fn2 -let mutable i = 0 - -let compare f1 f2 = - (f1,f2) ||> List.forall2 (fun a b -> - i <- i + 1 - if (a = b) then true - else - printfn "Files differ at line %d:" i - printfn "\t>> %s" a - printfn "\t<< %s" b - false) - -exit (if compare f1 f2 then 0 - else 1) - diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsi/exename/env.lst index 58ac3b820a0..4ab3350f39e 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/exename/env.lst +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/exename/env.lst @@ -1,5 +1,5 @@ -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo --exename:fsharpi --help >help.txt" FSIMODE=EXEC POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help.txt help40.437.1033.bsl" # -?-40 +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo --exename:fsharpi --help >help.txt" FSIMODE=EXEC POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help.txt help40.437.1033.bsl" # -?-40 diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/comparer.fsx b/tests/fsharpqa/Source/CompilerOptions/fsi/help/comparer.fsx deleted file mode 100644 index c0b39d14f3e..00000000000 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/comparer.fsx +++ /dev/null @@ -1,36 +0,0 @@ -// #NoMT #CompilerOptions #RequiresENU -#light - -let arg0 = System.Environment.GetCommandLineArgs().[0] -let path = System.Environment.GetEnvironmentVariable("PATH") -let fn1 = fsi.CommandLineArgs.[1] -let fn2 = fsi.CommandLineArgs.[2] - -// Read file into an array -let File2List (filename:string) = System.IO.File.ReadAllLines(filename) - -let f1 = File2List fn1 -let f2 = File2List fn2 - -let mutable i = 0 -let compare (f1:string[]) (f2:string[]) = - if f1.Length <> f2.Length then failwithf "Help text did not match. f1.Length = %d, f2.Length = %d, Check you have right fsi on path. fsi = %s, PATH=%s" f1.Length f2.Length arg0 path - (f1, f2) ||> Array.forall2 (fun (a:string) (b:string) -> - let aa = System.Text.RegularExpressions.Regex.Replace(a, @"F# Interactive build .+", "F# Interactive build") - let bb = System.Text.RegularExpressions.Regex.Replace(b, @"F# Interactive build .+", "F# Interactive build") - - // unify fsi.exe and FsiAnyCPU.exe - let aa = aa.Replace("FsiAnyCPU.exe", "fsi.exe") - let bb = aa.Replace("FsiAnyCPU.exe", "fsi.exe") - - i <- i+1 - if (aa = bb) then - true - else - printfn "Files differ at line %d:" i - printfn "\t>> %s" a - printfn "\t<< %s" b - false - ) - -exit (if compare f1 f2 then 0 else 1) diff --git a/tests/fsharpqa/Source/CompilerOptions/fsi/help/env.lst b/tests/fsharpqa/Source/CompilerOptions/fsi/help/env.lst index 236e79c6d76..c09c31f00a4 100644 --- a/tests/fsharpqa/Source/CompilerOptions/fsi/help/env.lst +++ b/tests/fsharpqa/Source/CompilerOptions/fsi/help/env.lst @@ -1,11 +1,11 @@ -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help.txt help40.437.1033.bsl" # -?-40 +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help.txt help40.437.1033.bsl" # -?-40 -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help.txt help40.437.1033.bsl" # --help-40 +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt --help 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help.txt help40.437.1033.bsl" # --help-40 -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help.txt help40.437.1033.bsl" # /?-40 +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt /? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help.txt help40.437.1033.bsl" # /?-40 # With --nologo -ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt --nologo -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec comparer.fsx help.txt help40-nologo.437.1033.bsl" # -? --nologo-40 +ReqENU SOURCE=dummy.fsx COMPILE_ONLY=1 SCFLAGS="--nologo" FSIMODE=EXEC PRECMD="\$FSI_PIPE >help.txt --nologo -? 2>&1" POSTCMD="\$FSI_PIPE --nologo --quiet --exec ..\\..\\..\\comparer.fsx help.txt help40-nologo.437.1033.bsl" # -? --nologo-40 diff --git a/tests/fsharpqa/Source/comparer.fsx b/tests/fsharpqa/Source/comparer.fsx new file mode 100644 index 00000000000..26bff8cb785 --- /dev/null +++ b/tests/fsharpqa/Source/comparer.fsx @@ -0,0 +1,44 @@ +// #NoMT #CompilerOptions #RequiresENU +#light +open System +open System.IO +open System.Text.RegularExpressions + +let arg0 = Environment.GetCommandLineArgs().[0] +let path = Environment.GetEnvironmentVariable("PATH") +let fn1 = fsi.CommandLineArgs.[1] +let fn2 = fsi.CommandLineArgs.[2] + +// Read file into an array +let File2List (filename:string) = File.ReadAllLines(filename) + +let f1 = File2List fn1 +let f2 = File2List fn2 + +let mutable i = 0 +let compare (f1:string[]) (f2:string[]) = + if f1.Length <> f2.Length then failwithf "Help text did not match. f1.Length = %d, f2.Length = %d, Check you have right fsi on path. fsi = %s, PATH=%s" f1.Length f2.Length arg0 path + (f1, f2) ||> Array.forall2 (fun (a:string) (b:string) -> + + let replace (sourcepattern:string) (replacement:string) (str:string) : string = + Regex.Replace(str, sourcepattern, replacement) + + let normalizeText (str:string) = + str |> replace @"F# Interactive version .+" "F# Interactive" + |> replace @"F# Compiler version .+" "F# Compiler" + |> replace "fsiAnyCpu.exe" "fsi.exe" + + let aa = normalizeText a + let bb = normalizeText b + + i <- i+1 + if (aa = bb) then + true + else + printfn "Files differ at line %d:" i + printfn "\t>> %s" a + printfn "\t<< %s" b + false + ) + +exit (if compare f1 f2 then 0 else 1) From 163cb4c6cfc8b4731c9a9399a0d03795664fa65f Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Sun, 26 May 2019 21:17:58 -0700 Subject: [PATCH 2/4] Clean navigation (#6849) * Remove need for IVT in ServiceNavigation * Apply Euguene's suggestions --- src/fsharp/service/ServiceNavigation.fs | 6 ++++-- src/fsharp/service/ServiceNavigation.fsi | 8 +++----- src/fsharp/service/ServiceUntypedParse.fs | 12 ++++++------ .../Navigation/NavigationBarItemService.fs | 6 ++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/fsharp/service/ServiceNavigation.fs b/src/fsharp/service/ServiceNavigation.fs index 1909f2454ff..0640e9ef06b 100755 --- a/src/fsharp/service/ServiceNavigation.fs +++ b/src/fsharp/service/ServiceNavigation.fs @@ -441,10 +441,12 @@ module NavigationImpl = items |> Array.sortInPlaceWith (fun a b -> compare a.Declaration.Name b.Declaration.Name) new FSharpNavigationItems(items) +[] +module FSharpNavigation = let getNavigation (parsedInput: ParsedInput) = match parsedInput with - | ParsedInput.SigFile (ParsedSigFileInput (modules = modules)) -> getNavigationFromSigFile modules - | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> getNavigationFromImplFile modules + | ParsedInput.SigFile (ParsedSigFileInput (modules = modules)) -> NavigationImpl.getNavigationFromSigFile modules + | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules)) -> NavigationImpl.getNavigationFromImplFile modules let empty = FSharpNavigationItems([||]) diff --git a/src/fsharp/service/ServiceNavigation.fsi b/src/fsharp/service/ServiceNavigation.fsi index be15736601e..b91389bbf2a 100755 --- a/src/fsharp/service/ServiceNavigation.fsi +++ b/src/fsharp/service/ServiceNavigation.fsi @@ -60,12 +60,10 @@ type public FSharpNavigationTopLevelDeclaration = type public FSharpNavigationItems = member Declarations : FSharpNavigationTopLevelDeclaration[] -// implementation details used by other code in the compiler -module internal NavigationImpl = - val internal getNavigationFromImplFile : Ast.SynModuleOrNamespace list -> FSharpNavigationItems - val internal getNavigationFromSigFile : Ast.SynModuleOrNamespaceSig list -> FSharpNavigationItems - val internal getNavigation : Ast.ParsedInput -> FSharpNavigationItems +// Functionality to access navigable F# items. +module public FSharpNavigation = val internal empty : FSharpNavigationItems + val getNavigation : Ast.ParsedInput -> FSharpNavigationItems module public NavigateTo = [] diff --git a/src/fsharp/service/ServiceUntypedParse.fs b/src/fsharp/service/ServiceUntypedParse.fs index 84197fc608c..4e5b1e596fe 100755 --- a/src/fsharp/service/ServiceUntypedParse.fs +++ b/src/fsharp/service/ServiceUntypedParse.fs @@ -111,15 +111,15 @@ type FSharpParseFileResults(errors: FSharpErrorInfo[], input: Ast.ParsedInput op ErrorScope.Protect Range.range0 (fun () -> match input with - | Some (ParsedInput.ImplFile (ParsedImplFileInput (modules = modules))) -> - NavigationImpl.getNavigationFromImplFile modules - | Some (ParsedInput.SigFile (ParsedSigFileInput _)) -> - NavigationImpl.empty + | Some (ParsedInput.ImplFile _ as p) -> + FSharpNavigation.getNavigation p + | Some (ParsedInput.SigFile _) -> + FSharpNavigation.empty | _ -> - NavigationImpl.empty ) + FSharpNavigation.empty) (fun err -> Trace.TraceInformation(sprintf "FCS: recovering from error in GetNavigationItemsImpl: '%s'" err) - NavigationImpl.empty) + FSharpNavigation.empty) member private scope.ValidateBreakpointLocationImpl pos = let isMatchRange m = rangeContainsPos m pos || m.StartLine = pos.Line diff --git a/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs b/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs index f80d10422d3..52d75c2b41b 100644 --- a/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs +++ b/vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs @@ -6,11 +6,9 @@ open System.Composition open System.Collections.Generic open System.Threading.Tasks -open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Editor open Microsoft.CodeAnalysis.Navigation open Microsoft.CodeAnalysis.Host.Mef -open Microsoft.CodeAnalysis.Text open Microsoft.CodeAnalysis.Notification open FSharp.Compiler.SourceCodeServices @@ -35,9 +33,9 @@ type internal FSharpNavigationBarItemService let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken) let! sourceText = document.GetTextAsync(cancellationToken) let! parsedInput = checkerProvider.Checker.ParseDocument(document, parsingOptions, sourceText=sourceText, userOpName=userOpName) - let navItems = NavigationImpl.getNavigation parsedInput + let navItems = FSharpNavigation.getNavigation parsedInput let rangeToTextSpan range = RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, range) - return + return navItems.Declarations |> Array.choose (fun topLevelDecl -> rangeToTextSpan(topLevelDecl.Declaration.Range) From 0b8ea174684c2811751ced71c8463743a914e13e Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Sun, 26 May 2019 21:18:19 -0700 Subject: [PATCH 3/4] Use FCS API for keywords instead of LexHelp internals (#6851) * Use FCS API for keywords instead of LexHelp internals * LexHelp gone --- .../src/FSharp.Editor/Completion/CompletionProvider.fs | 6 +----- .../src/FSharp.Editor/InlineRename/InlineRenameService.fs | 2 +- .../src/FSharp.Editor/LanguageService/Tokenizer.fs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs index 4b80da57009..2c1603181f1 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs @@ -7,7 +7,6 @@ open System.Collections.Generic open System.Collections.Immutable open System.Threading open System.Threading.Tasks -open System.Runtime.CompilerServices open Microsoft.CodeAnalysis open Microsoft.CodeAnalysis.Completion @@ -15,13 +14,10 @@ open Microsoft.CodeAnalysis.Options open Microsoft.CodeAnalysis.Text open Microsoft.VisualStudio.Shell -open Microsoft.VisualStudio.Shell.Interop open FSharp.Compiler open FSharp.Compiler.Range open FSharp.Compiler.SourceCodeServices -open System.Runtime.Caching -open System.Collections.Concurrent module Logger = Microsoft.VisualStudio.FSharp.Editor.Logger @@ -48,7 +44,7 @@ type internal FSharpCompletionProvider static let [] IndexPropName = "Index" static let keywordCompletionItems = - Lexhelp.Keywords.keywordsWithDescription + Keywords.KeywordsWithDescription |> List.filter (fun (keyword, _) -> not (PrettyNaming.IsOperatorName keyword)) |> List.sortBy (fun (keyword, _) -> keyword) |> List.mapi (fun n (keyword, description) -> diff --git a/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs b/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs index 36158eefbcb..82cccffbf1a 100644 --- a/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs +++ b/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs @@ -57,7 +57,7 @@ type internal InlineRenameLocationSet(locations: InlineRenameLocation [], origin match symbolKind with | LexerSymbolKind.GenericTypeParameter | LexerSymbolKind.StaticallyResolvedTypeParameter -> replacementText - | _ -> Lexhelp.Keywords.NormalizeIdentifierBackticks replacementText + | _ -> Keywords.NormalizeIdentifierBackticks replacementText return { new IInlineRenameReplacementInfo with member __.NewSolution = newSolution diff --git a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs index 66a3a22a63c..c71a4a01a75 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs @@ -809,7 +809,7 @@ module internal Tokenizer = else PrettyNaming.IsIdentifierPartCharacter c) let isFixableIdentifier (s: string) = - not (String.IsNullOrEmpty s) && Lexhelp.Keywords.NormalizeIdentifierBackticks s |> isIdentifier + not (String.IsNullOrEmpty s) && Keywords.NormalizeIdentifierBackticks s |> isIdentifier let forbiddenChars = [| '.'; '+'; '$'; '&'; '['; ']'; '/'; '\\'; '*'; '\"' |] From 14e5082c190681056c247dd27862b9583be5f253 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Sun, 26 May 2019 21:26:11 -0700 Subject: [PATCH 4/4] Clean unecessary constructs from LanguageService.fs (#6848) --- .../LanguageService/LanguageService.fs | 41 +++++-------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index da7ae84baf2..d28229441b9 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -2,43 +2,22 @@ namespace rec Microsoft.VisualStudio.FSharp.Editor -#nowarn "40" - open System -open System.Collections.Concurrent -open System.Collections.Generic -open System.Collections.Immutable -open System.ComponentModel.Composition open System.ComponentModel.Design -open System.Diagnostics -open System.IO -open System.Linq -open System.Runtime.CompilerServices open System.Runtime.InteropServices open System.Threading open Microsoft.CodeAnalysis -open Microsoft.CodeAnalysis.Diagnostics -open Microsoft.CodeAnalysis.Completion open Microsoft.CodeAnalysis.Options -open FSharp.Compiler.CompileOps open FSharp.Compiler.SourceCodeServices open Microsoft.VisualStudio -open Microsoft.VisualStudio.Editor open Microsoft.VisualStudio.FSharp.Editor -open Microsoft.VisualStudio.TextManager.Interop open Microsoft.VisualStudio.LanguageServices open Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService open Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem -open Microsoft.VisualStudio.LanguageServices.Implementation.TaskList open Microsoft.VisualStudio.LanguageServices.ProjectSystem open Microsoft.VisualStudio.Shell -open Microsoft.VisualStudio.Shell.Events open Microsoft.VisualStudio.Shell.Interop -open Microsoft.VisualStudio.ComponentModelHost open Microsoft.VisualStudio.Text.Outlining -open FSharp.NativeInterop - -#nowarn "9" // NativePtr.toNativeInt // Used to expose FSharpChecker/ProjectInfo manager to diagnostic providers // Diagnostic providers can be executed in environment that does not use MEF so they can rely only @@ -68,10 +47,10 @@ type internal FSharpCheckerWorkspaceServiceFactory projectInfoManager: FSharpProjectOptionsManager ) = interface Microsoft.CodeAnalysis.Host.Mef.IWorkspaceServiceFactory with - member this.CreateService(_workspaceServices) = + member __.CreateService(_workspaceServices) = upcast { new FSharpCheckerWorkspaceService with - member this.Checker = checkerProvider.Checker - member this.FSharpProjectOptionsManager = projectInfoManager } + member __.Checker = checkerProvider.Checker + member __.FSharpProjectOptionsManager = projectInfoManager } [] type private FSharpSolutionEvents(projectManager: FSharpProjectOptionsManager) = @@ -104,7 +83,7 @@ type private FSharpSolutionEvents(projectManager: FSharpProjectOptionsManager) = type internal FSharpSettingsFactory [] (settings: EditorOptions) = interface Microsoft.CodeAnalysis.Host.Mef.IWorkspaceServiceFactory with - member this.CreateService(_) = upcast settings + member __.CreateService(_) = upcast settings [] [, @@ -242,14 +221,14 @@ type internal FSharpLanguageService(package : FSharpPackage) = let theme = package.ComponentModel.DefaultExportProvider.GetExport().Value theme.SetColors() - override this.ContentTypeName = FSharpConstants.FSharpContentTypeName - override this.LanguageName = FSharpConstants.FSharpLanguageName - override this.RoslynLanguageName = FSharpConstants.FSharpLanguageName + override __.ContentTypeName = FSharpConstants.FSharpContentTypeName + override __.LanguageName = FSharpConstants.FSharpLanguageName + override __.RoslynLanguageName = FSharpConstants.FSharpLanguageName - override this.LanguageServiceId = new Guid(FSharpConstants.languageServiceGuidString) - override this.DebuggerLanguageId = DebuggerEnvironment.GetLanguageID() + override __.LanguageServiceId = new Guid(FSharpConstants.languageServiceGuidString) + override __.DebuggerLanguageId = DebuggerEnvironment.GetLanguageID() - override this.CreateContext(_,_,_,_,_) = raise(System.NotImplementedException()) + override __.CreateContext(_,_,_,_,_) = raise(System.NotImplementedException()) override this.SetupNewTextView(textView) = base.SetupNewTextView(textView)