From b5e5e84e8767e72f587ee7cb13802ec08d770ee0 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 5 Dec 2024 17:49:37 +0100 Subject: [PATCH] improvement: Also remove detail in case of scope completions and fix tests --- .../meta/internal/pc/CompletionProvider.scala | 5 +- .../pc/CompletionWithoutDetailsSuite.scala | 54 +++++++++++++++---- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/CompletionProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/CompletionProvider.scala index c08a8cef4c4..9a57c565461 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/CompletionProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/CompletionProvider.scala @@ -110,9 +110,10 @@ class CompletionProvider( case _ => detailString(member, history) } + val includeDetailInLabel = compiler.metalsConfig.isDetailIncludedInLabel def labelWithSig = if ( - compiler.metalsConfig.isDetailIncludedInLabel && (member.sym.isMethod || member.sym.isValue) + includeDetailInLabel && (member.sym.isMethod || member.sym.isValue) ) { ident + detail } else { @@ -130,7 +131,7 @@ class CompletionProvider( o.label.getOrElse(labelWithSig) case _: WorkspaceImplicitMember => s"$labelWithSig (implicit)" - case o: WorkspaceMember => + case o: WorkspaceMember if includeDetailInLabel => s"$ident - ${o.sym.owner.fullName}" case _ => labelWithSig } diff --git a/tests/cross/src/test/scala/tests/pc/CompletionWithoutDetailsSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionWithoutDetailsSuite.scala index eaab6836420..74aa27b6b03 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionWithoutDetailsSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionWithoutDetailsSuite.scala @@ -19,31 +19,63 @@ class CompletionWithoutDetailsSuite extends BaseCompletionSuite { | Lis@@ |}""".stripMargin, """|List - |List - java.awt - |List - java.util - |JList - javax.swing - |ListUI - javax.swing.plaf + |List + |List + |JList + |ListUI |""".stripMargin, compat = Map( "2.13" -> """|List |LazyList - |List - java.awt - |List - java.util - |JList - javax.swing + |List + |List + |JList |""".stripMargin, "3" -> """|List - |List - java.awt - |List - java.util - |List - scala.collection.immutable - |List[A](elems: A*): CC[A] + |List + |List + |List + |List |""".stripMargin ), includeDetail = false, topLines = Some(5) ) + check( + "scope-detail", + """ + |object A { + | Lis@@ + |}""".stripMargin, + """|List scala.collection.immutable + |List java.awt + |List java.util + |JList javax.swing + |ListUI javax.swing.plaf + |""".stripMargin, + compat = Map( + "2.13" -> + """|List scala.collection.immutable + |LazyList scala.collection.immutable + |List java.awt + |List java.util + |JList javax.swing + |""".stripMargin, + "3" -> + """|List scala.collection.immutable + |List java.awt + |List java.util + |List scala.collection.immutable + |List[A](elems: A*): CC[A] + |""".stripMargin + ), + includeDetail = true, + topLines = Some(5) + ) + check( "member", """