diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-20 12:25:03 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-20 14:58:09 -0700 |
commit | c4d0fd9998d96843cd9704d5610a29ab752ecb14 (patch) | |
tree | c8bf37f4c1e474b85c859593463a319ff1407104 /test/osgi | |
parent | 68c6ba7e59befa88b2f383dd7eca71a9329a8b6d (diff) | |
download | scala-c4d0fd9998d96843cd9704d5610a29ab752ecb14.tar.gz scala-c4d0fd9998d96843cd9704d5610a29ab752ecb14.tar.bz2 scala-c4d0fd9998d96843cd9704d5610a29ab752ecb14.zip |
-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.
Diffstat (limited to 'test/osgi')
0 files changed, 0 insertions, 0 deletions