[Analysis API] do not throw exception when KtCall is improperly resolved

Log the exception instead. This way the analysis of the file will not be stuck after finding an improperly resolved call
This commit is contained in:
Ilya Kirillov
2023-02-02 14:59:46 +01:00
committed by Space Team
parent 4a872928dd
commit 8b286577c7
3 changed files with 42 additions and 8 deletions
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.analysis.utils.errors
import com.intellij.openapi.diagnostic.Attachment
import com.intellij.openapi.diagnostic.Logger
import org.jetbrains.kotlin.analysis.utils.printer.PrettyPrinter
import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint
import org.jetbrains.kotlin.util.SourceCodeAnalysisException
@@ -70,6 +72,16 @@ public inline fun buildErrorWithAttachment(
throw exception
}
public inline fun Logger.logErrorWithAttachment(
message: String,
cause: Exception? = null,
attachmentName: String = "info.txt",
buildAttachment: ExceptionAttachmentBuilder.() -> Unit = {}
) {
val attachment = Attachment(attachmentName, ExceptionAttachmentBuilder().apply(buildAttachment).buildString())
this.error(message, cause, attachment)
}
public inline fun rethrowExceptionWithDetails(
message: String,
exception: Exception,