-
-
Notifications
You must be signed in to change notification settings - Fork 95
Automated Resyntax fixes #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
#lang racket/base | ||
(require racket/gui/base | ||
(require (for-syntax racket/base | ||
racket/list) | ||
framework | ||
pkg | ||
racket/class | ||
racket/contract | ||
racket/gui/base | ||
racket/pretty | ||
string-constants/string-constant | ||
setup/dirs | ||
setup/link | ||
framework | ||
pkg | ||
(for-syntax racket/base | ||
racket/list) | ||
string-constants/string-constant | ||
"buginfo.rkt" | ||
"save-bug-report.rkt") | ||
|
||
(provide/contract | ||
[add-bug-report-controls | ||
(-> (is-a?/c area-container<%>) | ||
saved-report? | ||
(-> any) | ||
(-> any) | ||
(-> any) | ||
any)]) | ||
(provide (contract-out | ||
[add-bug-report-controls | ||
(-> (is-a?/c area-container<%>) saved-report? (-> any) (-> any) (-> any) any)])) | ||
|
||
(define (add-bug-report-controls compose-panel init-bug-report ok cancel close-and-save) | ||
(define top-panel (make-object vertical-panel% compose-panel)) | ||
|
@@ -61,10 +56,9 @@ | |
(define (align-labels) | ||
(send synthesized-dialog reflow-container) | ||
(send compose-panel reflow-container) | ||
(let ([width (apply max (map (lambda (x) (send (car (send x get-children)) get-width)) | ||
lps))]) | ||
(for ([x (in-list lps)]) | ||
(send x min-width width)))) | ||
(define width (apply max (map (lambda (x) (send (car (send x get-children)) get-width)) lps))) | ||
(for ([x (in-list lps)]) | ||
(send x min-width width))) | ||
|
||
(define name | ||
(build/label | ||
|
@@ -151,24 +145,19 @@ | |
(build/label | ||
label | ||
(lambda (panel) | ||
(let* ([text (new (editor:standard-style-list-mixin | ||
(editor:keymap-mixin | ||
(if key | ||
save-text% | ||
text:basic%))))] | ||
[canvas (new canvas:basic% | ||
(style '(hide-hscroll)) | ||
(parent panel) | ||
(editor text))]) | ||
(send text set-paste-text-only #t) | ||
(send text auto-wrap #t) | ||
(send text set-max-undo-history 'forever) | ||
(send text set-styles-fixed #t) | ||
(when key | ||
(send text insert (saved-report-lookup init-bug-report key)) | ||
(send text set-position 0 0) | ||
(send text initialized)) | ||
canvas)) | ||
(define text | ||
(new (editor:standard-style-list-mixin | ||
(editor:keymap-mixin (if key save-text% text:basic%))))) | ||
(define canvas (new canvas:basic% (style '(hide-hscroll)) (parent panel) (editor text))) | ||
(send text set-paste-text-only #t) | ||
(send text auto-wrap #t) | ||
(send text set-max-undo-history 'forever) | ||
(send text set-styles-fixed #t) | ||
(when key | ||
(send text insert (saved-report-lookup init-bug-report key)) | ||
(send text set-position 0 0) | ||
(send text initialized)) | ||
canvas) | ||
#t | ||
#:stretch? stretch? | ||
#:top-panel top-panel | ||
|
@@ -253,28 +242,24 @@ | |
(send synthesized-dialog reflow-container) ;; help out the editor by resizing the container to a reasonable width (and thus make word-wrapping easier) | ||
|
||
(define extras | ||
(map (lambda (bri) | ||
(let ([label (bri-label bri)]) | ||
(cons | ||
label | ||
(build/label | ||
label | ||
(lambda (panel) | ||
(let ([field | ||
(keymap:call/text-keymap-initializer | ||
(lambda () | ||
(new text-field% | ||
[label #f] | ||
[parent panel] | ||
[callback void] | ||
[init-value ""] | ||
[min-height (bri-min-height bri)])))]) | ||
(send field set-value (bri-value bri)) | ||
(send (send field get-editor) set-position 0) | ||
field)) | ||
#f | ||
#:top-panel synthesized-panel)))) | ||
(get-bug-report-infos))) | ||
(for/list ([bri (in-list (get-bug-report-infos))]) | ||
(define label (bri-label bri)) | ||
(cons label | ||
(build/label label | ||
(lambda (panel) | ||
(let ([field (keymap:call/text-keymap-initializer | ||
(lambda () | ||
(new text-field% | ||
[label #f] | ||
[parent panel] | ||
[callback void] | ||
[init-value ""] | ||
[min-height (bri-min-height bri)])))]) | ||
(send field set-value (bri-value bri)) | ||
(send (send field get-editor) set-position 0) | ||
field)) | ||
#f | ||
#:top-panel synthesized-panel)))) | ||
|
||
(define still-save? #t) | ||
(define (no-more-saving) (set! still-save? #f)) | ||
|
@@ -308,9 +293,8 @@ | |
(cons 'description (get-content description)) | ||
(cons 'how-to-repeat (get-content reproduce)) | ||
(cons 'platform (get-environment))) | ||
(map (λ (bri) (cons (string->symbol (format "~a" (bri-label bri))) | ||
(bri-value bri))) | ||
(get-bug-report-infos)))) | ||
(for/list ([bri (in-list (get-bug-report-infos))]) | ||
(cons (string->symbol (format "~a" (bri-label bri))) (bri-value bri))))) | ||
|
||
(define (get-environment) | ||
(string-append (send environment get-value) | ||
|
@@ -324,28 +308,15 @@ | |
"\n" | ||
(apply | ||
string-append | ||
(map (lambda (extra) | ||
(format "~a: ~a\n" | ||
(car extra) | ||
(send (cdr extra) get-value))) | ||
extras)))) | ||
(for/list ([extra (in-list extras)]) | ||
(format "~a: ~a\n" (car extra) (send (cdr extra) get-value)))))) | ||
|
||
(define (get-content canvas) | ||
(define t (send canvas get-editor)) | ||
(send t get-text 0 (send t last-position))) | ||
|
||
(define (set-content canvas str) | ||
(define t (send canvas get-editor)) | ||
(send t begin-edit-sequence) | ||
(send t erase) | ||
(send t insert str) | ||
(send t end-edit-sequence)) | ||
|
||
(define (compose-view-focus) | ||
(send (if (string=? "" (preferences:get 'drracket:full-name)) | ||
name | ||
summary) | ||
focus)) | ||
(send (if (string=? "" (preferences:get 'drracket:full-name)) name summary) focus)) | ||
|
||
(define button-panel | ||
(new horizontal-panel% [parent compose-panel] | ||
|
@@ -368,34 +339,28 @@ | |
|
||
|
||
(define (sanity-checking) | ||
(let ([no-value? | ||
(lambda (f) | ||
(cond | ||
[(is-a? f editor-canvas%) | ||
(= 0 (send (send f get-editor) last-position))] | ||
[else (string=? "" (send f get-value))]))]) | ||
(let/ec done-checking | ||
(for-each | ||
(lambda (field field-name) | ||
(when (no-value? field) | ||
(message-box (string-constant illegal-bug-report) | ||
(format (string-constant pls-fill-in-field) field-name)) | ||
(done-checking #f))) | ||
(list name summary) | ||
(list (string-constant bug-report-field-name) | ||
(string-constant bug-report-field-summary))) | ||
|
||
(when (and (no-value? description) | ||
(no-value? reproduce)) | ||
(message-box (string-constant illegal-bug-report) | ||
(string-constant pls-fill-in-either-description-or-reproduce)) | ||
(done-checking #f)) | ||
|
||
(unless (regexp-match #rx"@" (or (preferences:get 'drracket:email) "")) | ||
(message-box (string-constant illegal-bug-report) | ||
(string-constant malformed-email-address)) | ||
(done-checking #f)) | ||
(done-checking #t)))) | ||
(define (no-value? f) | ||
(cond | ||
[(is-a? f editor-canvas%) (= 0 (send (send f get-editor) last-position))] | ||
[else (string=? "" (send f get-value))])) | ||
(let/ec done-checking | ||
(for-each (lambda (field field-name) | ||
(when (no-value? field) | ||
(message-box (string-constant illegal-bug-report) | ||
(format (string-constant pls-fill-in-field) field-name)) | ||
(done-checking #f))) | ||
(list name summary) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I would write it like this:
It's going to be difficult to come up with the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, but yeah there's no easy way to automatically pick a name for Unless... I suppose... one could use an LLM to do that... No. I will not walk down that dark road. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a |
||
(list (string-constant bug-report-field-name) | ||
(string-constant bug-report-field-summary))) | ||
(when (and (no-value? description) (no-value? reproduce)) | ||
(message-box (string-constant illegal-bug-report) | ||
(string-constant pls-fill-in-either-description-or-reproduce)) | ||
(done-checking #f)) | ||
(unless (regexp-match #rx"@" (or (preferences:get 'drracket:email) "")) | ||
(message-box (string-constant illegal-bug-report) | ||
(string-constant malformed-email-address)) | ||
(done-checking #f)) | ||
(done-checking #t))) | ||
|
||
(send version-tf set-value (format "~a" (version:version))) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we ask that
(provide (contract-out
always be on two lines?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which "two lines" are you talking about? Is it how in each clause, the identifier should be in one line, and the corresponding contract should be in another line? That can be adjusted by changing the formatter of
contract-out
. But wouldn't this look better?Or are you talking about how you always want:
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter. The
provide
and thecontract-out
on two separate lines.It may be better to think of this as something that should happen because future lines'll have less leftward drift just in general, or may it is better to special case these two? Or maybe this is an unreasonable request? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think it should always look like the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's totally reasonable! I'm simply trying to pinpoint what exactly is the general change that you want. I understand how you want the above, specific program to be formatted. But what about the below program -- which one do you prefer?
(A)
vs
(B)
I'm mentioning this because my understanding is that:
is the usual format for
provide
. So (A) seems to be more consistent with the usual format? But if that is the case, then it feels weird to me that we want:but at the same time also don't want
One possibility to satisfy all constraints might be to have a rule like "if
contract-out
is the only subform ofprovide
, thenprovide
andcontract-out
should be in different lines." That would work, but I'm not sure if that's what you had in mind.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer B in the options you provided, though I'm not thrilled about it when it happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @jackfirth's proposed rule is that if
contract-out
is one of subforms ofprovide
, then always enter a newline afterprovide
. That definitely could be done if we all agree with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree; option B is my preference too. Another option is to split the provide into two provides when there is a
contract-out
form. Maybe that's a bad idea, tho.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this? sorawee/fmt#81
which would affect the format of:
The file
test-contract-out.rkt.out
contains some example output.