]> gitweb.factorcode.org Git - factor.git/commitdiff
Error list: add toggles for different error types, source file icon
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 11 Apr 2009 19:18:23 +0000 (14:18 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 11 Apr 2009 19:18:23 +0000 (14:18 -0500)
basis/ui/tools/error-list/error-list-docs.factor [new file with mode: 0644]
basis/ui/tools/error-list/error-list.factor
basis/ui/tools/error-list/icons/source-file.tiff [new file with mode: 0644]

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 (file)
index 0000000..21e9a71
--- /dev/null
@@ -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"
index b1f3c725d4f217f25d5de09dc997cd6de0391a77..73b1d7991aa0a8ea3e97ae2ec8c5aeb523ffa653 100644 (file)
@@ -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 <image-name> ;
+
+: 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 ;
+
+: <checkboxes> ( alist -- gadget )
+    [ <shelf> { 15 0 } >>gap ] dip
+    [ swap <checkbox> add-gadget ] assoc-each ;
+
+: <error-toggle> ( -- model gadget )
+    #! Linkage errors are not shown by default.
+    error-types [ dup +linkage-error+ eq? not <model> ] { } map>assoc
+    [ [ [ error-icon ] dip ] assoc-map <checkboxes> ]
+    [ <mapping> ] 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 <pathname> ] 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 1 } ;
 
-M: source-file-renderer filled-column drop 0 ;
+M: source-file-renderer filled-column drop 1 ;
 
 : <source-file-model> ( model -- model' )
     [ group-by-source-file >alist sort-keys ] <arrow> ;
@@ -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 <image-name> ;
-
 M: error-renderer row-columns
     drop [
         {
@@ -123,9 +154,16 @@ error-display "toolbar" f {
     { f com-edit }
 } define-command-map
 
+: <error-list-toolbar> ( error-list -- toolbar )
+    [ <toolbar> ] [ error-toggle>> "Show errors:" label-on-left add-gadget ] bi ;
+
+: <error-model> ( visible-errors model -- model' )
+    [ swap '[ source-file-error-type _ at ] filter ] <smart-arrow> ;
+
 :: <error-list-gadget> ( model -- gadget )
     vertical error-list-gadget new-track
-        model >>model
+        <error-toggle> [ >>error-toggle ] [ >>visible-errors ] bi*
+        dup visible-errors>> model <error-model> >>model 
         f <model> >>source-file
         f <model> >>error
         dup <source-file-table> >>source-file-table
@@ -134,6 +172,7 @@ error-display "toolbar" f {
     :> error-list
     error-list vertical <track>
         { 5 5 } >>gap
+        error-list <error-list-toolbar> f track-add
         error-list source-file-table>> <scroller> "Source files" <labeled-gadget> 1/4 track-add
         error-list error-table>> <scroller> "Errors" <labeled-gadget> 1/2 track-add
         error-list error-display>> "Details" <labeled-gadget> 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 (file)
index 0000000..5fb3375
Binary files /dev/null and b/basis/ui/tools/error-list/icons/source-file.tiff differ