Skip to content

Commit

Permalink
Fix scala#2967: Adapt Vulpix, InteractiveDriver to SAM types
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Veeranki committed Aug 23, 2017
1 parent d70b8f4 commit 9a63bec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/interactive/Interactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object Interactive {
val buf = new mutable.ListBuffer[SourceTree]

trees foreach { case SourceTree(topTree, source) =>
(new untpd.TreeTraverser {
new untpd.TreeTraverser {
override def traverse(tree: untpd.Tree)(implicit ctx: Context) = {
tree match {
case _: untpd.Inlined =>
Expand All @@ -169,7 +169,7 @@ object Interactive {
}
traverseChildren(tree)
}
}).traverse(topTree)
}.traverse(topTree)
}

buf.toList
Expand Down
14 changes: 4 additions & 10 deletions compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,11 @@ class InteractiveDriver(settings: List[String]) extends Driver {

// Like in `ZipArchiveFileLookup` we assume that zips are immutable
private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp =>
// Working with Java 8 stream without SAMs and scala-java8-compat is awful.
val entries = new ZipFile(zipCp.zipFile)
new ZipFile(zipCp.zipFile)
.stream
.toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) })
.toSeq
for {
entry <- entries
name = entry.getName
tastySuffix <- tastySuffixes
if name.endsWith(tastySuffix)
} yield name.replace("/", ".").stripSuffix(tastySuffix)
.toArray((size: Int) => new Array[ZipEntry](size))
.map((e: ZipEntry) => e.getName)
.flatMap((name: String) => tastySuffixes.find(name.endsWith).map(name.replace("/", ".").stripSuffix))
}

// FIXME: classfiles in directories may change at any point, so we retraverse
Expand Down
36 changes: 17 additions & 19 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -288,30 +288,28 @@ trait ParallelTesting extends RunnerOrchestration { self =>
}

/** A single `Runnable` that prints a progress bar for the curent `Test` */
private def createProgressMonitor: Runnable = new Runnable {
def run(): Unit = {
val start = System.currentTimeMillis
var tCompiled = testSourcesCompleted
while (tCompiled < sourceCount) {
val timestamp = (System.currentTimeMillis - start) / 1000
val progress = (tCompiled.toDouble / sourceCount * 40).toInt

realStdout.print(
"[" + ("=" * (math.max(progress - 1, 0))) +
private def createProgressMonitor: Runnable = () => {
val start = System.currentTimeMillis
var tCompiled = testSourcesCompleted
while (tCompiled < sourceCount) {
val timestamp = (System.currentTimeMillis - start) / 1000
val progress = (tCompiled.toDouble / sourceCount * 40).toInt

realStdout.print(
"[" + ("=" * (math.max(progress - 1, 0))) +
(if (progress > 0) ">" else "") +
(" " * (39 - progress)) +
s"] completed ($tCompiled/$sourceCount, ${timestamp}s)\r"
)

Thread.sleep(100)
tCompiled = testSourcesCompleted
}
// println, otherwise no newline and cursor at start of line
realStdout.println(
s"[=======================================] completed ($sourceCount/$sourceCount, " +
s"${(System.currentTimeMillis - start) / 1000}s) "
)

Thread.sleep(100)
tCompiled = testSourcesCompleted
}
// println, otherwise no newline and cursor at start of line
realStdout.println(
s"[=======================================] completed ($sourceCount/$sourceCount, " +
s"${(System.currentTimeMillis - start) / 1000}s) "
)
}

/** Wrapper function to make sure that the compiler itself did not crash -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,10 @@ class DottyLanguageServer extends LanguageServer
// from this method and thus let the client know our capabilities.
CompletableFuture.supplyAsync(() => drivers)
.exceptionally {
// Can't use a function literal here because of #2367
new Function[Throwable, Nothing] {
def apply(ex: Throwable) = {
(ex: Throwable) => {
ex.printStackTrace
sys.exit(1)
}
}
}

new InitializeResult(c)
Expand Down

0 comments on commit 9a63bec

Please sign in to comment.