Skip to content

Commit 3b85486

Browse files
authored
Fix string-append-and-string-join-to-string-join (#439)
1 parent 2aba64a commit 3b85486

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

default-recommendations/string-shortcuts-test.rkt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ test: "string-append around string-join refactorable to string-join with keyword
4444
- (string-join (list "fox" "hen" "dog") #:before-first "The " #:after-last " jumped")
4545

4646

47+
test: "string-append before string-join with sep refactorable to string-join with #:before-first"
48+
- (string-append "The " (string-join (list "fox" "hen" "dog") ", "))
49+
- (string-join (list "fox" "hen" "dog") ", " #:before-first "The ")
50+
51+
4752
test:
4853
"multiline string-append around string-join refactorable to multiline string-join with keyword\
4954
arguments"

default-recommendations/string-shortcuts.rkt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,23 @@
5050
(~@ . after)))
5151

5252

53-
(define-syntax-class keywordless-string-join-call
54-
#:attributes ([original 1])
53+
(define-splicing-syntax-class keywordless-string-join-call
5554
#:literals (string-join)
56-
57-
(pattern ((~and id string-join) strs)
58-
#:with (original ...) #'(id strs))
59-
60-
(pattern ((~and id string-join) strs sep)
61-
#:with (original ...) #'(id sep)))
55+
(pattern (~seq string-join strs (~optional sep))))
6256

6357

6458
(define-syntax-class string-append-and-string-join-expression
6559
#:attributes (refactored)
6660
#:literals (string-append)
6761

68-
(pattern (string-append before join-call:keywordless-string-join-call)
69-
#:with refactored #'(join-call.original ... #:before-first before))
62+
(pattern (string-append before (join-call:keywordless-string-join-call))
63+
#:with refactored #'((~@ . join-call) #:before-first before))
7064

71-
(pattern (string-append join-call:keywordless-string-join-call after)
72-
#:with refactored #'(join-call.original ... #:after-last after))
65+
(pattern (string-append (join-call:keywordless-string-join-call) after)
66+
#:with refactored #'((~@ . join-call) #:after-last after))
7367

74-
(pattern (string-append before join-call:keywordless-string-join-call after)
75-
#:with refactored #'(join-call.original ... #:before-first before #:after-last after)))
68+
(pattern (string-append before (join-call:keywordless-string-join-call) after)
69+
#:with refactored #'((~@ . join-call) #:before-first before #:after-last after)))
7670

7771

7872
(define-refactoring-rule string-append-and-string-join-to-string-join

0 commit comments

Comments
 (0)