adjust the tooltip check syntax property to insist
on the syntax object itself to identify the source, instead of just handing over the source
This commit is contained in:
parent
2b48e6c08a
commit
8784bd984f
|
@ -545,7 +545,7 @@
|
|||
prop)])))
|
||||
|
||||
(define mouse-over-tooltip-prop?
|
||||
(vector/c #:flat? #t any/c exact-nonnegative-integer? exact-nonnegative-integer? string?))
|
||||
(vector/c #:flat? #t syntax? exact-nonnegative-integer? exact-nonnegative-integer? string?))
|
||||
(define (add-mouse-over-tooltips stx)
|
||||
(let loop ([prop (syntax-property stx 'mouse-over-tooltips)])
|
||||
(cond
|
||||
|
@ -553,7 +553,7 @@
|
|||
(loop (car prop))
|
||||
(loop (cdr prop))]
|
||||
[(mouse-over-tooltip-prop? prop)
|
||||
(add-mouse-over/loc (vector-ref prop 0)
|
||||
(add-mouse-over/loc (find-source-editor (vector-ref prop 0))
|
||||
(vector-ref prop 1)
|
||||
(vector-ref prop 2)
|
||||
(vector-ref prop 3))])))
|
||||
|
|
|
@ -753,11 +753,12 @@ After putting this code in the DrRacket window, mouse over the words ``big'' and
|
|||
The value of the @racket['mouse-over-tooltips] property is expected to be
|
||||
to be a tree of @racket[cons] pairs (in any configuration) whose leaves
|
||||
are either ignored or are vectors of the shape
|
||||
@racketblock[(vector/c any/c exact-nonnegative-integer? exact-nonnegative-integer? string?)]
|
||||
@racketblock[(vector/c syntax? exact-nonnegative-integer? exact-nonnegative-integer? string?)]
|
||||
Each vector's content indicates where to show a tooltip. The first three components are
|
||||
the @racket[syntax-source] indicating which file the tooltip goes in, the start and end position
|
||||
in the editor where mouseovers will show the tooltip, and the content of the tooltip.
|
||||
For example, here's a macro that shows the span of itself in a tooltip on mouseover:
|
||||
a syntax object whose @racket[syntax-source] field indicates which file the tooltip goes in,
|
||||
the start and end position in the editor where mouseovers will show the tooltip,
|
||||
and the content of the tooltip. For example, here's a macro that shows the span of itself
|
||||
in a tooltip on mouseover:
|
||||
@codeblock{
|
||||
#lang racket
|
||||
(define-syntax (char-span stx)
|
||||
|
@ -767,7 +768,7 @@ For example, here's a macro that shows the span of itself in a tooltip on mouseo
|
|||
#'a
|
||||
'mouse-over-tooltips
|
||||
(vector
|
||||
(syntax-source stx)
|
||||
stx
|
||||
(syntax-position stx)
|
||||
(+ (syntax-position stx)
|
||||
(syntax-span stx))
|
||||
|
|
|
@ -71,8 +71,7 @@
|
|||
(define (type-table->tooltips)
|
||||
(for/fold ([tooltips '()])
|
||||
([(stx results) (in-hash table)]
|
||||
#:when (and (syntax-source stx)
|
||||
(syntax-position stx)
|
||||
#:when (and (syntax-position stx)
|
||||
(syntax-span stx))
|
||||
#:unless (error-at-stx-loc? stx))
|
||||
;; `printed-types` is #f if we should skip the type because it's
|
||||
|
@ -105,17 +104,17 @@
|
|||
(let ([fst (car (syntax-e stx))])
|
||||
(and (identifier? fst)
|
||||
(free-identifier=? fst #'quote))))
|
||||
(cons (vector (syntax-source stx)
|
||||
(cons (vector stx
|
||||
(sub1 (syntax-position stx))
|
||||
(+ (sub1 (syntax-position stx)) (syntax-span stx))
|
||||
printed-types)
|
||||
tooltips)]
|
||||
[else
|
||||
(list* (vector (syntax-source stx)
|
||||
(list* (vector stx
|
||||
(sub1 (syntax-position stx))
|
||||
(syntax-position stx)
|
||||
printed-types)
|
||||
(vector (syntax-source stx)
|
||||
(vector stx
|
||||
(sub1 (+ (sub1 (syntax-position stx))
|
||||
(syntax-span stx)))
|
||||
(+ (sub1 (syntax-position stx))
|
||||
|
|
Loading…
Reference in New Issue
Block a user