[New Feature]: New code action for extracting expressions to let variables
within expression bodied functions
#39295
Labels
Area/CodeAction
Language Server Code Actions
IceBox
Older issues that are not being actively worked on but may be revisited in the future.
Priority/Low
Team/LanguageServer
Language Server Implementation related issues. #Compiler
Type/NewFeature
Description
$Subject
The Data Mapper users should be able to extract expressions into local variables(let declarations) and reuse within the function body.
The requirement is described in the following use case.
In this case the user need to extract the below three expressions to local variables to avoid repeating the logic.
person.country != "LK"
<string>m.characteristic.address?.country
from ContactMedium m in person.contactMediums where m.mediumType == "ADDRESS" select {...}
After extracting those to local variables, the code can be simplified like the following.
Please note that when extracting expressions within query expressions, users should have two options to locate the local variable.
ie:
<string>m.characteristic.address?.country
In above simplified function, this has placed as a let clause within the expressions. But the user can also place this at the top of the function right after the
addresses
local variable.Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Compilation
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: