bring back the syncheck:add-rename-menu method in a way
that preserves backwards compatibility for the drracket/check-syntax library
This commit is contained in:
parent
dc4a74ddf3
commit
afb61944db
|
@ -29,6 +29,7 @@
|
||||||
syncheck:add-require-open-menu
|
syncheck:add-require-open-menu
|
||||||
syncheck:add-docs-menu
|
syncheck:add-docs-menu
|
||||||
syncheck:add-id-set
|
syncheck:add-id-set
|
||||||
|
syncheck:add-rename-menu
|
||||||
syncheck:add-arrow
|
syncheck:add-arrow
|
||||||
syncheck:add-tail-arrow
|
syncheck:add-tail-arrow
|
||||||
syncheck:add-mouse-over-status
|
syncheck:add-mouse-over-status
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
syncheck:add-tail-arrow
|
syncheck:add-tail-arrow
|
||||||
syncheck:add-mouse-over-status
|
syncheck:add-mouse-over-status
|
||||||
syncheck:add-jump-to-definition
|
syncheck:add-jump-to-definition
|
||||||
syncheck:color-range))
|
syncheck:color-range
|
||||||
|
|
||||||
|
syncheck:add-rename-menu))
|
||||||
|
|
||||||
(define syncheck-text<%>
|
(define syncheck-text<%>
|
||||||
(interface (syncheck-annotations<%>)
|
(interface (syncheck-annotations<%>)
|
||||||
|
@ -36,7 +38,16 @@
|
||||||
(define/public (syncheck:find-source-object stx) #f)
|
(define/public (syncheck:find-source-object stx) #f)
|
||||||
(define/public (syncheck:add-background-color source start end color) (void))
|
(define/public (syncheck:add-background-color source start end color) (void))
|
||||||
(define/public (syncheck:add-require-open-menu source start end key) (void))
|
(define/public (syncheck:add-require-open-menu source start end key) (void))
|
||||||
(define/public (syncheck:add-id-set id all-ids new-name-intereferes?) (void))
|
(define/public (syncheck:add-id-set all-ids new-name-intereferes?)
|
||||||
|
(define fst (car all-ids))
|
||||||
|
(define src (list-ref fst 0))
|
||||||
|
(define sym
|
||||||
|
(cond
|
||||||
|
[(syntax? src) (syntax-e src)]
|
||||||
|
[(object? src) (send src get-text (list-ref fst 1) (list-ref fst 2))]
|
||||||
|
[else 'just-a-random-guess-as-to-a-good-id]))
|
||||||
|
(syncheck:add-rename-menu sym all-ids new-name-intereferes?))
|
||||||
|
(define/public (syncheck:add-rename-menu sym all-ids new-name-intereferes?) (void))
|
||||||
(define/public (syncheck:add-docs-menu text start-pos end-pos key the-label path definition-tag tag) (void))
|
(define/public (syncheck:add-docs-menu text start-pos end-pos key the-label path definition-tag tag) (void))
|
||||||
(define/public (syncheck:add-arrow start-text start-pos-left start-pos-right
|
(define/public (syncheck:add-arrow start-text start-pos-left start-pos-right
|
||||||
end-text end-pos-left end-pos-right
|
end-text end-pos-left end-pos-right
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
syncheck:add-require-open-menu
|
syncheck:add-require-open-menu
|
||||||
syncheck:add-id-set
|
syncheck:add-id-set
|
||||||
syncheck:add-arrow
|
syncheck:add-arrow
|
||||||
|
syncheck:add-rename-menu
|
||||||
syncheck:add-tail-arrow
|
syncheck:add-tail-arrow
|
||||||
syncheck:add-mouse-over-status
|
syncheck:add-mouse-over-status
|
||||||
syncheck:add-jump-to-definition
|
syncheck:add-jump-to-definition
|
||||||
|
|
|
@ -621,11 +621,12 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to
|
||||||
|
|
||||||
@defproc[(make-traversal [namespace namespace?]
|
@defproc[(make-traversal [namespace namespace?]
|
||||||
[path (or/c #f path-string?)])
|
[path (or/c #f path-string?)])
|
||||||
(values (->* (syntax?) ((-> (and/c syntax?
|
(values (->* (syntax?)
|
||||||
(λ (x)
|
((-> (and/c syntax?
|
||||||
(define lst (syntax->list x))
|
(λ (x)
|
||||||
(and lst (andmap identifier? lst))))
|
(define lst (syntax->list x))
|
||||||
void?))
|
(and lst (andmap identifier? lst))))
|
||||||
|
void?))
|
||||||
void?)
|
void?)
|
||||||
(-> void?))]{
|
(-> void?))]{
|
||||||
This function creates some local state about a traversal of syntax objects
|
This function creates some local state about a traversal of syntax objects
|
||||||
|
@ -782,21 +783,42 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to
|
||||||
in @racket[mode]. The mode either indicates regular check syntax or is used indicate blame for potential contract
|
in @racket[mode]. The mode either indicates regular check syntax or is used indicate blame for potential contract
|
||||||
violations (and still experimental).
|
violations (and still experimental).
|
||||||
}
|
}
|
||||||
|
@defmethod[(syncheck:add-rename-menu [id symbol?]
|
||||||
|
[all-ids (listof (list/c (not/c #f)
|
||||||
|
exact-nonnegative-integer?
|
||||||
|
exact-nonnegative-integer?))]
|
||||||
|
[new-name-interferes? (-> symbol boolean?)])
|
||||||
|
void?]{
|
||||||
|
This method is listed only for backwards compatibility. It is not called directly
|
||||||
|
by check syntax, but it is called by the default implementation of
|
||||||
|
@method[syncheck-annotations<%> syncheck:add-rename-menu] in
|
||||||
|
@racket[annotations-mixin].
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(define syncheck-example-eval (make-base-eval))
|
||||||
|
|
||||||
@defmixin[annotations-mixin () (syncheck-annotations<%>)]{
|
@defmixin[annotations-mixin () (syncheck-annotations<%>)]{
|
||||||
Supplies all of the methods in @racket[syncheck-annotations<%>]
|
Supplies all of the methods in @racket[syncheck-annotations<%>]
|
||||||
with default behavior. Be sure to use this mixin to future-proof
|
with default behavior. Be sure to use this mixin to future-proof
|
||||||
your code and then override the methods you're interested in.
|
your code and then override the methods you're interested in.
|
||||||
|
|
||||||
The @racket[syncheck:find-source-object] method ignores its arguments
|
By default:
|
||||||
and returns @racket[#f];
|
@itemlist[@item{The @method[syncheck-annotations<%> syncheck:find-source-object]
|
||||||
all of the other methods ignore their arguments and return @racket[(void)].
|
method ignores its arguments and returns @racket[#f];}
|
||||||
|
@item{the @method[syncheck-annotations<%> syncheck:add-id-set]
|
||||||
@examples[#:eval (let ([evaluator (make-base-eval)])
|
manufactures a symbol and then passes that and its arguments to
|
||||||
(evaluator '(require drracket/check-syntax))
|
@method[syncheck-annotations<%> syncheck:add-rename-menu]
|
||||||
evaluator)
|
(this is for backwards compatibility -- the @method[syncheck-annotations<%> syncheck:add-rename-menu]
|
||||||
(require racket/class)
|
is not called directly by Check Syntax anymore; the @method[syncheck-annotations<%> syncheck:add-id-set]
|
||||||
|
calls it instead); and}
|
||||||
|
@item{all of the other methods ignore their arguments and return @racket[(void)].}]
|
||||||
|
|
||||||
|
Here is an example showing how use this library to extract all
|
||||||
|
of the arrows that Check Syntax would draw from various
|
||||||
|
expressions:
|
||||||
|
@interaction[#:eval syncheck-example-eval
|
||||||
|
(require drracket/check-syntax racket/class)
|
||||||
(define arrows-collector%
|
(define arrows-collector%
|
||||||
(class (annotations-mixin object%)
|
(class (annotations-mixin object%)
|
||||||
(super-new)
|
(super-new)
|
||||||
|
@ -838,6 +860,8 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to
|
||||||
(arrows `(λ (,(make-id 'x 1 #t)) x))]
|
(arrows `(λ (,(make-id 'x 1 #t)) x))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(close-eval syncheck-example-eval)
|
||||||
|
|
||||||
@(define-syntax-rule
|
@(define-syntax-rule
|
||||||
(syncheck-method-id x ...)
|
(syncheck-method-id x ...)
|
||||||
(begin @defidform[x]{Bound to an identifier created with @racket[define-local-member-name]
|
(begin @defidform[x]{Bound to an identifier created with @racket[define-local-member-name]
|
||||||
|
@ -852,6 +876,7 @@ Check Syntax is a part of the DrRacket collection, but is implemented via the to
|
||||||
syncheck:add-tail-arrow
|
syncheck:add-tail-arrow
|
||||||
syncheck:add-mouse-over-status
|
syncheck:add-mouse-over-status
|
||||||
syncheck:add-jump-to-definition
|
syncheck:add-jump-to-definition
|
||||||
|
syncheck:add-id-set
|
||||||
syncheck:color-range]
|
syncheck:color-range]
|
||||||
|
|
||||||
@subsection{Check Syntax Button}
|
@subsection{Check Syntax Button}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user