-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support invoking actions directly in Ballerina shell #41587
Support invoking actions directly in Ballerina shell #41587
Conversation
3ddab8a
to
477f2d1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41587 +/- ##
=============================================
+ Coverage 0.00% 76.67% +76.67%
- Complexity 0 53101 +53101
=============================================
Files 9 2884 +2875
Lines 35 200222 +200187
Branches 0 26081 +26081
=============================================
+ Hits 0 153529 +153529
- Misses 35 38260 +38225
- Partials 0 8433 +8433 ☔ View full report in Codecov by Sentry. |
.../modules/shell-core/src/test/java/io/ballerina/shell/test/evaluator/ActionEvaluatorTest.java
Outdated
Show resolved
Hide resolved
477f2d1
to
fb46ac9
Compare
fb46ac9
to
e7b1f00
Compare
304c027
to
05e40dd
Compare
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
...modules/shell-core/src/main/java/io/ballerina/shell/snippet/factory/BasicSnippetFactory.java
Outdated
Show resolved
Hide resolved
4f617d4
to
67f7834
Compare
054d6fa
to
804049f
Compare
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
.../modules/shell-core/src/test/java/io/ballerina/shell/test/evaluator/ActionEvaluatorTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Added a few minor suggestions.
Purpose
Since Ballerina does not allow actions to be invoked at the module level, the current implementation has the limitation of invoking an action. As a workaround, this PR wraps the action in a function and returns the value to the module-level declared variable.
Fixes #39960
Fixes #39893
Approach
The new implementation wraps the action inside a function and returns the value to a module-level variable. Considering the user's input
http:Response response = check clientEndpoint->get("/entries");
, the shell generates the following snippet as a workaround for the issue.Samples
The following types of actions are now supported in Ballerina shell with this PR.
Remarks
Still, the user cannot assign the output of an action to a
var
variable. This requires additional implementation since we have to intact the semantic model to determine the return type of the action and then generate the custom function.Additionally, since the shell generates a function for each action, those function names are now disallowed for the user.
Check List