Migrate LightMemberOriginForCompiledElement from IJ repository

This commit is contained in:
Ilya Kirillov
2021-12-20 13:30:13 +03:00
parent 764ad8b9fa
commit b563824b35
8 changed files with 382 additions and 7 deletions
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2021 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.
*/
package org.jetbrains.kotlin.analysis.decompiled.light.classes.origin
import com.intellij.openapi.application.ApplicationManager
import com.intellij.psi.PsiMember
import org.jetbrains.kotlin.analysis.decompiler.psi.file.KtClsFile
import org.jetbrains.kotlin.load.kotlin.MemberSignature
import org.jetbrains.kotlin.psi.KtDeclaration
abstract class KotlinDeclarationInCompiledFileSearcher {
abstract fun findDeclarationInCompiledFile(file: KtClsFile, member: PsiMember, signature: MemberSignature): KtDeclaration?
companion object {
fun getInstance(): KotlinDeclarationInCompiledFileSearcher =
ApplicationManager.getApplication().getService(KotlinDeclarationInCompiledFileSearcher::class.java)
}
}
@@ -47,7 +47,7 @@ data class LightMemberOriginForCompiledField(val psiField: PsiField, val file: K
override val originalElement: KtDeclaration? by lazyPub {
val desc = MapPsiToAsmDesc.typeDesc(psiField.type)
val signature = MemberSignature.fromFieldNameAndDesc(psiField.name, desc)
findDeclarationInCompiledFile(file, psiField, signature)
KotlinDeclarationInCompiledFileSearcher.getInstance().findDeclarationInCompiledFile(file, psiField, signature)
}
}
@@ -70,6 +70,6 @@ data class LightMemberOriginForCompiledMethod(val psiMethod: PsiMethod, val file
val desc = MapPsiToAsmDesc.methodDesc(psiMethod)
val name = if (psiMethod.isConstructor) "<init>" else psiMethod.name
val signature = MemberSignature.fromMethodNameAndDesc(name, desc)
findDeclarationInCompiledFile(file, psiMethod, signature)
KotlinDeclarationInCompiledFileSearcher.getInstance().findDeclarationInCompiledFile(file, psiMethod, signature)
}
}