diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java index 0d5b916b87d2..5654bb88bf0d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/document/BallerinaDocumentService.java @@ -403,6 +403,7 @@ public CompletableFuture project(BallerinaProjectParams if (project.isEmpty()) { return ballerinaProject; } + ballerinaProject.setOrgName(project.get().currentPackage().packageOrg().value()); ballerinaProject.setPath(project.get().sourceRoot().toString()); ProjectKind projectKind = project.get().kind(); if (projectKind != ProjectKind.SINGLE_FILE_PROJECT) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/BallerinaPackageService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/BallerinaPackageService.java index 633d4b8e99a7..726e0a6ca478 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/BallerinaPackageService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/BallerinaPackageService.java @@ -74,6 +74,7 @@ public CompletableFuture metadata(PackageMetadataReques if (project.isEmpty()) { return metadata; } + metadata.setOrgName(project.get().currentPackage().packageOrg().value()); metadata.setPath(project.get().sourceRoot().toString()); ProjectKind projectKind = project.get().kind(); if (projectKind != ProjectKind.SINGLE_FILE_PROJECT) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/PackageMetadataResponse.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/PackageMetadataResponse.java index c519301b768b..4acbbad26e53 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/PackageMetadataResponse.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/PackageMetadataResponse.java @@ -20,6 +20,7 @@ */ public class PackageMetadataResponse { + private String orgName; private String path; private String packageName; private String kind; @@ -47,4 +48,12 @@ public String getKind() { public void setKind(String kind) { this.kind = kind; } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/packages/MetadataTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/packages/MetadataTest.java index 32bcca197861..ec75c19216d1 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/packages/MetadataTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/packages/MetadataTest.java @@ -35,6 +35,7 @@ */ public class MetadataTest { + private static final String ORG_NAME = "orgName"; private static final String PACKAGE_NAME = "packageName"; private static final String PATH = "path"; private static final String KIND = "kind"; @@ -76,11 +77,21 @@ private void compareResponse(String projectName, String response) { Assert.assertNull(responseJsonObject.getAsJsonPrimitive(PACKAGE_NAME), "Package MetadataTest " + PACKAGE_NAME + " fails with " + projectName + " test case."); } - Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(KIND), - expectedJsonObject.getAsJsonPrimitive(KIND), + + JsonPrimitive projectKind = expectedJsonObject.getAsJsonPrimitive(KIND); + Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(KIND), projectKind, "Package MetadataTest " + KIND + " fails with " + projectName + " test case."); Assert.assertNotNull(responseJsonObject.getAsJsonPrimitive(PATH), "Package MetadataTest " + PATH + " fails with " + projectName + " test case."); + + Assert.assertNotNull(responseJsonObject.getAsJsonPrimitive(ORG_NAME), + "Package MetadataTest " + ORG_NAME + " fails with " + projectName + " test case."); + + if (projectKind != null && !"SINGLE_FILE_PROJECT".equals(projectKind.getAsString())) { + Assert.assertEquals(responseJsonObject.getAsJsonPrimitive(ORG_NAME), + expectedJsonObject.getAsJsonPrimitive(ORG_NAME), + "Package MetadataTest " + ORG_NAME + " fails with " + projectName + " test case."); + } } @AfterClass diff --git a/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-functions_expected.json b/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-functions_expected.json index 5dbb406670cb..784b48a82725 100644 --- a/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-functions_expected.json +++ b/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-functions_expected.json @@ -1,4 +1,5 @@ { + "orgName": "wso2", "packageName": "project_functions", "kind": "BUILD_PROJECT", "path": "file:///" diff --git a/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-services_expected.json b/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-services_expected.json index b4f44e944415..362957d983e5 100644 --- a/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-services_expected.json +++ b/language-server/modules/langserver-core/src/test/resources/packages/metadata/project-services_expected.json @@ -1,4 +1,5 @@ { + "orgName": "bob", "packageName": "project_services", "kind": "BUILD_PROJECT", "path": "file:///"