[fir2ir] Support stub-based FIR declarations
In the IDE, FIR declarations for libraries are built on top of binary stubs. This helps to improve memory usage significantly, as Protobuf metadata isn't loaded all the time. However, the containing file type for stubs is different.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
import com.intellij.psi.PsiCompiledElement
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.backend.common.actualizer.IrActualizedResult
|
||||
@@ -55,6 +56,7 @@ import org.jetbrains.kotlin.ir.util.functions
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -76,7 +78,7 @@ internal inline fun <T : IrElement> KtSourceElement?.convertWithOffsets(f: (star
|
||||
val startOffset: Int
|
||||
val endOffset: Int
|
||||
|
||||
if (psi is PsiCompiledElement) {
|
||||
if (isCompiledElement(psi)) {
|
||||
startOffset = UNDEFINED_OFFSET
|
||||
endOffset = UNDEFINED_OFFSET
|
||||
} else {
|
||||
@@ -101,7 +103,7 @@ internal inline fun <T : IrElement> FirStatement.convertWithOffsets(
|
||||
): T {
|
||||
val startOffset: Int
|
||||
val endOffset: Int
|
||||
if (psi is PsiCompiledElement) {
|
||||
if (isCompiledElement(psi)) {
|
||||
startOffset = UNDEFINED_OFFSET
|
||||
endOffset = UNDEFINED_OFFSET
|
||||
} else {
|
||||
@@ -111,6 +113,19 @@ internal inline fun <T : IrElement> FirStatement.convertWithOffsets(
|
||||
return f(startOffset, endOffset)
|
||||
}
|
||||
|
||||
private fun isCompiledElement(element: PsiElement?): Boolean {
|
||||
if (element == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (element is PsiCompiledElement) {
|
||||
return true
|
||||
}
|
||||
|
||||
val containingFile = element.containingFile
|
||||
return containingFile !is KtFile || containingFile.isCompiled
|
||||
}
|
||||
|
||||
internal fun createErrorType(): IrErrorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT)
|
||||
|
||||
enum class ConversionTypeOrigin(val forSetter: Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user