-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
With #41 (comment) the master branch now supports preserving original code formatting when performing AST transformations. At this point formatting-preservation works well in practice, and remaining issues are addressed on an as-needed basis. Please open an issue or comment if you encounter a problem.
- Support adding and removing elements from list subnodes.
- Support toggling of boolean subnodes (like isRef). This can probably be handled with the same mechanism that is used for adding/removing nullable nodes, i.e. specifying which tokens need to be dropped when switching to false and which tokens need to be added (and where) when switching to true.
- Support changing of integer subnodes.
- Support changing of modifiers. (7762753)
- Support changing of use type (maybe?)
- Finalize support for adding a nullable node. The current implementation has a couple of open todos, and the resulting formatting is not perfect in some cases (namely everything that inserts
$key =>). - Make sure fixup of weird syntax like
"${foo[0]}"works correctly. I didn't test, but suspect that changing thefoohere might result in incorrect output. - Correctly handle changes involving inline HTML.
- Allow preservation of formatting for anonymous classes. Because anon classes mix the class declaration and the constructor arguments in a weird way, the offset information for this case is currently ... odd. Maybe a change in the node-structure will help here, maybe an extra hack for this case is needed. (5900d78)
- Add support for tab indented code. Currently we assume an ideal world where all code is indented with spaces.
- Handle comment changes.
- Extract token stream related code into a TokenStream class. Currently the pretty printer contains lots of code for searching / extracting from the token stream. (b1cd07a)
- Write tests for this class independently of pretty printer.
- Improve performance. There are lots of special cases to handle, but for the most we should be able to take over large chunks of the original code directly. The implementation can probably be a lot faster than it is right now.
- Decide on final handling of Identifier nodes. Do we want to keep this is an optional parser mode, or make it the only format? I think from an AST consumer perspective it does not make a huge difference, but for people who construct AST nodes having to create Identifiers in many places might be annoying.
- Resolution: This is no longer an optional parser mode, the parser will now always create Identifiers. Node constructors have been changed to implicitly create Identifier wrappers if plain strings are passed, to keep things more ergonomic.
- Document things.
- Add
getLexer()method to parser. Otherwise it would be necessary to pass around the lexer with the parser.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels