scala/scala — pull request #2421 by paulp (2013-04-20 21:59:56+00:00)
Title: -Yshow-member-pos, print the positions of members.

Here for instance is a command line which leverages the
output of this option to print the method bodies of all
methods called 'transformInfo' found under src. Given
1500 source files it accomplishes this in four seconds,
thanks to -Ystop-after:parser.

% scalac -Yshow-member-pos sed -Ystop-after:parser \
$(find src/compiler -name '*.scala') | \
grep transformInfo | sed 's/ # .*//;' | \
while read line; do echo "// $line" && gsed -n $line && echo; done

Or more simply, the start/end lines of each member of Random:

% scalac -Yshow-member-pos "" ./src/library/scala/util/Random.scala
./src/library/scala/util/Random.scala
20,134 class Random
33 def nextBoolean
38 def nextBytes
43 def nextDouble
48 def nextFloat
54 def nextGaussian
59 def nextInt
65 def nextInt
70 def nextLong
81,89 def nextString
82,86 def safeChar
83 val surrogateStart
84 val res
94,98 def nextPrintableChar
[snip]

It makes me sad I'm always in the position of having to hack
the compiler to do this sort of thing. All we need is something
like -Yinsert-phase:Foo where Foo is a class implementing a
(Phase, Tree) => Tree method, and the compiler runs all the
unit.bodies through it after each phase, and then one could
easily accomplish this in the privacy of one's own compiler.