Skip to content

Commit 81eefc2

Browse files
committed
Fix linting
1 parent f2c112d commit 81eefc2

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

‎src/main/java/org/javacs/JavaLanguageServer.java‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public void didOpen(DidOpenTextDocumentParams params) {
295295

296296
activeDocuments.put(uri, new VersionedContent(document.getText(), document.getVersion()));
297297

298-
doLintAndIndex(Collections.singleton(uri));
298+
doLint(Collections.singleton(uri));
299299
} catch (NoJavaConfigException e) {
300300
throw ShowMessageException.warning(e.getMessage(), e);
301301
}
@@ -333,7 +333,7 @@ public void didClose(DidCloseTextDocumentParams params) {
333333
@Override
334334
public void didSave(DidSaveTextDocumentParams params) {
335335
// Re-lint all active documents
336-
doLintAndIndex(activeDocuments.keySet());
336+
doLint(activeDocuments.keySet());
337337

338338
// Re-index javadocs of saved document
339339
URI uri = URI.create(params.getTextDocument().getUri());
@@ -381,21 +381,17 @@ private String patch(String sourceText, TextDocumentContentChangeEvent change) {
381381
}
382382
}
383383

384-
private void doLintAndIndex(Collection<URI> paths) {
384+
private void doLint(Collection<URI> paths) {
385385
LOG.info("Lint " + Joiner.on(", ").join(paths));
386386

387-
Map<JavacConfig, Map<URI, Optional<String>>> files = new HashMap<>();
388-
389-
for (URI each : paths) {
390-
file(each).flatMap(findConfig::forFile).ifPresent(config -> {
391-
files.computeIfAbsent(config, newConfig -> new HashMap<>()).put(each, Optional.empty());
392-
});
393-
}
394-
387+
Map<JavacHolder, Set<URI>> files = paths.stream()
388+
.collect(Collectors.groupingBy(this::findCompiler, Collectors.toSet()));
395389
List<javax.tools.Diagnostic<? extends JavaFileObject>> errors = new ArrayList<>();
396390

397-
files.forEach((config, configFiles) -> {
398-
BatchResult compile = findCompilerForConfig(config).compileBatch(configFiles);
391+
files.forEach((compiler, someFiles) -> {
392+
Map<URI, Optional<String>> content = someFiles.stream()
393+
.collect(Collectors.toMap(f -> f, this::activeContent));
394+
BatchResult compile = compiler.compileBatch(content);
399395

400396
errors.addAll(compile.errors.getDiagnostics());
401397
});

0 commit comments

Comments
 (0)