-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse Kotlin indexes in incremental providers
Also simplify finding Java sources. (cherry picked from commit ca7b06c)
- Loading branch information
Showing
6 changed files
with
140 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 0 additions & 107 deletions
107
...rc/main/kotlin/com/google/devtools/ksp/standalone/IncrementalKotlinDeclarationProvider.kt
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
.../kotlin/com/google/devtools/ksp/standalone/IncrementalKotlinDeclarationProviderFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.google.devtools.ksp.standalone | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import org.jetbrains.kotlin.analysis.project.structure.KtModule | ||
import org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProvider | ||
import org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProviderFactory | ||
import org.jetbrains.kotlin.analysis.providers.impl.KotlinStaticDeclarationProviderFactory | ||
import org.jetbrains.kotlin.analysis.providers.impl.declarationProviders.CompositeKotlinDeclarationProvider | ||
import org.jetbrains.kotlin.name.Name | ||
import org.jetbrains.kotlin.psi.KtClassOrObject | ||
import org.jetbrains.kotlin.psi.KtFile | ||
import org.jetbrains.kotlin.psi.KtTypeAlias | ||
|
||
class IncrementalKotlinDeclarationProviderFactory( | ||
private val project: Project, | ||
) : KotlinDeclarationProviderFactory() { | ||
private val staticFactories: MutableList<KotlinStaticDeclarationProviderFactory> = mutableListOf() | ||
|
||
override fun createDeclarationProvider( | ||
scope: GlobalSearchScope, | ||
contextualModule: KtModule? | ||
): KotlinDeclarationProvider { | ||
val providers = staticFactories.map { it.createDeclarationProvider(scope, contextualModule) } | ||
return CompositeKotlinDeclarationProvider.create(providers) | ||
} | ||
|
||
fun update(files: Collection<KtFile>) { | ||
val staticFactory = KotlinStaticDeclarationProviderFactory(project, files) | ||
staticFactories.add(staticFactory) | ||
} | ||
|
||
fun getDirectInheritorCandidates(baseClassName: Name): Set<KtClassOrObject> = | ||
staticFactories.flatMapTo(mutableSetOf()) { | ||
it.getDirectInheritorCandidates(baseClassName) | ||
} | ||
|
||
fun getInheritableTypeAliases(aliasedName: Name): Set<KtTypeAlias> = | ||
staticFactories.flatMapTo(mutableSetOf()) { | ||
it.getInheritableTypeAliases(aliasedName) | ||
} | ||
} |
73 changes: 0 additions & 73 deletions
73
...pi/src/main/kotlin/com/google/devtools/ksp/standalone/IncrementalKotlinPackageProvider.kt
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...main/kotlin/com/google/devtools/ksp/standalone/IncrementalKotlinPackageProviderFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.google.devtools.ksp.standalone | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import org.jetbrains.kotlin.analysis.providers.KotlinPackageProvider | ||
import org.jetbrains.kotlin.analysis.providers.KotlinPackageProviderFactory | ||
import org.jetbrains.kotlin.analysis.providers.impl.KotlinStaticPackageProviderFactory | ||
import org.jetbrains.kotlin.analysis.providers.impl.packageProviders.CompositeKotlinPackageProvider | ||
import org.jetbrains.kotlin.psi.KtFile | ||
|
||
class IncrementalKotlinPackageProviderFactory( | ||
private val project: Project, | ||
) : KotlinPackageProviderFactory() { | ||
private val staticFactories: MutableList<KotlinStaticPackageProviderFactory> = mutableListOf() | ||
|
||
override fun createPackageProvider(searchScope: GlobalSearchScope): KotlinPackageProvider { | ||
val providers = staticFactories.map { it.createPackageProvider(searchScope) } | ||
return CompositeKotlinPackageProvider.create(providers) | ||
} | ||
|
||
fun update(files: Collection<KtFile>) { | ||
val staticFactory = KotlinStaticPackageProviderFactory(project, files) | ||
staticFactories.add(staticFactory) | ||
} | ||
} |
Oops, something went wrong.