KTIJ-34800 IJPL-339 add kotlin support

Install the proper code insight context into kotlin class files.
Otherwise, these files don't satisfy the scopes of the modules and are ignored

GitOrigin-RevId: e48c0b3d12f93099525a2132947d3e47a2a78983
This commit is contained in:
Max Medvedev
2025-07-07 11:18:23 +00:00
committed by intellij-monorepo-bot
parent 5afd62353d
commit c33c6d8934
2 changed files with 39 additions and 0 deletions
@@ -0,0 +1,35 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.base.analysis
import com.intellij.codeInsight.multiverse.CodeInsightContextManagerImpl
import com.intellij.codeInsight.multiverse.codeInsightContext
import com.intellij.codeInsight.multiverse.isSharedSourceSupportEnabled
import com.intellij.psi.PsiFile
import com.intellij.psi.impl.compiled.ClsFileImpl
import org.jetbrains.kotlin.analysis.decompiled.light.classes.DecompiledClassCustomization
import org.jetbrains.kotlin.psi.KtFile
internal class IdeaDecompiledClassCustomization : DecompiledClassCustomization {
override fun customizeFakeClsFile(
fakeFile: ClsFileImpl,
originalKtFile: KtFile
) {
fakeFile.installCodeInsightContextFrom(originalKtFile)
}
/**
* we need to install code insight context from the original [context] file so that [this] file has the same context.
* todo ijpl-339 ensure all light files are covered
*/
private fun PsiFile.installCodeInsightContextFrom(
contextFile: KtFile
) {
if (!isSharedSourceSupportEnabled(project)) {
return
}
val viewProvider = this.viewProvider
val codeInsightContextManager = CodeInsightContextManagerImpl.getInstanceImpl(project)
codeInsightContextManager.setCodeInsightContext(viewProvider, contextFile.codeInsightContext)
}
}
@@ -4,5 +4,9 @@
serviceInterface="org.jetbrains.kotlin.asJava.classes.LightClassInheritanceHelper"
serviceImplementation="org.jetbrains.kotlin.idea.caches.lightClasses.IdeLightClassInheritanceHelper"
/>
<applicationService
serviceInterface="org.jetbrains.kotlin.analysis.decompiled.light.classes.DecompiledClassCustomization"
serviceImplementation="org.jetbrains.kotlin.idea.base.analysis.IdeaDecompiledClassCustomization"
/>
</extensions>
</idea-plugin>