Rework definition context rules
Creating a definition context rule with define-definition-context-refactoring-rule is somewhat awkward. There's a few usability issues:
- You have to match the entire definition context, which is rarely useful.
- You have to be careful to use
~replacement,~splicing-replacement, and~focus-replacement-onin order to avoid issues like #476. - The set of recognized definition context forms is hard-coded.
Something better should be possible. Perhaps something like how Rhombus macros work, where a statement macro can match on all following statements and statement macros return two values: an expansion and an "unprocessed tail". That would let Resyntax automatically use ~replacement, ~splicing-replacement, and ~focus-replacement-on, and it would remove the need for definition context rules to care about the forms earlier in the definition context.
Here's one possible idea: a define-splicing-refactoring-rule that matches a splice of syntax objects and suggests a new splice to replace it. The relationship between this and define-refactoring-rule would be similar to the relationship between define-syntax-class and define-splicing-syntax-class. This might require some careful thought about whether to analyze splices where either the parent syntax object wasn't visited or the individual splice syntax objects weren't visited. Integrating with the modular analyzers to expose that info on syntax properties might help.