|
329 | 329 | ; apply-current-subst-in-tooltips is called, however, we evaluate the thunk early and replace the |
330 | 330 | ; property with the new value, improving the information in the tooltips. |
331 | 331 |
|
332 | | -(struct deferred-type-in-tooltip (type) |
| 332 | +(struct deferred-type-in-tooltip (type string) |
333 | 333 | #:property prop:procedure |
334 | | - (λ (self) (type->string (apply-current-subst (deferred-type-in-tooltip-type self))))) |
| 334 | + (λ (self) (deferred-type-in-tooltip-string self))) |
335 | 335 |
|
336 | 336 | (define/contract (attach-type stx t #:tooltip-src [tooltip-src stx]) |
337 | 337 | (->* [syntax? type?] [#:tooltip-src any/c] syntax?) |
338 | | - (let ([stx* (syntax-property stx ': t)]) |
| 338 | + (let* ([t* (apply-current-subst t)] |
| 339 | + [stx* (syntax-property stx ': t*)]) |
339 | 340 | (if (and (not (syntax-property tooltip-src 'omit-type-tooltip)) |
340 | 341 | (syntax-source tooltip-src) |
341 | 342 | (syntax-position tooltip-src) |
342 | 343 | (syntax-span tooltip-src)) |
343 | 344 | (syntax-property |
344 | 345 | stx* 'mouse-over-tooltips |
345 | | - (syntax-parse tooltip-src |
346 | | - ; If it’s a pair, just add the tooltip “on the parens”. |
347 | | - [(_ . _) |
348 | | - (cons |
349 | | - (vector tooltip-src |
350 | | - (sub1 (syntax-position tooltip-src)) |
351 | | - (syntax-position tooltip-src) |
352 | | - (deferred-type-in-tooltip t)) |
353 | | - (vector tooltip-src |
354 | | - (+ (sub1 (syntax-position tooltip-src)) (sub1 (syntax-span tooltip-src))) |
355 | | - (+ (sub1 (syntax-position tooltip-src)) (syntax-span tooltip-src)) |
356 | | - (deferred-type-in-tooltip t)))] |
357 | | - ; Otherwise, add the tooltip on the whole region. |
358 | | - [_ |
359 | | - (vector tooltip-src |
360 | | - (sub1 (syntax-position tooltip-src)) |
361 | | - (+ (sub1 (syntax-position tooltip-src)) (syntax-span tooltip-src)) |
362 | | - (deferred-type-in-tooltip t))])) |
| 346 | + (let* ([t-str (type->string t*)] |
| 347 | + [deferred-tooltip (deferred-type-in-tooltip t* t-str)]) |
| 348 | + (syntax-parse tooltip-src |
| 349 | + ; If it’s a pair, just add the tooltip “on the parens”. |
| 350 | + [(_ . _) |
| 351 | + (cons |
| 352 | + (vector tooltip-src |
| 353 | + (sub1 (syntax-position tooltip-src)) |
| 354 | + (syntax-position tooltip-src) |
| 355 | + deferred-tooltip) |
| 356 | + (vector tooltip-src |
| 357 | + (+ (sub1 (syntax-position tooltip-src)) (sub1 (syntax-span tooltip-src))) |
| 358 | + (+ (sub1 (syntax-position tooltip-src)) (syntax-span tooltip-src)) |
| 359 | + deferred-tooltip))] |
| 360 | + ; Otherwise, add the tooltip on the whole region. |
| 361 | + [_ |
| 362 | + (vector tooltip-src |
| 363 | + (sub1 (syntax-position tooltip-src)) |
| 364 | + (+ (sub1 (syntax-position tooltip-src)) (syntax-span tooltip-src)) |
| 365 | + deferred-tooltip)]))) |
363 | 366 | stx*))) |
364 | 367 | (define/contract (attach-expected stx t) |
365 | 368 | (-> syntax? type? syntax?) |
|
378 | 381 | (recursively-adjust-property |
379 | 382 | stx 'mouse-over-tooltips |
380 | 383 | (match-lambda |
381 | | - [(vector a b c (? deferred-type-in-tooltip? d)) |
382 | | - (vector a b c (d))] |
| 384 | + [(vector a b c (deferred-type-in-tooltip t _)) |
| 385 | + (vector a b c (type->string (apply-current-subst t)))] |
383 | 386 | [other other]))) |
384 | 387 |
|
385 | 388 | (define/contract (make-typed-var-transformer x t) |
|
0 commit comments