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-docs-menu
|
||||
syncheck:add-id-set
|
||||
syncheck:add-rename-menu
|
||||
syncheck:add-arrow
|
||||
syncheck:add-tail-arrow
|
||||
syncheck:add-mouse-over-status
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
syncheck:add-tail-arrow
|
||||
syncheck:add-mouse-over-status
|
||||
syncheck:add-jump-to-definition
|
||||
syncheck:color-range))
|
||||
syncheck:color-range
|
||||
|
||||
syncheck:add-rename-menu))
|
||||
|
||||
(define syncheck-text<%>
|
||||
(interface (syncheck-annotations<%>)
|
||||
|
@ -36,7 +38,16 @@
|
|||
(define/public (syncheck:find-source-object stx) #f)
|
||||
(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-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-arrow start-text start-pos-left start-pos-right
|
||||
end-text end-pos-left end-pos-right
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
syncheck:add-require-open-menu
|
||||
syncheck:add-id-set
|
||||
syncheck:add-arrow
|
||||
syncheck:add-rename-menu
|
||||
syncheck:add-tail-arrow
|
||||
syncheck:add-mouse-over-status
|
||||
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?]
|
||||
[path (or/c #f path-string?)])
|
||||
(values (->* (syntax?) ((-> (and/c syntax?
|
||||
(λ (x)
|
||||
(define lst (syntax->list x))
|
||||
(and lst (andmap identifier? lst))))
|
||||
void?))
|
||||
(values (->* (syntax?)
|
||||
((-> (and/c syntax?
|
||||
(λ (x)
|
||||
(define lst (syntax->list x))
|
||||
(and lst (andmap identifier? lst))))
|
||||
void?))
|
||||
void?)
|
||||
(-> void?))]{
|
||||
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
|
||||
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<%>)]{
|
||||
Supplies all of the methods in @racket[syncheck-annotations<%>]
|
||||
with default behavior. Be sure to use this mixin to future-proof
|
||||
your code and then override the methods you're interested in.
|
||||
|
||||
The @racket[syncheck:find-source-object] method ignores its arguments
|
||||
and returns @racket[#f];
|
||||
all of the other methods ignore their arguments and return @racket[(void)].
|
||||
|
||||
@examples[#:eval (let ([evaluator (make-base-eval)])
|
||||
(evaluator '(require drracket/check-syntax))
|
||||
evaluator)
|
||||
(require racket/class)
|
||||
By default:
|
||||
@itemlist[@item{The @method[syncheck-annotations<%> syncheck:find-source-object]
|
||||
method ignores its arguments and returns @racket[#f];}
|
||||
@item{the @method[syncheck-annotations<%> syncheck:add-id-set]
|
||||
manufactures a symbol and then passes that and its arguments to
|
||||
@method[syncheck-annotations<%> syncheck:add-rename-menu]
|
||||
(this is for backwards compatibility -- the @method[syncheck-annotations<%> syncheck:add-rename-menu]
|
||||
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%
|
||||
(class (annotations-mixin object%)
|
||||
(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))]
|
||||
}
|
||||
|
||||
@(close-eval syncheck-example-eval)
|
||||
|
||||
@(define-syntax-rule
|
||||
(syncheck-method-id x ...)
|
||||
(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-mouse-over-status
|
||||
syncheck:add-jump-to-definition
|
||||
syncheck:add-id-set
|
||||
syncheck:color-range]
|
||||
|
||||
@subsection{Check Syntax Button}
|
||||
|
|
Loading…
Reference in New Issue
Block a user