diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt index ba2f82cdbfc..411d56f37dd 100644 --- a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -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") } diff --git a/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java b/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java index 52cc1ffa7b7..e832ffbca4c 100644 --- a/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java +++ b/idea/src/org/jetbrains/jet/plugin/ktSignature/KotlinSignatureInJavaMarkerProvider.java @@ -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) )); } } diff --git a/idea/src/org/jetbrains/jet/plugin/util/attachment/attachmentUtils.kt b/idea/src/org/jetbrains/jet/plugin/util/attachment/attachmentUtils.kt index 4840458c0c6..89cfc18f7b4 100644 --- a/idea/src/org/jetbrains/jet/plugin/util/attachment/attachmentUtils.kt +++ b/idea/src/org/jetbrains/jet/plugin/util/attachment/attachmentUtils.kt @@ -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 { - if (file == null) return array() +public fun attachmentByPsiFileAsArray(file: PsiFile?): Array { + 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()) } \ No newline at end of file