ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.54k stars 733 forks source link

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

Open nipunayf opened 2 weeks ago

nipunayf commented 2 weeks ago

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

github-actions[bot] commented 4 days ago

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.