Skip to content

Commit c63f304

Browse files
style: spotless reformat, no functional change
1 parent a1fbbac commit c63f304

2 files changed

Lines changed: 66 additions & 56 deletions

File tree

‎lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtLibraryModule.kt‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ internal class KtLibraryModule(
3636
override val isSdk: Boolean = false,
3737
private val jvmTarget: JvmTarget = DEFAULT_JVM_TARGET,
3838
override val librarySources: KaLibrarySourceModule? = null,
39-
) : KaLibraryModule,
40-
AbstractKtModule(
39+
) : AbstractKtModule(
4140
project,
42-
dependencies
43-
) {
44-
41+
dependencies,
42+
),
43+
KaLibraryModule {
4544
class Builder(
4645
private val project: Project,
4746
private val applicationEnvironment: CoreApplicationEnvironment,
@@ -61,31 +60,37 @@ internal class KtLibraryModule(
6160
dependencies.add(dep)
6261
}
6362

64-
fun build(): KtLibraryModule = KtLibraryModule(
65-
project = project,
66-
id = id,
67-
contentRoots = contentRoots.toSet(),
68-
dependencies = dependencies.toList(),
69-
applicationEnvironment = applicationEnvironment,
70-
isSdk = isSdk,
71-
jvmTarget = jvmTarget,
72-
librarySources = librarySources,
73-
)
63+
fun build(): KtLibraryModule =
64+
KtLibraryModule(
65+
project = project,
66+
id = id,
67+
contentRoots = contentRoots.toSet(),
68+
dependencies = dependencies.toList(),
69+
applicationEnvironment = applicationEnvironment,
70+
isSdk = isSdk,
71+
jvmTarget = jvmTarget,
72+
librarySources = librarySources,
73+
)
7474
}
7575

7676
@OptIn(KaImplementationDetail::class)
7777
override fun computeFiles(extended: Boolean): Sequence<VirtualFile> {
78-
val roots = if (isSdk) project.read {
79-
LibraryUtils.findClassesFromJdkHome(
80-
contentRoots.first(),
81-
isJre = false
82-
)
83-
}
84-
else contentRoots
78+
val roots =
79+
if (isSdk) {
80+
project.read {
81+
LibraryUtils.findClassesFromJdkHome(
82+
contentRoots.first(),
83+
isJre = false,
84+
)
85+
}
86+
} else {
87+
contentRoots
88+
}
8589

86-
val notExtendedFiles = roots
87-
.asSequence()
88-
.mapNotNull { getVirtualFileForLibraryRoot(it, applicationEnvironment, project) }
90+
val notExtendedFiles =
91+
roots
92+
.asSequence()
93+
.mapNotNull { getVirtualFileForLibraryRoot(it, applicationEnvironment, project) }
8994

9095
if (!extended) return notExtendedFiles
9196

@@ -97,17 +102,11 @@ internal class KtLibraryModule(
97102
override val baseContentScope: GlobalSearchScope by lazy {
98103
val virtualFileUrls = computeFiles(extended = true).map { it.url }.toSet()
99104
object : GlobalSearchScope(project) {
100-
override fun contains(vf: VirtualFile): Boolean {
101-
return vf.url in virtualFileUrls
102-
}
105+
override fun contains(vf: VirtualFile): Boolean = vf.url in virtualFileUrls
103106

104-
override fun isSearchInModuleContent(module: Module): Boolean {
105-
return false
106-
}
107+
override fun isSearchInModuleContent(module: Module): Boolean = false
107108

108-
override fun isSearchInLibraries(): Boolean {
109-
return true
110-
}
109+
override fun isSearchInLibraries(): Boolean = true
111110
}
112111
}
113112

@@ -136,6 +135,7 @@ internal fun buildKtLibraryModule(
136135
): KtLibraryModule = KtLibraryModule.Builder(project, applicationEnvironment).apply(init).build()
137136

138137
private const val JAR_SEPARATOR = "!/"
138+
139139
private fun getVirtualFileForLibraryRoot(
140140
root: Path,
141141
environment: CoreApplicationEnvironment,

‎lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtSourceModule.kt‎

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ internal class KtSourceModule(
2121
project: Project,
2222
val module: ModuleProject,
2323
directRegularDependencies: List<KtModule>,
24-
) : KaSourceModule, AbstractSourceModule(project, directRegularDependencies) {
25-
24+
) : AbstractSourceModule(project, directRegularDependencies),
25+
KaSourceModule {
2626
companion object {
2727
private val logger = LoggerFactory.getLogger(KtSourceModule::class.java)
2828
}
2929

30-
class Builder(private val project: Project) {
30+
class Builder(
31+
private val project: Project,
32+
) {
3133
lateinit var module: ModuleProject
3234
private val dependencies = mutableListOf<KtModule>()
3335

@@ -42,29 +44,38 @@ internal class KtSourceModule(
4244
get() = module.path
4345

4446
override val contentRoots by lazy {
45-
module.getSourceDirectories()
47+
module
48+
.getSourceDirectories()
4649
.asSequence()
4750
.map { it.toPath() }
4851
.toSet()
4952
}
5053

5154
private val versions by lazy {
52-
val kotlinCompilerSettings = when {
53-
module.hasJavaProject() -> module.javaProject
54-
.kotlinCompilerSettings
55-
56-
module.hasAndroidProject() -> module.androidProject
57-
.kotlinCompilerSettings
58-
59-
else -> null
60-
}
55+
val kotlinCompilerSettings =
56+
when {
57+
module.hasJavaProject() -> {
58+
module.javaProject
59+
.kotlinCompilerSettings
60+
}
61+
62+
module.hasAndroidProject() -> {
63+
module.androidProject
64+
.kotlinCompilerSettings
65+
}
66+
67+
else -> {
68+
null
69+
}
70+
}
6171

6272
if (kotlinCompilerSettings == null) {
6373
return@lazy DEFAULT_LANGUAGE_VERSION to DEFAULT_JVM_TARGET
6474
}
6575

66-
val apiVersion = LanguageVersion.fromVersionString(kotlinCompilerSettings.apiVersion)
67-
?: LanguageVersion.fromFullVersionString(kotlinCompilerSettings.apiVersion)
76+
val apiVersion =
77+
LanguageVersion.fromVersionString(kotlinCompilerSettings.apiVersion)
78+
?: LanguageVersion.fromFullVersionString(kotlinCompilerSettings.apiVersion)
6879

6980
val jvmTarget = JvmTarget.fromString(kotlinCompilerSettings.jvmTarget)
7081

@@ -79,18 +90,17 @@ internal class KtSourceModule(
7990
get() = super<AbstractSourceModule>.moduleDescription
8091

8192
override val languageVersionSettings: LanguageVersionSettings
82-
get() = LanguageVersionSettingsImpl(
83-
languageVersion = versions.first,
84-
apiVersion = ApiVersion.createByLanguageVersion(versions.first),
85-
)
93+
get() =
94+
LanguageVersionSettingsImpl(
95+
languageVersion = versions.first,
96+
apiVersion = ApiVersion.createByLanguageVersion(versions.first),
97+
)
8698

8799
override val targetPlatform: TargetPlatform
88100
get() = JvmPlatforms.jvmPlatformByTargetVersion(versions.second)
89-
90-
91101
}
92102

93103
internal fun buildKtSourceModule(
94104
project: Project,
95105
init: KtSourceModule.Builder.() -> Unit,
96-
): KtSourceModule = KtSourceModule.Builder(project).apply(init).build()
106+
): KtSourceModule = KtSourceModule.Builder(project).apply(init).build()

0 commit comments

Comments
 (0)