1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser lexer kernel namespaces sequences definitions
4 io.files io.backend io.pathnames io summary continuations
5 tools.crossref vocabs.hierarchy prettyprint source-files
6 source-files.errors assocs vocabs.loader splitting
7 accessors debugger help.topics ;
8 FROM: vocabs => vocab-name >vocab-link ;
13 M: no-edit-hook summary
14 drop "You must load one of the below vocabularies before using editor integration:" ;
18 : available-editors ( -- seq )
19 "editors" child-vocabs no-roots no-prefixes [ vocab-name ] map ;
21 : editor-restarts ( -- alist )
23 [ [ "Load " prepend ] keep ] { } map>assoc ;
27 editor-restarts throw-restarts
30 : edit-location ( file line -- )
31 [ absolute-path ] dip edit-hook get-global
32 [ call( file line -- ) ] [ no-edit-hook edit-location ] if* ;
34 ERROR: cannot-find-source definition ;
36 M: cannot-find-source error.
37 "Cannot find source for ``" write
38 definition>> pprint-short
43 [ first2 edit-location ]
44 [ dup word-link? [ name>> edit ] [ cannot-find-source ] if ]
47 : edit-vocab ( name -- )
50 : edit-error ( error -- )
51 [ error-file ] [ error-line ] bi
52 over [ 1 or edit-location ] [ 2drop ] if ;
55 error get edit-error ;
57 : edit-each ( seq -- )
59 [ "Editing " write . ]
61 "RETURN moves on to the next usage, C+d stops." print
69 [ "Fixing " write pprint " and all usages..." print nl ]
70 [ [ smart-usage ] keep prefix ] bi