private void HandleOutputDataReceived(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            try
            {
                Match match = GeneratedFileMessageFormat.Match(data);
                if (!match.Success)
                {
                    _buildMessages.Add(new BuildMessage(data));
                    return;
                }

                string fileName = match.Groups["OUTPUT"].Value;
                if (LanguageSourceExtensions.Contains(Path.GetExtension(fileName), StringComparer.OrdinalIgnoreCase))
                {
                    GeneratedCodeFiles.Add(match.Groups["OUTPUT"].Value);
                }
            }
            catch (Exception ex)
            {
                if (Antlr4ClassGenerationTask.IsFatalException(ex))
                {
                    throw;
                }

                _buildMessages.Add(new BuildMessage(ex.Message));
            }
        }
        private void HandleOutputDataReceivedFirstTime(object sender, DataReceivedEventArgs e)
        {
            string dep = e.Data as string;

            if (string.IsNullOrEmpty(dep))
            {
                return;
            }
            // Parse the dep string as "file-name1 : file-name2". Strip off the name
            // file-name1 and cache it.
            try
            {
                Match match = GeneratedFileMessageFormatJavaTool.Match(dep);
                if (!match.Success)
                {
                    return;
                }
                string fileName = match.Groups["OUTPUT"].Value;
                if (LanguageSourceExtensions.Contains(Path.GetExtension(fileName), StringComparer.OrdinalIgnoreCase))
                {
                    GeneratedCodeFiles.Add(match.Groups["OUTPUT"].Value);
                }
            }
            catch (Exception ex)
            {
                if (Antlr4ClassGenerationTask.IsFatalException(ex))
                {
                    throw;
                }

                _buildMessages.Add(new BuildMessage(ex.Message));
            }
        }
예제 #3
0
        public BuildMessage(string message)
            : this(TraceLevel.Error, message, null, 0, 0)
        {
            try
            {
                Match match = BuildMessageFormat.Match(message);
                if (match.Success)
                {
                    FileName     = match.Groups["FILE"].Length > 0 ? match.Groups["FILE"].Value : "";
                    LineNumber   = match.Groups["LINE"].Length > 0 ? int.Parse(match.Groups["LINE"].Value) : 0;
                    ColumnNumber = match.Groups["COLUMN"].Length > 0 ? int.Parse(match.Groups["COLUMN"].Value) + 1 : 0;

                    switch (match.Groups["SEVERITY"].Value)
                    {
                    case "warning":
                        Severity = TraceLevel.Warning;
                        break;

                    case "error":
                        Severity = TraceLevel.Error;
                        break;

                    default:
                        Severity = TraceLevel.Info;
                        break;
                    }

                    int code = int.Parse(match.Groups["CODE"].Value);
                    Message = string.Format("AC{0:0000}: {1}", code, match.Groups["MESSAGE"].Value);
                }
                else
                {
                    Message = message;
                }
            }
            catch (Exception ex)
            {
                if (Antlr4ClassGenerationTask.IsFatalException(ex))
                {
                    throw;
                }
            }
        }
        private void HandleErrorDataReceived(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            try
            {
                _buildMessages.Add(new BuildMessage(data));
            }
            catch (Exception ex)
            {
                if (Antlr4ClassGenerationTask.IsFatalException(ex))
                {
                    throw;
                }

                _buildMessages.Add(new BuildMessage(ex.Message));
            }
        }