forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCil2AsOutputParser.cs
More file actions
43 lines (40 loc) · 1.52 KB
/
Copy pathCil2AsOutputParser.cs
File metadata and controls
43 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System.Collections.Generic;
using System.Text;
namespace UnityEditor.Scripting.Compilers
{
class Cil2AsOutputParser : UnityScriptCompilerOutputParser
{
public override IEnumerable<CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
{
var parsingError = false;
var currentErrorBuffer = new StringBuilder();
foreach (var str in errorOutput)
{
if (str.StartsWith("ERROR: "))
{
if (parsingError)
{
yield return CompilerErrorFor(currentErrorBuffer);
currentErrorBuffer.Length = 0;
}
currentErrorBuffer.AppendLine(str.Substring("ERROR: ".Length));
parsingError = true;
}
else
{
if (parsingError)
currentErrorBuffer.AppendLine(str);
}
}
if (parsingError)
yield return CompilerErrorFor(currentErrorBuffer);
}
private static CompilerMessage CompilerErrorFor(StringBuilder currentErrorBuffer)
{
return new CompilerMessage() { type = CompilerMessageType.Error, message = currentErrorBuffer.ToString() };
}
}
}