AnalyzerMessage { public AnalyzerMessage(JavaCheck check, InputComponent inputComponent, int line, String message, int cost) { this(check, inputComponent, line > 0 ? new TextSpan(line) : null, message, cost); } AnalyzerMessage(JavaCheck check, InputComponent inputComponent, int line, String message, int cost);  AnalyzerMessage(JavaCheck check, InputComponent inputComponent, @Nullable TextSpan textSpan, String message, int cost); JavaCheck getCheck(); InputComponent getInputComponent(); @Nullable TextSpan primaryLocation(); @Nullable Integer getLine(); String getMessage(); @Nullable Double getCost(); static AnalyzerMessage.TextSpan textSpanFor(Tree syntaxNode); static AnalyzerMessage.TextSpan textSpanBetween(Tree startTree, Tree endTree); @Override String toString(); final List<List<AnalyzerMessage>> flows; }
@Test void testAnalyzerMessage() { JavaCheck javaCheck = mock(JavaCheck.class); InputFile file = TestUtils.emptyInputFile("a"); int line = 5; String message = "analyzer message"; int cost = 3; AnalyzerMessage analyzerMessage = new AnalyzerMessage(javaCheck, file, line, message, cost); assertThat(analyzerMessage.getCheck()).isEqualTo(javaCheck); assertThat(analyzerMessage.getInputComponent()).isEqualTo(file); assertThat(analyzerMessage.getLine()).isEqualTo(line); assertThat(analyzerMessage.getMessage()).isEqualTo(message); assertThat(analyzerMessage.getCost()).isEqualTo(cost); AnalyzerMessage.TextSpan location = analyzerMessage.primaryLocation(); assertThat(location).hasToString("(5:-1)-(5:-1)"); assertThat(location.startLine).isEqualTo(line); assertThat(location.startCharacter).isEqualTo(-1); assertThat(location.endLine).isEqualTo(line); assertThat(location.endCharacter).isEqualTo(-1); assertThat(location.isEmpty()).isTrue(); }