From a254e07fdae37912eecc23f30a8b7b4831ebdfd6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 11 Apr 2009 14:18:23 -0500 Subject: [PATCH] Error list: add toggles for different error types, source file icon --- .../tools/error-list/error-list-docs.factor | 20 ++++ basis/ui/tools/error-list/error-list.factor | 89 +++++++++++++----- .../tools/error-list/icons/source-file.tiff | Bin 0 -> 900 bytes 3 files changed, 84 insertions(+), 25 deletions(-) create mode 100644 basis/ui/tools/error-list/error-list-docs.factor create mode 100644 basis/ui/tools/error-list/icons/source-file.tiff diff --git a/basis/ui/tools/error-list/error-list-docs.factor b/basis/ui/tools/error-list/error-list-docs.factor new file mode 100644 index 0000000000..21e9a71db5 --- /dev/null +++ b/basis/ui/tools/error-list/error-list-docs.factor @@ -0,0 +1,20 @@ +IN: ui.tools.error-list +USING: help.markup help.syntax ; + +ARTICLE: "ui.tools.error-list" "UI error list tool" +"The error list tool displays messages generated by tools which process source files and definitions." +$nl +"The different types of messages displayed:" +{ $table + { "Icon" "Message type" "Reference" } + { { $image "vocab:ui/tools/error-list/icons/note.tiff" } "Parser note" { $link "parser" } } + { { $image "vocab:ui/tools/error-list/icons/syntax-error.tiff" } "Syntax error" { $link "syntax" } } + { { $image "vocab:ui/tools/error-list/icons/compiler-warning.tiff" } "Compiler warning" { $link "compiler-errors" } } + { { $image "vocab:ui/tools/error-list/icons/compiler-error.tiff" } "Compiler error" { $link "compiler-errors" } } + { { $image "vocab:ui/tools/error-list/icons/unit-test-error.tiff" } "Unit test failure" { $link "tools.test" } } + { { $image "vocab:ui/tools/error-list/icons/help-lint-error.tiff" } "Help lint failure" { $link "help.lint" } } + { { $image "vocab:ui/tools/error-list/icons/linkage-error.tiff" } "Linkage error" { $link "compiler-errors" } } +} +"The " { $vocab-link "source-files.errors" } " vocabulary contains backend code used by this tool." ; + +ABOUT: "ui.tools.error-list" diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor index b1f3c725d4..73b1d7991a 100644 --- a/basis/ui/tools/error-list/error-list.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -1,33 +1,73 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays sequences sorting assocs colors.constants -combinators combinators.smart combinators.short-circuit editors +USING: accessors arrays sequences sorting assocs colors.constants fry +combinators combinators.smart combinators.short-circuit editors memoize compiler.errors compiler.units fonts kernel io.pathnames prettyprint -stack-checker.errors source-files.errors math.parser math.order models -models.arrow models.search debugger namespaces summary locals ui -ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.tables -ui.gadgets.labeled ui.gadgets.tracks ui.gestures ui.operations -ui.tools.browser ui.tools.common ui.gadgets.scrollers -ui.tools.inspector ui.gadgets.status-bar ui.operations -ui.gadgets.buttons ui.gadgets.borders ui.images tools.test ; +tools.test stack-checker.errors source-files.errors math.parser +math.order models models.arrow models.arrow.smart models.search +models.mapping debugger namespaces summary locals ui ui.commands +ui.gadgets ui.gadgets.panes ui.gadgets.tables ui.gadgets.labeled +ui.gadgets.tracks ui.gestures ui.operations ui.tools.browser +ui.tools.common ui.gadgets.scrollers ui.tools.inspector +ui.gadgets.status-bar ui.operations ui.gadgets.buttons +ui.gadgets.borders ui.gadgets.packs ui.gadgets.labels +ui.baseline-alignment ui.images ; IN: ui.tools.error-list -TUPLE: error-list-gadget < tool source-file error source-file-table error-table error-display ; +CONSTANT: error-types + { + +compiler-warning+ + +compiler-error+ + +test-failure+ + +linkage-error+ + } + +MEMO: error-list-icon ( object -- object ) + "vocab:ui/tools/error-list/icons/" ".tiff" surround ; + +: error-icon ( type -- icon ) + { + { +compiler-error+ [ "compiler-error" ] } + { +compiler-warning+ [ "compiler-warning" ] } + { +linkage-error+ [ "linkage-error" ] } + { +test-failure+ [ "unit-test-error" ] } + } case error-list-icon ; + +: ( alist -- gadget ) + [ { 15 0 } >>gap ] dip + [ swap add-gadget ] assoc-each ; + +: ( -- model gadget ) + #! Linkage errors are not shown by default. + error-types [ dup +linkage-error+ eq? not ] { } map>assoc + [ [ [ error-icon ] dip ] assoc-map ] + [ ] bi ; + +TUPLE: error-list-gadget < tool +visible-errors source-file error +error-toggle source-file-table error-table error-display ; SINGLETON: source-file-renderer +: source-file-icon ( -- image-name ) + "source-file" error-list-icon ; + M: source-file-renderer row-columns - drop first2 length number>string 2array ; + drop first2 + [ [ source-file-icon ] [ ] [ length number>string ] tri* ] output>array ; + +M: source-file-renderer prototype-row + drop source-file-icon "" "" 3array ; M: source-file-renderer row-value drop dup [ first ] when ; M: source-file-renderer column-titles - drop { "File" "Errors" } ; + drop { "" "File" "Errors" } ; -M: source-file-renderer column-alignment drop { 0 1 } ; +M: source-file-renderer column-alignment drop { 0 0 1 } ; -M: source-file-renderer filled-column drop 0 ; +M: source-file-renderer filled-column drop 1 ; : ( model -- model' ) [ group-by-source-file >alist sort-keys ] ; @@ -48,15 +88,6 @@ M: source-file-renderer filled-column drop 0 ; SINGLETON: error-renderer -: error-icon ( type -- icon ) - { - { +compiler-error+ [ "compiler-error" ] } - { +compiler-warning+ [ "compiler-warning" ] } - { +linkage-error+ [ "linkage-error" ] } - { +test-failure+ [ "unit-test-error" ] } - } case - "vocab:ui/tools/error-list/icons/" ".tiff" surround ; - M: error-renderer row-columns drop [ { @@ -123,9 +154,16 @@ error-display "toolbar" f { { f com-edit } } define-command-map +: ( error-list -- toolbar ) + [ ] [ error-toggle>> "Show errors:" label-on-left add-gadget ] bi ; + +: ( visible-errors model -- model' ) + [ swap '[ source-file-error-type _ at ] filter ] ; + :: ( model -- gadget ) vertical error-list-gadget new-track - model >>model + [ >>error-toggle ] [ >>visible-errors ] bi* + dup visible-errors>> model >>model f >>source-file f >>error dup >>source-file-table @@ -134,6 +172,7 @@ error-display "toolbar" f { :> error-list error-list vertical { 5 5 } >>gap + error-list f track-add error-list source-file-table>> "Source files" 1/4 track-add error-list error-table>> "Errors" 1/2 track-add error-list error-display>> "Details" 1/4 track-add @@ -142,7 +181,7 @@ error-display "toolbar" f { M: error-list-gadget focusable-child* source-file-table>> ; -: error-list-help ( -- ) "ui-error-list" com-browse ; +: error-list-help ( -- ) "ui.tools.error-list" com-browse ; \ error-list-help H{ { +nullary+ t } } define-command diff --git a/basis/ui/tools/error-list/icons/source-file.tiff b/basis/ui/tools/error-list/icons/source-file.tiff new file mode 100644 index 0000000000000000000000000000000000000000..5fb33755202237f1a33c26dd51c0b0669faee4fe GIT binary patch literal 900 zcmebD)MC(LVqj>nf8fBOBF4+!;*=P$BSnejf9vEE&4+XZ{|PtS$8Vg#lEuYTzu!T> zf$M3`i4>cK8!BpKwsKu!2HC#t7K|qz7VVjr|2^8WfeIN{OzZoMlFxj>zY~pMdV71=JWXT&#ZI}W?zcQ-q6~$GJqjYPwaFm z*VY{GdzlNCJ?2a(V5ql`cu}$_?*H_s2d`yq4PdO>^-}Gsw%!qO0|v`yyT7Jc2`U}j z?dQX^W6RN%F<}gBj8(DIj_h;`+qYtKRTF>jkAgboG)o3|9Ruk%>lD`-=0u1dU~G#M zU%F8#V5&iPJmUntCwg`BpIQ8Ho!IB&@Ws-Bu^>`Rfw3drRVC9R*!BEQu0N|bF6^@w zSfa$i(BPrLtZnn*w_oJ61je2O@uwU4d_;nL)EESvXIxp;pr>%pzCVG1S<72^%6jcn zn>X1tPhYw+i$UTUXG63=%0hc%hm?wUW^L^snCfRHOwi(z7vT1pyL|PlUvrOsxx`T! z!l3w}dfw9&e=c$qk1L7{8YnmYLdiV5};pX@vs zs#@kdHFY5ehX?}$BQpad0|SEq5HljNnSg8-pqK(P0|PTuoE6AtgR+6ii-8Nu2I=Qz zWMU8k(i%YZf{ZL+GdX~KAtW`TP&UY1F(|tM$QFmHR{|O;#mEZQYXvk%8p?J8vSpCW z(SWjn!VHE$d#!-97m#BM6$iP^3u-2i$qYJFJnVhX)re~sOpkQFGZ)l`%V4)CbXr_=+Qc_^0uU}qXu9pc? N3B*8^dih1^3;;CY5T5`5 literal 0 HcmV?d00001