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

Add extract to constant code action

Open TharushiJay opened this issue 2 years ago • 2 comments

Purpose

This PR implements the Extract to constant code action, which creates a const field from the selected expression and substitutes a field reference.

Fixes #36568

Samples

https://user-images.githubusercontent.com/27485094/177472213-a490db42-2488-4785-97ed-a99c14c14f11.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 06 '22 05:07 TharushiJay

Codecov Report

Merging #36876 (14581b9) into 2201.2.x (ea3aa19) will increase coverage by 0.00%. The diff coverage is 93.54%.

@@             Coverage Diff             @@
##             2201.2.x   #36876   +/-   ##
===========================================
  Coverage       74.75%   74.76%           
- Complexity      50073    50087   +14     
===========================================
  Files            3334     3335    +1     
  Lines          192936   192997   +61     
  Branches        25207    25214    +7     
===========================================
+ Hits           144234   144287   +53     
- Misses          40374    40377    +3     
- Partials         8328     8333    +5     
Impacted Files Coverage Δ
.../langserver/common/constants/CommandConstants.java 90.00% <ø> (ø)
...eaction/providers/ExtractToConstantCodeAction.java 91.83% <91.83%> (ø)
.../langserver/codeaction/CodeActionNodeAnalyzer.java 81.73% <100.00%> (+1.00%) :arrow_up:
...allerinalang/langserver/common/utils/NameUtil.java 71.91% <100.00%> (ø)
...b/lang.__internal/src/main/ballerina/int-range.bal 66.66% <0.00%> (-4.77%) :arrow_down:
...runtime/internal/scheduling/WorkerDataChannel.java 86.33% <0.00%> (-3.11%) :arrow_down:
...rver/codeaction/providers/TypeGuardCodeAction.java 63.01% <0.00%> (-2.74%) :arrow_down:
.../ballerina/runtime/internal/scheduling/Strand.java 78.66% <0.00%> (-0.84%) :arrow_down:
...rinalang/langserver/codeaction/CodeActionUtil.java 87.08% <0.00%> (+0.27%) :arrow_up:
...ava/io/ballerina/compiler/api/impl/NodeFinder.java 67.90% <0.00%> (+0.84%) :arrow_up:

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 06 '22 07:07 codecov[bot]

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[bot] avatar Aug 12 '22 19:08 github-actions[bot]