@@ -9,6 +9,7 @@ import dotty.tools.dotc.core.Symbols.Symbol
9
9
import dotty .tools .dotc .core .Types .Type
10
10
import dotty .tools .dotc .transform .SymUtils .*
11
11
import dotty .tools .pc .printer .ShortenedTypePrinter
12
+ import dotty .tools .pc .utils .MtagsEnrichments .decoded
12
13
13
14
import org .eclipse .lsp4j .CompletionItemKind
14
15
import org .eclipse .lsp4j .CompletionItemTag
@@ -35,9 +36,7 @@ sealed trait CompletionValue:
35
36
* Label with potentially attached description.
36
37
*/
37
38
def labelWithDescription (printer : ShortenedTypePrinter )(using Context ): String =
38
- labelWithSuffix
39
- def labelWithSuffix : String =
40
- s " $label${snippetSuffix.labelSnippet.getOrElse(" " )}"
39
+ label
41
40
def lspTags (using Context ): List [CompletionItemTag ] = Nil
42
41
end CompletionValue
43
42
@@ -77,14 +76,24 @@ object CompletionValue:
77
76
override def labelWithDescription (
78
77
printer : ShortenedTypePrinter
79
78
)(using Context ): String =
80
- if symbol.is(Method ) then s " ${labelWithSuffix}${description(printer)}"
81
- else if symbol.isConstructor then labelWithSuffix
82
- else if symbol.is(Mutable ) then
83
- s " ${labelWithSuffix}: ${description(printer)}"
79
+ if symbol.is(Method ) then s " ${label}${description(printer)}"
80
+ else if symbol.isConstructor then label
81
+ else if symbol.is(Mutable ) then s " $label: ${description(printer)}"
84
82
else if symbol.is(Package ) || symbol.is(Module ) || symbol.isClass then
85
- if isFromWorkspace then s " ${labelWithSuffix} - ${description(printer)}"
86
- else s " ${labelWithSuffix}${description(printer)}"
87
- else s " ${labelWithSuffix}: ${description(printer)}"
83
+ if isFromWorkspace then
84
+ s " ${labelWithSuffix(printer)} - ${description(printer)}"
85
+ else s " ${labelWithSuffix(printer)}${description(printer)}"
86
+ else if symbol.isType then labelWithSuffix(printer)
87
+ else s " $label: ${description(printer)}"
88
+
89
+ private def labelWithSuffix (printer : ShortenedTypePrinter )(using Context ): String =
90
+ if snippetSuffix.addLabelSnippet
91
+ then
92
+ val printedParams = symbol.info.typeParams.map(p =>
93
+ p.paramName.decoded ++ printer.tpe(p.paramInfo)
94
+ )
95
+ s " ${label}${printedParams.mkString(" [" , " ," , " ]" )}"
96
+ else label
88
97
89
98
override def description (printer : ShortenedTypePrinter )(
90
99
using Context
@@ -97,7 +106,11 @@ object CompletionValue:
97
106
symbol : Symbol ,
98
107
override val snippetSuffix : CompletionSuffix
99
108
) extends Symbolic
100
- case class Scope (label : String , symbol : Symbol ) extends Symbolic
109
+ case class Scope (
110
+ label : String ,
111
+ symbol : Symbol ,
112
+ override val snippetSuffix : CompletionSuffix ,
113
+ ) extends Symbolic
101
114
case class Workspace (
102
115
label : String ,
103
116
symbol : Symbol ,
@@ -262,6 +275,4 @@ object CompletionValue:
262
275
): CompletionValue =
263
276
Document (label, insertText, description)
264
277
265
- def scope (label : String , sym : Symbol ): CompletionValue =
266
- Scope (label, sym)
267
278
end CompletionValue
0 commit comments