@@ -6,11 +6,26 @@ import scala.io.Source
6
6
7
7
object StdLibSources {
8
8
9
+ /* For debug only */
10
+ private val useExplicitWhiteList = false
11
+
9
12
private final val stdLibPath = " ../scala-scala/src/library/"
10
13
11
14
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
+ }
12
28
13
- def whitelisted : List [String ] = (all.toSet -- blacklisted).toList
14
29
def blacklisted : List [String ] = loadList(blacklistFile)
15
30
16
31
def all : List [String ] = {
@@ -22,6 +37,17 @@ object StdLibSources {
22
37
collectAllFilesInDir(new File (stdLibPath), Nil )
23
38
}
24
39
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
+
25
51
private def loadList (path : String ): List [String ] = Source .fromFile(path, " UTF8" ).getLines()
26
52
.map(_.trim) // allow identation
27
53
.filter(! _.startsWith(" #" )) // allow comment lines prefixed by #
0 commit comments