1 ! Copyright (C) 2005, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser kernel namespaces sequences definitions io.files
4 inspector continuations tools.crossref tools.vocabs
5 io prettyprint source-files assocs vocabs vocabs.loader
6 io.backend splitting accessors ;
11 M: no-edit-hook summary
12 drop "You must load one of the below vocabularies before using editor integration:" ;
16 : available-editors ( -- seq )
17 "editors" all-child-vocabs-seq [ vocab-name ] map ;
19 : editor-restarts ( -- alist )
21 [ [ "Load " prepend ] keep ] { } map>assoc ;
25 editor-restarts throw-restarts
28 : edit-location ( file line -- )
29 >r (normalize-path) r>
30 edit-hook get [ call ] [ no-edit-hook edit-location ] if* ;
33 where [ first2 edit-location ] when* ;
35 : edit-vocab ( name -- )
36 vocab-source-path 1 edit-location ;
38 GENERIC: find-parse-error ( error -- error' )
40 M: parse-error find-parse-error
41 dup error>> find-parse-error [ ] [ ] ?if ;
43 M: condition find-parse-error
44 error>> find-parse-error ;
46 M: object find-parse-error
50 error get find-parse-error [
51 [ file>> path>> ] [ line>> ] bi edit-location
55 [ "Fixing " write pprint " and all usages..." print nl ]
56 [ [ smart-usage ] keep prefix ] bi
58 [ "Editing " write . ]
60 "RETURN moves on to the next usage, C+d stops." print