Skip to content

Commit

Permalink
Merge pull request #41534 from nipunayf/bal-persist-codeaction
Browse files Browse the repository at this point in the history
Fix invalid stream signature in `CreateVariableWithTypeCodeAction`
  • Loading branch information
KavinduZoysa authored Nov 22, 2023
2 parents 88bb122 + 2b9e233 commit 3957cf1
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private String getTypeName(TypeSymbol symbol, CodeActionContext context) {
: getRawType(symbol, context).signature());
return FunctionGenerator.processModuleIDsInText(new ImportsAcceptor(context), moduleQualifiedName, context);
}
return symbol.signature();
return FunctionGenerator.processModuleIDsInText(new ImportsAcceptor(context), symbol.signature(), context);
}

private boolean isLangAnnotationModule(ModuleID moduleID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public Object[][] dataProvider() {
{"type_infer_for_remote_method_call_config1.json"},
{"type_infer_for_remote_method_call_config2.json"},
{"type_infer_for_resource_action_config.json"},
{"type_infer_for_resource_action_config2.json"},
{"type_infer_for_resource_action_with_check1.json"},
{"type_infer_for_resource_action_with_check2.json"}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"position": {
"line": 27,
"character": 23
},
"source": "source1.bal",
"expected": [
{
"title": "Create variable",
"kind": "quickfix",
"edits": [
{
"range": {
"start": {
"line": 27,
"character": 4
},
"end": {
"line": 27,
"character": 4
}
},
"newText": "stream<targetType, module1:ClientError?> streamResult = "
}
],
"resolvable": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ function testRemoteMethodCallWithCheck() returns error? {
function testRemoteMethodCallWithCheck2() returns error? {
check 'client->/path4/["pathParam"];
}

function testResourceAccessOfStreamReturnType() returns error? {
'client->/responses
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,40 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(module1:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, module1:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `module1:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, module1:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "C",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"additionalTextEdits": [
{
"range": {
"start": {
"line": 5,
"character": 22
},
"end": {
"line": 5,
"character": 23
}
},
"newText": ""
}
],
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(module1:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, module1:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `module1:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, module1:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "CC",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(module1:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, module1:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `module1:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, module1:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "CC",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(module1:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, module1:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `module1:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, module1:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "CC",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(mod:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, mod:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `mod:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, mod:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "CC",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
},
{
"label": "/responses(module1:TargetType2 targetType)",
"kind": "Function",
"detail": "stream<targetType, module1:ClientError?>",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _ballerina/module1:0.1.0_ \n \nSample resource function to return a stream of objects\n \n**Params** \n- `module1:TargetType2` targetType: Response or `anydata`, which is expected to be returned after data binding(Defaultable) \n \n**Return** `stream<targetType, module1:ClientError?>` \n- A stream of targetType and/or ClientError \n \n"
}
},
"sortText": "CC",
"filterText": "responses|get",
"insertText": "/responses(${1});",
"insertTextFormat": "Snippet",
"command": {
"title": "editor.action.triggerParameterHints",
"command": "editor.action.triggerParameterHints"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"result": {
"contents": {
"kind": "markdown",
"value": "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. \n \n--- \n \n### Fields \n \n`string` ***url*** : Target service url \n \n--- \n \n### Methods \n \n+ `remote function post(string path, module1:RequestMessage message, string targetType) returns module1:Response` \nThe `Client.post()` function can be used to send HTTP POST requests to HTTP endpoints. \n \n+ `resource function post path1/[string id1]/path2/[string... ids] (string str, string... ids2) returns module1:Response` \nSample resource method. \n \n+ `remote function get(string path, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample remote method with java interoperability \n \n+ `remote function forward(string path, handle request, module1:TargetType targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `remote function delete(module1:TargetType2 targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `resource function get path3 (module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with java interoperability \n \n+ `resource function get path4/[string pathParam] (module1:TargetType targetType) returns targetType|module1:ClientError|error` \nSample resource function with multiple target types with java interoperability \n \n+ `isolated resource function post [string... path] (module1:RequestMessage message, map<string|string[]>? headers, string? mediaType, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with rest path praram with multiple target types with java interoperability \n \n \n--- \n \n[View API Docs](https://lib.ballerina.io/ballerina/module1/0.1.0#Client)"
"value": "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. \n \n--- \n \n### Fields \n \n`string` ***url*** : Target service url \n \n--- \n \n### Methods \n \n+ `remote function post(string path, module1:RequestMessage message, string targetType) returns module1:Response` \nThe `Client.post()` function can be used to send HTTP POST requests to HTTP endpoints. \n \n+ `resource function post path1/[string id1]/path2/[string... ids] (string str, string... ids2) returns module1:Response` \nSample resource method. \n \n+ `remote function get(string path, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample remote method with java interoperability \n \n+ `remote function forward(string path, handle request, module1:TargetType targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `remote function delete(module1:TargetType2 targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `resource function get path3 (module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with java interoperability \n \n+ `resource function get path4/[string pathParam] (module1:TargetType targetType) returns targetType|module1:ClientError|error` \nSample resource function with multiple target types with java interoperability \n \n+ `isolated resource function post [string... path] (module1:RequestMessage message, map<string|string[]>? headers, string? mediaType, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with rest path praram with multiple target types with java interoperability \n \n+ `isolated resource function get responses (module1:TargetType2 targetType) returns stream<targetType, module1:ClientError?>` \nSample resource function to return a stream of objects \n \n \n--- \n \n[View API Docs](https://lib.ballerina.io/ballerina/module1/0.1.0#Client)"
}
},
"id": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"result": {
"contents": {
"kind": "markdown",
"value": "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. \n \n--- \n \n### Fields \n \n`string` ***url*** : Target service url \n \n--- \n \n### Methods \n \n+ `remote function post(string path, module1:RequestMessage message, string targetType) returns module1:Response` \nThe `Client.post()` function can be used to send HTTP POST requests to HTTP endpoints. \n \n+ `resource function post path1/[string id1]/path2/[string... ids] (string str, string... ids2) returns module1:Response` \nSample resource method. \n \n+ `remote function get(string path, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample remote method with java interoperability \n \n+ `remote function forward(string path, handle request, module1:TargetType targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `remote function delete(module1:TargetType2 targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `resource function get path3 (module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with java interoperability \n \n+ `resource function get path4/[string pathParam] (module1:TargetType targetType) returns targetType|module1:ClientError|error` \nSample resource function with multiple target types with java interoperability \n \n+ `isolated resource function post [string... path] (module1:RequestMessage message, map<string|string[]>? headers, string? mediaType, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with rest path praram with multiple target types with java interoperability \n \n \n--- \n \n[View API Docs](https://lib.ballerina.io/ballerina/module1/0.1.0#Client)"
"value": "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. \n \n--- \n \n### Fields \n \n`string` ***url*** : Target service url \n \n--- \n \n### Methods \n \n+ `remote function post(string path, module1:RequestMessage message, string targetType) returns module1:Response` \nThe `Client.post()` function can be used to send HTTP POST requests to HTTP endpoints. \n \n+ `resource function post path1/[string id1]/path2/[string... ids] (string str, string... ids2) returns module1:Response` \nSample resource method. \n \n+ `remote function get(string path, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample remote method with java interoperability \n \n+ `remote function forward(string path, handle request, module1:TargetType targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `remote function delete(module1:TargetType2 targetType) returns targetType` \nSample remote method with java interoperability \n \n+ `resource function get path3 (module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with java interoperability \n \n+ `resource function get path4/[string pathParam] (module1:TargetType targetType) returns targetType|module1:ClientError|error` \nSample resource function with multiple target types with java interoperability \n \n+ `isolated resource function post [string... path] (module1:RequestMessage message, map<string|string[]>? headers, string? mediaType, module1:TargetType targetType) returns targetType|module1:ClientError` \nSample resource function with rest path praram with multiple target types with java interoperability \n \n+ `isolated resource function get responses (module1:TargetType2 targetType) returns stream<targetType, module1:ClientError?>` \nSample resource function to return a stream of objects \n \n \n--- \n \n[View API Docs](https://lib.ballerina.io/ballerina/module1/0.1.0#Client)"
}
},
"id": {
Expand Down
Loading

0 comments on commit 3957cf1

Please sign in to comment.