[SLC] SymbolKotlinAsJavaSupport: implement getKotlinInternalClasses
^KTIJ-24067
This commit is contained in:
committed by
Space Team
parent
e81f34d4b0
commit
f9d5534689
+6
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,11 @@ public abstract class KotlinDeclarationProvider {
|
||||
|
||||
public abstract fun findFilesForFacadeByPackage(packageFqName: FqName): Collection<KtFile>
|
||||
public abstract fun findFilesForFacade(facadeFqName: FqName): Collection<KtFile>
|
||||
|
||||
/**
|
||||
* Currently we want only classes from libraries ([org.jetbrains.kotlin.analysis.decompiler.psi.file.KtClsFile])
|
||||
*/
|
||||
public abstract fun findInternalFilesForFacade(facadeFqName: FqName): Collection<KtFile>
|
||||
}
|
||||
|
||||
public abstract class KotlinDeclarationProviderFactory {
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
|
||||
internal class KotlinStaticDeclarationIndex {
|
||||
internal val facadeFileMap: MutableMap<FqName, MutableSet<KtFile>> = mutableMapOf()
|
||||
internal val multiFileClassPartMap: MutableMap<FqName, MutableSet<KtFile>> = mutableMapOf()
|
||||
internal val classMap: MutableMap<FqName, MutableSet<KtClassOrObject>> = mutableMapOf()
|
||||
internal val typeAliasMap: MutableMap<FqName, MutableSet<KtTypeAlias>> = mutableMapOf()
|
||||
internal val topLevelFunctionMap: MutableMap<FqName, MutableSet<KtNamedFunction>> = mutableMapOf()
|
||||
|
||||
+20
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,9 @@ package org.jetbrains.kotlin.analysis.providers.impl
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.SingleRootFileViewProvider
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.util.indexing.FileContent
|
||||
@@ -77,6 +79,10 @@ public class KotlinStaticDeclarationProvider internal constructor(
|
||||
.filter { it.javaFileFacadeFqName == facadeFqName }
|
||||
}
|
||||
|
||||
override fun findInternalFilesForFacade(facadeFqName: FqName): Collection<KtFile> {
|
||||
return index.multiFileClassPartMap[facadeFqName].orEmpty().filter { it.virtualFile in scope }
|
||||
}
|
||||
|
||||
override fun getTopLevelProperties(callableId: CallableId): Collection<KtProperty> =
|
||||
index.topLevelPropertyMap[callableId.packageName]
|
||||
?.filter { ktProperty ->
|
||||
@@ -240,7 +246,18 @@ public class KotlinStaticDeclarationProviderFactory(
|
||||
}
|
||||
|
||||
loadBuiltIns().forEach { ktFileStub ->
|
||||
addToFacadeFileMap(ktFileStub.psi)
|
||||
val ktFile: KtFile = ktFileStub.psi
|
||||
addToFacadeFileMap(ktFile)
|
||||
|
||||
val partNames = ktFileStub.facadePartSimpleNames
|
||||
if (partNames != null) {
|
||||
val packageFqName = ktFileStub.getPackageFqName()
|
||||
for (partName in partNames) {
|
||||
val multiFileClassPartFqName: FqName = packageFqName.child(Name.identifier(partName))
|
||||
index.multiFileClassPartMap.computeIfAbsent(multiFileClassPartFqName) { mutableSetOf() }.add(ktFile)
|
||||
}
|
||||
}
|
||||
|
||||
// top-level functions and properties, built-in classes
|
||||
ktFileStub.childrenStubs.forEach(::indexStub)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user