mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
committed by
intellij-monorepo-bot
parent
5afd62353d
commit
c33c6d8934
+35
@@ -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>
|
||||
Reference in New Issue
Block a user