Skip to content

Commit 21060b7

Browse files
Automated Resyntax fixes (#695)
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>
1 parent 0375cc8 commit 21060b7

File tree

3 files changed

+51
-57
lines changed

3 files changed

+51
-57
lines changed

drracket-tool-test/tests/check-syntax/syncheck-direct.rkt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#lang racket/base
22

33
(require drracket/check-syntax
4-
(only-in drracket/private/syncheck/traversals
5-
[build-trace% basic-build-trace%])
64
racket/class
5+
racket/file
6+
racket/format
77
racket/match
8+
racket/runtime-path
89
racket/set
910
rackunit
1011
syntax/modread
11-
racket/file
12-
racket/format
13-
racket/runtime-path)
12+
(only-in drracket/private/syncheck/traversals [build-trace% basic-build-trace%]))
1413

1514
(define-syntax-rule
1615
(define-get-arrows get-what-arrows method-header arrow-info)
@@ -36,9 +35,7 @@
3635
(when x
3736
(set! results (cons x results))))
3837
(define/override (syncheck:find-source-object stx)
39-
(if (eq? 'the-source (syntax-source stx))
40-
'yep
41-
#f))))))
38+
(and (eq? 'the-source (syntax-source stx)) 'yep))))))
4239

4340
(define-values (add-syntax done)
4441
(make-traversal (make-base-namespace) #f))
@@ -1109,7 +1106,7 @@ abcdef
11091106
;; ensure that the submodules argument gets correctly sent along
11101107
;; in a syncheck:add-jump-to-definition/phase-level+space call
11111108
(let ()
1112-
(define root-dir (make-temporary-file "test-from-syncheck-direct-rkt~a" 'directory))
1109+
(define root-dir (make-temporary-directory "test-from-syncheck-direct-rkt~a"))
11131110
(define src (build-path root-dir "a.rkt"))
11141111
(call-with-output-file src
11151112
(λ (port)
@@ -1136,7 +1133,7 @@ abcdef
11361133
;; make sure that `make-traversal` is called with
11371134
;; the containing directory by `show-content`
11381135
(let ()
1139-
(define root-dir (make-temporary-file "test-from-syncheck-direct-rkt~a" 'directory))
1136+
(define root-dir (make-temporary-directory "test-from-syncheck-direct-rkt~a"))
11401137
(parameterize ([current-directory root-dir])
11411138
(make-directory "test"))
11421139
(define tmp-dir (build-path root-dir "test"))
@@ -1213,9 +1210,9 @@ abcdef
12131210
[p2-ele (in-list p2-eles)])
12141211
(equal? p1-ele p2-ele))))
12151212

1216-
(for ([path (in-set paths)])
1217-
(when (path-extension-of? tmp-dir path)
1218-
(check-pred file-exists? path)))
1213+
(for ([path (in-set paths)]
1214+
#:when (path-extension-of? tmp-dir path))
1215+
(check-pred file-exists? path))
12191216

12201217
(delete-directory/files root-dir))
12211218

drracket/help/private/bug-report-controls.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@
184184
(define synthesized-ok-button (make-object button% (string-constant ok) synthesized-button-panel
185185
(lambda (x y)
186186
(send synthesized-dialog show #f))))
187-
(define synthesized-info-shown? #t)
188187
(define (show-synthesized-info)
189188
(send synthesized-dialog show #t))
190189

drracket/macro-debugger/tool.rkt

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@
7777

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

8484
(super-new)))
8585

@@ -165,21 +165,21 @@
165165
(enable/disable-stuff (allow-macro-stepper?)))
166166

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

173173
(define/private (enable/disable-stuff enable?)
174-
(if enable?
175-
(begin (send macro-debug-menu-item enable #t)
176-
(unless (send macro-debug-button is-shown?)
177-
(send macro-debug-panel
178-
add-child macro-debug-button)))
179-
(begin (send macro-debug-menu-item enable #f)
180-
(when (send macro-debug-button is-shown?)
181-
(send macro-debug-panel
182-
delete-child macro-debug-button)))))
174+
(cond
175+
[enable?
176+
(send macro-debug-menu-item enable #t)
177+
(unless (send macro-debug-button is-shown?)
178+
(send macro-debug-panel add-child macro-debug-button))]
179+
[else
180+
(send macro-debug-menu-item enable #f)
181+
(when (send macro-debug-button is-shown?)
182+
(send macro-debug-panel delete-child macro-debug-button))]))
183183

184184
(send (get-button-panel) change-children
185185
(lambda (_)
@@ -222,8 +222,8 @@
222222
(define director
223223
(parameterize ((current-eventspace drracket-eventspace)
224224
(current-custodian drracket-custodian))
225-
(let ([filename (send definitions-text get-filename/untitled-name)])
226-
(new drracket-macro-stepper-director% (filename filename)))))
225+
(define filename (send definitions-text get-filename/untitled-name))
226+
(new drracket-macro-stepper-director% (filename filename))))
227227
(send interactions-text set-macro-stepper-director director)
228228

229229
(define (the-module-name-resolver . args)
@@ -284,14 +284,13 @@
284284
(send the-tab set-breakables old-break-thread old-custodian)
285285
(send the-tab enable-evaluation)
286286
;; do this with some lag ... not great, but should be okay.
287-
(let ([err-port (send (send the-tab get-error-report-text) get-err-port)])
288-
(thread
289-
(λ ()
290-
(flush-output err-port)
291-
(queue-callback
292-
(λ ()
293-
(unless (= 0 (send (send the-tab get-error-report-text) last-position))
294-
(show-error-report/tab))))))))
287+
(define err-port (send (send the-tab get-error-report-text) get-err-port))
288+
(thread (λ ()
289+
(flush-output err-port)
290+
(queue-callback
291+
(λ ()
292+
(unless (= 0 (send (send the-tab get-error-report-text) last-position))
293+
(show-error-report/tab)))))))
295294
(define (kill-termination)
296295
(unless normal-termination?
297296
(parameterize ([current-eventspace drs-eventspace])
@@ -346,12 +345,12 @@
346345
;; sets and restores some state of the definitions text
347346
;; so that edits to the definitions text work out.
348347
(define/private (with-lock/edit-sequence definitions-text thnk)
349-
(let* ([locked? (send definitions-text is-locked?)])
350-
(send definitions-text begin-edit-sequence)
351-
(send definitions-text lock #f)
352-
(thnk)
353-
(send definitions-text end-edit-sequence)
354-
(send definitions-text lock locked?)))
348+
(define locked? (send definitions-text is-locked?))
349+
(send definitions-text begin-edit-sequence)
350+
(send definitions-text lock #f)
351+
(thnk)
352+
(send definitions-text end-edit-sequence)
353+
(send definitions-text lock locked?))
355354

356355
(define/private (expand+trace expr)
357356
(define (handle-macro-limit c)
@@ -407,11 +406,10 @@
407406
(define/private (notify-macro-stepper-of-change)
408407
(unless modified-since-macro-stepper?
409408
(set! modified-since-macro-stepper? #f)
410-
(let ([win (get-top-level-window)])
411-
;; should only be #f when win is #f
412-
(when (is-a? win drracket:unit:frame<%>)
413-
(send (send win get-interactions-text)
414-
obsolete-macro-stepper)))))
409+
(define win (get-top-level-window))
410+
;; should only be #f when win is #f
411+
(when (is-a? win drracket:unit:frame<%>)
412+
(send (send win get-interactions-text) obsolete-macro-stepper))))
415413

416414
;; Catch program changes and mark macro stepper obsolete.
417415
(define/augment (on-insert x y)
@@ -462,12 +460,12 @@
462460
"macro stepper"
463461
(lambda (obj evt)
464462
(when (is-a? obj editor<%>)
465-
(let ([canvas (send obj get-canvas)])
466-
(when canvas
467-
(let ([frame (send canvas get-top-level-window)])
468-
(when (is-a? frame frame/supports-macro-stepper<%>)
469-
(when (send frame allow-macro-stepper?)
470-
(send frame run-macro-stepper)))))))))
463+
(define canvas (send obj get-canvas))
464+
(when canvas
465+
(define frame (send canvas get-top-level-window))
466+
(when (is-a? frame frame/supports-macro-stepper<%>)
467+
(when (send frame allow-macro-stepper?)
468+
(send frame run-macro-stepper)))))))
471469
(send keymap map-function "c:c;c:m" "macro stepper"))
472470

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

0 commit comments

Comments
 (0)