@@ -185,6 +185,32 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
185
185
else Patch .empty
186
186
}
187
187
188
+ def extractCollection (toCol : Tree ): String = {
189
+ toCol match {
190
+ case Term .ApplyType (q " scala.Predef.fallbackStringCanBuildFrom " , _) =>
191
+ " scala.collection.immutable.IndexedSeq"
192
+ case Term .ApplyType (Term .Select (coll,_), _) =>
193
+ coll.syntax
194
+ case Term .Apply (Term .ApplyType (Term .Select (coll, _), _), _) =>
195
+ coll.syntax
196
+ case Term .Select (coll,_) =>
197
+ coll.syntax
198
+ case _ => {
199
+ throw new Exception (
200
+ s """ |cannot extract collection from .to
201
+ |
202
+ |---------------------------------------------
203
+ |syntax:
204
+ | ${toCol.syntax}
205
+ |
206
+ |---------------------------------------------
207
+ |structure:
208
+ | ${toCol.structure}""" .stripMargin
209
+ )
210
+ }
211
+ }
212
+ }
213
+
188
214
def replaceToList (ctx : RuleCtx ): Patch = {
189
215
ctx.tree.collect {
190
216
case iterator(t : Name ) =>
@@ -194,6 +220,14 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
194
220
trailingBrackets(n, ctx).map { case (open, close) =>
195
221
ctx.replaceToken(open, " (" ) + ctx.replaceToken(close, " )" )
196
222
}.asPatch
223
+
224
+ case Term .Select (_, to @ toTpe(_)) =>
225
+ val synth = ctx.index.synthetics.find(_.position.end == to.pos.end)
226
+ synth.map{ s =>
227
+ val Term .Apply (_, List (toCol)) = s.text.parse[Term ].get
228
+ val col = extractCollection(toCol)
229
+ ctx.addRight(to, " (" + col + " )" )
230
+ }.getOrElse(Patch .empty)
197
231
}.asPatch
198
232
}
199
233
0 commit comments