resyntax
resyntax copied to clipboard
A Racket refactoring engine
Refactoring rules need to know the expansion context (`'module`, `'expression`, `'internal-definition`) of forms to determine valid transformations. This adds an expansion analyzer that labels each form with its context based...
Whenever a form is being expanded, the result of `syntax-local-context` has one of five values: `'expression`, `'top-level`, `'module`, `'module-begin`, or a value representing a specific definition context. This is useful...
Nested syntax template flattening operations can be simplified. The pattern `(apply append (map syntax->list (syntax->list #'((a ...) ...))))` does the same work as `(syntax->list #'(a ... ...))` but with unnecessary...
### Rule summary The code `(apply append (map syntax->list (syntax->list #'((id ...) ...))))` is more directly expressed as `(syntax->list #'(id ... ...))`. ### Test case ```scheme #lang resyntax/test test: "original...
Suggests replacing `make-immutable-hash` with quasiquoted pairs with the simpler `hash` constructor when all keys are statically known. ### Changes - Added `make-immutable-hash-with-quasiquote-to-hash` rule to `hash-shortcuts.rkt` - Matches pattern `(make-immutable-hash `((key...
The `when-expression-in-for-loop-to-when-keyword` and `unless-expression-in-for-loop-to-unless-keyword` rules were refactoring single-statement loops, which doesn't meaningfully reduce indentation or improve readability. ## Changes - Added `#:when (>= (length (attribute body)) 2)` guard to both...
Often, the `unless-expression-in-for-loop-to-unless-keyword` rule (and its corresponding `when`-based rule) rewrites this: ```scheme (for ([v (in-list vs)]) (unless (good? v) (raise-arguments-error ...))) ``` to this: ```scheme (for ([v (in-list vs)] #:unless...
TODO: more details Notes: - Only warn when at least one other export in the same module is documented - Cannot suggest a fix, so this is a warn-only rule
Adds a `keep-sorted` macro that marks collections for Resyntax to keep sorted. When elements are out of order, Resyntax suggests reordering them alphabetically by identifier name. ## Changes - **`keep-sorted.rkt`**...