From e99d6f70232e6a7493657ddbc70f9b672a623b94 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 6 Dec 2024 13:02:25 +0100 Subject: [PATCH 1/2] Completion: fix qualified completion in sequence expressions --- src/Compiler/Service/ServiceParseTreeWalk.fs | 6 --- .../CompletionTests.fs | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/Compiler/Service/ServiceParseTreeWalk.fs b/src/Compiler/Service/ServiceParseTreeWalk.fs index 4c55c78a437..b55844e51ae 100644 --- a/src/Compiler/Service/ServiceParseTreeWalk.fs +++ b/src/Compiler/Service/ServiceParseTreeWalk.fs @@ -388,12 +388,6 @@ module SyntaxTraversal = seq { match expr with | SynExpr.Sequential(expr1 = expr1; expr2 = SynExpr.Sequential _ as expr2) -> - // It's a nested sequential expression. - // Visit it, but make defaultTraverse do nothing, - // since we're going to traverse its descendants ourselves. - yield dive expr expr.Range (fun expr -> visitor.VisitExpr(path, traverseSynExpr path, (fun _ -> None), expr)) - - // Now traverse its descendants. let path = SyntaxNode.SynExpr expr :: path yield dive expr1 expr1.Range (traverseSynExpr path) yield! traverseSequentials path expr2 diff --git a/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs b/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs index 7666fb005a1..38c6812728d 100644 --- a/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs @@ -97,3 +97,40 @@ let ``Type decl - Record - Field type 01`` () = type Record = { Field: } """ assertHasItemWithNames ["string"] info + + +[] +let ``Expr - Qualifier 01`` () = + let info = + getCompletionInfo "s.Trim(). " (3, 13) """ +let f (s: string) = + s.Trim(). + s.Trim() + s.Trim() + () +""" + assertHasItemWithNames ["Length"] info + +[] +let ``Expr - Qualifier 02`` () = + let info = + getCompletionInfo "s.Trim(). " (4, 13) """ +let f (s: string) = + s.Trim() + s.Trim(). + s.Trim() + () +""" + assertHasItemWithNames ["Length"] info + +[] +let ``Expr - Qualifier 03`` () = + let info = + getCompletionInfo "s.Trim(). " (5, 13) """ +let f (s: string) = + s.Trim() + s.Trim() + s.Trim(). + () +""" + assertHasItemWithNames ["Length"] info From 848788100f491a78930cb931eab16e1281ef8462 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 6 Dec 2024 17:33:46 +0300 Subject: [PATCH 2/2] Release notes --- docs/release-notes/.FSharp.Compiler.Service/9.0.200.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md index 4c8d5c04829..3590e3801a4 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md @@ -17,6 +17,7 @@ * Add missing nullable-metadata for C# consumers of records,exceptions and DU subtypes generated from F# code. [PR #18079](https://github.com/dotnet/fsharp/pull/18079) * Fix a race condition in file book keeping in the compiler service ([#18008](https://github.com/dotnet/fsharp/pull/18008)) * Fix trimming '%' characters when lowering interpolated string to a concat call [PR #18123](https://github.com/dotnet/fsharp/pull/18123) +* Completion: fix qualified completion in sequence expressions [PR #18111](https://github.com/dotnet/fsharp/pull/18111) ### Added