Skip to content

Commit

Permalink
Provide completions after variable resource param
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunayf committed Nov 6, 2023
1 parent 39298db commit 9ae8b30
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3823,6 +3823,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn
}

if (resourceFunctions.size() == 0) {
checkExpr(resourceAccessInvocation.resourceAccessPathSegments, data);
dlog.error(resourceAccessInvocation.resourceAccessPathSegments.pos, DiagnosticErrorCode.UNDEFINED_RESOURCE,
lhsExprType);
data.resultType = symTable.semanticError;
Expand All @@ -3833,10 +3834,12 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn
resourceFunctions.removeIf(func -> !func.accessor.value.equals(resourceAccessInvocation.name.value));
int targetResourceFuncCount = resourceFunctions.size();
if (targetResourceFuncCount == 0) {
checkExpr(resourceAccessInvocation.resourceAccessPathSegments, data);
dlog.error(resourceAccessInvocation.name.pos,
DiagnosticErrorCode.UNDEFINED_RESOURCE_METHOD, resourceAccessInvocation.name, lhsExprType);
data.resultType = symTable.semanticError;
} else if (targetResourceFuncCount > 1) {
checkExpr(resourceAccessInvocation.resourceAccessPathSegments, data);
dlog.error(resourceAccessInvocation.pos, DiagnosticErrorCode.AMBIGUOUS_RESOURCE_ACCESS_NOT_YET_SUPPORTED);
data.resultType = symTable.semanticError;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"position": {
"line": 7,
"character": 25
},
"source": "action_node_context/source/client_resource_access_action_source37.bal",
"description": "",
"items": [
{
"label": "/third",
"kind": "Function",
"detail": "()",
"documentation": {
"right": {
"kind": "markdown",
"value": "**Package:** _._ \n \n \n**Params** \n- `string` second"
}
},
"sortText": "C",
"filterText": "third|get",
"insertText": "/third;",
"insertTextFormat": "Snippet",
"additionalTextEdits": [
{
"range": {
"start": {
"line": 7,
"character": 24
},
"end": {
"line": 7,
"character": 25
}
},
"newText": ""
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
client class MyClient {
resource function get first/[string second]/third() {}
}

public function main() {
string someVar = "check";
MyClient cl = new;
cl->/first/[someVar]/;
}

0 comments on commit 9ae8b30

Please sign in to comment.