SLC: add support for .kts
^KTIJ-21108 ^KT-50241 ^KT-55626 Fixed
This commit is contained in:
committed by
Dmitrii Gridin
parent
4327c6645a
commit
f9086daf4d
+11
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.asJava
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
@@ -200,6 +201,16 @@ abstract class KotlinAsJavaSupportBase<TModule>(protected val project: Project)
|
||||
val tracker = lightClassCachedValue?.tracker ?: projectWideOutOfBlockModificationTracker()
|
||||
return CachedValueProvider.Result.createSingleDependency(value, tracker)
|
||||
}
|
||||
|
||||
override fun getScriptClasses(scriptFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
if (scriptFqName.isRoot) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
return findFilesForPackage(scriptFqName.parent(), scope).mapNotNull { file ->
|
||||
file.script?.takeIf { it.fqName == scriptFqName }?.let { getLightClassForScript(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <T : PsiElement, V> ifValid(element: T, action: () -> V?): V? {
|
||||
|
||||
+5
-1
@@ -20,7 +20,11 @@ import org.jetbrains.kotlin.psi.KtScript
|
||||
import javax.swing.Icon
|
||||
|
||||
abstract class KtLightClassForScript(val script: KtScript) : KtLightClassBase(script.manager) {
|
||||
private val modifierList: PsiModifierList = LightModifierList(manager, KotlinLanguage.INSTANCE, PsiModifier.PUBLIC)
|
||||
private val modifierList: PsiModifierList = LightModifierList(
|
||||
manager,
|
||||
KotlinLanguage.INSTANCE,
|
||||
PsiModifier.PUBLIC, PsiModifier.FINAL
|
||||
)
|
||||
|
||||
private val scriptImplementsList: LightEmptyImplementsList = LightEmptyImplementsList(manager)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user