Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE_AA_VERSION: 2.1.20-dev-5634 #2285

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ junit5Version=5.8.2
junitPlatformVersion=1.8.2
googleTruthVersion=1.1

aaKotlinBaseVersion=2.1.20-dev-3305
aaKotlinBaseVersion=2.1.20-dev-5634
aaIntellijVersion=233.13135.128
aaGuavaVersion=33.2.0-jre
aaAsmVersion=9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import org.jetbrains.kotlin.analysis.api.platform.modification.KotlinGlobalModif
import org.jetbrains.kotlin.analysis.api.platform.modification.KotlinModificationTrackerFactory
import org.jetbrains.kotlin.analysis.api.platform.packages.KotlinPackagePartProviderFactory
import org.jetbrains.kotlin.analysis.api.platform.packages.KotlinPackageProviderFactory
import org.jetbrains.kotlin.analysis.api.platform.permissions.KotlinAnalysisPermissionOptions
import org.jetbrains.kotlin.analysis.api.platform.projectStructure.KotlinByModulesResolutionScopeProvider
import org.jetbrains.kotlin.analysis.api.platform.projectStructure.KotlinResolutionScopeProvider
import org.jetbrains.kotlin.analysis.api.projectStructure.KaModule
Expand All @@ -78,14 +79,14 @@ import org.jetbrains.kotlin.analysis.api.standalone.base.declarations.KotlinStan
import org.jetbrains.kotlin.analysis.api.standalone.base.declarations.KotlinStandaloneDeclarationProviderMerger
import org.jetbrains.kotlin.analysis.api.standalone.base.modification.KotlinStandaloneGlobalModificationService
import org.jetbrains.kotlin.analysis.api.standalone.base.modification.KotlinStandaloneModificationTrackerFactory
import org.jetbrains.kotlin.analysis.api.standalone.base.permissions.KotlinStandaloneAnalysisPermissionOptions
import org.jetbrains.kotlin.analysis.api.standalone.base.projectStructure.FirStandaloneServiceRegistrar
import org.jetbrains.kotlin.analysis.api.standalone.base.projectStructure.StandaloneProjectFactory
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getFirResolveSession
import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.LLSealedInheritorsProvider
import org.jetbrains.kotlin.analysis.project.structure.builder.KtModuleBuilder
import org.jetbrains.kotlin.analysis.project.structure.builder.KtModuleProviderBuilder
import org.jetbrains.kotlin.analysis.project.structure.builder.buildKtSdkModule
import org.jetbrains.kotlin.analysis.project.structure.impl.KaSourceModuleImpl
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreApplicationEnvironmentMode
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment
Expand Down Expand Up @@ -136,6 +137,9 @@ class KotlinSymbolProcessing(
// Let exceptions pop through to the caller. Don't catch and convert them to, e.g., INTERNAL_ERROR.
}

private var applicationServiceRegistered = false
private var applicationServiceRegisteredLock = object {}

init {
// We depend on swing (indirectly through PSI or something), so we want to declare headless mode,
// to avoid accidentally starting the UI thread. But, don't set it if it was set externally.
Expand All @@ -145,7 +149,7 @@ class KotlinSymbolProcessing(
setupIdeaStandaloneExecution()
}

@OptIn(KaExperimentalApi::class)
@OptIn(KaExperimentalApi::class, KaImplementationDetail::class)
private fun createAASession(
compilerConfiguration: CompilerConfiguration,
projectDisposable: Disposable,
Expand Down Expand Up @@ -238,6 +242,21 @@ class KotlinSymbolProcessing(
StandaloneProjectFactory.createPackagePartsProvider(
libraryRoots,
)

synchronized(applicationServiceRegisteredLock) {
if (!applicationServiceRegistered) {
applicationServiceRegistered = true
val application = kotlinCoreProjectEnvironment.environment.application
application.registerService(
org.jetbrains.kotlin.analysis.api.permissions.KaAnalysisPermissionRegistry::class.java,
org.jetbrains.kotlin.analysis.api.impl.base.permissions.KaBaseAnalysisPermissionRegistry::class.java
)
application.registerService(
KotlinAnalysisPermissionOptions::class.java,
KotlinStandaloneAnalysisPermissionOptions::class.java
)
}
}
registerProjectServices(
kotlinCoreProjectEnvironment,
ktFiles,
Expand Down Expand Up @@ -331,6 +350,7 @@ class KotlinSymbolProcessing(
}
}

@OptIn(KaExperimentalApi::class)
private fun prepareAllKSFiles(
kotlinCoreProjectEnvironment: KotlinCoreProjectEnvironment,
modules: List<KaModule>,
Expand All @@ -339,8 +359,8 @@ class KotlinSymbolProcessing(
val project = kotlinCoreProjectEnvironment.project
val ktFiles = mutableSetOf<KtFile>()
val javaFiles = mutableSetOf<PsiJavaFile>()
modules.filterIsInstance<KaSourceModuleImpl>().forEach {
it.sourceRoots.forEach {
modules.filterIsInstance<KaSourceModule>().forEach {
it.psiRoots.forEach {
when (it) {
is KtFile -> ktFiles.add(it)
is PsiJavaFile -> if (javaFileManager != null) javaFiles.add(it)
Expand Down Expand Up @@ -652,6 +672,8 @@ internal val DEAR_SHADOW_JAR_PLEASE_DO_NOT_REMOVE_THESE = listOf(
org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSessionInvalidationService::class.java,
org.jetbrains.kotlin.analysis.low.level.api.fir.stubBased.deserialization.LLStubBasedLibrarySymbolProviderFactory::class.java,
org.jetbrains.kotlin.analysis.api.impl.base.permissions.KaBaseAnalysisPermissionChecker::class.java,
org.jetbrains.kotlin.analysis.api.impl.base.permissions.KaBaseAnalysisPermissionRegistry::class.java,
org.jetbrains.kotlin.analysis.api.permissions.KaAnalysisPermissionRegistry::class.java,
org.jetbrains.kotlin.analysis.api.platform.KotlinProjectMessageBusProvider::class.java,
org.jetbrains.kotlin.analysis.api.platform.permissions.KaAnalysisPermissionChecker::class.java,
org.jetbrains.kotlin.analysis.api.platform.projectStructure.KotlinSimpleGlobalSearchScopeMerger::class.java,
Expand Down
4 changes: 2 additions & 2 deletions kotlin-analysis-api/testData/javaModifiers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
// DependencyOuterJavaClass.staticPublicField: FINAL JAVA_STATIC PUBLIC : FINAL JAVA_STATIC PUBLIC
// DependencyOuterJavaClass.staticPublicMethod: FINAL JAVA_STATIC PUBLIC : FINAL JAVA_STATIC PUBLIC
// DependencyOuterJavaClass.synchronizedFun: OPEN : JAVA_SYNCHRONIZED
// DependencyOuterJavaClass.transientField: OPEN : JAVA_TRANSIENT
// DependencyOuterJavaClass.volatileField: OPEN : JAVA_VOLATILE
// DependencyOuterJavaClass.transientField: FINAL : FINAL JAVA_TRANSIENT
// DependencyOuterJavaClass.volatileField: FINAL : FINAL JAVA_VOLATILE
// DependencyOuterJavaClass: OPEN PUBLIC : PUBLIC
// DependencyOuterKotlinClass.<init>: FINAL PUBLIC : FINAL PUBLIC
// DependencyOuterKotlinClass.Companion.<init>: FINAL PRIVATE : FINAL PRIVATE
Expand Down
Loading