Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ private static LogAccessor getLogAccessor(NotificationCategory category) {
static String format(Notification notification, String forQuery) {

InputPosition position = notification.position();
boolean hasPosition = position != null;

StringBuilder queryHint = new StringBuilder();
String[] lines = forQuery.split("(\r\n|\n)");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
queryHint.append("\t").append(line).append(LINE_SEPARATOR);
if (i + 1 == position.line()) {
if (hasPosition && i + 1 == position.line()) {
queryHint.append("\t").append(Stream.generate(() -> " ").limit(position.column() - 1)
.collect(Collectors.joining())).append("^").append(System.lineSeparator());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,24 @@ private static Stream<Arguments> params() {
+ "\tmatch (n) " + LINE_SEPARATOR
+ "\t- [r:FOO*] -> (m) " + LINE_SEPARATOR
+ "\t^" + LINE_SEPARATOR
+ "\tRETURN r" + LINE_SEPARATOR)
+ "\tRETURN r" + LINE_SEPARATOR),
Arguments.of("match (n) - [r] -> (m) RETURN r", null, null, ""
+ "\tmatch (n) - [r] -> (m) RETURN r" + LINE_SEPARATOR)
);
}

@ParameterizedTest(name = "{index}: Notifications for \"{0}\"")
@MethodSource("params")
void shouldFormatNotifications(String query, int line, int column, String expected) {
void shouldFormatNotifications(String query, Integer line, Integer column, String expected) {

InputPosition inputPosition = mock(InputPosition.class);
when(inputPosition.line()).thenReturn(line);
when(inputPosition.column()).thenReturn(column);
InputPosition inputPosition;
if (line == null || column == null) {
inputPosition = null;
} else {
inputPosition = mock(InputPosition.class);
when(inputPosition.line()).thenReturn(line);
when(inputPosition.column()).thenReturn(column);
}

Notification notification = mock(Notification.class);
when(notification.severity()).thenReturn("WARNING");
Expand Down