Skip to content

Commit

Permalink
multiple-round: cache delegate provider factories
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-yuan committed Aug 18, 2023
1 parent 5bc2f16 commit 729cf04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class IncrementalKotlinDeclarationProviderFactory(
private lateinit var scope: GlobalSearchScope
private var contextualModule: KtModule? = null
private var files: Collection<KtFile> = emptyList()
private lateinit var staticFactory: KotlinDeclarationProviderFactory

override fun createDeclarationProvider(
scope: GlobalSearchScope,
Expand All @@ -93,13 +94,13 @@ class IncrementalKotlinDeclarationProviderFactory(

fun update(files: Collection<KtFile>) {
this.files = files
this.staticFactory = KotlinStaticDeclarationProviderFactory(project, files)
provider?.let {
it.del = createDelegateProvider()
}
}

private fun createDelegateProvider(): KotlinDeclarationProvider {
val staticFactory = KotlinStaticDeclarationProviderFactory(project, files)
return staticFactory.createDeclarationProvider(scope, contextualModule)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class IncrementalKotlinPackageProviderFactory(
private var provider: IncrementalKotlinPackageProvider? = null
private lateinit var scope: GlobalSearchScope
private var files: Collection<KtFile> = emptyList()
private lateinit var staticFactory: KotlinPackageProviderFactory

override fun createPackageProvider(searchScope: GlobalSearchScope): KotlinPackageProvider {
this.scope = searchScope
Expand All @@ -60,13 +61,13 @@ class IncrementalKotlinPackageProviderFactory(

fun update(files: Collection<KtFile>) {
this.files = files
this.staticFactory = KotlinStaticPackageProviderFactory(project, files)
provider?.let {
it.del = createDelegateProvider()
}
}

private fun createDelegateProvider(): KotlinPackageProvider {
val staticFactory = KotlinStaticPackageProviderFactory(project, files)
return staticFactory.createPackageProvider(scope)
}
}

0 comments on commit 729cf04

Please sign in to comment.