]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/fuel/fuel.factor
FUEL: Display lists of callers/callees, linked to their source.
[factor.git] / extra / fuel / fuel.factor
index 0b81696ad4c70f1722a00a7b1e6ee84c7898d2fe..29fd2a43dca2d8f4b04898d7cc42a1fe28944438 100644 (file)
@@ -4,10 +4,10 @@
 USING: accessors arrays assocs classes classes.tuple
 combinators compiler.units continuations debugger definitions
 eval help io io.files io.pathnames io.streams.string kernel
-lexer listener listener.private make math memoize namespaces
-parser prettyprint prettyprint.config quotations sequences sets
-sorting source-files strings summary tools.vocabs vectors
-vocabs vocabs.loader vocabs.parser ;
+lexer listener listener.private make math math.order memoize
+namespaces parser prettyprint prettyprint.config quotations
+sequences sets sorting source-files strings summary tools.vocabs
+vectors vocabs vocabs.loader vocabs.parser words ;
 
 IN: fuel
 
@@ -166,6 +166,22 @@ M: source-file fuel-pprint path>> fuel-pprint ;
        first2 [ (normalize-path) ] dip 2array fuel-eval-set-result
     ] when* ; inline
 
+: fuel-xref-desc ( word -- str )
+    [ name>> ]
+    [ vocabulary>> [ " (" prepend ")" append ] [ "" ] if* ] bi append ; inline
+
+: fuel-format-xrefs ( seq -- seq )
+    [ word? ] filter [
+        [ fuel-xref-desc ]
+        [ where [ first2 [ (normalize-path) ] dip ] [ f f ] if* ] bi 3array
+    ] map [ [ first ] dip first <=> ] sort ; inline
+
+: fuel-callers-xref ( word -- )
+    usage fuel-format-xrefs fuel-eval-set-result ; inline
+
+: fuel-callees-xref ( word -- )
+    uses fuel-format-xrefs fuel-eval-set-result ; inline
+
 : fuel-get-vocab-location ( vocab -- )
     >vocab-link fuel-get-edit-location ; inline