Skip to content

Commit 0ae6f04

Browse files
committed
Polishing
1 parent 169da6d commit 0ae6f04

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,17 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
128128

129129
// Like in `ZipArchiveFileLookup` we assume that zips are immutable
130130
private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp =>
131-
new ZipFile(zipCp.zipFile)
132-
.stream
133-
.toArray((size: Int) => new Array[ZipEntry](size))
134-
.map((e: ZipEntry) => e.getName)
135-
.flatMap((name: String) => tastySuffixes.find(name.endsWith).map(name.replace("/", ".").stripSuffix))
131+
val zipFile = new ZipFile(zipCp.zipFile)
132+
133+
try {
134+
for {
135+
entry <- zipFile.stream.iterator().asScala
136+
name = entry.getName
137+
tastySuffix <- tastySuffixes
138+
if name.endsWith(tastySuffix)
139+
} yield name.replace("/", ".").stripSuffix(tastySuffix)
140+
}
141+
finally zipFile.close()
136142
}
137143

138144
// FIXME: classfiles in directories may change at any point, so we retraverse

language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ class DottyLanguageServer extends LanguageServer
165165
// Do most of the initialization asynchronously so that we can return early
166166
// from this method and thus let the client know our capabilities.
167167
CompletableFuture.supplyAsync(() => drivers)
168-
.exceptionally {
169-
(ex: Throwable) => {
170-
ex.printStackTrace
171-
sys.exit(1)
172-
}
168+
.exceptionally { (ex: Throwable) =>
169+
ex.printStackTrace
170+
sys.exit(1)
173171
}
174172

175173
new InitializeResult(c)

0 commit comments

Comments
 (0)