feat(xatu): add lint architecture
This commit was merged in pull request #71.
This commit is contained in:
@@ -1,14 +1,29 @@
|
||||
use std::path::PathBuf;
|
||||
mod ast;
|
||||
mod file_store;
|
||||
mod parser;
|
||||
mod rules;
|
||||
|
||||
pub use file_store::{FileId, FileStore, SourceFile};
|
||||
|
||||
pub fn run(files: Vec<SourceFile>) -> status::Result<()> {
|
||||
let mut store = FileStore::default();
|
||||
|
||||
for file in files {
|
||||
println!("{}", file.path.display());
|
||||
let file_id = store.add(file);
|
||||
let file = store.get(file_id);
|
||||
let parsed = parser::parse_file(file_id, &file.source);
|
||||
|
||||
for diagnostic in rules::run_rules(&parsed) {
|
||||
println!(
|
||||
"{}:{}..{}: {}: {}",
|
||||
file.path.display(),
|
||||
diagnostic.finding.range.start,
|
||||
diagnostic.finding.range.end,
|
||||
diagnostic.finding.rule_id,
|
||||
diagnostic.finding.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SourceFile {
|
||||
pub path: PathBuf,
|
||||
pub source: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user