Skip to content
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

Provide code actions to fix invalid transferring of an isolated value out from a lock statement #42734

Merged
merged 12 commits into from
Jul 19, 2024

Conversation

nipunayf
Copy link
Contributor

@nipunayf nipunayf commented May 10, 2024

Purpose

$title.

Fixes #42333

Approach

Introduced two code actions, namely clone value and add readonly type, to fix the respective scenarios.

Samples

Clone the value

Screen.Recording.2024-05-10.at.5.21.20.PM.mov

Clone as a readonly value

Screen.Recording.2024-05-10.at.5.21.29.PM.mov

Add readonly to type

Screen.Recording.2024-05-20.at.11.04.55.PM.mov

Remarks

  • For union types, we are enclosing the entire type instead of making each required individual type readonly.
  • The "Add readonly" code action is not supported for any and json types, as their locations cannot be captured.
  • Type reference type symbols are not supported for Add readonly code action as their original location points to the definition.

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@nipunayf nipunayf added the Team/LanguageServer Language Server Implementation related issues. #Compiler label May 10, 2024
@nipunayf nipunayf changed the title Provide code actions to fix invalid attempts to transfer out a value from a lock statement [WIP] Provide code actions to fix invalid attempts to transfer out a value from a lock statement May 10, 2024
@nipunayf nipunayf changed the title [WIP] Provide code actions to fix invalid attempts to transfer out a value from a lock statement [WIP] Provide code actions to fix invalid transferring of an isolated value out from a lock statement May 10, 2024
Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 91.93548% with 5 lines in your changes missing coverage. Please review.

Project coverage is 77.35%. Comparing base (aa29e98) to head (087ebac).
Report is 1 commits behind head on master.

Files Patch % Lines
...ver/codeaction/providers/CloneValueCodeAction.java 84.00% 2 Missing and 2 partials ⚠️
...er/codeaction/providers/AddReadonlyCodeAction.java 97.22% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #42734   +/-   ##
=========================================
  Coverage     77.35%   77.35%           
- Complexity    58262    58289   +27     
=========================================
  Files          3450     3452    +2     
  Lines        218969   219031   +62     
  Branches      28745    28755   +10     
=========================================
+ Hits         169379   169432   +53     
- Misses        40262    40268    +6     
- Partials       9328     9331    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nipunayf nipunayf added this to the 2201.10.0 milestone May 17, 2024
@nipunayf nipunayf marked this pull request as ready for review May 21, 2024 04:27
@nipunayf nipunayf changed the title [WIP] Provide code actions to fix invalid transferring of an isolated value out from a lock statement Provide code actions to fix invalid transferring of an isolated value out from a lock statement May 21, 2024
@nipunayf nipunayf force-pushed the fix-42333 branch 3 times, most recently from 320c306 to 69485b3 Compare May 21, 2024 13:42
Copy link

github-actions bot commented Jun 5, 2024

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jun 5, 2024
@nipunayf nipunayf removed the Stale label Jun 6, 2024
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jun 21, 2024
@nipunayf nipunayf added Area/CodeAction Language Server Code Actions and removed Stale labels Jun 22, 2024
@KavinduZoysa
Copy link
Contributor

@nipunayf, shall we add a test case like this?

isolated stream<string[]> streamName = new;

isolated function isolatedFn3() returns record {| string[] value; |}? {
    lock {
        return streamName.next();
    }
}

Here it gives only 2 CAs.

Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jul 16, 2024
@nipunayf nipunayf removed the Stale label Jul 17, 2024
@nipunayf nipunayf merged commit 41161fa into ballerina-platform:master Jul 19, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CodeAction Language Server Code Actions Team/LanguageServer Language Server Implementation related issues. #Compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Provide a quick-fix code action for invalid transfer out of a lock statement
2 participants