Skip to content

Commit

Permalink
Automated Resyntax fixes (#695)
Browse files Browse the repository at this point in the history
This is an automated change generated by Resyntax.

#### Pass 1

Applied 1 fix to [`drracket/help/private/bug-report-controls.rkt`](../blob/HEAD/drracket/help/private/bug-report-controls.rkt)

  * Line 187, `unused-definition`: This definition is not used.

Applied 5 fixes to [`drracket-tool-test/tests/check-syntax/syncheck-direct.rkt`](../blob/HEAD/drracket-tool-test/tests/check-syntax/syncheck-direct.rkt)

  * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 39, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`.
  * Line 1112, `make-temporary-directory-migration`: Use `make-temporary-directory` to make directories instead of `make-temporary-file`.
  * Line 1139, `make-temporary-directory-migration`: Use `make-temporary-directory` to make directories instead of `make-temporary-file`.
  * Line 1216, `when-expression-in-for-loop-to-when-keyword`: Use the `#:when` keyword instead of `when` to reduce loop body indentation.

Applied 8 fixes to [`drracket/macro-debugger/tool.rkt`](../blob/HEAD/drracket/macro-debugger/tool.rkt)

  * Line 80, `unless-expression-in-for-loop-to-unless-keyword`: Use the `#:unless` keyword instead of `unless` to reduce loop body indentation.
  * Line 168, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 174, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary
  * Line 225, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 287, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 349, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 410, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 465, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

#### Pass 2

Applied 1 fix to [`drracket/macro-debugger/tool.rkt`](../blob/HEAD/drracket/macro-debugger/tool.rkt)

  * Line 465, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

## Summary

Fixed 15 issues in 3 files.

  * Fixed 7 occurrences of `let-to-define`
  * Fixed 2 occurrences of `make-temporary-directory-migration`
  * Fixed 1 occurrence of `tidy-require`
  * Fixed 1 occurrence of `if-else-false-to-and`
  * Fixed 1 occurrence of `when-expression-in-for-loop-to-when-keyword`
  * Fixed 1 occurrence of `unless-expression-in-for-loop-to-unless-keyword`
  * Fixed 1 occurrence of `if-begin-to-cond`
  * Fixed 1 occurrence of `unused-definition`

Co-authored-by: resyntax-ci[bot] <181813515+resyntax-ci[bot]@users.noreply.github.com>
  • Loading branch information
resyntax-ci[bot] authored Nov 12, 2024
1 parent 0375cc8 commit 21060b7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 57 deletions.
23 changes: 10 additions & 13 deletions drracket-tool-test/tests/check-syntax/syncheck-direct.rkt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#lang racket/base

(require drracket/check-syntax
(only-in drracket/private/syncheck/traversals
[build-trace% basic-build-trace%])
racket/class
racket/file
racket/format
racket/match
racket/runtime-path
racket/set
rackunit
syntax/modread
racket/file
racket/format
racket/runtime-path)
(only-in drracket/private/syncheck/traversals [build-trace% basic-build-trace%]))

(define-syntax-rule
(define-get-arrows get-what-arrows method-header arrow-info)
Expand All @@ -36,9 +35,7 @@
(when x
(set! results (cons x results))))
(define/override (syncheck:find-source-object stx)
(if (eq? 'the-source (syntax-source stx))
'yep
#f))))))
(and (eq? 'the-source (syntax-source stx)) 'yep))))))

(define-values (add-syntax done)
(make-traversal (make-base-namespace) #f))
Expand Down Expand Up @@ -1109,7 +1106,7 @@ abcdef
;; ensure that the submodules argument gets correctly sent along
;; in a syncheck:add-jump-to-definition/phase-level+space call
(let ()
(define root-dir (make-temporary-file "test-from-syncheck-direct-rkt~a" 'directory))
(define root-dir (make-temporary-directory "test-from-syncheck-direct-rkt~a"))
(define src (build-path root-dir "a.rkt"))
(call-with-output-file src
(λ (port)
Expand All @@ -1136,7 +1133,7 @@ abcdef
;; make sure that `make-traversal` is called with
;; the containing directory by `show-content`
(let ()
(define root-dir (make-temporary-file "test-from-syncheck-direct-rkt~a" 'directory))
(define root-dir (make-temporary-directory "test-from-syncheck-direct-rkt~a"))
(parameterize ([current-directory root-dir])
(make-directory "test"))
(define tmp-dir (build-path root-dir "test"))
Expand Down Expand Up @@ -1213,9 +1210,9 @@ abcdef
[p2-ele (in-list p2-eles)])
(equal? p1-ele p2-ele))))

(for ([path (in-set paths)])
(when (path-extension-of? tmp-dir path)
(check-pred file-exists? path)))
(for ([path (in-set paths)]
#:when (path-extension-of? tmp-dir path))
(check-pred file-exists? path))

(delete-directory/files root-dir))

Expand Down
1 change: 0 additions & 1 deletion drracket/help/private/bug-report-controls.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
(define synthesized-ok-button (make-object button% (string-constant ok) synthesized-button-panel
(lambda (x y)
(send synthesized-dialog show #f))))
(define synthesized-info-shown? #t)
(define (show-synthesized-info)
(send synthesized-dialog show #t))

Expand Down
84 changes: 41 additions & 43 deletions drracket/macro-debugger/tool.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@

(define/public (shutdown)
(when (pref:close-on-reset-console?)
(for ([(frame flags) (in-hash stepper-frames)])
(unless (memq 'no-obsolete flags)
(send frame show #f)))))
(for ([(frame flags) (in-hash stepper-frames)]
#:unless (memq 'no-obsolete flags))
(send frame show #f))))

(super-new)))

Expand Down Expand Up @@ -165,21 +165,21 @@
(enable/disable-stuff (allow-macro-stepper?)))

(define/public (allow-macro-stepper?)
(let ([lang
(drracket:language-configuration:language-settings-language
(send (get-definitions-text) get-next-settings))])
(send lang capability-value 'macro-stepper:enabled)))
(define lang
(drracket:language-configuration:language-settings-language (send (get-definitions-text)
get-next-settings)))
(send lang capability-value 'macro-stepper:enabled))

(define/private (enable/disable-stuff enable?)
(if enable?
(begin (send macro-debug-menu-item enable #t)
(unless (send macro-debug-button is-shown?)
(send macro-debug-panel
add-child macro-debug-button)))
(begin (send macro-debug-menu-item enable #f)
(when (send macro-debug-button is-shown?)
(send macro-debug-panel
delete-child macro-debug-button)))))
(cond
[enable?
(send macro-debug-menu-item enable #t)
(unless (send macro-debug-button is-shown?)
(send macro-debug-panel add-child macro-debug-button))]
[else
(send macro-debug-menu-item enable #f)
(when (send macro-debug-button is-shown?)
(send macro-debug-panel delete-child macro-debug-button))]))

(send (get-button-panel) change-children
(lambda (_)
Expand Down Expand Up @@ -222,8 +222,8 @@
(define director
(parameterize ((current-eventspace drracket-eventspace)
(current-custodian drracket-custodian))
(let ([filename (send definitions-text get-filename/untitled-name)])
(new drracket-macro-stepper-director% (filename filename)))))
(define filename (send definitions-text get-filename/untitled-name))
(new drracket-macro-stepper-director% (filename filename))))
(send interactions-text set-macro-stepper-director director)

(define (the-module-name-resolver . args)
Expand Down Expand Up @@ -284,14 +284,13 @@
(send the-tab set-breakables old-break-thread old-custodian)
(send the-tab enable-evaluation)
;; do this with some lag ... not great, but should be okay.
(let ([err-port (send (send the-tab get-error-report-text) get-err-port)])
(thread
(λ ()
(flush-output err-port)
(queue-callback
(λ ()
(unless (= 0 (send (send the-tab get-error-report-text) last-position))
(show-error-report/tab))))))))
(define err-port (send (send the-tab get-error-report-text) get-err-port))
(thread (λ ()
(flush-output err-port)
(queue-callback
(λ ()
(unless (= 0 (send (send the-tab get-error-report-text) last-position))
(show-error-report/tab)))))))
(define (kill-termination)
(unless normal-termination?
(parameterize ([current-eventspace drs-eventspace])
Expand Down Expand Up @@ -346,12 +345,12 @@
;; sets and restores some state of the definitions text
;; so that edits to the definitions text work out.
(define/private (with-lock/edit-sequence definitions-text thnk)
(let* ([locked? (send definitions-text is-locked?)])
(send definitions-text begin-edit-sequence)
(send definitions-text lock #f)
(thnk)
(send definitions-text end-edit-sequence)
(send definitions-text lock locked?)))
(define locked? (send definitions-text is-locked?))
(send definitions-text begin-edit-sequence)
(send definitions-text lock #f)
(thnk)
(send definitions-text end-edit-sequence)
(send definitions-text lock locked?))

(define/private (expand+trace expr)
(define (handle-macro-limit c)
Expand Down Expand Up @@ -407,11 +406,10 @@
(define/private (notify-macro-stepper-of-change)
(unless modified-since-macro-stepper?
(set! modified-since-macro-stepper? #f)
(let ([win (get-top-level-window)])
;; should only be #f when win is #f
(when (is-a? win drracket:unit:frame<%>)
(send (send win get-interactions-text)
obsolete-macro-stepper)))))
(define win (get-top-level-window))
;; should only be #f when win is #f
(when (is-a? win drracket:unit:frame<%>)
(send (send win get-interactions-text) obsolete-macro-stepper))))

;; Catch program changes and mark macro stepper obsolete.
(define/augment (on-insert x y)
Expand Down Expand Up @@ -462,12 +460,12 @@
"macro stepper"
(lambda (obj evt)
(when (is-a? obj editor<%>)
(let ([canvas (send obj get-canvas)])
(when canvas
(let ([frame (send canvas get-top-level-window)])
(when (is-a? frame frame/supports-macro-stepper<%>)
(when (send frame allow-macro-stepper?)
(send frame run-macro-stepper)))))))))
(define canvas (send obj get-canvas))
(when canvas
(define frame (send canvas get-top-level-window))
(when (is-a? frame frame/supports-macro-stepper<%>)
(when (send frame allow-macro-stepper?)
(send frame run-macro-stepper)))))))
(send keymap map-function "c:c;c:m" "macro stepper"))

(add-macro-stepper-key-bindings (drracket:rep:get-drs-bindings-keymap))
Expand Down

0 comments on commit 21060b7

Please sign in to comment.