1 ! (c)2009 Joe Groff bsd license
2 USING: accessors arrays assocs combinators.short-circuit
3 compiler.units debugger init io sets
4 io.streams.null kernel namespaces prettyprint sequences
5 source-files.errors summary tools.crossref
6 tools.crossref.private tools.errors words ;
9 SYMBOL: +deprecation-note+
10 SYMBOL: deprecation-notes
12 deprecation-notes [ H{ } clone ] initialize
14 TUPLE: deprecation-note-error < source-file-error ;
16 M: deprecation-note-error error-type drop +deprecation-note+ ;
18 TUPLE: deprecated-usages asset usages ;
20 : :deprecations ( -- )
21 deprecation-notes get-global values errors. ;
24 { type +deprecation-note+ }
25 { word ":deprecations" }
26 { plural "deprecated word usages" }
27 { icon "vocab:ui/tools/error-list/icons/deprecation-note.tiff" }
28 { quot [ deprecation-notes get values ] }
29 { forget-quot [ deprecation-notes get delete-at ] }
33 : <deprecation-note-error> ( error word -- deprecation-note )
34 \ deprecation-note-error <definition-error> ;
36 : deprecation-note ( word usages -- )
37 [ deprecated-usages boa ]
38 [ drop <deprecation-note-error> ]
39 [ drop deprecation-notes get-global set-at ] 2tri ;
41 : clear-deprecation-note ( word -- )
42 deprecation-notes get-global delete-at ;
44 : check-deprecations ( usage -- )
46 dup { [ "forgotten" word-prop ] [ deprecated? ] } 1||
47 [ clear-deprecation-note ] [
48 dup def>> uses [ deprecated? ] filter
49 [ clear-deprecation-note ] [ >array deprecation-note ] if-empty
53 M: deprecated-usages summary
54 drop "Deprecated words used" ;
56 M: deprecated-usages error.
57 "The definition of " write
59 " uses these deprecated words:" write nl
60 usages>> [ " " write pprint nl ] each ;
62 SINGLETON: deprecation-observer
64 : initialize-deprecation-notes ( -- )
66 get-crossref [ drop deprecated? ] assoc-filter
67 values [ keys [ check-deprecations ] each ] each
70 M: deprecation-observer definitions-changed
71 drop members [ word? ] filter
72 dup [ deprecated? ] any? not
73 [ [ check-deprecations ] each ]
74 [ drop initialize-deprecation-notes ] if ;
76 [ \ deprecation-observer add-definition-observer ]
77 "tools.deprecation" add-startup-hook
79 initialize-deprecation-notes