diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java index 2c70b506af23..caf4b30d4ea1 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java @@ -16,9 +16,9 @@ package org.ballerinalang.langserver; import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -import com.google.gson.Gson; import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.projects.Module; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/ModuleObject.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/ModuleObject.java index 0704f0cab044..d480b5606243 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/ModuleObject.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/packages/ModuleObject.java @@ -92,7 +92,7 @@ private void addListener(DataObject dataObject) { } private void addEnum(DataObject dataObject) { - this.listeners.add(dataObject); + this.enums.add(dataObject); } protected void addDataObject(MapperObject mapperObject) { diff --git a/language-server/modules/langserver-core/src/test/resources/packages/components/multiple-packages_expected.json b/language-server/modules/langserver-core/src/test/resources/packages/components/multiple-packages_expected.json index fff340d5d9be..4a225bd496fb 100644 --- a/language-server/modules/langserver-core/src/test/resources/packages/components/multiple-packages_expected.json +++ b/language-server/modules/langserver-core/src/test/resources/packages/components/multiple-packages_expected.json @@ -4,38 +4,6 @@ "name": "project", "filePath": "file:///", "modules": [ - { - "functions": [ - { - "name": "main", - "filePath": "main.bal", - "startLine": 3, - "startColumn": 0, - "endLine": 6, - "endColumn": 1 - } - ], - "services": [], - "records": [], - "objects": [], - "classes": [], - "types": [], - "constants": [], - "enums": [], - "listeners": [], - "moduleVariables": [], - "configurableVariables": [], - "automations": [ - { - "name": "main", - "filePath": "main.bal", - "startLine": 3, - "startColumn": 0, - "endLine": 6, - "endColumn": 1 - } - ] - }, { "functions": [], "services": [ @@ -69,6 +37,38 @@ "configurableVariables": [], "automations": [], "name": "services" + }, + { + "functions": [ + { + "name": "main", + "filePath": "main.bal", + "startLine": 3, + "startColumn": 0, + "endLine": 6, + "endColumn": 1 + } + ], + "services": [], + "records": [], + "objects": [], + "classes": [], + "types": [], + "constants": [], + "enums": [], + "listeners": [], + "moduleVariables": [], + "configurableVariables": [], + "automations": [ + { + "name": "main", + "filePath": "main.bal", + "startLine": 3, + "startColumn": 0, + "endLine": 6, + "endColumn": 1 + } + ] } ] }, @@ -103,8 +103,8 @@ { "functions": [ { - "name": "runServices", - "filePath": "svc.bal", + "name": "main", + "filePath": "main.bal", "startLine": 3, "startColumn": 0, "endLine": 6, @@ -121,14 +121,22 @@ "listeners": [], "moduleVariables": [], "configurableVariables": [], - "automations": [], - "name": "services" + "automations": [ + { + "name": "main", + "filePath": "main.bal", + "startLine": 3, + "startColumn": 0, + "endLine": 6, + "endColumn": 1 + } + ] }, { "functions": [ { - "name": "main", - "filePath": "main.bal", + "name": "runServices", + "filePath": "svc.bal", "startLine": 3, "startColumn": 0, "endLine": 6, @@ -145,16 +153,8 @@ "listeners": [], "moduleVariables": [], "configurableVariables": [], - "automations": [ - { - "name": "main", - "filePath": "main.bal", - "startLine": 3, - "startColumn": 0, - "endLine": 6, - "endColumn": 1 - } - ] + "automations": [], + "name": "services" } ] }, @@ -166,19 +166,19 @@ "functions": [], "services": [ { - "name": "/hello ", - "filePath": "hello.bal", - "startLine": 5, + "name": "/ ", + "filePath": "main.bal", + "startLine": 3, "startColumn": 0, - "endLine": 13, + "endLine": 11, "endColumn": 1, "resources": [ { - "name": "get-satyHello", - "filePath": "hello.bal", - "startLine": 10, + "name": "get-welcome", + "filePath": "main.bal", + "startLine": 8, "startColumn": 4, - "endLine": 12, + "endLine": 10, "endColumn": 5 } ] @@ -190,20 +190,10 @@ "types": [], "constants": [], "enums": [], - "listeners": [ - { - "name": "helloEp", - "filePath": "hello.bal", - "startLine": 2, - "startColumn": 0, - "endLine": 2, - "endColumn": 44 - } - ], + "listeners": [], "moduleVariables": [], "configurableVariables": [], - "automations": [], - "name": "hello_service" + "automations": [] }, { "functions": [], @@ -243,19 +233,19 @@ "functions": [], "services": [ { - "name": "/ ", - "filePath": "main.bal", - "startLine": 3, + "name": "/hello ", + "filePath": "hello.bal", + "startLine": 5, "startColumn": 0, - "endLine": 11, + "endLine": 13, "endColumn": 1, "resources": [ { - "name": "get-welcome", - "filePath": "main.bal", - "startLine": 8, + "name": "get-satyHello", + "filePath": "hello.bal", + "startLine": 10, "startColumn": 4, - "endLine": 10, + "endLine": 12, "endColumn": 5 } ] @@ -267,10 +257,20 @@ "types": [], "constants": [], "enums": [], - "listeners": [], + "listeners": [ + { + "name": "helloEp", + "filePath": "hello.bal", + "startLine": 2, + "startColumn": 0, + "endLine": 2, + "endColumn": 44 + } + ], "moduleVariables": [], "configurableVariables": [], - "automations": [] + "automations": [], + "name": "hello_service" } ] }, @@ -377,8 +377,7 @@ "endColumn": 30 } ], - "enums": [], - "listeners": [ + "enums": [ { "name": "Color", "filePath": "main.bal", @@ -388,6 +387,7 @@ "endColumn": 1 } ], + "listeners": [], "moduleVariables": [ { "name": "modLevelVariable ", diff --git a/language-server/modules/langserver-core/src/test/resources/packages/components/project-other_expected.json b/language-server/modules/langserver-core/src/test/resources/packages/components/project-other_expected.json index f428396d926c..9aef28e69104 100644 --- a/language-server/modules/langserver-core/src/test/resources/packages/components/project-other_expected.json +++ b/language-server/modules/langserver-core/src/test/resources/packages/components/project-other_expected.json @@ -4,29 +4,6 @@ "name": "project_other", "filePath": "file:///", "modules": [ - { - "functions": [ - { - "name": "multiply", - "filePath": "main.bal", - "startLine": 0, - "startColumn": 0, - "endLine": 2, - "endColumn": 1 - } - ], - "services": [], - "records": [], - "objects": [], - "classes": [], - "types": [], - "constants": [], - "enums": [], - "listeners": [], - "moduleVariables": [], - "configurableVariables": [], - "automations": [] - }, { "functions": [], "services": [], @@ -162,8 +139,7 @@ "endColumn": 41 } ], - "enums": [], - "listeners": [ + "enums": [ { "name": "Language", "filePath": "model.bal", @@ -173,6 +149,7 @@ "endColumn": 1 } ], + "listeners": [], "moduleVariables": [ { "name": "ESCAPES ", @@ -194,6 +171,29 @@ "configurableVariables": [], "automations": [], "name": "models" + }, + { + "functions": [ + { + "name": "multiply", + "filePath": "main.bal", + "startLine": 0, + "startColumn": 0, + "endLine": 2, + "endColumn": 1 + } + ], + "services": [], + "records": [], + "objects": [], + "classes": [], + "types": [], + "constants": [], + "enums": [], + "listeners": [], + "moduleVariables": [], + "configurableVariables": [], + "automations": [] } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/packages/components/single-file-package_expected.json b/language-server/modules/langserver-core/src/test/resources/packages/components/single-file-package_expected.json index 5a400e8babc6..e3b25c9184f0 100644 --- a/language-server/modules/langserver-core/src/test/resources/packages/components/single-file-package_expected.json +++ b/language-server/modules/langserver-core/src/test/resources/packages/components/single-file-package_expected.json @@ -103,8 +103,7 @@ "endColumn": 30 } ], - "enums": [], - "listeners": [ + "enums": [ { "name": "Color", "filePath": "main.bal", @@ -114,6 +113,7 @@ "endColumn": 1 } ], + "listeners": [], "moduleVariables": [ { "name": "modLevelVariable ",