Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportMessage"/> class.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="code">The error code.</param>
 /// <param name="text">The text.</param>
 /// <param name="span">The span.</param>
 public ReportMessage(ReportMessageLevel level, string code, string text, SourceSpan span)
 {
     this.Level = level;
     this.Code  = code;
     this.Text  = text;
     this.Span  = span;
 }
Пример #2
0
        private static void HandleMessages(ParseTree parseTree, string file, ParsingResult result)
        {
            foreach (var parserMessage in parseTree.ParserMessages)
            {
                var level = new ReportMessageLevel();
                switch (parserMessage.Level)
                {
                case ParserErrorLevel.Info:
                    level = ReportMessageLevel.Info;
                    break;

                case ParserErrorLevel.Error:
                    level = ReportMessageLevel.Error;
                    break;

                case ParserErrorLevel.Warning:
                    level = ReportMessageLevel.Warning;
                    break;
                }

                result.Messages.Add(new ReportMessage(level, "", parserMessage.Message, new Ast.SourceSpan(SpanConverter.Convert(parserMessage.Location), 0)));

                if (parserMessage.Level != ParserErrorLevel.Info)
                {
                    result.HasErrors = true;
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportMessage"/> class.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="code">The error code.</param>
 /// <param name="text">The text.</param>
 /// <param name="span">The span.</param>
 public ReportMessage(ReportMessageLevel level, string code, string text, SourceSpan span)
 {
     this.Level = level;
     this.Code = code;
     this.Text = text;
     this.Span = span;
 }
Пример #4
0
 /// <summary>
 /// Adds the message.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="message">The message.</param>
 /// <param name="span">The span.</param>
 /// <param name="parameters">The parameters.</param>
 protected void AddMessage(ReportMessageLevel level, MessageCode message, SourceSpan span, params object[] parameters)
 {
     if (level == ReportMessageLevel.Error)
     {
         this.HasErrors = true;
     }
     this.Messages.Add(new ReportMessage(level, message.Code, string.Format(message.Text, parameters), span));
 }
Пример #5
0
 /// <summary>
 /// Adds the message.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="message">The message.</param>
 /// <param name="span">The span.</param>
 protected void AddMessage(ReportMessageLevel level, MessageCode message, SourceSpan span)
 {
     if (level == ReportMessageLevel.Error)
     {
         this.HasErrors = true;
     }
     this.Messages.Add(new ReportMessage(level, message.Code, message.Text, span));
 }
Пример #6
0
 /// <summary>
 /// Dumps the messages.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="writer">The writer.</param>
 public void DumpMessages(ReportMessageLevel level, TextWriter writer)
 {
     foreach (var reportMessage in this.Messages)
     {
         if (reportMessage.Level >= level)
         {
             writer.WriteLine(reportMessage);
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Dumps the messages.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="writer">The writer.</param>
 public void DumpMessages(ReportMessageLevel level, TextWriter writer)
 {
     foreach (var reportMessage in this.Messages)
     {
         if (reportMessage.Level >= level)
         {
             writer.WriteLine(reportMessage);
         }
     }
 }
Пример #8
0
 private static string ConvertToStringLevel(ReportMessageLevel level)
 {
     return(level.ToString().ToLowerInvariant());
 }
Пример #9
0
 private static string ConvertToStringLevel(ReportMessageLevel level)
 {
     return level.ToString().ToLowerInvariant();
 }
Пример #10
0
 /// <summary>
 /// Adds the message.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="message">The message.</param>
 /// <param name="span">The span.</param>
 /// <param name="parameters">The parameters.</param>
 protected void AddMessage(ReportMessageLevel level, MessageCode message, SourceSpan span, params object[] parameters)
 {
     if (level == ReportMessageLevel.Error) this.HasErrors = true;
     this.Messages.Add(new ReportMessage(level, message.Code, string.Format(message.Text, parameters), span));
 }
Пример #11
0
 /// <summary>
 /// Adds the message.
 /// </summary>
 /// <param name="level">The type.</param>
 /// <param name="message">The message.</param>
 /// <param name="span">The span.</param>
 protected void AddMessage(ReportMessageLevel level, MessageCode message, SourceSpan span)
 {
     if (level == ReportMessageLevel.Error) this.HasErrors = true;
     this.Messages.Add(new ReportMessage(level, message.Code, message.Text, span));
 }
Пример #12
0
 public ReportMessage(string message, ReportMessageLevel level)
 {
     Message = message;
     Level   = level;
 }