[analyzer] New refactoring: wrap expression in IIFE #51423
Labels
area-devexp
For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
devexp-assist
Issues with analysis server assists
devexp-server
Issues related to some aspect of the analysis server
P4
type-enhancement
A request for a change that isn't a bug
An immediately invoked function expression (IIFE) is a quick and common way to embed multiple statements, followed by a return statement, where only an expression is expected.
I think a refactoring for wrapping an expression in an IIFE would be very helpful.
Here is a simple concrete example:
Initial program:
Refactored program:
The usefulness of such a refactoring becomes much more apparent when considered in a context where e.g. big Trees need to be constructed (as is common in Flutter). Having the statements close to the related expression is useful for improving code readability, but manually wrapping expressions in IIFEs is very tedious.
The text was updated successfully, but these errors were encountered: