Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.itsaky.androidide.lsp.kotlin.compiler.CompilationKind
import com.itsaky.androidide.lsp.kotlin.compiler.modules.KtModule
import com.itsaky.androidide.lsp.kotlin.compiler.read
import com.itsaky.androidide.lsp.kotlin.utils.toVirtualFileOrNull
import com.itsaky.androidide.utils.DocumentUtils
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -172,8 +173,9 @@ internal class KtSymbolIndex(

fun getOpenedKtFile(path: Path) = openedFiles[path]

fun getKtFile(vf: VirtualFile): KtFile {
fun getKtFile(vf: VirtualFile): KtFile? {
val path = vf.toNioPath()
if (!DocumentUtils.isKotlinFile(path)) return null

openedFiles[path]?.also { return it }
ktFileCache.getIfPresent(path)?.also { return it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ internal class DeclarationProvider(
return index.filesForPackage(fqName.asString())
.mapNotNull { VirtualFileManager.getInstance().findFileByNioPath(Paths.get(it.filePath)) }
.filter { it in scope }
.map { index.getKtFile(it) }
.mapNotNull { index.getKtFile(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal class DirectInheritorsProvider: KtLspService, KotlinDirectInheritorsPro
modules
.asFlatSequence()
.filter { it.isSourceModule }.flatMap { it.computeFiles(extended = true) }
.map { index.getKtFile(it) }
.mapNotNull { index.getKtFile(it) }
.forEach { ktFile ->
ktFile.accept(object : KtTreeVisitorVoid() {
override fun visitClassOrObject(classOrObject: KtClassOrObject) {
Expand Down
Loading