@@ -46,7 +46,7 @@ final class PcSyntheticDecorationsProvider(
46
46
47
47
def provide (): List [SyntheticDecoration ] =
48
48
val deepFolder = DeepFolder [Synthetics ](collectDecorations)
49
- deepFolder(Synthetics .empty, tpdTree).decorations
49
+ deepFolder(Synthetics .empty, tpdTree).result()
50
50
51
51
def collectDecorations (
52
52
decorations : Synthetics ,
@@ -256,11 +256,23 @@ case class Synthetics(
256
256
def containsDef (offset : Int ) = definitions(offset)
257
257
def add (decoration : Decoration , offset : Int ) =
258
258
copy(
259
- decorations = decoration :: decorations ,
259
+ decorations = addDecoration( decoration) ,
260
260
definitions = definitions + offset,
261
261
)
262
262
def add (decoration : Decoration ) =
263
- copy(decorations = decoration :: decorations)
263
+ copy (
264
+ decorations = addDecoration(decoration)
265
+ )
266
+
267
+ // If method has both type parameter and implicit parameter, we want the type parameter decoration to be displayed first,
268
+ // but it's added second. This method adds the decoration to the right position in the list.
269
+ private def addDecoration (decoration : Decoration ): List [Decoration ] =
270
+ val atSamePos =
271
+ decorations.takeWhile(_.range.getStart() == decoration.range.getStart())
272
+ (atSamePos :+ decoration) ++ decorations.drop(atSamePos.size)
273
+
274
+ def result (): List [Decoration ] = decorations.reverse
275
+ end Synthetics
264
276
265
277
object Synthetics :
266
278
def empty : Synthetics = Synthetics (Nil , Set .empty)
0 commit comments