From 66a340937b0adead0aa7a96e21f68d43a03cba00 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 5 Jan 2017 11:08:26 +0100 Subject: Add stdlib whitelist loader. --- compiler/test/dotty/tools/StdLibSources.scala | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 compiler/test/dotty/tools/StdLibSources.scala (limited to 'compiler/test/dotty/tools/StdLibSources.scala') diff --git a/compiler/test/dotty/tools/StdLibSources.scala b/compiler/test/dotty/tools/StdLibSources.scala new file mode 100644 index 000000000..9afb81d20 --- /dev/null +++ b/compiler/test/dotty/tools/StdLibSources.scala @@ -0,0 +1,31 @@ +package dotty.tools + +import java.io.File + +import scala.io.Source + +object StdLibSources { + + def whitelistFile: String = "./test/dotc/scala-collections.whitelist" + def blacklistFile: String = "./test/dotc/scala-collections.blacklist" + + def whitelisted: List[String] = loadList(whitelistFile) + def blacklisted: List[String] = loadList(blacklistFile) + + def all: List[String] = { + def collectAllFilesInDir(dir: File, acc: List[String]): List[String] = { + val files = dir.listFiles() + val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(".scala")) file.getPath :: acc1 else acc1) + files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3) + } + collectAllFilesInDir(new File("../scala-scala/src/library/"), Nil) + } + + private def loadList(path: String): List[String] = Source.fromFile(path, "UTF8").getLines() + .map(_.trim) // allow identation + .filter(!_.startsWith("#")) // allow comment lines prefixed by # + .map(_.takeWhile(_ != '#').trim) // allow comments in the end of line + .filter(_.nonEmpty) + .toList + +} -- cgit v1.2.3