diff --git a/drracket-core-lib/drracket/private/init.rkt b/drracket-core-lib/drracket/private/init.rkt index a5e26c652..fcbbe3d8c 100644 --- a/drracket-core-lib/drracket/private/init.rkt +++ b/drracket-core-lib/drracket/private/init.rkt @@ -104,18 +104,17 @@ ;; little bit from errors that are raised in the dynamic ;; extent of an edit-sequence. (when (eq? (current-thread) (eventspace-handler-thread system-eventspace)) - (for ([f (in-list (get-top-level-windows))]) - (when (is-a? f drracket:unit:frame<%>) - (let loop ([o f]) - (cond - [(is-a? o editor-canvas%) - (define t (send o get-editor)) - (when (or (is-a? t drracket:unit:definitions-text<%>) - (is-a? t drracket:rep:text<%>)) - (let loop () - (when (send t in-edit-sequence?) - (send t end-edit-sequence) - (loop))))] - [(is-a? o area-container<%>) - (for ([c (in-list (send o get-children))]) - (loop c))]))))))) + (for ([f (in-list (get-top-level-windows))] + #:when (is-a? f drracket:unit:frame<%>)) + (let loop ([o f]) + (cond + [(is-a? o editor-canvas%) + (define t (send o get-editor)) + (when (or (is-a? t drracket:unit:definitions-text<%>) (is-a? t drracket:rep:text<%>)) + (let loop () + (when (send t in-edit-sequence?) + (send t end-edit-sequence) + (loop))))] + [(is-a? o area-container<%>) + (for ([c (in-list (send o get-children))]) + (loop c))])))))) diff --git a/drracket-core-lib/drracket/private/language-object-contract.rkt b/drracket-core-lib/drracket/private/language-object-contract.rkt index 98878f154..0252de822 100644 --- a/drracket-core-lib/drracket/private/language-object-contract.rkt +++ b/drracket-core-lib/drracket/private/language-object-contract.rkt @@ -23,12 +23,12 @@ (let loop ([s #'arg]) (cond [(syntax? s) - (let ([loc (vector (syntax-source s) - (syntax-line s) - (syntax-column s) - (syntax-position s) - (syntax-span s))]) - (make-sloc (loop (syntax-e s)) loc))] + (vector (syntax-source s) + (syntax-line s) + (syntax-column s) + (syntax-position s) + (syntax-span s)) + (make-sloc (loop (syntax-e s)) loc)] [(pair? s) (cons (loop (car s)) (loop (cdr s)))] [else s]))]) #'ans)]))]) diff --git a/drracket-core-lib/drracket/private/tool-contract-language.rkt b/drracket-core-lib/drracket/private/tool-contract-language.rkt index 0c9d2affe..abc17bcac 100644 --- a/drracket-core-lib/drracket/private/tool-contract-language.rkt +++ b/drracket-core-lib/drracket/private/tool-contract-language.rkt @@ -59,23 +59,19 @@ body)))))])))))))] [(_ (name type type-names strs ...) ...) (begin - (for-each - (λ (str-stx) - (when (string? (syntax->datum str-stx)) - (raise-syntax-error 'tool-contract-language.rkt "expected type name specification" - stx - str-stx))) - (syntax->list (syntax (type-names ...)))) - (for-each - (λ (name) - (unless (identifier? name) - (raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))) - (syntax->list (syntax (name ...)))) - (for-each - (λ (str) - (unless (string? (syntax->datum str)) - (raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))) - (apply append (map syntax->list (syntax->list (syntax ((strs ...) ...)))))))])) + (for ([str-stx (in-list (syntax->list (syntax (type-names ...))))]) + (when (string? (syntax->datum str-stx)) + (raise-syntax-error 'tool-contract-language.rkt + "expected type name specification" + stx + str-stx))) + (for ([name (in-list (syntax->list (syntax (name ...))))]) + (unless (identifier? name) + (raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))) + (for ([str (in-list (apply append + (map syntax->list (syntax->list (syntax ((strs ...) ...))))))]) + (unless (string? (syntax->datum str)) + (raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))))])) (define-syntax (-#%module-begin2 stx) (syntax-case stx () @@ -116,20 +112,16 @@ body)))]))))))] [(_ (name type type-names strs ...) ...) (begin - (for-each - (λ (str-stx) - (when (string? (syntax->datum str-stx)) - (raise-syntax-error 'tool-contract-language.rkt "expected type name specification" - stx - str-stx))) - (syntax->list (syntax (type-names ...)))) - (for-each - (λ (name) - (unless (identifier? name) - (raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))) - (syntax->list (syntax (name ...)))) - (for-each - (λ (str) - (unless (string? (syntax->datum str)) - (raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))) - (apply append (map syntax->list (syntax->list (syntax ((strs ...) ...)))))))])) + (for ([str-stx (in-list (syntax->list (syntax (type-names ...))))]) + (when (string? (syntax->datum str-stx)) + (raise-syntax-error 'tool-contract-language.rkt + "expected type name specification" + stx + str-stx))) + (for ([name (in-list (syntax->list (syntax (name ...))))]) + (unless (identifier? name) + (raise-syntax-error 'tool-contract-language.rkt "expected identifier" stx name))) + (for ([str (in-list (apply append + (map syntax->list (syntax->list (syntax ((strs ...) ...))))))]) + (unless (string? (syntax->datum str)) + (raise-syntax-error 'tool-contract-language.rkt "expected docs string" stx str))))])) diff --git a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt index c715ac956..2c4741a0d 100644 --- a/drracket-tool-text-lib/drracket/find-module-path-completions.rkt +++ b/drracket-tool-text-lib/drracket/find-module-path-completions.rkt @@ -183,20 +183,20 @@ (and (regexp? (list-ref link-ent 2)) (regexp-match (list-ref link-ent 2) (version))) #t)) - `(,(list-ref link-ent 0) - ,(simplify-path - (let* ([encoded-path (list-ref link-ent 1)] - [path (cond - [(string? encoded-path) encoded-path] - [(bytes? encoded-path) (bytes->path encoded-path)] - [else (apply build-path - (for/list ([elem (in-list encoded-path)]) - (if (bytes? elem) - (bytes->path-element elem) - elem)))])]) - (if (relative-path? path) - (build-path base path) - path)))))] + (list (list-ref link-ent 0) + (simplify-path (let* ([encoded-path (list-ref link-ent 1)] + [path (cond + [(string? encoded-path) encoded-path] + [(bytes? encoded-path) (bytes->path encoded-path)] + [else + (apply build-path + (for/list ([elem (in-list encoded-path)]) + (if (bytes? elem) + (bytes->path-element elem) + elem)))])]) + (if (relative-path? path) + (build-path base path) + path)))))] [else '()])] [else (for/list ([clp (in-list library-collection-paths)]) diff --git a/drracket/gui-debugger/debug-tool.rkt b/drracket/gui-debugger/debug-tool.rkt index ce8e80c38..837dded50 100644 --- a/drracket/gui-debugger/debug-tool.rkt +++ b/drracket/gui-debugger/debug-tool.rkt @@ -191,18 +191,16 @@ (begin-edit-sequence) (define breakpoints (send (get-tab) get-breakpoints)) (define shifts empty) - (hash-for-each - breakpoints - (lambda (pos status) - (cond - ; deletion after breakpoint: no effect - [(<= pos start)] - ; deletion of breakpoint: remove from table - [(and (< start pos) (<= pos (+ start len))) (hash-remove! breakpoints pos)] - ; deletion before breakpoint: shift breakpoint - [(> pos (+ start len)) - (hash-remove! breakpoints pos) - (set! shifts (cons (cons (- pos len) status) shifts))]))) + (for ([(pos status) (in-hash breakpoints)]) + (cond + ; deletion after breakpoint: no effect + [(<= pos start)] + ; deletion of breakpoint: remove from table + [(and (< start pos) (<= pos (+ start len))) (hash-remove! breakpoints pos)] + ; deletion before breakpoint: shift breakpoint + [(> pos (+ start len)) + (hash-remove! breakpoints pos) + (set! shifts (cons (cons (- pos len) status) shifts))])) (for-each (lambda (p) (hash-set! breakpoints (car p) (cdr p))) shifts)) (inner (void) on-delete start len)) @@ -219,13 +217,12 @@ (begin-edit-sequence) (define breakpoints (send (get-tab) get-breakpoints)) (define shifts empty) - (hash-for-each breakpoints - (lambda (pos status) - (when (< start pos) - ;; text inserted before this breakpoint, so shift - ;; the breakpoint forward by positions - (hash-remove! breakpoints pos) - (set! shifts (cons (cons (+ pos len) status) shifts))))) + (for ([(pos status) (in-hash breakpoints)]) + (when (< start pos) + ;; text inserted before this breakpoint, so shift + ;; the breakpoint forward by positions + (hash-remove! breakpoints pos) + (set! shifts (cons (cons (+ pos len) status) shifts)))) ;; update the breakpoint locations (for-each (lambda (p) (hash-set! breakpoints (car p) (cdr p))) shifts))) @@ -489,28 +486,26 @@ (when (and (send (get-tab) debug?) (not before)) ;; render breakpoints (let ([breakpoints (send (get-tab) get-breakpoints)]) - (hash-for-each - breakpoints - (lambda (pos enabled?) - (when (and (>= pos 0) (or enabled? (and mouse-over-pos (= mouse-over-pos pos)))) - (define-values (xl yl xr yr) (find-char-box this pos)) - (define diameter (- xr xl)) - (define yoff (/ (- yr yl diameter) 2)) - (define op (send dc get-pen)) - (define ob (send dc get-brush)) - (case enabled? - [(#t) - (send dc set-pen bp-pen) - (send dc set-brush bp-brush)] - [(#f) - (send dc set-pen bp-mo-pen) - (send dc set-brush bp-mo-brush)] - [else - (send dc set-pen bp-tmp-pen) - (send dc set-brush bp-tmp-brush)]) - (send dc draw-ellipse (+ xl dx) (+ yl dy yoff) diameter diameter) - (send dc set-pen op) - (send dc set-brush ob))))) + (for ([(pos enabled?) (in-hash breakpoints)]) + (when (and (>= pos 0) (or enabled? (and mouse-over-pos (= mouse-over-pos pos)))) + (define-values (xl yl xr yr) (find-char-box this pos)) + (define diameter (- xr xl)) + (define yoff (/ (- yr yl diameter) 2)) + (define op (send dc get-pen)) + (define ob (send dc get-brush)) + (case enabled? + [(#t) + (send dc set-pen bp-pen) + (send dc set-brush bp-brush)] + [(#f) + (send dc set-pen bp-mo-pen) + (send dc set-brush bp-mo-brush)] + [else + (send dc set-pen bp-tmp-pen) + (send dc set-brush bp-tmp-brush)]) + (send dc draw-ellipse (+ xl dx) (+ yl dy yoff) diameter diameter) + (send dc set-pen op) + (send dc set-brush ob)))) ;; mark the boundaries of the current stack frame ;; unless we're at the end of the expression and looking at the top frame, ;; in which case just mark the current location @@ -804,11 +799,11 @@ ; break-after (case-lambda [(top-mark ccm val) - (let* ([debug-marks (continuation-mark-set->list ccm debug-key)]) - (car (send (get-tab) suspend - oeh - (cons top-mark debug-marks) - (list 'exit-break val))))] + (define debug-marks (continuation-mark-set->list ccm debug-key)) + (car (send (get-tab) suspend + oeh + (cons top-mark debug-marks) + (list 'exit-break val)))] [(top-mark ccm . vals) (define debug-marks (continuation-mark-set->list ccm debug-key)) (apply values @@ -818,15 +813,16 @@ (cons 'exit-break vals)))]))) (uncaught-exception-handler (lambda (exn) - (if (and (exn:break? exn) (send (get-tab) suspend-on-break?)) - (let ([marks (exn-continuation-marks exn)] - [cont (exn:break-continuation exn)]) - (send (get-tab) suspend - oeh - (continuation-mark-set->list marks debug-key) - 'break) - (cont)) - (oeh exn))))))))))) + (cond + [(and (exn:break? exn) (send (get-tab) suspend-on-break?)) + (define marks (exn-continuation-marks exn)) + (define cont (exn:break-continuation exn)) + (send (get-tab) suspend + oeh + (continuation-mark-set->list marks debug-key) + 'break) + (cont)] + [else (oeh exn)])))))))))) (define (debug-tab-mixin super%) (class super% @@ -1237,37 +1233,37 @@ (send variables-text end-edit-sequence)) (define/public (register-stack-frames frames already-stopped?) - (let* ([trimmed-exprs - (map (lambda (frame) - (let ([expr (mark-source frame)]) - (cond - ; should succeed unless the user closes a secondary tab during debugging - [(and expr (filename->defs (syntax-source expr))) - => (lambda (defs) - (trim-expr-str - (if (syntax-position expr) - (send defs get-text - (sub1 (syntax-position expr)) - (+ -1 (syntax-position expr) (syntax-span expr))) - "??") - 15))] - ["??"]))) - frames)] - [trimmed-lengths (map add1 (map string-length trimmed-exprs))] - [positions (foldl + 0 trimmed-lengths)]) - (send stack-frames begin-edit-sequence) - (send stack-frames lock #f) - (unless already-stopped? - (send stack-frames delete 0 (send stack-frames last-position)) - (for-each (lambda (trimmed-expr) - (send stack-frames insert (format "~a\n" trimmed-expr))) - trimmed-exprs)) - (send stack-frames change-style normal-sd 0 (send stack-frames last-position)) - (send stack-frames change-style bold-sd - (send stack-frames paragraph-start-position (send (get-current-tab) get-frame-num)) - (send stack-frames paragraph-end-position (send (get-current-tab) get-frame-num))) - (send stack-frames lock #t) - (send stack-frames end-edit-sequence))) + (define trimmed-exprs + (map (lambda (frame) + (let ([expr (mark-source frame)]) + (cond + ; should succeed unless the user closes a secondary tab during debugging + [(and expr (filename->defs (syntax-source expr))) + => + (lambda (defs) + (trim-expr-str (if (syntax-position expr) + (send defs get-text + (sub1 (syntax-position expr)) + (+ -1 (syntax-position expr) (syntax-span expr))) + "??") + 15))] + ["??"]))) + frames)) + (define trimmed-lengths (map add1 (map string-length trimmed-exprs))) + (foldl + 0 trimmed-lengths) + (send stack-frames begin-edit-sequence) + (send stack-frames lock #f) + (unless already-stopped? + (send stack-frames delete 0 (send stack-frames last-position)) + (for-each (lambda (trimmed-expr) (send stack-frames insert (format "~a\n" trimmed-expr))) + trimmed-exprs)) + (send stack-frames change-style normal-sd 0 (send stack-frames last-position)) + (send stack-frames change-style + bold-sd + (send stack-frames paragraph-start-position (send (get-current-tab) get-frame-num)) + (send stack-frames paragraph-end-position (send (get-current-tab) get-frame-num))) + (send stack-frames lock #t) + (send stack-frames end-edit-sequence)) (define/public (clear-stack-frames/vars) (send stack-frames begin-edit-sequence) @@ -1551,29 +1547,35 @@ (define/augment (on-tab-change old new) (check-current-language-for-debugger) - (if (send new debug?) - (let ([status (send new get-break-status)]) - (if status - (send new suspend-gui (send new get-stack-frames) status #f #t) - (send new resume-gui)) - (show-debug)) - (hide-debug)) + (cond + [(send new debug?) + (define status (send new get-break-status)) + (if status + (send new suspend-gui (send new get-stack-frames) status #f #t) + (send new resume-gui)) + (show-debug)] + [else (hide-debug)]) (inner (void) on-tab-change old new)) (define/public (check-current-language-for-debugger) - (let* ([settings (send (get-definitions-text) get-next-settings)] - [lang (drscheme:language-configuration:language-settings-language settings)] - [visible? (and (send lang capability-value 'gui-debugger:debug-button) - (not (is-a? lang drscheme:module-language:module-language<%>)) ;; the opt-out button handles this language - (not (debugger-does-not-work-for? - (extract-language-level settings))))]) - (define debug-parent (send debug-button get-parent)) - (define debug-button-currently-visible? (member debug-button (send debug-parent get-children))) - (if visible? - (unless debug-button-currently-visible? - (send debug-parent add-child debug-button)) - (when debug-button-currently-visible? - (send debug-parent delete-child debug-button))))) + (define settings (send (get-definitions-text) get-next-settings)) + (define lang (drscheme:language-configuration:language-settings-language settings)) + (define visible? + (and + (send lang capability-value 'gui-debugger:debug-button) + (not + (is-a? + lang + drscheme:module-language:module-language<%>)) ;; the opt-out button handles this language + (not (debugger-does-not-work-for? (extract-language-level settings))))) + (define debug-parent (send debug-button get-parent)) + (define debug-button-currently-visible? + (member debug-button (send debug-parent get-children))) + (if visible? + (unless debug-button-currently-visible? + (send debug-parent add-child debug-button)) + (when debug-button-currently-visible? + (send debug-parent delete-child debug-button)))) (send (get-button-panel) change-children (lambda (children) @@ -1582,7 +1584,7 @@ ; hide debug button if it's not supported for the initial language: (check-current-language-for-debugger))) - (drscheme:language:register-capability 'gui-debugger:debug-button (flat-contract boolean?) #t) + (drscheme:language:register-capability 'gui-debugger:debug-button boolean? #t) (drscheme:get/extend:extend-definitions-text debug-definitions-text-mixin) (drscheme:get/extend:extend-interactions-text debug-interactions-text-mixin) (drscheme:get/extend:extend-unit-frame debug-unit-frame-mixin) diff --git a/drracket/version/tool.rkt b/drracket/version/tool.rkt index 81aca6f9e..34a31b20e 100644 --- a/drracket/version/tool.rkt +++ b/drracket/version/tool.rkt @@ -30,9 +30,11 @@ ;; wait until the definitions are instantiated, return top-level window (define (wait-for-definitions) (define ws (get-top-level-windows)) - (if (null? ws) - (begin (sleep 1) (wait-for-definitions)) - (car ws))) + (cond + [(null? ws) + (sleep 1) + (wait-for-definitions)] + [else (car ws)])) #| ;; Cute code, but may resize the window if too much space, and people ;; didn't like this way of asking if you want update checks. ;; show a message and a disable button @@ -181,4 +183,4 @@ (super help-menu:after-about m)) (super-new)))) (thread check-for-updates)) - (when (> patchlevel 0) (version:add-spec 'p patchlevel)))) + (when (positive? patchlevel) (version:add-spec 'p patchlevel))))