diff options
Diffstat (limited to 'bin/src/lint.rs')
-rw-r--r-- | bin/src/lint.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/bin/src/lint.rs b/bin/src/lint.rs index 65ae824..e889d31 100644 --- a/bin/src/lint.rs +++ b/bin/src/lint.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | use crate::err::LintErr; | ||
2 | |||
3 | use lib::{Report, LINTS}; | 1 | use lib::{Report, LINTS}; |
4 | use rnix::WalkEvent; | 2 | use rnix::WalkEvent; |
5 | use vfs::{FileId, VfsEntry}; | 3 | use vfs::{FileId, VfsEntry}; |
@@ -10,11 +8,16 @@ pub struct LintResult { | |||
10 | pub reports: Vec<Report>, | 8 | pub reports: Vec<Report>, |
11 | } | 9 | } |
12 | 10 | ||
13 | pub fn lint(vfs_entry: VfsEntry) -> Result<LintResult, LintErr> { | 11 | pub fn lint(vfs_entry: VfsEntry) -> LintResult { |
12 | let file_id = vfs_entry.file_id; | ||
14 | let source = vfs_entry.contents; | 13 | let source = vfs_entry.contents; |
15 | let parsed = rnix::parse(source) | 14 | let parsed = rnix::parse(source); |
16 | .as_result() | 15 | |
17 | .map_err(|e| LintErr::Parse(vfs_entry.file_path.to_path_buf(), e))?; | 16 | let error_reports = parsed |
17 | .errors() | ||
18 | .into_iter() | ||
19 | .map(|e| Report::from_parse_err(e)); | ||
20 | |||
18 | let reports = parsed | 21 | let reports = parsed |
19 | .node() | 22 | .node() |
20 | .preorder_with_tokens() | 23 | .preorder_with_tokens() |
@@ -28,9 +31,8 @@ pub fn lint(vfs_entry: VfsEntry) -> Result<LintResult, LintErr> { | |||
28 | _ => None, | 31 | _ => None, |
29 | }) | 32 | }) |
30 | .flatten() | 33 | .flatten() |
34 | .chain(error_reports) | ||
31 | .collect(); | 35 | .collect(); |
32 | Ok(LintResult { | 36 | |
33 | file_id: vfs_entry.file_id, | 37 | LintResult { file_id, reports } |
34 | reports, | ||
35 | }) | ||
36 | } | 38 | } |