@@ -80,15 +80,15 @@ class PcInlayHintsProvider(
80
80
LabelPart (" )" ) :: Nil ,
81
81
InlayHintKind .Parameter ,
82
82
)
83
- case ImplicitParameters (symbols, pos, allImplicit) =>
84
- val labelParts = symbols.map(s => List (labelPart(s, s.decodedName)))
85
- val label =
86
- if allImplicit then labelParts.separated(" (using " , " , " , " )" )
87
- else labelParts.separated(" , " )
83
+ case ImplicitParameters (trees, pos) =>
88
84
inlayHints.add(
89
85
adjustPos(pos).toLsp,
90
- label,
91
- InlayHintKind .Parameter ,
86
+ ImplicitParameters .partsFromImplicitArgs(trees).map((label, maybeSymbol) =>
87
+ maybeSymbol match
88
+ case Some (symbol) => labelPart(symbol, label)
89
+ case None => LabelPart (label)
90
+ ),
91
+ InlayHintKind .Parameter
92
92
)
93
93
case ValueOf (label, pos) =>
94
94
inlayHints.add(
@@ -221,12 +221,8 @@ object ImplicitParameters:
221
221
case Apply (fun, args)
222
222
if args.exists(isSyntheticArg) && ! tree.sourcePos.span.isZeroExtent && ! args.exists(isQuotes(_)) =>
223
223
val (implicitArgs, providedArgs) = args.partition(isSyntheticArg)
224
- val allImplicit = providedArgs.isEmpty || providedArgs.forall {
225
- case Ident (name) => name == nme.MISSING
226
- case _ => false
227
- }
228
224
val pos = implicitArgs.head.sourcePos
229
- Some (implicitArgs.map(_.symbol) , pos, allImplicit )
225
+ Some (implicitArgs, pos)
230
226
case _ => None
231
227
} else None
232
228
@@ -242,6 +238,67 @@ object ImplicitParameters:
242
238
private def isQuotes (tree : Tree )(using Context ) =
243
239
tree.tpe.typeSymbol == defn.QuotesClass
244
240
241
+ def partsFromImplicitArgs (trees : List [Tree ])(using Context ): List [(String , Option [Symbol ])] = {
242
+ @ tailrec
243
+ def recurseImplicitArgs (
244
+ currentArgs : List [Tree ],
245
+ remainingArgsLists : List [List [Tree ]],
246
+ parts : List [(String , Option [Symbol ])]
247
+ ): List [(String , Option [Symbol ])] =
248
+ (currentArgs, remainingArgsLists) match {
249
+ case (Nil , Nil ) => parts
250
+ case (Nil , headArgsList :: tailArgsList) =>
251
+ if (headArgsList.isEmpty) {
252
+ recurseImplicitArgs(
253
+ headArgsList,
254
+ tailArgsList,
255
+ (" )" , None ) :: parts
256
+ )
257
+ } else {
258
+ recurseImplicitArgs(
259
+ headArgsList,
260
+ tailArgsList,
261
+ (" , " , None ) :: (" )" , None ) :: parts
262
+ )
263
+ }
264
+ case (arg :: remainingArgs, remainingArgsLists) =>
265
+ arg match {
266
+ case Apply (fun, args) =>
267
+ val applyLabel = (fun.symbol.decodedName, Some (fun.symbol))
268
+ recurseImplicitArgs(
269
+ args,
270
+ remainingArgs :: remainingArgsLists,
271
+ (" (" , None ) :: applyLabel :: parts
272
+ )
273
+ case t if t.isTerm =>
274
+ val termLabel = (t.symbol.decodedName, Some (t.symbol))
275
+ if (remainingArgs.isEmpty)
276
+ recurseImplicitArgs(
277
+ remainingArgs,
278
+ remainingArgsLists,
279
+ termLabel :: parts
280
+ )
281
+ else
282
+ recurseImplicitArgs(
283
+ remainingArgs,
284
+ remainingArgsLists,
285
+ (" , " , None ) :: termLabel :: parts
286
+ )
287
+ case _ =>
288
+ recurseImplicitArgs(
289
+ remainingArgs,
290
+ remainingArgsLists,
291
+ parts
292
+ )
293
+ }
294
+ }
295
+ ((" )" , None ) :: recurseImplicitArgs(
296
+ trees,
297
+ Nil ,
298
+ List ((" (using " , None ))
299
+ )).reverse
300
+ }
301
+
245
302
end ImplicitParameters
246
303
247
304
object ValueOf :
0 commit comments