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

Remove the type from the text generated by the `Extract to constant` code action

Open nipunayf opened this issue 1 year ago • 1 comments

Purpose

As described in https://github.com/ballerina-platform/ballerina-dev-website/pull/8884, it is the best practice to opt out using the type symbol when declaring a constant. With this PR, the Extract to constant code action is modified to reflect this change.

Fixes #42041

Approach

Removed appending the type symbol to the generated text edit.

Samples

https://github.com/ballerina-platform/ballerina-lang/assets/59343084/76b40988-ea47-46d0-af7a-d8fb8c6d9df8

Remarks

In the https://github.com/ballerina-platform/ballerina-dev-website/pull/8884, there are some scenarios in which having the type symbol in the declaration can be beneficial. However, the revised design does not consider those cases due to the following points.

  1. Having the type symbol is only applicable when the respective declaration requires more readability. Since there is no precise distinction for such cases, it is difficult to write an precise algorithm to handle these cases.
  2. Including such logic would impact the performance slightly.

Hence, it is up to the user to add the type symbol if it is necessary.

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [ ] 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 avatar Apr 26 '24 04:04 nipunayf

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 May 11 '24 19:05 github-actions[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 May 27 '24 19:05 github-actions[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 Jun 12 '24 19:06 github-actions[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 Jul 12 '24 19:07 github-actions[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 Jul 28 '24 19:07 github-actions[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 14 '24 19:08 github-actions[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 30 '24 19:08 github-actions[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 Sep 15 '24 19:09 github-actions[bot]

Codecov Report

Attention: Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.50%. Comparing base (b45e1e1) to head (cae206e). Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
...eaction/providers/ExtractToConstantCodeAction.java 82.35% 0 Missing and 3 partials :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #42643      +/-   ##
============================================
- Coverage     77.51%   77.50%   -0.01%     
- Complexity    58585    58589       +4     
============================================
  Files          3438     3438              
  Lines        219219   219221       +2     
  Branches      28921    28916       -5     
============================================
- Hits         169921   169911      -10     
- Misses        39884    39890       +6     
- Partials       9414     9420       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 17 '24 21:09 codecov[bot]