Exception analyzer doesn't show multiple attachments
This commit is contained in:
@@ -73,8 +73,9 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.codegen.StackValue
|
||||
import org.jetbrains.jet.lang.types.Flexibility
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.plugin.util.attachment.attachmentsByPsiFile
|
||||
import org.jetbrains.jet.plugin.util.attachment.attachmentByPsiFile
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import org.jetbrains.jet.plugin.util.attachment.mergeAttachments
|
||||
|
||||
private val RECEIVER_NAME = "\$receiver"
|
||||
private val THIS_NAME = "this"
|
||||
@@ -91,11 +92,11 @@ object KotlinEvaluationBuilder: EvaluatorBuilder {
|
||||
}
|
||||
|
||||
if (codeFragment.getContext() !is JetElement) {
|
||||
val attachments = (attachmentsByPsiFile(position.getFile()) +
|
||||
attachmentsByPsiFile(codeFragment) +
|
||||
listOf(Attachment("breakpoint.info", "line: ${position.getLine()}"))
|
||||
).copyToArray()
|
||||
logger.error("Trying to evaluate ${codeFragment.javaClass} with context ${codeFragment.getContext()?.javaClass}", *attachments)
|
||||
val attachments = array(attachmentByPsiFile(position.getFile()),
|
||||
attachmentByPsiFile(codeFragment),
|
||||
Attachment("breakpoint.info", "line: ${position.getLine()}"))
|
||||
|
||||
logger.error("Trying to evaluate ${codeFragment.javaClass} with context ${codeFragment.getContext()?.javaClass}", mergeAttachments(*attachments))
|
||||
throw EvaluateExceptionUtil.createEvaluateException("Couldn't evaluate kotlin expression in this context")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
||||
LOG.error(LogMessageEx.createEvent(
|
||||
"Exception while collecting KotlinSignature markers",
|
||||
ExceptionUtil.getThrowableText(error),
|
||||
AttachmentPackage.attachmentsByPsiFile(psiFile)
|
||||
AttachmentPackage.attachmentByPsiFileAsArray(psiFile)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,37 @@ import com.intellij.psi.PsiFile
|
||||
import com.intellij.openapi.diagnostic.Attachment
|
||||
import com.intellij.diagnostic.AttachmentFactory
|
||||
|
||||
public fun attachmentsByPsiFile(file: PsiFile?): Array<Attachment> {
|
||||
if (file == null) return array()
|
||||
public fun attachmentByPsiFileAsArray(file: PsiFile?): Array<Attachment> {
|
||||
val attachment = attachmentByPsiFile(file)
|
||||
if (attachment == null) {
|
||||
return array()
|
||||
}
|
||||
return array(attachment)
|
||||
}
|
||||
|
||||
public fun attachmentByPsiFile(file: PsiFile?): Attachment? {
|
||||
if (file == null) return null
|
||||
|
||||
val virtualFile = file.getVirtualFile()
|
||||
if (virtualFile != null) return array(AttachmentFactory.createAttachment(virtualFile))
|
||||
if (virtualFile != null) return AttachmentFactory.createAttachment(virtualFile)
|
||||
|
||||
val text = try { file.getText() } catch(e: Exception) { null }
|
||||
val name = try { file.getName() } catch(e: Exception) { null }
|
||||
|
||||
if (text != null && name != null) return array(Attachment(name, text))
|
||||
if (text != null && name != null) return Attachment(name, text)
|
||||
|
||||
return array()
|
||||
return null
|
||||
}
|
||||
|
||||
public fun mergeAttachments(vararg attachments: Attachment?): Attachment {
|
||||
val builder = StringBuilder()
|
||||
attachments.forEach {
|
||||
if (it != null) {
|
||||
builder.append("\n----- START ${it.getPath()} -----\n")
|
||||
builder.append(it.getDisplayText())
|
||||
builder.append("\n----- END ${it.getPath()} -----\n")
|
||||
}
|
||||
}
|
||||
|
||||
return Attachment("message.txt", builder.toString())
|
||||
}
|
||||
Reference in New Issue
Block a user