public OutputParserResult ParseOutput(IEnumerable <string> inputLines)
        {
            OutputParserResult parserResult = new OutputParserResult();

            if (inputLines == null)
            {
                return(parserResult);
            }

            List <string> outputLines     = new List <string>();
            List <string> processingLines = new List <string>();

            processingLines.AddRange(inputLines);

            foreach (string line in processingLines)
            {
                TaskError error = IsErrorMatch(line);

                if (error != null)
                {
                    parserResult.ErrorList.Add(error);
                }
                else
                {
                    outputLines.Add(line);
                }
            }

            parserResult.OutputLines = outputLines;
            return(parserResult);
        }
        private IEnumerable <string> ParseOutputInternal(IEnumerable <string> inputLines, OutputParserResult parserResult)
        {
            foreach (var line in inputLines)
            {
                bool matchFound = false;

                if (line.Length < 200)
                {
                    var cleanLine = _colorSwitchRegex.Replace(line, string.Empty);

                    foreach (var regex in _regexes)
                    {
                        Match match = regex.Match(cleanLine);

                        if (match.Success)
                        {
                            TaskError error = TaskHelpers.CreateErrorFromRegex(match);
                            parserResult.ErrorList.Add(error);
                            matchFound = true;
                            break;
                        }
                    }
                }

                if (!matchFound)
                {
                    yield return(line);
                }
            }
        }
Exemple #3
0
        public OutputParserResult ParseOutput(IEnumerable <string> inputLines)
        {
            OutputParserResult parserResult = new OutputParserResult();

            if (inputLines == null)
            {
                return(parserResult);
            }

            List <string> outputLines = new List <string>();

            foreach (var line in inputLines)
            {
                var cleanLine = _colorSwitchRegex.Replace(line, "");

                if (cleanLine.Contains(":\\"))
                {
                    var trimmed = cleanLine.Trim();
                    if (File.Exists(trimmed))
                    {
                        _lastFile = trimmed;
                    }
                }

                // If there is no file name, proceed to next line
                if (string.IsNullOrEmpty(_lastFile))
                {
                    outputLines.Add(line);
                    continue;
                }

                Match match = _regex.Match(cleanLine);

                if (match.Success)
                {
                    TaskError error = TaskHelpers.CreateErrorFromRegex(match, _lastFile);
                    parserResult.ErrorList.Add(error);
                }
                else
                {
                    outputLines.Add(line);
                }
            }

            parserResult.OutputLines = outputLines;

            return(parserResult);
        }
        private TaskError IsErrorMatch(string line)
        {
            TaskError error = null;

            string fileName      = "";
            string lineNumberStr = "";
            string colNumberStr  = "";
            string message       = "";
            string errorCode     = "";

            string noColorSwitchLine = colorSwitchRegex.Replace(line, "");
            string cleanLine         = lineBreakRegex.Replace(noColorSwitchLine, "");

            Match errorMatch = lineColumnRegex.Match(cleanLine);

            if (errorMatch.Success)
            {
                fileName      = errorMatch.Groups["FILEPATH"].Value;
                lineNumberStr = errorMatch.Groups["LINE"].Value;
                colNumberStr  = errorMatch.Groups["COLUMN"].Value;
                message       = errorMatch.Groups["TEXT"].Value.TrimEnd(' ');
                errorCode     = errorMatch.Groups["ERRORCODE"].Value;


                // Convert / to \
                fileName = fileName.Replace('/', '\\');
                int lineNumber;
                int colNumber;
                int.TryParse(lineNumberStr, out lineNumber);
                int.TryParse(colNumberStr, out colNumber);

                error = new TaskError
                {
                    Line      = lineNumber,
                    Column    = colNumber,
                    Message   = message,
                    Filename  = fileName,
                    Severity  = MessageSeverity.Error,
                    ErrorCode = errorCode
                };
            }

            return(error);
        }
Exemple #5
0
        /// <summary>
        /// Generates a list of IErrorListItem from the
        /// buffered errors info
        /// </summary>
        /// <returns></returns>
        private List <IErrorListItem> GenerateErrorListItems()
        {
            List <IErrorListItem> errors = new List <IErrorListItem>();

            foreach (ErrorInfo errorInfo in _errorsBuffer)
            {
                TaskError error = new TaskError
                {
                    Line      = errorInfo.LineNumber,
                    Column    = errorInfo.ColumnNumber,
                    Message   = errorInfo.Message,
                    Filename  = _previousFileName,
                    Severity  = errorInfo.Severity,
                    ErrorCode = errorInfo.ErrorCode
                };

                errors.Add(error);
            }

            return(errors);
        }