From fd5ab25a09ad0ea85e40bd3f94ac9f3391cabf4c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 13 Apr 2009 17:19:32 -0500 Subject: [PATCH] Better handling of errors without file/line info --- basis/editors/editors.factor | 2 +- basis/tools/walker/walker.factor | 4 ++-- basis/ui/tools/error-list/error-list.factor | 16 +++++++++++----- core/generic/standard/engines/tuple/tuple.factor | 2 ++ core/source-files/errors/errors.factor | 10 +++++----- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor index 9aed3ed8c0..6088400bd8 100644 --- a/basis/editors/editors.factor +++ b/basis/editors/editors.factor @@ -82,7 +82,7 @@ M: object error-line error get (:edit) ; : edit-error ( error -- ) - [ file>> ] [ line#>> ] bi edit-location ; + [ file>> ] [ line#>> ] bi 2dup and [ edit-location ] [ 2drop ] if ; : edit-each ( seq -- ) [ diff --git a/basis/tools/walker/walker.factor b/basis/tools/walker/walker.factor index 83a4f196e9..e6cdc36fe1 100644 --- a/basis/tools/walker/walker.factor +++ b/basis/tools/walker/walker.factor @@ -92,7 +92,7 @@ M: object add-breakpoint ; : (step-into-call-next-method) ( method -- ) next-method-quot (step-into-quot) ; -{ +<< { (step-into-quot) (step-into-dip) (step-into-2dip) @@ -102,7 +102,7 @@ M: object add-breakpoint ; (step-into-execute) (step-into-continuation) (step-into-call-next-method) -} [ t "no-compile" set-word-prop ] each +} [ t "no-compile" set-word-prop ] each >> ! Messages sent to walker thread SYMBOL: step diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor index ceb5ff0921..666801b361 100644 --- a/basis/ui/tools/error-list/error-list.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -37,14 +37,17 @@ error-toggle source-file-table error-table error-display ; SINGLETON: source-file-renderer M: source-file-renderer row-columns - drop first2 - [ [ source-file-icon ] [ ] [ length number>string ] tri* ] output>array ; + drop first2 [ + [ source-file-icon ] + [ "" or ] + [ 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 ; + drop dup [ first [ ] [ f ] if* ] when ; M: source-file-renderer column-titles drop { "" "File" "Errors" } ; @@ -76,7 +79,7 @@ M: error-renderer row-columns drop [ { [ error-type error-icon ] - [ line#>> number>string ] + [ line#>> [ number>string ] [ "" ] if* ] [ asset>> unparse-short ] [ error>> summary ] } cleave @@ -96,9 +99,12 @@ M: error-renderer column-alignment drop { 0 1 0 0 } ; : sort-errors ( seq -- seq' ) [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ; +: file-matches? ( error pathname/f -- ? ) + [ file>> ] [ dup [ string>> ] when ] bi* = ; + : ( error-list -- model ) [ model>> ] [ source-file>> ] bi - [ [ file>> ] [ string>> ] bi* = ] + [ file-matches? ] [ sort-errors ] ; :: ( error-list -- table ) diff --git a/core/generic/standard/engines/tuple/tuple.factor b/core/generic/standard/engines/tuple/tuple.factor index c88bd9d97e..7e91adfaa1 100644 --- a/core/generic/standard/engines/tuple/tuple.factor +++ b/core/generic/standard/engines/tuple/tuple.factor @@ -82,6 +82,8 @@ M: engine-word stack-effect effect boa ] [ 2drop f ] if ; +M: engine-word where "tuple-dispatch-generic" word-prop where ; + M: engine-word crossref? "forgotten" word-prop not ; M: engine-word irrelevant? drop t ; diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index 880472bc0a..ec0dbc0ddd 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -20,10 +20,7 @@ GENERIC: error-type ( error -- type ) new swap [ >>asset ] - [ - where [ first2 ] [ "" 0 ] if* - [ >>file ] [ >>line# ] bi* - ] bi + [ where [ first2 [ >>file ] [ >>line# ] bi* ] when* ] bi swap >>error ; inline : delete-file-errors ( seq file type -- ) @@ -42,8 +39,11 @@ error-types [ V{ } clone ] initialize : error-icon-path ( type -- icon ) error-types get at icon>> ; +: error-counts ( -- alist ) + error-types get [ nip dup quot>> call( -- seq ) length ] assoc-map ; + : error-summary ( -- ) - error-types get [ nip dup quot>> call( -- seq ) length ] assoc-map + error-counts [ nip 0 > ] assoc-filter [ over