diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16.json new file mode 100644 index 000000000000..3b8de757522c --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16.json @@ -0,0 +1,309 @@ +{ + "position": { + "line": 3, + "character": 12 + }, + "source": "function_body/source/source16.bal", + "description": "Test completions after qualified name in function body block", + "items": [ + { + "label": "TEST_INT_CONST1", + "kind": "Variable", + "detail": "1", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "C", + "insertText": "TEST_INT_CONST1", + "insertTextFormat": "Snippet" + }, + { + "label": "TEST_STRING_CONST1", + "kind": "Variable", + "detail": "\"HELLO WORLD\"", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "C", + "insertText": "TEST_STRING_CONST1", + "insertTextFormat": "Snippet" + }, + { + "label": "ENUM1_FIELD1", + "kind": "EnumMember", + "detail": "\"ENUM1_FIELD1\"", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "H", + "insertText": "ENUM1_FIELD1", + "insertTextFormat": "Snippet" + }, + { + "label": "AnnotationType", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "AnnotationType", + "insertTextFormat": "Snippet" + }, + { + "label": "ResponseMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `listener` when sending out the outbound response." + }, + "sortText": "I", + "insertText": "ResponseMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "RequestMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `client` when sending out the outbound request." + }, + "sortText": "I", + "insertText": "RequestMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The types of data values that are expected by the `client` to return after the data binding operation." + }, + "sortText": "N", + "insertText": "TargetType", + "insertTextFormat": "Snippet" + }, + { + "label": "ClientError", + "kind": "Event", + "detail": "Error", + "documentation": { + "left": "Defines the possible client error types." + }, + "sortText": "L", + "insertText": "ClientError", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType2", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The super type of all the types." + }, + "sortText": "N", + "insertText": "TargetType2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestEnum1", + "kind": "Enum", + "detail": "enum", + "sortText": "I", + "insertText": "TestEnum1", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord1", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "TestRecord1", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord2", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "TestRecord2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap2", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "N", + "insertText": "TestMap2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap3", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "N", + "insertText": "TestMap3", + "insertTextFormat": "Snippet" + }, + { + "label": "TestObject1", + "kind": "Interface", + "detail": "Object", + "sortText": "K", + "insertText": "TestObject1", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorOne", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "ErrorOne", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorTwo", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "ErrorTwo", + "insertTextFormat": "Snippet" + }, + { + "label": "Client", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes functions for the standard HTTP methods, forwarding a received request and sending requests\nusing custom HTTP verbs." + }, + "sortText": "K", + "insertText": "Client", + "insertTextFormat": "Snippet" + }, + { + "label": "Response", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "Represents a response.\n" + }, + "sortText": "K", + "insertText": "Response", + "insertTextFormat": "Snippet" + }, + { + "label": "Listener", + "kind": "Interface", + "detail": "Class", + "sortText": "K", + "insertText": "Listener", + "insertTextFormat": "Snippet" + }, + { + "label": "TestClass1", + "kind": "Interface", + "detail": "Class", + "sortText": "K", + "insertText": "TestClass1", + "insertTextFormat": "Snippet" + }, + { + "label": "TEST_FUTURE_INT", + "kind": "Variable", + "detail": "future", + "sortText": "C", + "insertText": "TEST_FUTURE_INT", + "insertTextFormat": "Snippet" + }, + { + "label": "GLOBAL_VAR", + "kind": "Variable", + "detail": "int", + "sortText": "C", + "insertText": "GLOBAL_VAR", + "insertTextFormat": "Snippet" + }, + { + "label": "listener1", + "kind": "Variable", + "detail": "module1:Listener", + "sortText": "C", + "insertText": "listener1", + "insertTextFormat": "Snippet" + }, + { + "label": "function1()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \n \n" + } + }, + "sortText": "A", + "filterText": "function1", + "insertText": "function1()", + "insertTextFormat": "Snippet" + }, + { + "label": "function2()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function2 \n" + } + }, + "sortText": "A", + "filterText": "function2", + "insertText": "function2()", + "insertTextFormat": "Snippet" + }, + { + "label": "function3(int param1, int param2, float... param3)", + "kind": "Function", + "detail": "int", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function3 with input parameters\n \n**Params** \n- `int` param1: param1 Parameter Description \n- `int` param2: param2 Parameter Description \n- `float[]` param3: param3 Parameter Description \n \n**Return** `int` \n- Return Value Description \n \n" + } + }, + "sortText": "A", + "filterText": "function3", + "insertText": "function3(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "function4(int param1, int param2, string param3, float... param4)", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function4 with input parameters\n \n**Params** \n- `int` param1: param1 Parameter Description \n- `int` param2: param2 Parameter Description \n- `string` param3: param3 Parameter Description(Defaultable) \n- `float[]` param4: param4 Parameter Description" + } + }, + "sortText": "A", + "filterText": "function4", + "insertText": "function4(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config17.json new file mode 100644 index 000000000000..262d8afe3d0f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config17.json @@ -0,0 +1,309 @@ +{ + "position": { + "line": 3, + "character": 13 + }, + "source": "function_body/source/source17.bal", + "description": "Test completions after qualified name in function body block", + "items": [ + { + "label": "TEST_INT_CONST1", + "kind": "Variable", + "detail": "1", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "C", + "insertText": "TEST_INT_CONST1", + "insertTextFormat": "Snippet" + }, + { + "label": "TEST_STRING_CONST1", + "kind": "Variable", + "detail": "\"HELLO WORLD\"", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "C", + "insertText": "TEST_STRING_CONST1", + "insertTextFormat": "Snippet" + }, + { + "label": "ENUM1_FIELD1", + "kind": "EnumMember", + "detail": "\"ENUM1_FIELD1\"", + "documentation": { + "right": { + "kind": "markdown", + "value": "" + } + }, + "sortText": "H", + "insertText": "ENUM1_FIELD1", + "insertTextFormat": "Snippet" + }, + { + "label": "AnnotationType", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "AnnotationType", + "insertTextFormat": "Snippet" + }, + { + "label": "ResponseMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `listener` when sending out the outbound response." + }, + "sortText": "I", + "insertText": "ResponseMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "RequestMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `client` when sending out the outbound request." + }, + "sortText": "I", + "insertText": "RequestMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The types of data values that are expected by the `client` to return after the data binding operation." + }, + "sortText": "N", + "insertText": "TargetType", + "insertTextFormat": "Snippet" + }, + { + "label": "ClientError", + "kind": "Event", + "detail": "Error", + "documentation": { + "left": "Defines the possible client error types." + }, + "sortText": "L", + "insertText": "ClientError", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType2", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The super type of all the types." + }, + "sortText": "N", + "insertText": "TargetType2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestEnum1", + "kind": "Enum", + "detail": "enum", + "sortText": "I", + "insertText": "TestEnum1", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord1", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "TestRecord1", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord2", + "kind": "Struct", + "detail": "Record", + "sortText": "M", + "insertText": "TestRecord2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap2", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "N", + "insertText": "TestMap2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap3", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "N", + "insertText": "TestMap3", + "insertTextFormat": "Snippet" + }, + { + "label": "TestObject1", + "kind": "Interface", + "detail": "Object", + "sortText": "K", + "insertText": "TestObject1", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorOne", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "ErrorOne", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorTwo", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "ErrorTwo", + "insertTextFormat": "Snippet" + }, + { + "label": "Client", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes functions for the standard HTTP methods, forwarding a received request and sending requests\nusing custom HTTP verbs." + }, + "sortText": "K", + "insertText": "Client", + "insertTextFormat": "Snippet" + }, + { + "label": "Response", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "Represents a response.\n" + }, + "sortText": "K", + "insertText": "Response", + "insertTextFormat": "Snippet" + }, + { + "label": "Listener", + "kind": "Interface", + "detail": "Class", + "sortText": "K", + "insertText": "Listener", + "insertTextFormat": "Snippet" + }, + { + "label": "TestClass1", + "kind": "Interface", + "detail": "Class", + "sortText": "K", + "insertText": "TestClass1", + "insertTextFormat": "Snippet" + }, + { + "label": "TEST_FUTURE_INT", + "kind": "Variable", + "detail": "future", + "sortText": "C", + "insertText": "TEST_FUTURE_INT", + "insertTextFormat": "Snippet" + }, + { + "label": "GLOBAL_VAR", + "kind": "Variable", + "detail": "int", + "sortText": "C", + "insertText": "GLOBAL_VAR", + "insertTextFormat": "Snippet" + }, + { + "label": "listener1", + "kind": "Variable", + "detail": "module1:Listener", + "sortText": "C", + "insertText": "listener1", + "insertTextFormat": "Snippet" + }, + { + "label": "function1()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \n \n" + } + }, + "sortText": "A", + "filterText": "function1", + "insertText": "function1()", + "insertTextFormat": "Snippet" + }, + { + "label": "function2()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function2 \n" + } + }, + "sortText": "A", + "filterText": "function2", + "insertText": "function2()", + "insertTextFormat": "Snippet" + }, + { + "label": "function3(int param1, int param2, float... param3)", + "kind": "Function", + "detail": "int", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function3 with input parameters\n \n**Params** \n- `int` param1: param1 Parameter Description \n- `int` param2: param2 Parameter Description \n- `float[]` param3: param3 Parameter Description \n \n**Return** `int` \n- Return Value Description \n \n" + } + }, + "sortText": "A", + "filterText": "function3", + "insertText": "function3(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "function4(int param1, int param2, string param3, float... param4)", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/module1:0.1.0_ \n \nThis is function4 with input parameters\n \n**Params** \n- `int` param1: param1 Parameter Description \n- `int` param2: param2 Parameter Description \n- `string` param3: param3 Parameter Description(Defaultable) \n- `float[]` param4: param4 Parameter Description" + } + }, + "sortText": "A", + "filterText": "function4", + "insertText": "function4(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16.bal b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16.bal new file mode 100644 index 000000000000..a976ed6b8699 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16.bal @@ -0,0 +1,7 @@ +import ballerina/module1; + +public function main() { + module1: + + map data = {}; +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source17.bal b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source17.bal new file mode 100644 index 000000000000..c13002e5af40 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source17.bal @@ -0,0 +1,7 @@ +import ballerina/module1; + +public function main() { + module1:T + + map data = {}; +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config18.json new file mode 100644 index 000000000000..cf924242df85 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config18.json @@ -0,0 +1,167 @@ +{ + "position": { + "line": 2, + "character": 8 + }, + "source": "module_part_context/source/source19.bal", + "description": "Test completions after qualified name in module part node", + "items": [ + { + "label": "AnnotationType", + "kind": "Struct", + "detail": "Record", + "sortText": "CA", + "insertText": "AnnotationType", + "insertTextFormat": "Snippet" + }, + { + "label": "ResponseMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `listener` when sending out the outbound response." + }, + "sortText": "CA", + "insertText": "ResponseMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "RequestMessage", + "kind": "Enum", + "detail": "Union", + "documentation": { + "left": "The types of messages that are accepted by HTTP `client` when sending out the outbound request." + }, + "sortText": "CA", + "insertText": "RequestMessage", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The types of data values that are expected by the `client` to return after the data binding operation." + }, + "sortText": "CA", + "insertText": "TargetType", + "insertTextFormat": "Snippet" + }, + { + "label": "ClientError", + "kind": "Event", + "detail": "Error", + "documentation": { + "left": "Defines the possible client error types." + }, + "sortText": "CA", + "insertText": "ClientError", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType2", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The super type of all the types." + }, + "sortText": "CA", + "insertText": "TargetType2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord1", + "kind": "Struct", + "detail": "Record", + "sortText": "CA", + "insertText": "TestRecord1", + "insertTextFormat": "Snippet" + }, + { + "label": "TestRecord2", + "kind": "Struct", + "detail": "Record", + "sortText": "CA", + "insertText": "TestRecord2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap2", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "CA", + "insertText": "TestMap2", + "insertTextFormat": "Snippet" + }, + { + "label": "TestMap3", + "kind": "TypeParameter", + "detail": "Map", + "sortText": "CA", + "insertText": "TestMap3", + "insertTextFormat": "Snippet" + }, + { + "label": "TestObject1", + "kind": "Interface", + "detail": "Object", + "sortText": "CA", + "insertText": "TestObject1", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorOne", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "ErrorOne", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorTwo", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "ErrorTwo", + "insertTextFormat": "Snippet" + }, + { + "label": "Client", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes functions for the standard HTTP methods, forwarding a received request and sending requests\nusing custom HTTP verbs." + }, + "sortText": "CA", + "insertText": "Client", + "insertTextFormat": "Snippet" + }, + { + "label": "Response", + "kind": "Interface", + "detail": "Class", + "documentation": { + "left": "Represents a response.\n" + }, + "sortText": "CA", + "insertText": "Response", + "insertTextFormat": "Snippet" + }, + { + "label": "Listener", + "kind": "Interface", + "detail": "Class", + "sortText": "CA", + "insertText": "Listener", + "insertTextFormat": "Snippet" + }, + { + "label": "TestClass1", + "kind": "Interface", + "detail": "Class", + "sortText": "CA", + "insertText": "TestClass1", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source19.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source19.bal new file mode 100644 index 000000000000..26fcba739fae --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source19.bal @@ -0,0 +1,8 @@ +import ballerina/module1; + +module1: + +map data = {}; + +public function main() { +}