diff --git a/default-recommendations/syntax-parse-shortcuts-test.rkt b/default-recommendations/syntax-parse-shortcuts-test.rkt index 47b8e59..221db07 100644 --- a/default-recommendations/syntax-parse-shortcuts-test.rkt +++ b/default-recommendations/syntax-parse-shortcuts-test.rkt @@ -84,3 +84,29 @@ no-change-test: "define-syntax-parser with multiple clauses not refactorable" [(_ a) #'a]) ------------------------------ + + +no-change-test: "define-syntax-parser with syntax/loc not refactorable" +------------------------------ +(define-syntax-parser my-macro + [(_ pattern) + (syntax/loc this-syntax + (some-expr))]) +------------------------------ + + +no-change-test: "define-syntax-parser without syntax wrapper not refactorable" +------------------------------ +(define-syntax-parser my-macro + [(_ x:id) + (let ([tmp (syntax-e #'x)]) + #'(quote tmp))]) +------------------------------ + + +no-change-test: "define-syntax-parser with quasisyntax not refactorable" +------------------------------ +(define-syntax-parser my-macro + [(_ x:id) + #`(quote #,#'x)]) +------------------------------ diff --git a/default-recommendations/syntax-parse-shortcuts.rkt b/default-recommendations/syntax-parse-shortcuts.rkt index 29d5c0f..6b64e5d 100644 --- a/default-recommendations/syntax-parse-shortcuts.rkt +++ b/default-recommendations/syntax-parse-shortcuts.rkt @@ -49,21 +49,15 @@ equivalent `define-syntax-parse-rule` macro." #:description "This `define-syntax-parser` macro with a single clause can be replaced with a simpler, equivalent `define-syntax-parse-rule` macro." - #:literals (define-syntax-parser) + #:literals (define-syntax-parser [syntax-id syntax #:phase 1]) (define-syntax-parser macro:id - [(_ . pattern) body ...]) + [(_ . pattern) directive:syntax-parse-pattern-directive ... (syntax-id last-form)]) - #:do [(define (strip-syntax-wrapper stx) - (syntax-parse stx - #:literals (syntax) - [(syntax body) #'body] - [other #'other])) - (define new-body (map strip-syntax-wrapper (attribute body)))] - - #:with (new-body-part ...) new-body + #:with (new-body ...) + #'((~@ . directive) ... last-form) - (define-syntax-parse-rule (macro . pattern) new-body-part ...)) + (define-syntax-parse-rule (macro . pattern) new-body ...)) (define-refactoring-suite syntax-parse-shortcuts