Closed YasithD closed 6 months ago
Below are two possible user flows for suggesting the code action:
Selecting Range from Code: Users can select a range from the code encompassing multiple records. Subsequently, VSCode will prompt a quick pick menu to choose the target or output record type.
Cursor Placement at Record Type Definition: Users can place the cursor at the definition of a record type. Then, we suggest a quick pick menu to select all input records that required transform function.
Using above two approaches we can identify source and target record types. Once identified, we can generate an arrow function for transformation. However, if we leaving the body empty would trigger a set of 'missing non-defaultable required record field' diagnostics. This is something we should avoid.
We can write an algorithm to populate the body with dummy mappings by default. However, for data mappings involving large record types, this could lead to erroneous mappings (functional errors).
@YasithD @madushajg Is the above mentioned user flow is that you intended? What is your thoughts on populating the body of the arrow function?
Hi @LakshanWeerasinghe,
Using above two approaches we can identify source and target record types. Once identified, we can generate an arrow function for transformation.
For the approach can we have something similar to the currently available Extract to function
code action?
We can write an algorithm to populate the body with dummy mappings by default. However, for data mappings involving large record types, this could lead to erroneous mappings (functional errors).
For the default behaviour the default value mapping would work in the Data Mapper.
This will be the flow of actions.
User positions the cursor within the value expression or selects a range within the value expression of a specific field (where both the value expression and the field are of record type), VS Code will suggest the "extract to transform function" code action.
Upon receiving the suggestion, the user can select the "extract to transform function" code action from the VS Code interface.
Upon selection, the Language Server will generate a new expression-bodied function. This function will include default value mappings. The selected value expression is replaced by a function call expression to the newly generated function.
Description
The feature mentioned in the $title is an useful feature for the Data Mapper. It is helpful when there are lengthy input and output records to be mapped.
Please refer to the following issue: https://github.com/wso2/ballerina-vscode/issues/527
Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Editor
Related issue(s) (optional)
https://github.com/wso2/ballerina-vscode/issues/527
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response