From 80ed1dd9542d420992c7f1ee9a197a3fd0674939 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 20 Aug 2009 15:10:42 -0500 Subject: [PATCH] "deprecated" declaration, "deprecation" vocab to track deprecations in the error log --- basis/deprecation/authors.txt | 1 + basis/deprecation/deprecation.factor | 72 ++++++++++++++++++ basis/deprecation/summary.txt | 1 + basis/see/see.factor | 3 +- .../error-list/icons/deprecation-note.tiff | Bin 0 -> 2542 bytes core/bootstrap/syntax.factor | 1 + core/syntax/syntax-docs.factor | 4 + core/syntax/syntax.factor | 1 + core/words/words-docs.factor | 10 +++ core/words/words.factor | 10 ++- 10 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 basis/deprecation/authors.txt create mode 100644 basis/deprecation/deprecation.factor create mode 100644 basis/deprecation/summary.txt create mode 100644 basis/ui/tools/error-list/icons/deprecation-note.tiff diff --git a/basis/deprecation/authors.txt b/basis/deprecation/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/basis/deprecation/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/basis/deprecation/deprecation.factor b/basis/deprecation/deprecation.factor new file mode 100644 index 0000000000..4774ba7ff9 --- /dev/null +++ b/basis/deprecation/deprecation.factor @@ -0,0 +1,72 @@ +! (c)2009 Joe Groff bsd license +USING: accessors arrays assocs compiler.units +debugger io kernel namespaces prettyprint sequences +source-files.errors summary tools.crossref.private +tools.errors words ; +IN: deprecation + +SYMBOL: +deprecation-note+ +SYMBOL: deprecation-notes + +deprecation-notes [ H{ } clone ] initialize + +TUPLE: deprecation-note < source-file-error ; + +M: deprecation-note error-type drop +deprecation-note+ ; + +TUPLE: deprecated-usages asset usages ; + +: :deprecations ( -- ) + deprecation-notes get-global values errors. ; + +T{ error-type + { type +deprecation-note+ } + { word ":deprecations" } + { plural "deprecated word usages" } + { icon "vocab:ui/tools/error-list/icons/deprecation-note.tiff" } + { quot [ deprecation-notes get values ] } + { forget-quot [ deprecation-notes get delete-at ] } +} define-error-type + +: ( error word -- deprecation-note ) + \ deprecation-note ; + +: deprecation-note ( word usages -- ) + [ deprecated-usages boa ] + [ drop ] + [ drop deprecation-notes get-global set-at ] 2tri ; + +: clear-deprecation-note ( word -- ) + deprecation-notes get-global delete-at ; + +: check-deprecations ( word -- ) + dup "forgotten" word-prop + [ clear-deprecation-note ] [ + dup def>> [ deprecated? ] filter + [ clear-deprecation-note ] [ >array deprecation-note ] if-empty + ] if ; + +M: deprecated-usages summary + drop "Deprecated words used" ; + +M: deprecated-usages error. + "The definition of " write + dup asset>> pprint + " uses these deprecated words:" write nl + usages>> [ " " write pprint nl ] each ; + +SINGLETON: deprecation-observer + +: initialize-deprecation-notes ( -- ) + get-crossref [ drop deprecated? ] assoc-filter + values [ keys [ check-deprecations ] each ] each ; + +M: deprecation-observer definitions-changed + drop keys [ word? ] filter + dup [ deprecated? ] filter empty? + [ [ check-deprecations ] each ] + [ drop initialize-deprecation-notes ] if ; + +\ deprecation-observer add-definition-observer + +initialize-deprecation-notes diff --git a/basis/deprecation/summary.txt b/basis/deprecation/summary.txt new file mode 100644 index 0000000000..513938d044 --- /dev/null +++ b/basis/deprecation/summary.txt @@ -0,0 +1 @@ +Tracking usage of deprecated words diff --git a/basis/see/see.factor b/basis/see/see.factor index 206bdbb906..1b3bd4bfb5 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -101,6 +101,7 @@ M: object declarations. drop ; M: word declarations. { POSTPONE: delimiter + POSTPONE: deprecated POSTPONE: inline POSTPONE: recursive POSTPONE: foldable @@ -229,4 +230,4 @@ PRIVATE> ] { } make prune ; : see-methods ( word -- ) - methods see-all nl ; \ No newline at end of file + methods see-all nl ; diff --git a/basis/ui/tools/error-list/icons/deprecation-note.tiff b/basis/ui/tools/error-list/icons/deprecation-note.tiff new file mode 100644 index 0000000000000000000000000000000000000000..1eef0ef52ce5283374bdda2f33871ba4fd9dbcfe GIT binary patch literal 2542 zcmebEWzb?^;NA*cgZKZ@B!&OVf^7KQvlPkvlf;@0Gyi|R*8eY6 z8voOb1##JN1KoUmaSpKCK<>kb+nvS!gUpBFEm3m+C3slS?ZGgAhL0p%4@@ty^qVsE z|G}Dk$aYZGe3&~H1xo+tXJ-Q0Lv{220mE#Pr^J6w7DlR@|F}@~zl#z#-tZweewPMG z{}OpZjYAxFNv8ZVdjJK>Leud zg@F85#M;5j22LL^v(V{3KyzLLu`JAd5Df$%J3#&bg%v12lY>tH^|b=AD6-k3?BQEK zG6*m-FfapSoRL8SNH8L?nZRroU@PeyBQsPSsF;xr%4Pzx1sQgIH NAO ; -INSTANCE: word definition \ No newline at end of file +INSTANCE: word definition