Skip to content

Commit

Permalink
Fix jar file loading on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Coalwell committed Apr 19, 2022
1 parent 40993b8 commit be2e5d7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/software/amazon/smithy/lsp/ext/SmithyProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ private static Map<String, List<Location>> collectLocations(Model model) {
.distinct()
.collect(Collectors.toList());
for (String modelFile : modelFiles) {
Path modelPath = Paths.get(modelFile);
List<String> lines = getFileLines(modelPath);
List<String> lines = getFileLines(modelFile);
int endMarker = lines.size();

// Get shapes reverse-sorted by source location to work from bottom of file to top.
Expand Down Expand Up @@ -213,14 +212,14 @@ private static Map<String, List<Location>> collectLocations(Model model) {
return locations;
}

private static List<String> getFileLines(Path path) {
private static List<String> getFileLines(String file) {
try {
if (Utils.isSmithyJarFile(path.toString())) {
return Utils.jarFileContents(path.toString());
if (Utils.isSmithyJarFile(file)) {
return Utils.jarFileContents(file);
}
return Files.readAllLines(path);
return Files.readAllLines(Paths.get(file));
} catch (IOException e) {
LspLog.println("Path " + path + " was found in temporary buffer");
LspLog.println("File " + file + " could not be loaded.");
}
return Collections.emptyList();
}
Expand Down

0 comments on commit be2e5d7

Please sign in to comment.