Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
greghendershott committed Jan 13, 2025
1 parent 79ef9e9 commit f6d0e41
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions racket/commands/requires.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@
[(parameterize ([current-module-old-requires null])
(syntax-parse #'(ml ...)
[(_:module-level ...)
;; Intentionally not supplying adds/drops.
;; Analysis doesn't work for submodules.
(olds->new)]))]))
;; Intentionally not supplying adds/drops because
;; analysis doesn't work for submodules.
(add-insert-change-for-new-require)]))]))

(define-syntax-class root-module
#:attributes (lang)
Expand All @@ -591,7 +591,9 @@
(parameterize ([current-file-changes null])
(syntax-parse (file->syntax path-str)
[rm:root-module
(olds->new #:adds adds #:drops drops #:lang #'rm.lang)
(add-insert-change-for-new-require #:adds adds
#:drops drops
#:lang #'rm.lang)
;; Sort changes in reverse position, with deletes sorting
;; before inserts at the same position.
(define changes (sort (current-file-changes)
Expand All @@ -615,11 +617,11 @@
(cons (list 'insert pos str) (loop more))]))])))

;; Given current-module-old-requires, as well as optional adds and
;; drops, tidy into a single new require statement to be inserted. Add
;; that `insert` change to current-file-changes.
(define (olds->new #:adds [adds null]
#:drops [drops null]
#:lang [lang #f])
;; drops, tidy into a single new require statement. Add that `insert`
;; change to current-file-changes.
(define (add-insert-change-for-new-require #:adds [adds null]
#:drops [drops null]
#:lang [lang #f])
(define olds (current-module-old-requires))
(define new (tidy-module (sort olds < #:key syntax-position)
#:adds adds
Expand Down

0 comments on commit f6d0e41

Please sign in to comment.