Skip to content

Commit

Permalink
Extra debug info for the KLSP (#3872)
Browse files Browse the repository at this point in the history
Small PR to help with showing more information about how the KLSP finds
the `cache.bin` file.

Co-authored-by: rv-jenkins <[email protected]>
  • Loading branch information
radumereuta and rv-jenkins authored Dec 13, 2023
1 parent 585d74e commit a4e9877
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void findCacheFile() {
cacheFile =
Files.walk(Path.of(URI.create(workspaceFolder.getUri())))
.filter(p -> p.endsWith(CACHE_FILE_NAME))
.findFirst();
.min(Comparator.comparing(Path::getNameCount, Comparator.naturalOrder()));
clientLogger.logMessage("Found cache file: " + cacheFile);
loadCaches();
} catch (IOException e) {
clientLogger.logMessage("findCachesException: " + e);
Expand All @@ -81,7 +82,7 @@ public void loadCaches() {
// this way we can find all the updated locations when finding references
if (!files.containsKey(uri)) add(uri);
});
clientLogger.logMessage("loaded cached modules: " + caches.size());
clientLogger.logMessage("Loaded cached modules: " + caches.size());
}

public void add(String uri) {
Expand Down
3 changes: 2 additions & 1 deletion kernel/src/test/java/org/kframework/lsp/LSPTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void testKLSPathK() throws IOException {
Optional<Path> cacheFile =
Files.walk(Path.of(URI.create(workspaceFolder.getUri())))
.filter(p -> p.endsWith(Kompile.CACHE_FILE_NAME))
.findFirst();
.min(Comparator.comparing(Path::getNameCount, Comparator.naturalOrder()));
if (cacheFile.isPresent())
caches = loader.loadCache(java.util.Map.class, cacheFile.get().toFile());

Expand Down

0 comments on commit a4e9877

Please sign in to comment.