Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit 10cc938

Browse files
committed
Fix a compile error with Scala-2.10
1 parent 649c5f1 commit 10cc938

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

org.scala-refactoring.library/src/main/scala/scala/tools/refactoring/common/CompilerApiExtensions.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,32 @@ trait CompilerApiExtensions {
2727
private class FilteringLocator(pos: Position, p: Tree => Boolean) extends Locator(pos) {
2828
override def isEligible(t: Tree) = super.isEligible(t) && p(t)
2929
}
30+
31+
/*
32+
* For Scala-2.10 (see scala.reflect.internal.Positions.Locator in Scala-2.11).
33+
*/
34+
private class Locator(pos: Position) extends Traverser {
35+
var last: Tree = _
36+
def locateIn(root: Tree): Tree = {
37+
this.last = EmptyTree
38+
traverse(root)
39+
this.last
40+
}
41+
protected def isEligible(t: Tree) = !t.pos.isTransparent
42+
override def traverse(t: Tree) {
43+
t match {
44+
case tt : TypeTree if tt.original != null && (tt.pos includes tt.original.pos) =>
45+
traverse(tt.original)
46+
case _ =>
47+
if (t.pos includes pos) {
48+
if (isEligible(t)) last = t
49+
super.traverse(t)
50+
} else t match {
51+
case mdef: MemberDef =>
52+
traverseTrees(mdef.mods.annotations)
53+
case _ =>
54+
}
55+
}
56+
}
57+
}
3058
}

0 commit comments

Comments
 (0)