Skip to content

Commit 783a80d

Browse files
committed
Add useExplicitWhiteList for debugging.
1 parent fd9ae07 commit 783a80d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

compiler/test/dotty/tools/StdLibSources.scala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,26 @@ import scala.io.Source
66

77
object StdLibSources {
88

9+
/* For debug only */
10+
private val useExplicitWhiteList = false
11+
912
private final val stdLibPath = "../scala-scala/src/library/"
1013

1114
def blacklistFile: String = "./test/dotc/scala-collections.blacklist"
15+
private def whitelistFile: String = "./test/dotc/scala-collections.whitelist"
16+
17+
def whitelisted: List[String] = {
18+
lazy val whitelistBasedOnBlacklist = all.diff(blacklisted)
19+
if (!useExplicitWhiteList) {
20+
whitelistBasedOnBlacklist
21+
} else if (!new File(whitelistFile).exists()) {
22+
genWhitelist(whitelistBasedOnBlacklist.map(_.replace(stdLibPath, "")))
23+
whitelistBasedOnBlacklist
24+
} else {
25+
loadList(whitelistFile)
26+
}
27+
}
1228

13-
def whitelisted: List[String] = (all.toSet -- blacklisted).toList
1429
def blacklisted: List[String] = loadList(blacklistFile)
1530

1631
def all: List[String] = {
@@ -22,6 +37,17 @@ object StdLibSources {
2237
collectAllFilesInDir(new File(stdLibPath), Nil)
2338
}
2439

40+
private def genWhitelist(list: List[String]): Unit = {
41+
println(s"Generating $whitelistFile based on $blacklistFile")
42+
val whitelist = new File(whitelistFile)
43+
val p = new java.io.PrintWriter(whitelist)
44+
try {
45+
list.foreach(p.println)
46+
} finally {
47+
p.close()
48+
}
49+
}
50+
2551
private def loadList(path: String): List[String] = Source.fromFile(path, "UTF8").getLines()
2652
.map(_.trim) // allow identation
2753
.filter(!_.startsWith("#")) // allow comment lines prefixed by #

0 commit comments

Comments
 (0)