Skip to content

Fix #2967: Adapt Vulpix, InteractiveDriver to SAM types #3010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -305,7 +305,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 utree: untpd.NameTree if tree.hasType =>
Expand All @@ -324,7 +324,7 @@ object Interactive {
traverseChildren(tree)
}
}
}).traverse(topTree)
}.traverse(topTree)
}

buf.toList
Expand Down
22 changes: 11 additions & 11 deletions compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ class InteractiveDriver(val 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)
.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)
val zipFile = new ZipFile(zipCp.zipFile)

try {
for {
entry <- zipFile.stream.iterator().asScala
name = entry.getName
tastySuffix <- tastySuffixes
if name.endsWith(tastySuffix)
} yield name.replace("/", ".").stripSuffix(tastySuffix)
}
finally zipFile.close()
}

// 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 @@ -284,30 +284,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 @@ -165,14 +165,9 @@ class DottyLanguageServer extends LanguageServer
// Do most of the initialization asynchronously so that we can return early
// 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.printStackTrace
sys.exit(1)
}
}
.exceptionally { (ex: Throwable) =>
ex.printStackTrace
sys.exit(1)
}

new InitializeResult(c)
Expand Down