Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit f2e055f

Browse files
committed
Merge pull request scala#4595 from som-snytt/issue/9370
SI-9370 Xplugin scans plugin path for descriptor
2 parents 6b3c518 + c32ba93 commit f2e055f

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

src/compiler/scala/tools/nsc/plugins/Plugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ object Plugin {
158158
def loop(qs: List[Path]): Try[PluginDescription] = qs match {
159159
case Nil => Failure(new MissingPluginException(ps))
160160
case p :: rest =>
161-
if (p.isDirectory) loadDescriptionFromFile(p.toDirectory / PluginXML)
162-
else if (p.isFile) loadDescriptionFromJar(p.toFile)
161+
if (p.isDirectory) loadDescriptionFromFile(p.toDirectory / PluginXML) orElse loop(rest)
162+
else if (p.isFile) loadDescriptionFromJar(p.toFile) orElse loop(rest)
163163
else loop(rest)
164164
}
165165
loop(ps)

test/files/pos/t9370/ThePlugin.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package scala.test.plugins
2+
3+
import scala.tools.nsc
4+
import nsc.Global
5+
import nsc.Phase
6+
import nsc.plugins.Plugin
7+
import nsc.plugins.PluginComponent
8+
9+
class ThePlugin(val global: Global) extends Plugin {
10+
import global._
11+
12+
val name = "timebomb"
13+
val description = "Explodes if run. Maybe I haven't implemented it yet."
14+
val components = List[PluginComponent](thePhase1)
15+
16+
private object thePhase1 extends PluginComponent {
17+
val global = ThePlugin.this.global
18+
19+
val runsAfter = List[String]("parser")
20+
override val runsBefore = List[String]("namer")
21+
val phaseName = ThePlugin.this.name
22+
23+
def newPhase(prev: Phase) = new ThePhase(prev)
24+
}
25+
26+
private class ThePhase(prev: Phase) extends Phase(prev) {
27+
override def name = ThePlugin.this.name
28+
override def run = ???
29+
}
30+
}
31+

test/files/pos/t9370/sample_2.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xplugin:/tmp:. -Xplugin-require:timebomb -Ystop-after:parser

test/files/pos/t9370/sample_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
package sample
3+
4+
// just a sample that is compiled with the explosive plugin disabled
5+
object Sample extends App {
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<plugin>
2+
<name>ignored</name>
3+
<classname>scala.test.plugins.ThePlugin</classname>
4+
</plugin>
5+

0 commit comments

Comments
 (0)