Skip to content

Commit 2aedd27

Browse files
committed
Catch errors with indexed symbols on the package level
1 parent 34fa4ff commit 2aedd27

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

server/src/main/kotlin/org/javacs/kt/SymbolIndex.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,27 @@ class SymbolIndex {
2020
val started = System.currentTimeMillis()
2121
LOG.info("Updating symbol index...")
2222

23-
try {
24-
val foundDescriptors = allDescriptors(module)
25-
lock.withLock {
26-
globalDescriptors += foundDescriptors
27-
}
28-
29-
val finished = System.currentTimeMillis()
30-
LOG.info("Updated symbol index in ${finished - started} ms! (${globalDescriptors.size} symbol(s))")
31-
} catch (e: Exception) {
32-
LOG.warn("Could not update symbol index: $e")
23+
val foundDescriptors = allDescriptors(module)
24+
lock.withLock {
25+
globalDescriptors += foundDescriptors
3326
}
27+
28+
val finished = System.currentTimeMillis()
29+
LOG.info("Updated symbol index in ${finished - started} ms! (${globalDescriptors.size} symbol(s))")
3430
}
3531

3632
fun <T> withGlobalDescriptors(action: (Set<DeclarationDescriptor>) -> T): T = lock.withLock { action(globalDescriptors) }
3733

3834
private fun allDescriptors(module: ModuleDescriptor): Collection<DeclarationDescriptor> = allPackages(module)
3935
.map(module::getPackage)
40-
.flatMap { it.memberScope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER) }
36+
.flatMap {
37+
try {
38+
it.memberScope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER)
39+
} catch (e: IllegalStateException) {
40+
LOG.warn("Could not query descriptors in package $it")
41+
emptyList()
42+
}
43+
}
4144

4245
private fun allPackages(module: ModuleDescriptor, pkgName: FqName = FqName.ROOT): Collection<FqName> = module
4346
.getSubPackagesOf(pkgName) { it.toString() != "META-INF" }

0 commit comments

Comments
 (0)