[racket-dev] check-syntax hack: patch to show how many uses an identifier has

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jun 21 11:58:09 EDT 2012

+a lot; I'd like that


On Jun 20, 2012, at 10:48 PM, John Clements wrote:

> When I'm using online check syntax, I often look at the lines leaving an identifier and wonder: is that just one line, or are there two or three? When lines overlap, there's no easy way to tell. This can be important in refactoring decisions, or in debugging (how many uses of this thing are there to check?).
> 
> Let me show you what I mean:
> 
> <Screen Shot 2012-06-20 at 7.44.52 PM.png>
> 
> How many uses of 'x' are there?
> 
> I decided to spend a few minutes digging through the source, and came up with this *EXTREMELY ROUGH* hack which helps me. :
> 
> oiseau:...plt/collects/drracket/private/syncheck clements> git diff gui.rkt
> diff --git a/collects/drracket/private/syncheck/gui.rkt b/collects/drracket/private/syncheck/gui.rkt
> index 5f691bd..e69b9c7 100644
> --- a/collects/drracket/private/syncheck/gui.rkt
> +++ b/collects/drracket/private/syncheck/gui.rkt
> @@ -1069,6 +1069,11 @@ If the namespace does not, they are colored the unbound color.
>                                        [var-arrows (filter var-arrow? arrows)]
>                                        [add-menus (append (map cdr (filter pair? vec-ents))
>                                                           (filter procedure? vec-ents))])
> +                                 (make-object menu-item%
> +                                   (string-append ">> " (number->string (length arrows))
> +                                                  " arrows from this identifier")
> +                                   menu
> +                                   (λ (item evt) (void)))
>                                   (unless (null? arrows)
>                                     (make-object menu-item%
>                                       (string-constant cs-tack/untack-arrow)
> 
> 
> Let me just emphasize how rough this hack is: when I use it on a use of an identifier rather than a definition, it just shows the number 1, because that's the number of arrows--that is, the one that goes back to the definition.
> 
> Keeping its limitations in mind, though, it's really nice to be able to see:
> 
> <Screen Shot 2012-06-20 at 7.46.24 PM.png>
> 
> 
> Would others find this useful?
> 
> John
> 
> 
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev



Posted on the dev mailing list.