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

From: John Clements (clements at brinckerhoff.org)
Date: Wed Jun 20 22:48:27 EDT 2012

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:



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:




Would others find this useful?

John


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120620/7f0bae25/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2012-06-20 at 7.44.52 PM.png
Type: image/png
Size: 13604 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120620/7f0bae25/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2012-06-20 at 7.46.24 PM.png
Type: image/png
Size: 28353 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120620/7f0bae25/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120620/7f0bae25/attachment-0001.p7s>

Posted on the dev mailing list.