Beispiel #1
0
            /// <summary>Receives and processes the compiler message</summary>
            /// <param name="severity">Message severity level</param>
            /// <param name="code">Identifies the error, warning or info by code</param>
            /// <param name="text">Message text</param>
            /// <param name="fileName">Optional: Name of path of file where the error happened (null when unknown)</param>
            /// <param name="line">Optional: 1-based line number where the error happened (0 when unknown)</param>
            /// <param name="column">Optional: 1-based column number where the error happened (0 when unknown)</param>
            public void Report(RegexCompilerMessageSeverity severity, RegexCompilerErrorCodes code, string text, string fileName, int line, int column)
            {
                switch (severity)
                {
                case RegexCompilerMessageSeverity.Error: ErrorCount++; break;

                case RegexCompilerMessageSeverity.Warning: WarningCount++; break;
                }
            }
Beispiel #2
0
        void IRegexCompilerMessageSink.Report(RegexCompilerMessageSeverity severity, RegexCompilerErrorCodes code, string text, string fileName, int line, int column)
        {
            switch (severity)
            {
            case RegexCompilerMessageSeverity.Error:
                Log.LogError(null, $"RXC{code:d}", null, fileName, line, column, -1, -1, text);
                ErrorCount++;
                break;

            case RegexCompilerMessageSeverity.Warning:
                Log.LogWarning(null, $"RXC{code:d}", null, fileName, line, column, -1, -1, text);
                WarningCount++;
                break;

            default: Log.LogMessage(null, $"RXC{code:d}", null, fileName, line, column, -1, -1, text); break;
            }
        }
Beispiel #3
0
        /// <summary>Receives and processes the compiler message</summary>
        /// <param name="severity">Message severity level</param>
        /// <param name="code">Identifies the error, warning or info by code</param>
        /// <param name="text">Message text</param>
        /// <param name="fileName">Optional: Name of path of file where the error happened (null when unknown)</param>
        /// <param name="line">Optional: 1-based line number where the error happened (0 when unknown)</param>
        /// <param name="column">Optional: 1-based column number where the error happened (0 when unknown)</param>
        public void Report(RegexCompilerMessageSeverity severity, RegexCompilerErrorCodes code, string text, string fileName, int line, int column)
        {
            Action <string> log;

            if (severity == RegexCompilerMessageSeverity.Error)
            {
                log = Console.Error.WriteLine;
            }
            else
            {
                log = Console.WriteLine;
            }
            ConsoleColor oldc = Console.ForegroundColor;

            switch (severity)
            {
            case RegexCompilerMessageSeverity.Warning:
                WarningCount++;
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case RegexCompilerMessageSeverity.Error:
                ErrorCount++;
                Console.ForegroundColor = ConsoleColor.Red;
                break;
            }
            try
            {
                log(
                    (fileName == null ? null : (fileName + ":")) +
                    (line > 0 ? line.ToString() : null) +
                    (column > 0 ? (line > 0 ? "," : null) + column.ToString() : null) +
                    ((column > 0 || line > 0) ? ": " : (fileName == null ? null : " ")) +
                    $"{severity}: RXC{code:d3} + text"
                    );
            }
            finally
            {
                if (Console.ForegroundColor != oldc)
                {
                    Console.ForegroundColor = oldc;
                }
            }
        }