Skip to content

Commit bb771f0

Browse files
committed
Release 0.0.39
1 parent ab71fe8 commit bb771f0

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "liquid-java",
33
"displayName": "LiquidJava",
44
"description": "Extending Java with Liquid Types",
5-
"version": "0.0.38",
5+
"version": "0.0.39",
66
"publisher": "AlcidesFonseca",
77
"repository": {
88
"type": "git",
389 Bytes
Binary file not shown.

server/src/main/java/LJDiagnostics.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import java.util.ArrayList;
33
import java.util.Collections;
44
import java.util.List;
5+
import java.util.Map;
6+
import java.util.stream.Collectors;
57
import org.eclipse.lsp4j.Diagnostic;
68
import org.eclipse.lsp4j.DiagnosticSeverity;
79
import org.eclipse.lsp4j.Position;
@@ -54,13 +56,21 @@ public static List<PublishDiagnosticsParams> generateDiagnostics(String uri) {
5456
*/
5557
public static List<PublishDiagnosticsParams> getDiagnostics(List<LJDiagnostic> diagnostics,
5658
DiagnosticSeverity severity) {
57-
return diagnostics.stream().map(d -> {
58-
String filePath = FILE_PREFIX + d.getFile();
59-
Range range = getRangeFromErrorPosition(d.getPosition());
60-
String message = String.format("%s: %s", d.getTitle(), d.getMessage());
61-
Diagnostic diagnostic = new Diagnostic(range, message, severity, SOURCE);
62-
return new PublishDiagnosticsParams(filePath, List.of(diagnostic));
63-
}).toList();
59+
// group diagnostics by file
60+
Map<String, List<Diagnostic>> diagnosticsByFile = diagnostics.stream()
61+
.collect(Collectors.groupingBy(
62+
d -> FILE_PREFIX + d.getFile(),
63+
Collectors.mapping(d -> {
64+
Range range = getRangeFromErrorPosition(d.getPosition());
65+
String message = String.format("%s: %s", d.getTitle(), d.getMessage());
66+
return new Diagnostic(range, message, severity, SOURCE);
67+
}, Collectors.toList())
68+
));
69+
70+
// create a PublishDiagnosticsParams per file with all its diagnostics
71+
return diagnosticsByFile.entrySet().stream()
72+
.map(entry -> new PublishDiagnosticsParams(entry.getKey(), entry.getValue()))
73+
.toList();
6474
}
6575

6676
/**

0 commit comments

Comments
 (0)