scala - Splitting scalac plugin into multiple files -


i'd split scalac plugin multiple files. sounds easy haven't managed pull off due path-dependent type issues stemming import global._ line.

here's lex spoon's sample plugin:

package localhost  import scala.tools.nsc import nsc.global import nsc.phase import nsc.plugins.plugin import nsc.plugins.plugincomponent  class divbyzero(val global: global) extends plugin {   import global._    val name = "divbyzero"   val description = "checks division zero"   val components = list[plugincomponent](component)    private object component extends plugincomponent {     val global: divbyzero.this.global.type = divbyzero.this.global     val runsafter = "refchecks"     // using scala compiler 2.8.x runsafter should written below     // val runsafter = list[string]("refchecks");     val phasename = divbyzero.this.name     def newphase(_prev: phase) = new divbyzerophase(_prev)          class divbyzerophase(prev: phase) extends stdphase(prev) {       override def name = divbyzero.this.name       def apply(unit: compilationunit) {         ( tree @ apply(select(rcvr, nme.div), list(literal(constant(0)))) <- unit.body;              if rcvr.tpe <:< definitions.intclass.tpe)            {             unit.error(tree.pos, "definitely division zero")           }       }     }   } } 

how can put component , divbyzerophase in own files without having import global._ in scope?

here's old project i've done same thing:

https://github.com/jsuereth/osgi-scalac-plugin/blob/master/src/main/scala/scala/osgi/compiler/osgiplugin.scala

if don't need pass path-dependent types global, don't worry trying keep "this.global" portions of relevant.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -