@@ -4,6 +4,7 @@ import com.intellij.build.FilePosition
4
4
import com.intellij.build.events.BuildEvent
5
5
import com.intellij.build.events.MessageEvent
6
6
import com.intellij.build.events.impl.FileMessageEventImpl
7
+ import com.intellij.build.events.impl.MessageEventImpl
7
8
import com.intellij.build.output.BuildOutputInstantReader
8
9
import com.intellij.build.output.BuildOutputParser
9
10
import java.io.File
@@ -14,15 +15,21 @@ class RsBuildOutputParser(private val instance: RsBuildInstance) : BuildOutputPa
14
15
private val fileMessageContext = FileMessageContext ()
15
16
private val detailsBuilder = StringBuilder ()
16
17
private var detailsCount = 0
18
+ private var collectingStackTrace = false
17
19
18
- override fun parse (line : String , reader : BuildOutputInstantReader , messageConsumer : Consumer <in BuildEvent >): Boolean {
20
+ override fun parse (
21
+ line : String ,
22
+ reader : BuildOutputInstantReader ,
23
+ messageConsumer : Consumer <in BuildEvent >
24
+ ): Boolean {
19
25
if (detailsCount > 0 ) {
20
26
detailsCount--
21
27
detailsBuilder.appendLine(line)
22
28
if (detailsCount == 0 ) {
23
29
val filePath = File (fileMessageContext.path)
24
30
val filePosition = FilePosition (filePath, fileMessageContext.line, fileMessageContext.column)
25
- val fileMessage = FileMessageEventImpl (instance.buildId,
31
+ val fileMessage = FileMessageEventImpl (
32
+ instance.buildId,
26
33
MessageEvent .Kind .ERROR ,
27
34
" Compiler Errors" ,
28
35
fileMessageContext.message,
@@ -45,12 +52,39 @@ class RsBuildOutputParser(private val instance: RsBuildInstance) : BuildOutputPa
45
52
detailsCount = 2
46
53
return true
47
54
}
55
+ if (collectingStackTrace) {
56
+ if (line.startsWith(" Process finished" )) {
57
+ val fileMessage = MessageEventImpl (
58
+ instance.buildId,
59
+ MessageEvent .Kind .ERROR ,
60
+ " Compiler Errors" ,
61
+ " Internal Error" ,
62
+ detailsBuilder.toString()
63
+ )
64
+ messageConsumer.accept(fileMessage)
65
+ collectingStackTrace = false
66
+ } else {
67
+ detailsBuilder.appendLine(line)
68
+ }
69
+ } else if (line.startsWith(EXCEPTION_BEGINNING )) {
70
+ detailsBuilder.setLength(0 )
71
+ val exceptionLine = line.substring(line.indexOf(' "' , EXCEPTION_BEGINNING .length) + 2 )
72
+ detailsBuilder.appendLine(exceptionLine)
73
+ collectingStackTrace = true
74
+ }
48
75
return false
49
76
}
50
77
51
78
companion object {
52
- private val ERROR_PATTERN = Regex (" (?<path>.+):(?<line>\\ d+):(?<column>\\ d+): (?:ERROR|SYNTAX_ERROR): (?<message>[^\\ r\\ n]+)" )
79
+ private val ERROR_PATTERN =
80
+ Regex (" (?<path>.+):(?<line>\\ d+):(?<column>\\ d+): (?:ERROR|SYNTAX_ERROR): (?<message>[^\\ r\\ n]+)" )
81
+ private const val EXCEPTION_BEGINNING = " Exception in thread \" "
53
82
}
54
83
}
55
84
56
- private data class FileMessageContext (var path : String = " " , var line : Int = 0 , var column : Int = 0 , var message : String = " " )
85
+ private data class FileMessageContext (
86
+ var path : String = " " ,
87
+ var line : Int = 0 ,
88
+ var column : Int = 0 ,
89
+ var message : String = " "
90
+ )
0 commit comments