scala/scala — pull request #2963 by sjrd (2013-09-18 18:07:52+00:00)
Title: Small refactorings giving hooks for Scala.js

I have reviewed the ugliest parts of Scala.js, where I need to circumvent the lack of appropriate hooks in scalac, and I came up with these three small refactorings.

Each one of these has its corresponding simplifying commit in Scala.js, in the following comparison:
https://github.com/sjrd/scala-js/compare/scala-2.11...topic/what-if-scalac-was-nicer-to-us
(in the same order).

There is no test accompanying this pull request, because there is absolutely no functionality change (it's only refactoring) and I don't quite see how to test that with partest. I'll be glad to add tests if someone can hint at me how.

(In case you care:) Incidentally, these hooks are the only ones on which Scala.js relies, in addition to being able to manipulate the phase set. Which means that *if* they were (experimentally) overridable by plugins, then Scala.js could be implemented as a plugin, which would bring lots of advantages in terms of integration with our various tools (sbt and IDE mainly).

(There are still two files with a non-negligible amount of code duplication in Scala.js, [JSSymbolLoaders.scala](https://github.com/sjrd/scala-js/blob/topic/what-if-scalac-was-nicer-to-us/compiler/src/main/scala/scala/tools/nsc/scalajs/JSSymbolLoaders.scala) and [JSTypefileParser.scala](https://github.com/sjrd/scala-js/blob/topic/what-if-scalac-was-nicer-to-us/compiler/src/main/scala/scala/tools/nsc/scalajs/JSTypefileParser.scala), but a proper fix to these two would require much bigger refactorings in scalac; and I don't care so much about these because they are not specifically the hooks I am relying on.)