Skip to content

Commit

Permalink
Merge pull request scala#4595 from som-snytt/issue/9370
Browse files Browse the repository at this point in the history
SI-9370 Xplugin scans plugin path for descriptor
  • Loading branch information
lrytz committed Jul 16, 2015
2 parents 6b3c518 + c32ba93 commit f2e055f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/plugins/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ object Plugin {
def loop(qs: List[Path]): Try[PluginDescription] = qs match {
case Nil => Failure(new MissingPluginException(ps))
case p :: rest =>
if (p.isDirectory) loadDescriptionFromFile(p.toDirectory / PluginXML)
else if (p.isFile) loadDescriptionFromJar(p.toFile)
if (p.isDirectory) loadDescriptionFromFile(p.toDirectory / PluginXML) orElse loop(rest)
else if (p.isFile) loadDescriptionFromJar(p.toFile) orElse loop(rest)
else loop(rest)
}
loop(ps)
Expand Down
31 changes: 31 additions & 0 deletions test/files/pos/t9370/ThePlugin.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package scala.test.plugins

import scala.tools.nsc
import nsc.Global
import nsc.Phase
import nsc.plugins.Plugin
import nsc.plugins.PluginComponent

class ThePlugin(val global: Global) extends Plugin {
import global._

val name = "timebomb"
val description = "Explodes if run. Maybe I haven't implemented it yet."
val components = List[PluginComponent](thePhase1)

private object thePhase1 extends PluginComponent {
val global = ThePlugin.this.global

val runsAfter = List[String]("parser")
override val runsBefore = List[String]("namer")
val phaseName = ThePlugin.this.name

def newPhase(prev: Phase) = new ThePhase(prev)
}

private class ThePhase(prev: Phase) extends Phase(prev) {
override def name = ThePlugin.this.name
override def run = ???
}
}

1 change: 1 addition & 0 deletions test/files/pos/t9370/sample_2.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Xplugin:/tmp:. -Xplugin-require:timebomb -Ystop-after:parser
6 changes: 6 additions & 0 deletions test/files/pos/t9370/sample_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

package sample

// just a sample that is compiled with the explosive plugin disabled
object Sample extends App {
}
5 changes: 5 additions & 0 deletions test/files/pos/t9370/scalac-plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<plugin>
<name>ignored</name>
<classname>scala.test.plugins.ThePlugin</classname>
</plugin>

0 comments on commit f2e055f

Please sign in to comment.