Track changes in inline function when friend paths are disabled in JS
This commit is contained in:
+38
-28
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.kotlin.js.translate.expression
|
||||
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.descriptor
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.functionDescriptor
|
||||
@@ -103,36 +105,12 @@ fun TranslationContext.wrapWithInlineMetadata(
|
||||
): JsExpression {
|
||||
val sourceInfo = descriptor.source.getPsi()
|
||||
return if (descriptor.isInline) {
|
||||
val incrementalResults = config.configuration[JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER]
|
||||
incrementalResults?.reportInlineFunction(descriptor, function, sourceInfo)
|
||||
|
||||
if (descriptor.shouldBeExported(config)) {
|
||||
val metadata = InlineMetadata.compose(function, descriptor, this)
|
||||
val functionWithMetadata = metadata.functionWithMetadata(outerContext, sourceInfo)
|
||||
config.configuration[JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER]?.apply {
|
||||
val psiFile = (descriptor.source.containingFile as? PsiSourceFile)?.psiFile ?: return@apply
|
||||
val file = VfsUtilCore.virtualToIoFile(psiFile.virtualFile)
|
||||
|
||||
val fqName = when (descriptor) {
|
||||
is PropertyGetterDescriptor -> {
|
||||
"<get>" + descriptor.correspondingProperty.fqNameSafe.asString()
|
||||
}
|
||||
is PropertySetterDescriptor -> {
|
||||
"<set>" + descriptor.correspondingProperty.fqNameSafe.asString()
|
||||
}
|
||||
else -> descriptor.fqNameSafe.asString()
|
||||
}
|
||||
|
||||
val offset = sourceInfo?.node?.startOffset
|
||||
val document = psiFile.viewProvider.document
|
||||
var sourceLine = -1
|
||||
var sourceColumn = -1
|
||||
if (offset != null && document != null) {
|
||||
sourceLine = document.getLineNumber(offset)
|
||||
sourceColumn = offset - document.getLineStartOffset(sourceLine)
|
||||
}
|
||||
|
||||
processInlineFunction(file, fqName, functionWithMetadata, sourceLine, sourceColumn)
|
||||
}
|
||||
|
||||
functionWithMetadata
|
||||
metadata.functionWithMetadata(outerContext, sourceInfo)
|
||||
}
|
||||
else {
|
||||
val block =
|
||||
@@ -147,3 +125,35 @@ fun TranslationContext.wrapWithInlineMetadata(
|
||||
function
|
||||
}
|
||||
}
|
||||
|
||||
private fun IncrementalResultsConsumer.reportInlineFunction(
|
||||
descriptor: FunctionDescriptor,
|
||||
translatedFunction: JsExpression,
|
||||
sourceInfo: PsiElement?
|
||||
) {
|
||||
val psiFile = (descriptor.source.containingFile as? PsiSourceFile)?.psiFile ?: return
|
||||
val file = VfsUtilCore.virtualToIoFile(psiFile.virtualFile)
|
||||
|
||||
if (effectiveVisibility(descriptor.visibility, descriptor, true).privateApi) return
|
||||
|
||||
val fqName = when (descriptor) {
|
||||
is PropertyGetterDescriptor -> {
|
||||
"<get>" + descriptor.correspondingProperty.fqNameSafe.asString()
|
||||
}
|
||||
is PropertySetterDescriptor -> {
|
||||
"<set>" + descriptor.correspondingProperty.fqNameSafe.asString()
|
||||
}
|
||||
else -> descriptor.fqNameSafe.asString()
|
||||
}
|
||||
|
||||
val offset = sourceInfo?.node?.startOffset
|
||||
val document = psiFile.viewProvider.document
|
||||
var sourceLine = -1
|
||||
var sourceColumn = -1
|
||||
if (offset != null && document != null) {
|
||||
sourceLine = document.getLineNumber(offset)
|
||||
sourceColumn = offset - document.getLineStartOffset(sourceLine)
|
||||
}
|
||||
|
||||
processInlineFunction(file, fqName, translatedFunction, sourceLine, sourceColumn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user