diff --git a/collects/drscheme/private/main.ss b/collects/drscheme/private/main.ss index 5748249977..7ee10a072d 100644 --- a/collects/drscheme/private/main.ss +++ b/collects/drscheme/private/main.ss @@ -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] diff --git a/collects/drscheme/private/module-browser.ss b/collects/drscheme/private/module-browser.ss index efcc57b997..9da23f68cb 100644 --- a/collects/drscheme/private/module-browser.ss +++ b/collects/drscheme/private/module-browser.ss @@ -113,6 +113,10 @@ dc-location-to-editor-location 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) @@ -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))) diff --git a/collects/drscheme/private/unit.ss b/collects/drscheme/private/unit.ss index 9bae57887a..b2b67e6c6e 100644 --- a/collects/drscheme/private/unit.ss +++ b/collects/drscheme/private/unit.ss @@ -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) diff --git a/collects/scribblings/drscheme/interface-essentials.scrbl b/collects/scribblings/drscheme/interface-essentials.scrbl index a80a896aa9..fbedebd94d 100644 --- a/collects/scribblings/drscheme/interface-essentials.scrbl +++ b/collects/scribblings/drscheme/interface-essentials.scrbl @@ -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 diff --git a/collects/scribblings/drscheme/menus.scrbl b/collects/scribblings/drscheme/menus.scrbl index acc88b6073..acdb664dce 100644 --- a/collects/scribblings/drscheme/menus.scrbl +++ b/collects/scribblings/drscheme/menus.scrbl @@ -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. + + See also @secref["module-browser"].} - @item{@defmenuitem{Hide Module Browser} Hides the 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 diff --git a/collects/string-constants/english-string-constants.ss b/collects/string-constants/english-string-constants.ss index cccb684eba..c8511c7be4 100644 --- a/collects/string-constants/english-string-constants.ss +++ b/collects/string-constants/english-string-constants.ss @@ -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!")