ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

Add extract to local variable code action

Open TharushiJay opened this issue 2 years ago • 1 comments

Purpose

This PR implements the Extract to local variable code action, which creates a new variable assigned to the expression currently selected and replaces the selection with a reference to the new variable.

Fixes https://github.com/ballerina-platform/ballerina-lang/issues/36569

Samples

https://user-images.githubusercontent.com/27485094/180998752-7a85074a-081a-4ac9-8e3b-762503cdbafb.mov

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [x] Added necessary tests
    • [x] 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

TharushiJay avatar Jul 26 '22 12:07 TharushiJay

Codecov Report

Merging #37131 (944776c) into 2201.2.x (9ef3e47) will increase coverage by 0.01%. The diff coverage is 78.20%.

@@              Coverage Diff               @@
##             2201.2.x   #37131      +/-   ##
==============================================
+ Coverage       74.75%   74.77%   +0.01%     
- Complexity      50148    50237      +89     
==============================================
  Files            3338     3339       +1     
  Lines          193274   193459     +185     
  Branches        25258    25297      +39     
==============================================
+ Hits           144487   144663     +176     
+ Misses          40439    40430       -9     
- Partials         8348     8366      +18     
Impacted Files Coverage Δ
...a/io/ballerina/shell/cli/handlers/HelpCommand.java 15.38% <0.00%> (ø)
...erina/shell/cli/handlers/help/BbeHelpProvider.java 18.75% <0.00%> (ø)
...rc/main/java/io/ballerina/cli/cmd/PullCommand.java 34.78% <0.00%> (-0.26%) :arrow_down:
.../compiler/api/impl/SyntaxNodeToLocationMapper.java 87.77% <0.00%> (+1.11%) :arrow_up:
...iler/api/impl/symbols/BallerinaConstantSymbol.java 80.85% <0.00%> (ø)
...lerina/compiler/api/impl/symbols/TypesFactory.java 73.64% <ø> (ø)
...c/main/java/io/ballerina/projects/JarResolver.java 76.14% <0.00%> (ø)
...nalang/langserver/commons/CodeActionExtension.java 50.00% <0.00%> (ø)
...ang/langserver/commons/DocumentServiceContext.java 0.00% <ø> (ø)
...s/codeaction/spi/ResolvableCodeActionProvider.java 0.00% <0.00%> (ø)
... and 147 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 26 '22 13:07 codecov[bot]

@gayalkuruppu Can you please check your review comments and update?

mohanvive avatar Aug 25 '22 05:08 mohanvive

@gayalkuruppu Can you please check your review comments and update?

Earlier comments are addressed but this should be reviewed again, will do

gayalkuruppu avatar Aug 25 '22 06:08 gayalkuruppu

@gayalkuruppu Can you please check your review comments and update?

Earlier comments are addressed but this should be reviewed again, will do As per the offline discussion, will post the bugs separately.

gayalkuruppu avatar Aug 26 '22 07:08 gayalkuruppu