Skip to content

Commit 3e70adf

Browse files
committed
Polishing
1 parent ff519cd commit 3e70adf

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
@@ -122,11 +122,17 @@ class InteractiveDriver(settings: List[String]) extends Driver {
122122

123123
// Like in `ZipArchiveFileLookup` we assume that zips are immutable
124124
private val zipClassPathClasses: Seq[String] = zipClassPaths.flatMap { zipCp =>
125-
new ZipFile(zipCp.zipFile)
126-
.stream
127-
.toArray((size: Int) => new Array[ZipEntry](size))
128-
.map((e: ZipEntry) => e.getName)
129-
.flatMap((name: String) => tastySuffixes.find(name.endsWith).map(name.replace("/", ".").stripSuffix))
125+
val zipFile = new ZipFile(zipCp.zipFile)
126+
127+
try {
128+
for {
129+
entry <- zipFile.stream.iterator().asScala
130+
name = entry.getName
131+
tastySuffix <- tastySuffixes
132+
if name.endsWith(tastySuffix)
133+
} yield name.replace("/", ".").stripSuffix(tastySuffix)
134+
}
135+
finally zipFile.close()
130136
}
131137

132138
// 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
@@ -134,11 +134,9 @@ class DottyLanguageServer extends LanguageServer
134134
// Do most of the initialization asynchronously so that we can return early
135135
// from this method and thus let the client know our capabilities.
136136
CompletableFuture.supplyAsync(() => drivers)
137-
.exceptionally {
138-
(ex: Throwable) => {
139-
ex.printStackTrace
140-
sys.exit(1)
141-
}
137+
.exceptionally { (ex: Throwable) =>
138+
ex.printStackTrace
139+
sys.exit(1)
142140
}
143141

144142
new InitializeResult(c)

0 commit comments

Comments
 (0)