protected void AssertCompilerReturnsMessage( string input, CompilerMessageId messageId, CompilerMessageType messageType, string[] messageParameters) { // Arrange var compiler = new ThriftCompiler(); var parserInput = ParserInput.FromString(input); // Act var result = compiler.Compile(parserInput.GetStream()); // Assert var message = result.Messages.FirstOrDefault( m => m.MessageType == messageType && m.MessageId == messageId); Assert.True(message != null, $"No {messageType.ToString().ToLower()} messages were returned from the compiler"); if (parserInput.LineNumber != null) { Assert.Equal(parserInput.LineNumber, message.LineNumber); Assert.Equal(parserInput.StartPosition, message.StartPosition); Assert.Equal(parserInput.EndPosition, message.EndPosition); } if (messageParameters?.Length > 0) { var expectedMessage = string.Format( CompilerMessages.Get(messageId), messageParameters); Assert.Equal(expectedMessage, message.Message); } }
private CompilerMessage(CompilerMessageType type, int id, string name, string message) { this.type = type; this.id = id; this.name = name; this.message = message; }
private string TranslateErrorType(CompilerMessageType type) { if (type == CompilerMessageType.Warning) { return(PredefinedErrorTypeNames.Warning); } return(PredefinedErrorTypeNames.SyntaxError); }
public CompilerMessage(CompilerMessage cm) { message = cm.message; file = cm.file; line = cm.line; column = cm.column; type = cm.type; normalizedStatus = cm.normalizedStatus; }
/// <summary> /// Initializes a new instance of the <see cref="CompilationMessage" /> class. /// </summary> /// <param name="messageId">The compiler message Id.</param> /// <param name="messageType">The type of message being reported.</param> /// <param name="lineNumber">The 1-based line number in the document.</param> /// <param name="startPosition"> /// The 1-based starting position of the message on the line. /// </param> /// <param name="endPosition"> /// The 1-based ending position of the message on the line. /// </param> /// <param name="message"> /// The user-friendly compiler message. /// </param> public CompilationMessage( CompilerMessageId messageId, CompilerMessageType messageType, int lineNumber, int startPosition, int endPosition, string message) { this.MessageId = messageId; this.MessageType = messageType; this.LineNumber = lineNumber; this.StartPosition = startPosition; this.EndPosition = endPosition; this.Message = message; }
public CompilerMessage(CompilerMessageType type, string header, string message, bool showLineInfo = true) { CodeLocation = new LSLSourceCodeRange(); MessageText = message; MessageHeader = header; if (showLineInfo) { LineText = "(" + CodeLocation.LineStart + ", " + CodeLocation.ColumnStart + "):"; } else { LineText = ":"; } Clickable = true; SetColors(type); }
private void SetColors(CompilerMessageType type) { switch (type) { case CompilerMessageType.Error: MessageTypeColor = Brushes.Red; BackgroundColor = Brushes.LavenderBlush; break; case CompilerMessageType.General: MessageTypeColor = Brushes.Blue; BackgroundColor = Brushes.White; break; case CompilerMessageType.Warning: MessageTypeColor = Brushes.DimGray; BackgroundColor = Brushes.Cornsilk; break; } }
public static TaskErrorCategory ConvertMessageType(CompilerMessageType type) { switch (type) { case CompilerMessageType.FatalError: return(TaskErrorCategory.Error); case CompilerMessageType.Error: return(TaskErrorCategory.Error); case CompilerMessageType.Warning: return(TaskErrorCategory.Warning); case CompilerMessageType.Hint: return(TaskErrorCategory.Message); default: return(TaskErrorCategory.Error); } }
protected void AssertCompilerReturnsMessage( string input, CompilerMessageId messageId, CompilerMessageType messageType, string[] messageParameters) { // Arrange var compiler = new ThriftCompiler(); var parserInput = ParserInput.FromString(input); // Act var result = compiler.Compile(parserInput.GetStream()); // Assert var message = result.Messages.FirstOrDefault( m => m.MessageType == messageType && m.MessageId == messageId); Assert.True(message != null, $"No {messageType.ToString().ToLower()} messages were returned from the compiler"); // Although we know that message cannot be null because of the assert on // the previous line, check for null here because the lgtm check isn't // smart enough to realise that if (message != null) { if (parserInput.LineNumber != null) { Assert.Equal(parserInput.LineNumber, message.LineNumber); Assert.Equal(parserInput.StartPosition, message.StartPosition); Assert.Equal(parserInput.EndPosition, message.EndPosition); } if (messageParameters?.Length > 0) { var expectedMessage = string.Format( CompilerMessages.Get(messageId), messageParameters); Assert.Equal(expectedMessage, message.Message); } } }
public CompilerMessage(CompilerMessageType type, string message, CompilerMessageLocation location) { Type = type; Message = message; Location = location; }
static TaskErrorCategory ConvertMessageType(CompilerMessageType type) { switch (type) { case CompilerMessageType.FatalError: return TaskErrorCategory.Error; case CompilerMessageType.Error: return TaskErrorCategory.Error; case CompilerMessageType.Warning: return TaskErrorCategory.Warning; case CompilerMessageType.Hint: return TaskErrorCategory.Message; default: return TaskErrorCategory.Error; } }