summaryrefslogtreecommitdiff
path: root/docs/examples/plugintemplate/src/plugintemplate/standalone/PluginRunner.scala
blob: 979437c8c28b801a03849d82627d6bdf2e10e2b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package plugintemplate.standalone

import scala.tools.nsc.{Global, Settings, SubComponent}
import scala.tools.nsc.reporters.{ConsoleReporter, Reporter}

/** This class is a compiler that will be used for running
 *  the plugin in standalone mode.
 */
class PluginRunner(settings: Settings, reporter: Reporter)
extends Global(settings, reporter) {
  def this(settings: Settings) = this(settings, new ConsoleReporter(settings))

  val annotChecker = new TemplateAnnotationChecker {
      val global: PluginRunner.this.type = PluginRunner.this
  }
  addAnnotationChecker(annotChecker.checker)

  /** The phases to be run.
   *
   *  @todo: Adapt to specific plugin implementation
   */
  override protected def computeInternalPhases() : Unit = {
    phasesSet += syntaxAnalyzer
    phasesSet += (analyzer.namerFactory: SubComponent) // note: types are there because otherwise
    phasesSet += (analyzer.typerFactory: SubComponent) // consistency check after refchecks would fail.
    phasesSet += superAccessors			       // add super accessors
    phasesSet += pickler			       // serialize symbol tables
    phasesSet += refchecks			       // perform reference and override checking, translate nested objects

    for (phase <- TemplatePlugin.components(this)) {
      phasesSet += phase
    }
  }

}