From 601922ab951b5661294fa9428cd998897e34d2d9 Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Tue, 5 Dec 2023 14:38:38 +0100 Subject: [PATCH] Show documentation for value forwarders in completions --- .../src/main/dotty/tools/pc/CompletionItemResolver.scala | 2 ++ .../main/dotty/tools/pc/completions/CompletionValue.scala | 2 ++ .../tools/pc/tests/completion/CompletionDocSuite.scala | 2 +- .../dotty/tools/pc/tests/completion/CompletionSuite.scala | 8 ++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala b/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala index 4a20ab0f8e5f..c962617ac7fb 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala @@ -69,6 +69,8 @@ object CompletionItemResolver extends ItemResolver: fullDocstring(tr.symbol, search) case _ => "" + else if gsym.isTerm && gsym.info.typeSymbol.is(Module) then + fullDocstring(gsym.info.typeSymbol.companion, search) else "" else gsymDoc else diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala index d267d2660776..def023320d0d 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala @@ -100,6 +100,8 @@ object CompletionValue: s"${labelWithSuffix(printer)} -${description(printer)}" else s"${labelWithSuffix(printer)}${description(printer)}" else if symbol.isType then labelWithSuffix(printer) + else if symbol.isTerm && symbol.info.typeSymbol.is(Module) then + s"${label}${description(printer)}" else s"$label: ${description(printer)}" private def labelWithSuffix(printer: ShortenedTypePrinter)(using Context): String = diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionDocSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionDocSuite.scala index 6c5da76114a2..c419ce3946d9 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionDocSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionDocSuite.scala @@ -214,7 +214,7 @@ class CompletionDocSuite extends BaseCompletionSuite: """.stripMargin, """ |> Found documentation for scala/package.Vector. - |Vector: scala.collection.immutable + |Vector scala.collection.immutable |""".stripMargin, includeDocs = true ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala index b77404d4e7fc..055363830a1b 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala @@ -25,7 +25,7 @@ class CompletionSuite extends BaseCompletionSuite: | Lis@@ |}""".stripMargin, """ - |List: scala.collection.immutable + |List scala.collection.immutable |List - java.awt |List - java.util |List - scala.collection.immutable @@ -647,7 +647,7 @@ class CompletionSuite extends BaseCompletionSuite: |} |""".stripMargin, """|None scala - |NoManifest: scala.reflect + |NoManifest scala.reflect |""".stripMargin, topLines = Some(2) ) @@ -660,8 +660,8 @@ class CompletionSuite extends BaseCompletionSuite: |} |""".stripMargin, """|Some(value) scala - |Seq: scala.collection.immutable - |Set: scala.collection.immutable + |Seq scala.collection.immutable + |Set scala.collection.immutable |""".stripMargin, topLines = Some(3) )