Skip to content

Commit

Permalink
Merge pull request #41873 from axewilledge/2201.8.x_origin
Browse files Browse the repository at this point in the history
[2201.8.x] Update component fetch logic
  • Loading branch information
axewilledge authored Jan 9, 2024
2 parents e3c05d9 + fce3914 commit a955730
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ public CompletableFuture<PackageComponentsResponse> components(PackageComponents
try {
Arrays.stream(documentIdentifiers).iterator().forEachRemaining(documentIdentifier -> {
PathUtil.getPathFromURI(documentIdentifier.getUri()).ifPresent(path -> {
Optional<Project> project = this.workspaceManager.project(path);
project.ifPresent(value -> jsonPackages.add(getPackageComponents(value)));
Project project = null;
try {
project = this.workspaceManager.loadProject(path);
jsonPackages.add(getPackageComponents(project));
} catch (Throwable e) {
String msg = "Operation 'ballerinaPackage/components' load project failed!";
this.clientLogger.logError(PackageContext.PACKAGE_COMPONENTS, msg, e, null);
}
});
});
response.setProjectPackages(jsonPackages);
} catch (Throwable e) {
String msg = "Operation 'ballerinaPackage/components' failed!";
this.clientLogger.logError(PackageContext.PACKAGE_COMPONENTS, msg, e, null, (Position) null);
}
response.setProjectPackages(jsonPackages);
return response;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void packageComponentsTestCase(String[] projects, String expected) throws
List<String> filePaths = new ArrayList<>();
for (String project : projects) {
Path path = configsPath.resolve(project).resolve("main.bal").toAbsolutePath();
TestUtil.openDocument(serviceEndpoint, path);
filePaths.add(path.toString());
}

Expand Down Expand Up @@ -133,7 +132,8 @@ public Object[][] getDataProvider() {
{new String[]{"project", "project-functions", "project-services", "single-file"},
"multiple-packages_expected.json"},
{new String[]{"single-file"}, "single-file-package_expected.json"},
{new String[]{"project-other"}, "project-other_expected.json"}
{new String[]{"project-other"}, "project-other_expected.json"},
{new String[]{"non-exist"}, "project-exception_expected.json"}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"result": []
}

0 comments on commit a955730

Please sign in to comment.