]> gitweb.factorcode.org Git - factor.git/blob - core/source-files/errors/errors.factor
Working on adding help-lint errors to error list
[factor.git] / core / source-files / errors / errors.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs kernel math.order sorting sequences definitions ;
4 IN: source-files.errors
5
6 TUPLE: source-file-error error asset file line# ;
7
8 : sort-errors ( errors -- alist )
9     [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ;
10
11 : group-by-source-file ( errors -- assoc )
12     H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
13
14 GENERIC: source-file-error-type ( error -- type )
15
16 : <definition-error> ( error definition class -- source-file-error )
17     new
18         swap
19         [ >>asset ]
20         [
21             where [ first2 ] [ "<unknown file>" 0 ] if*
22             [ >>file ] [ >>line# ] bi*
23         ] bi
24         swap >>error ; inline
25
26 : delete-file-errors ( seq file type -- )
27     [
28         [ swap file>> = ] [ swap source-file-error-type = ]
29         bi-curry* bi and not
30     ] 2curry filter-here ;