예제 #1
0
        public virtual IEnumerable <CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
        {
            bool flag = false;
            List <CompilerMessage> compilerMessageList = new List <CompilerMessage>();
            Regex outputRegex = this.GetOutputRegex();

            foreach (string line in errorOutput)
            {
                string input = line.Length <= 1000 ? line : line.Substring(0, 100);
                Match  match = outputRegex.Match(input);
                if (match.Success)
                {
                    CompilerMessage fromMatchedRegex = CompilerOutputParserBase.CreateCompilerMessageFromMatchedRegex(line, match, this.GetErrorIdentifier());
                    fromMatchedRegex.normalizedStatus = this.NormalizedStatusFor(match);
                    if (fromMatchedRegex.type == CompilerMessageType.Error)
                    {
                        flag = true;
                    }
                    compilerMessageList.Add(fromMatchedRegex);
                }
            }
            if (compilationHadFailure && !flag)
            {
                compilerMessageList.Add(CompilerOutputParserBase.CreateInternalCompilerErrorMessage(errorOutput));
            }
            return((IEnumerable <CompilerMessage>)compilerMessageList);
        }
예제 #2
0
        /// <summary>
        /// the returned array of compiler messages corresponds to the input array of noderesult. Each node result can result in 0,1 or more compilermessages.
        /// We return them as an array of arrays, so on the caller side you're still able to map a compilermessage to the noderesult where it originated from,
        /// which we need when invoking per assembly compilation callbacks.
        /// </summary>
        public static CompilerMessage[][] ParseAllResultsIntoCompilerMessages(BeeDriverResult.Message[] beeDriverMessages, NodeResult[] nodeResults, EditorCompilation editorCompilation)
        {
            // If there's any messages from the bee driver, we add one additional array to the result which contains all of the driver messages converted and augmented like the nodes messages arrays.
            bool hasBeeDriverMessages = beeDriverMessages.Length > 0;
            var  result = new CompilerMessage[nodeResults.Length + (hasBeeDriverMessages ? 1 : 0)][];

            int resultIndex = 0;

            if (hasBeeDriverMessages)
            {
                result[resultIndex] = beeDriverMessages.Select(AsCompilerMessage).ToArray();
                ++resultIndex;
            }
            for (int i = 0; i != nodeResults.Length; i++)
            {
                result[resultIndex] = ParseCompilerOutput(nodeResults[i]);
                ++resultIndex;
            }

            //To be more kind to performance issues in situations where there are thousands of compiler messages, we're going to assume
            //that after the first 10 compiler error messages, we get very little benefit from augmenting the rest with higher quality unity specific messaging.
            int totalErrors         = 0;
            int nextResultToAugment = 0;

            while (totalErrors < 10 && nextResultToAugment < result.Length)
            {
                UnitySpecificCompilerMessages.AugmentMessagesInCompilationErrorsWithUnitySpecificAdvice(result[nextResultToAugment], editorCompilation);
                totalErrors += result[nextResultToAugment].Count(m => m.type == CompilerMessageType.Error);
                ++nextResultToAugment;
            }

            return(result);
        }
        public virtual IEnumerable <CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
        {
            bool flag = false;
            List <CompilerMessage> list = new List <CompilerMessage>();
            Regex outputRegex           = this.GetOutputRegex();

            foreach (string str in errorOutput)
            {
                string input = (str.Length <= 0x3e8) ? str : str.Substring(0, 100);
                Match  m     = outputRegex.Match(input);
                if (m.Success)
                {
                    CompilerMessage item = CreateCompilerMessageFromMatchedRegex(str, m, this.GetErrorIdentifier());
                    item.normalizedStatus = this.NormalizedStatusFor(m);
                    if (item.type == CompilerMessageType.Error)
                    {
                        flag = true;
                    }
                    list.Add(item);
                }
            }
            if (compilationHadFailure && !flag)
            {
                list.Add(CreateInternalCompilerErrorMessage(errorOutput));
            }
            return(list);
        }
        public virtual IEnumerable <CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
        {
            bool flag = false;
            List <CompilerMessage> list = new List <CompilerMessage>();
            Regex outputRegex           = this.GetOutputRegex();

            for (int i = 0; i < errorOutput.Length; i++)
            {
                string text  = errorOutput[i];
                string input = (text.Length <= 1000) ? text : text.Substring(0, 100);
                Match  match = outputRegex.Match(input);
                if (match.Success)
                {
                    CompilerMessage item = CompilerOutputParserBase.CreateCompilerMessageFromMatchedRegex(text, match, this.GetErrorIdentifier());
                    item.normalizedStatus = this.NormalizedStatusFor(match);
                    if (item.type == CompilerMessageType.Error)
                    {
                        flag = true;
                    }
                    list.Add(item);
                }
            }
            if (compilationHadFailure && !flag)
            {
                list.Add(CompilerOutputParserBase.CreateInternalCompilerErrorMessage(errorOutput));
            }
            return(list);
        }
 public CompilerMessage(CompilerMessage cm)
 {
     message          = cm.message;
     file             = cm.file;
     line             = cm.line;
     column           = cm.column;
     type             = cm.type;
     normalizedStatus = cm.normalizedStatus;
 }
예제 #6
0
        public virtual IEnumerable <CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure, string assemblyName)
        {
            var hasErrors          = false;
            var msgs               = new List <CompilerMessage>();
            var regex              = GetOutputRegex();
            var internalErrorRegex = GetInternalErrorOutputRegex();

            foreach (var line in errorOutput)
            {
                //Jamplus can fail with enormous lines in the stdout, parsing of which can take 30! seconds.
                var line2 = line.Length > 1000 ? line.Substring(0, 100) : line;

                Match m = regex.Match(line2);
                if (!m.Success)
                {
                    if (internalErrorRegex != null)
                    {
                        m = internalErrorRegex.Match(line2);
                    }
                    if (!m.Success)
                    {
                        continue;
                    }
                }
                CompilerMessage message = CreateCompilerMessageFromMatchedRegex(line, m, GetErrorIdentifier());
                message.normalizedStatus = NormalizedStatusFor(m);
                message.assemblyName     = assemblyName;

                if (message.type == CompilerMessageType.Error)
                {
                    hasErrors = true;
                }

                msgs.Add(message);
            }
            if (compilationHadFailure && !hasErrors)
            {
                msgs.Add(CreateInternalCompilerErrorMessage(errorOutput));
            }
            return(msgs);
        }
예제 #7
0
        public override IEnumerable <CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
        {
            List <CompilerMessage> list = new List <CompilerMessage>();

            for (int i = 0; i < standardOutput.Length; i++)
            {
                string input = standardOutput[i];
                if (input.StartsWith("IL2CPP error"))
                {
                    string        path    = string.Empty;
                    int           num2    = 0;
                    StringBuilder builder = new StringBuilder();
                    Match         match   = sErrorRegexWithSourceInformation.Match(input);
                    if (match.Success)
                    {
                        path = match.Groups["filename"].Value;
                        num2 = int.Parse(match.Groups["line"].Value);
                        builder.AppendFormat("{0} in {1}:{2}", match.Groups["message"].Value, Path.GetFileName(path), num2);
                    }
                    else
                    {
                        builder.Append(input);
                    }
                    if (((i + 1) < standardOutput.Length) && standardOutput[i + 1].StartsWith("Additional information:"))
                    {
                        builder.AppendFormat("{0}{1}", Environment.NewLine, standardOutput[i + 1]);
                        i++;
                    }
                    CompilerMessage item = new CompilerMessage {
                        file    = path,
                        line    = num2,
                        message = builder.ToString(),
                        type    = CompilerMessageType.Error
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #8
0
 public override IEnumerable<CompilerMessage> Parse(string[] errorOutput, string[] standardOutput, bool compilationHadFailure)
 {
     List<CompilerMessage> list = new List<CompilerMessage>();
     for (int i = 0; i < standardOutput.Length; i++)
     {
         string input = standardOutput[i];
         if (input.StartsWith("IL2CPP error"))
         {
             string path = string.Empty;
             int num2 = 0;
             StringBuilder builder = new StringBuilder();
             Match match = sErrorRegexWithSourceInformation.Match(input);
             if (match.Success)
             {
                 path = match.Groups["filename"].Value;
                 num2 = int.Parse(match.Groups["line"].Value);
                 builder.AppendFormat("{0} in {1}:{2}", match.Groups["message"].Value, Path.GetFileName(path), num2);
             }
             else
             {
                 builder.Append(input);
             }
             if (((i + 1) < standardOutput.Length) && standardOutput[i + 1].StartsWith("Additional information:"))
             {
                 builder.AppendFormat("{0}{1}", Environment.NewLine, standardOutput[i + 1]);
                 i++;
             }
             CompilerMessage item = new CompilerMessage {
                 file = path,
                 line = num2,
                 message = builder.ToString(),
                 type = CompilerMessageType.Error
             };
             list.Add(item);
         }
     }
     return list;
 }
예제 #9
0
        protected internal static CompilerMessage CreateCompilerMessageFromMatchedRegex(string line, Match m, string errorId, string informationId = null)
        {
            CompilerMessage message = new CompilerMessage();

            if (m.Groups["filename"].Success)
            {
                message.file = m.Groups["filename"].Value;
            }

            if (m.Groups["line"].Success)
            {
                message.line = Int32.Parse(m.Groups["line"].Value);
            }
            if (m.Groups["column"].Success)
            {
                message.column = Int32.Parse(m.Groups["column"].Value);
            }

            message.message = line;

            string messageType = m.Groups["type"].Value;

            if (messageType == errorId)
            {
                message.type = CompilerMessageType.Error;
            }
            else if (!string.IsNullOrEmpty(informationId) && messageType == informationId)
            {
                message.type = CompilerMessageType.Information;
            }
            else
            {
                message.type = CompilerMessageType.Warning;
            }

            return(message);
        }
            public override IEnumerable <UnityEditor.Scripting.Compilers.CompilerMessage> Parse(
                string[] errorOutput,
                string[] standardOutput,
                bool compilationHadFailure,
                string assemblyName)
            {
                var messages    = new List <UnityEditor.Scripting.Compilers.CompilerMessage>();
                var textBuilder = new StringBuilder();

                for (var i = 0; i < errorOutput.Length; i++)
                {
                    string line = errorOutput[i];

                    var message = new UnityEditor.Scripting.Compilers.CompilerMessage {
                        assemblyName = assemblyName
                    };

                    // If we are able to match a location, we can decode it including the following attached " at " lines
                    textBuilder.Clear();

                    var match = MatchLocation.Match(line);
                    if (match.Success)
                    {
                        var path = match.Groups[1].Value;
                        int.TryParse(match.Groups[2].Value, out message.line);
                        int.TryParse(match.Groups[3].Value, out message.column);
                        if (match.Groups[4].Value == "error")
                        {
                            message.type = CompilerMessageType.Error;
                        }
                        else
                        {
                            message.type = CompilerMessageType.Warning;
                        }
                        message.file = !string.IsNullOrEmpty(path) ? path : "unknown";
                        // Replace '\' with '/' to let the editor open the file
                        message.file = message.file.Replace('\\', '/');

                        // Make path relative to project path path
                        var projectPath = Path.GetDirectoryName(Application.dataPath)?.Replace('\\', '/');
                        if (projectPath != null && message.file.StartsWith(projectPath))
                        {
                            message.file = message.file.Substring(projectPath.EndsWith("/") ? projectPath.Length : projectPath.Length + 1);
                        }

                        // debug
                        // textBuilder.AppendLine("line: " + message.line + " column: " + message.column + " error: " + message.type + " file: " + message.file);
                        textBuilder.Append(match.Groups[5].Value);
                    }
                    else
                    {
                        // Don't output any blank line
                        if (string.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }
                        // Otherwise we output an error, but without source location information
                        // so that at least the user can see it directly in the log errors
                        message.type   = CompilerMessageType.Error;
                        message.line   = 0;
                        message.column = 0;
                        message.file   = "unknown";


                        textBuilder.Append(line);
                    }

                    // Collect attached location call context information ("at ...")
                    // we do it for both case (as if we have an exception in bcl we want to print this in a single line)
                    bool isFirstAt = true;
                    for (int j = i + 1; j < errorOutput.Length; j++)
                    {
                        var nextLine = errorOutput[j];
                        if (MatchAt.Match(nextLine).Success)
                        {
                            i++;
                            if (isFirstAt)
                            {
                                textBuilder.AppendLine();
                                isFirstAt = false;
                            }
                            textBuilder.AppendLine(nextLine);
                        }
                        else
                        {
                            break;
                        }
                    }
                    message.message = textBuilder.ToString();

                    messages.Add(message);
                }
                return(messages);
            }
 private static bool Run(out CompilerMessage[] messages, bool includeModules)
 {
   int exitCode;
   messages = ManagedEditorCodeRebuilder.ParseResults(ManagedEditorCodeRebuilder.GetOutputStream(ManagedEditorCodeRebuilder.GetJamStartInfo(includeModules), out exitCode));
   return exitCode == 0;
 }