@@ -6,7 +6,7 @@ import scala.meta._
6
6
7
7
case class Collectionstrawman_v0 (sctx : SemanticCtx )
8
8
extends SemanticRewrite (sctx) {
9
- val immutableListSymbol = Symbol ( " _root_.scala.collection.immutable.List. " )
9
+
10
10
implicit class XtensionSymbolCollection (symbol : Symbol ) {
11
11
def name = symbol match {
12
12
case Symbol .Global (_, sig) => sig.name
@@ -75,7 +75,7 @@ case class Collectionstrawman_v0(sctx: SemanticCtx)
75
75
def m (name : String ) =
76
76
s " scala.collection.mutable. $name" -> s " strawman.collection.mutable. $name"
77
77
ctx.replaceSymbols(
78
- s (" Set" ),
78
+ p (" Set" ),
79
79
i(" HashMap" ),
80
80
i(" Map" ),
81
81
p(" Map" ),
@@ -115,8 +115,10 @@ case class Collectionstrawman_v0(sctx: SemanticCtx)
115
115
sctx.symbol(arg.pos).map(x => arg -> x)
116
116
}
117
117
118
- val toX = SymbolMatcher (
119
- Symbol (" _root_.scala.collection.TraversableOnce.toMap." ),
118
+ val toGenericX = SymbolMatcher (
119
+ Symbol (" _root_.scala.collection.TraversableOnce.toMap." )
120
+ )
121
+ val toImmutableX = SymbolMatcher (
120
122
Symbol (" _root_.scala.collection.TraversableOnce.toList." ),
121
123
Symbol (" _root_.scala.collection.TraversableOnce.toSet." )
122
124
)
@@ -131,8 +133,10 @@ case class Collectionstrawman_v0(sctx: SemanticCtx)
131
133
ctx.tree.collect {
132
134
case iterator(n : Name , _) =>
133
135
ctx.addRight(n.tokens.last, " ()" )
134
- case toX(n : Name , s) =>
135
- ctx.replaceTree(n, s " to( ${s.name.stripPrefix(" to" )}) " )
136
+ case toImmutableX(n : Name , s) =>
137
+ ctx.replaceTree(n, s " to(strawman.collection.immutable. ${s.name.stripPrefix(" to" )}) " )
138
+ case toGenericX(n : Name , s) =>
139
+ ctx.replaceTree(n, s " to(strawman.collection. ${s.name.stripPrefix(" to" )}) " )
136
140
case toTpe(n : Name , _) =>
137
141
ctx.debug(n)
138
142
(for {
@@ -141,6 +145,7 @@ case class Collectionstrawman_v0(sctx: SemanticCtx)
141
145
open <- ctx.tokenList.find(name)(t => t.is[Token .LeftBracket ])
142
146
_ = ctx.debug(open)
143
147
close <- ctx.matching.close(open.asInstanceOf [Token .LeftBracket ])
148
+ replacedTokens = ctx.tokenList.slice(open, close)
144
149
} yield
145
150
ctx.replaceToken(open, " (" ) +
146
151
ctx.replaceToken(close, " )" )).getOrElse(Patch .empty)
0 commit comments