diff --git a/gradle.properties b/gradle.properties index 4255bf1840..6ac225b01f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/KotlinSymbolProcessing.kt b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/KotlinSymbolProcessing.kt index bf9f6ae92e..f04b2d881b 100644 --- a/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/KotlinSymbolProcessing.kt +++ b/kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/KotlinSymbolProcessing.kt @@ -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 @@ -78,6 +79,7 @@ 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 @@ -85,7 +87,6 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.LLSealedInherit 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 @@ -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. @@ -145,7 +149,7 @@ class KotlinSymbolProcessing( setupIdeaStandaloneExecution() } - @OptIn(KaExperimentalApi::class) + @OptIn(KaExperimentalApi::class, KaImplementationDetail::class) private fun createAASession( compilerConfiguration: CompilerConfiguration, projectDisposable: Disposable, @@ -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, @@ -331,6 +350,7 @@ class KotlinSymbolProcessing( } } + @OptIn(KaExperimentalApi::class) private fun prepareAllKSFiles( kotlinCoreProjectEnvironment: KotlinCoreProjectEnvironment, modules: List, @@ -339,8 +359,8 @@ class KotlinSymbolProcessing( val project = kotlinCoreProjectEnvironment.project val ktFiles = mutableSetOf() val javaFiles = mutableSetOf() - modules.filterIsInstance().forEach { - it.sourceRoots.forEach { + modules.filterIsInstance().forEach { + it.psiRoots.forEach { when (it) { is KtFile -> ktFiles.add(it) is PsiJavaFile -> if (javaFileManager != null) javaFiles.add(it) @@ -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, diff --git a/kotlin-analysis-api/testData/javaModifiers.kt b/kotlin-analysis-api/testData/javaModifiers.kt index 82373c7978..2ae515e5e3 100644 --- a/kotlin-analysis-api/testData/javaModifiers.kt +++ b/kotlin-analysis-api/testData/javaModifiers.kt @@ -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.: FINAL PUBLIC : FINAL PUBLIC // DependencyOuterKotlinClass.Companion.: FINAL PRIVATE : FINAL PRIVATE