added phase information to the module browser
svn: r15968
This commit is contained in:
parent
13392b229a
commit
a9cf0a39a7
|
@ -138,7 +138,7 @@
|
|||
number-between-zero-and-one?))
|
||||
|
||||
(preferences:set-default 'drscheme:module-browser:name-length 1
|
||||
(λ (x) (memq x '(0 1 2))))
|
||||
(λ (x) (memq x '(0 1 2 3))))
|
||||
|
||||
(let ([frame-width 600]
|
||||
[frame-height 650]
|
||||
|
|
|
@ -114,6 +114,10 @@
|
|||
find-snip
|
||||
get-canvas)
|
||||
|
||||
;; require-depth-ht : hash[(list snip snip) -o> (listof integer)]
|
||||
;; maps parent/child snips (ie, those that match up to modules that require each other) to phase differences
|
||||
(define require-depth-ht (make-hash))
|
||||
|
||||
(define name-length 'long)
|
||||
(define/public (set-name-length nl)
|
||||
(unless (eq? name-length nl)
|
||||
|
@ -192,11 +196,24 @@
|
|||
|
||||
|
||||
(set! max-lines #f)
|
||||
|
||||
(compute-snip-require-phases)
|
||||
(remove-specially-linked)
|
||||
(render-snips)
|
||||
(end-edit-sequence))
|
||||
|
||||
(define/private (compute-snip-require-phases)
|
||||
(let ([ht (make-hash)]) ;; avoid infinite loops
|
||||
(for ([snip (in-list (get-top-most-snips))])
|
||||
(let loop ([parent snip]
|
||||
[depth 0]) ;; depth is either an integer or #f (indicating for-label)
|
||||
(unless (hash-ref ht (cons parent depth) #f)
|
||||
(hash-set! ht (cons parent depth) #t)
|
||||
(send parent add-require-phase depth)
|
||||
(for ([child (in-list (send parent get-children))])
|
||||
(for ([delta-depth (in-list (hash-ref require-depth-ht (list parent child)))])
|
||||
(loop child
|
||||
(and depth delta-depth (+ delta-depth depth))))))))))
|
||||
|
||||
;; add-connection : string string (union symbol #f) number -> void
|
||||
;; name-original and name-require and the identifiers for those paths and
|
||||
;; original-filename? and require-filename? are booleans indicating if the names
|
||||
|
@ -210,6 +227,10 @@
|
|||
[require-snip (find/create-snip name-require require-filename?)]
|
||||
[original-level (send original-snip get-level)]
|
||||
[require-level (send require-snip get-level)])
|
||||
(let ([require-depth-key (list original-snip require-snip)])
|
||||
(hash-set! require-depth-ht
|
||||
require-depth-key
|
||||
(cons require-depth (hash-ref require-depth-ht require-depth-key '()))))
|
||||
(case require-depth
|
||||
[(0)
|
||||
(add-links original-snip require-snip
|
||||
|
@ -499,6 +520,13 @@
|
|||
lines
|
||||
pb)
|
||||
|
||||
(define require-phases '())
|
||||
(define/public (add-require-phase d)
|
||||
(unless (member d require-phases)
|
||||
(set! last-name #f)
|
||||
(set! last-size #f)
|
||||
(set! require-phases (sort (cons d require-phases) < #:key (λ (x) (or x +inf.0))))))
|
||||
|
||||
(field [special-children (make-hasheq)])
|
||||
(define/public (is-special-key-child? key child)
|
||||
(let ([ht (hash-ref special-children key #f)])
|
||||
|
@ -591,7 +619,12 @@
|
|||
(cons (substring short-name 0 1)
|
||||
(map (λ (x) (substring x 1 2))
|
||||
ms)))])))))]
|
||||
[(long) word]))
|
||||
[(long) word]
|
||||
[(very-long)
|
||||
(string-append
|
||||
word
|
||||
": "
|
||||
(format "~s" require-phases))]))
|
||||
last-name])))
|
||||
|
||||
(super-new)))
|
||||
|
|
|
@ -3225,7 +3225,8 @@ module browser threading seems wrong.
|
|||
(label (string-constant module-browser-name-length))
|
||||
(choices (list (string-constant module-browser-name-short)
|
||||
(string-constant module-browser-name-medium)
|
||||
(string-constant module-browser-name-long)))
|
||||
(string-constant module-browser-name-long)
|
||||
(string-constant module-browser-name-very-long)))
|
||||
(selection (preferences:get 'drscheme:module-browser:name-length))
|
||||
(callback
|
||||
(λ (x y)
|
||||
|
@ -3257,7 +3258,8 @@ module browser threading seems wrong.
|
|||
(case i
|
||||
[(0) 'short]
|
||||
[(1) 'medium]
|
||||
[(2) 'long])))
|
||||
[(2) 'long]
|
||||
[(3) 'very-long])))
|
||||
|
||||
(define/private (mouse-currently-over snips)
|
||||
(if (null? snips)
|
||||
|
|
|
@ -706,6 +706,32 @@ file cannot be included in another debugging session.
|
|||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section[#:tag "module-browser"]{The Module Browser}
|
||||
|
||||
The module browser shows you the structure of all of the files in your program.
|
||||
It can be opened via the @onscreen{Show} menu, or via the @onscreen{Module Browser ...}
|
||||
menu item in the @onscreen{Scheme} menu.
|
||||
|
||||
A module browser window contains a square for each
|
||||
module. The squares are colored based on the number of
|
||||
lines of code in the module. If a module has more lines of
|
||||
code, it gets a darker color.
|
||||
|
||||
In addition, for each normal import, a blue line drawn is
|
||||
from the module to the importing module. Similarly, purple
|
||||
lines are drawn for each for-syntax, for-template or for-meta import. In the initial
|
||||
module layout, modules to the left import modules to the
|
||||
right, but since modules can be moved around
|
||||
interactively, that property might not be preserved.
|
||||
|
||||
To open the file corresponding to the module, right-click or
|
||||
control-click (Mac OS X) on the box for that module.
|
||||
|
||||
The module browser will also show you the phases that each
|
||||
module is loaded in; choose the ``Long, with phases'' menu item
|
||||
in the ``Names'' popup menu. The integers indicate the phases and
|
||||
if @scheme[#f] is present, it means the module is loaded @scheme[for-label].
|
||||
|
||||
@section[#:tag "create-exe"]{Creating Executables}
|
||||
|
||||
DrScheme's @onscreen{Create Executable...} menu item lets you create
|
||||
|
|
|
@ -195,9 +195,13 @@ appears at any time.
|
|||
@item{@defmenuitem{Hide Program Contour} Hides the contour window.}
|
||||
|
||||
@item{@defmenuitem{Show Module Browser} Shows the module DAG rooted
|
||||
at the currently opened file in DrScheme.}
|
||||
at the currently opened file in DrScheme.
|
||||
|
||||
@item{@defmenuitem{Hide Module Browser} Hides the module browser.}
|
||||
See also @secref["module-browser"].}
|
||||
|
||||
@item{@defmenuitem{Hide Module Browser} Hides the module browser.
|
||||
|
||||
See also @secref["module-browser"].}
|
||||
|
||||
@item{@defmenuitem{Toolbar}
|
||||
@itemize[
|
||||
|
@ -300,20 +304,8 @@ background that signals the source location of an error.}
|
|||
then opens a window showing the module import structure
|
||||
for the module import DAG starting at the selected module.
|
||||
|
||||
The module browser window contains a square for each
|
||||
module. The squares are colored based on the number of
|
||||
lines of code in the module. If a module has more lines of
|
||||
code, it gets a darker color.
|
||||
|
||||
In addition, for each normal import, a blue line drawn is
|
||||
from the module to the importing module. Similarly, purple
|
||||
lines are drawn for each for-syntax import. In the initial
|
||||
module layout, modules to the left import modules to the
|
||||
right, but since modules can be moved around
|
||||
interactively, that property might not be preserved.
|
||||
|
||||
To open the file corresponding to the module, right-click or
|
||||
control-click (Mac OS X) on the box for that module.}
|
||||
See also @secref["module-browser"].
|
||||
}
|
||||
|
||||
@item{@defmenuitem{Reindent} Indents the selected text according to
|
||||
the standard Scheme formatting conventions. (Pressing the Tab key
|
||||
|
|
|
@ -1196,6 +1196,7 @@ please adhere to these guidelines:
|
|||
(module-browser-name-short "Short")
|
||||
(module-browser-name-medium "Medium")
|
||||
(module-browser-name-long "Long")
|
||||
(module-browser-name-very-long "Long, with phases") ;; like 'Long' but shows the phases where this file is loaded
|
||||
(module-browser-open-all "Open all files shown here")
|
||||
|
||||
(happy-birthday-matthias "Happy Birthday, Matthias!")
|
||||
|
|
Loading…
Reference in New Issue
Block a user