[FIR] builder: drop unused forcedElementSourceKind
There was only one usage by withDefaultSourceElementKind that was dropped in the previous commit ^KT-63042
This commit is contained in:
committed by
Space Team
parent
6c1f5b7a74
commit
9d72c1c370
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class AbstractLightTreeRawFirBuilder(
|
||||
override fun LighterASTNode.toFirSourceElement(kind: KtFakeSourceElementKind?): KtLightSourceElement {
|
||||
val startOffset = tree.getStartOffset(this)
|
||||
val endOffset = tree.getEndOffset(this)
|
||||
return toKtLightSourceElement(tree, kind ?: context.forcedElementSourceKind ?: KtRealSourceElementKind, startOffset, endOffset)
|
||||
return toKtLightSourceElement(tree, kind ?: KtRealSourceElementKind, startOffset, endOffset)
|
||||
}
|
||||
|
||||
override val LighterASTNode.elementType: IElementType
|
||||
|
||||
+2
-2
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ class LightTreeRawFirExpressionBuilder(
|
||||
)
|
||||
}
|
||||
else -> buildErrorExpression(
|
||||
converted?.source?.withForcedKindFrom(context) ?: expression?.toFirSourceElement(),
|
||||
converted?.source?.realElement() ?: expression?.toFirSourceElement(),
|
||||
if (expression == null) ConeSyntaxDiagnostic(errorReason)
|
||||
else ConeSimpleDiagnostic(errorReason, DiagnosticKind.ExpressionExpected),
|
||||
converted,
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ open class PsiRawFirBuilder(
|
||||
}
|
||||
|
||||
override fun PsiElement.toFirSourceElement(kind: KtFakeSourceElementKind?): KtPsiSourceElement {
|
||||
val actualKind = kind ?: this@PsiRawFirBuilder.context.forcedElementSourceKind ?: KtRealSourceElementKind
|
||||
val actualKind = kind ?: KtRealSourceElementKind
|
||||
return this.toKtPsiSourceElement(actualKind)
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ open class PsiRawFirBuilder(
|
||||
else -> buildErrorExpression {
|
||||
nonExpressionElement = fir
|
||||
diagnostic = diagnosticFn()
|
||||
source = fir?.source?.withForcedKindFrom(this@PsiRawFirBuilder.context) ?: toFirSourceElement()
|
||||
source = fir?.source?.realElement() ?: toFirSourceElement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-11
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -1003,16 +1003,6 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
initContainingClassAttr(context)
|
||||
}
|
||||
|
||||
protected inline fun <R> withDefaultSourceElementKind(newDefault: KtSourceElementKind, action: () -> R): R {
|
||||
val currentForced = context.forcedElementSourceKind
|
||||
context.forcedElementSourceKind = newDefault
|
||||
try {
|
||||
return action()
|
||||
} finally {
|
||||
context.forcedElementSourceKind = currentForced
|
||||
}
|
||||
}
|
||||
|
||||
protected fun buildLabelAndErrorSource(rawName: String, source: KtSourceElement): Pair<FirLabel, KtSourceElement?> {
|
||||
val firLabel = buildLabel {
|
||||
name = KtPsiUtil.unquoteIdentifier(rawName)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.builder
|
||||
|
||||
import org.jetbrains.kotlin.KtSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.FirFunctionTarget
|
||||
import org.jetbrains.kotlin.fir.FirLabel
|
||||
import org.jetbrains.kotlin.fir.FirLoopTarget
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildOuterClassTypeParameterRef
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -19,6 +17,7 @@ import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
|
||||
class Context<T> {
|
||||
lateinit var packageFqName: FqName
|
||||
@@ -51,7 +50,6 @@ class Context<T> {
|
||||
val capturedTypeParameters = mutableListOf<StatusFirTypeParameterSymbolList>()
|
||||
val arraySetArgument = mutableMapOf<T, FirExpression>()
|
||||
|
||||
var forcedElementSourceKind: KtSourceElementKind? = null
|
||||
val dispatchReceiverTypesStack = mutableListOf<ConeClassLikeType>()
|
||||
var containerIsExpect: Boolean = false
|
||||
|
||||
|
||||
+1
-9
@@ -6,10 +6,10 @@
|
||||
package org.jetbrains.kotlin.fir.builder
|
||||
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.KtRealSourceElementKind
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.*
|
||||
import org.jetbrains.kotlin.contracts.description.LogicOperationKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
@@ -707,14 +707,6 @@ fun AnnotationUseSiteTarget?.appliesToPrimaryConstructorParameter() = this == nu
|
||||
this == AnnotationUseSiteTarget.RECEIVER ||
|
||||
this == AnnotationUseSiteTarget.FILE
|
||||
|
||||
fun KtSourceElement.withForcedKindFrom(context: Context<*>): KtSourceElement {
|
||||
return when (val forcedKind = context.forcedElementSourceKind) {
|
||||
kind -> this
|
||||
is KtFakeSourceElementKind -> fakeElement(forcedKind)
|
||||
else -> this.realElement()
|
||||
}
|
||||
}
|
||||
|
||||
fun FirErrorTypeRef.wrapIntoArray(): FirResolvedTypeRef {
|
||||
val typeRef = this
|
||||
return buildResolvedTypeRef {
|
||||
|
||||
Reference in New Issue
Block a user