Skip to content

Commit 4465a5c

Browse files
committed
Convert classpath sources function to property
1 parent d14420b commit 4465a5c

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CompilerClassPath(private val config: CompilerConfiguration) : Closeable {
4545
}
4646

4747
async.compute {
48-
val newClassPathWithSources = resolver.fetchClasspathWithSources()
48+
val newClassPathWithSources = resolver.classpathWithSources
4949
synchronized(classPath) {
5050
syncClassPathEntries(classPath, newClassPathWithSources, "class path")
5151
}

shared/src/main/kotlin/org/javacs/kt/classpath/ClassPathResolver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface ClassPathResolver {
2828
emptySet<Path>()
2929
}
3030

31-
fun fetchClasspathWithSources(): Set<ClassPathEntry> = classpath
31+
val classpathWithSources: Set<ClassPathEntry> get() = classpath
3232

3333
companion object {
3434
/** A default empty classpath implementation */
@@ -56,7 +56,7 @@ internal class UnionClassPathResolver(val lhs: ClassPathResolver, val rhs: Class
5656
override val classpathOrEmpty get() = lhs.classpathOrEmpty + rhs.classpathOrEmpty
5757
override val buildScriptClasspath get() = lhs.buildScriptClasspath + rhs.buildScriptClasspath
5858
override val buildScriptClasspathOrEmpty get() = lhs.buildScriptClasspathOrEmpty + rhs.buildScriptClasspathOrEmpty
59-
override fun fetchClasspathWithSources() = lhs.fetchClasspathWithSources() + rhs.fetchClasspathWithSources()
59+
override val classpathWithSources = lhs.classpathWithSources + rhs.classpathWithSources
6060
}
6161

6262
internal class FirstNonEmptyClassPathResolver(val lhs: ClassPathResolver, val rhs: ClassPathResolver) : ClassPathResolver {
@@ -65,5 +65,5 @@ internal class FirstNonEmptyClassPathResolver(val lhs: ClassPathResolver, val rh
6565
override val classpathOrEmpty get() = lhs.classpathOrEmpty.takeIf { it.isNotEmpty() } ?: rhs.classpathOrEmpty
6666
override val buildScriptClasspath get() = lhs.buildScriptClasspath.takeIf { it.isNotEmpty() } ?: rhs.buildScriptClasspath
6767
override val buildScriptClasspathOrEmpty get() = lhs.buildScriptClasspathOrEmpty.takeIf { it.isNotEmpty() } ?: rhs.buildScriptClasspathOrEmpty
68-
override fun fetchClasspathWithSources() = lhs.fetchClasspathWithSources().takeIf { it.isNotEmpty() } ?: rhs.fetchClasspathWithSources()
68+
override val classpathWithSources = lhs.classpathWithSources.takeIf { it.isNotEmpty() } ?: rhs.classpathWithSources
6969
}

shared/src/main/kotlin/org/javacs/kt/classpath/MavenClassPathResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class MavenClassPathResolver private constructor(private val pom: Path)
2828
return artifacts.mapNotNull { findMavenArtifact(it, false)?.let { it1 -> ClassPathEntry(it1, null) } }.toSet()
2929
}
3030

31-
override fun fetchClasspathWithSources(): Set<ClassPathEntry> {
31+
override val classpathWithSources: Set<ClassPathEntry> get() {
3232
// Fetch artifacts if not yet present.
3333
var artifacts: Set<Artifact>
3434
if (this.artifacts != null) {

shared/src/main/kotlin/org/javacs/kt/classpath/WithStdlibResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class WithStdlibResolver(private val wrapped: ClassPathResolver) : Clas
99
override val classpathOrEmpty: Set<ClassPathEntry> get() = wrapWithStdlibEntries(wrapped.classpathOrEmpty)
1010
override val buildScriptClasspath: Set<Path> get() = wrapWithStdlib(wrapped.buildScriptClasspath)
1111
override val buildScriptClasspathOrEmpty: Set<Path> get() = wrapWithStdlib(wrapped.buildScriptClasspathOrEmpty)
12-
override fun fetchClasspathWithSources(): Set<ClassPathEntry> = wrapWithStdlibEntries(wrapped.fetchClasspathWithSources())
12+
override val classpathWithSources: Set<ClassPathEntry> = wrapWithStdlibEntries(wrapped.classpathWithSources)
1313
}
1414

1515
private fun wrapWithStdlibEntries(paths: Set<ClassPathEntry>): Set<ClassPathEntry> {

0 commit comments

Comments
 (0)