Migrate some FIR/Analysis API KotlinExceptionWithAttachment usages to buildErrorWithAttachment API

This commit is contained in:
Ilya Kirillov
2023-07-11 15:11:02 +02:00
committed by Space Team
parent 24f60a542d
commit 24db4e62f5
6 changed files with 49 additions and 59 deletions
@@ -21,7 +21,8 @@ import com.intellij.openapi.diagnostic.Logger
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets.INSIDE_DIRECTIVE_EXPRESSIONS
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
import org.jetbrains.kotlin.utils.exceptions.logErrorWithAttachment
import org.jetbrains.kotlin.utils.exceptions.withPsiEntry
class KtDotQualifiedExpression : KtExpressionImplStub<KotlinPlaceHolderStub<KtDotQualifiedExpression>>, KtQualifiedExpression {
constructor(node: ASTNode) : super(node)
@@ -69,11 +70,9 @@ class KtDotQualifiedExpression : KtExpressionImplStub<KotlinPlaceHolderStub<KtDo
} else {
val expressions = stub.getChildrenByType(INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY)
if (expressions.size !in 1..2) {
LOG.error(
KotlinExceptionWithAttachments(
"Invalid stub structure. DOT_QUALIFIED_EXPRESSION must have one or two children. Was: ${expressions.size}\n"
).withPsiAttachment("file.kt", containingFile)
)
LOG.logErrorWithAttachment("Invalid stub structure. DOT_QUALIFIED_EXPRESSION must have one or two children. Was: ${expressions.size}") {
withPsiEntry("file", containingFile)
}
return null
}
return expressions