Skip to content

Commit

Permalink
improvement: Also remove detail in case of scope completions and fix …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
tgodzik committed Dec 6, 2024
1 parent bbc0ec1 commit b5e5e84
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"""
Expand Down

0 comments on commit b5e5e84

Please sign in to comment.