Skip to content

Commit

Permalink
try to fix windows failure
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Sep 19, 2024
1 parent 0318e3a commit 4a19902
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions rust/extractor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use anyhow::Context;
use ra_ap_ide_db::line_index::LineIndex;
use std::path::PathBuf;

mod archive;
mod config;
pub mod generated;
Expand All @@ -20,16 +18,15 @@ fn main() -> anyhow::Result<()> {
root: cfg.source_archive_dir,
};
for file in cfg.inputs {
let mut trap = traps.create("source", &PathBuf::from(format!("/{}", &file.display())));
let canonical = std::path::absolute(&file).unwrap_or(file);

let canonical = std::fs::canonicalize(&canonical).unwrap_or(canonical);
archiver.archive(&canonical);
let label = trap.emit_file(&canonical);
let input = std::fs::read(&canonical)?;
let file = std::path::absolute(&file).unwrap_or(file);
let file = std::fs::canonicalize(&file).unwrap_or(file);
archiver.archive(&file);
let input = std::fs::read(&file)?;
let input = String::from_utf8(input)?;
let line_index = LineIndex::new(&input);
let display_path = canonical.to_string_lossy();
let display_path = file.to_string_lossy();
let mut trap = traps.create("source", &file);
let label = trap.emit_file(&file);
translate::SourceFileTranslator::new(trap, label, line_index)
.extract(&display_path, &input)
.context("writing trap file")?;
Expand Down
4 changes: 2 additions & 2 deletions rust/extractor/src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl SourceFileTranslator {
line_index,
}
}
pub fn extract(&mut self, path: &str, input: &str) -> Option<()> {
pub fn extract(&mut self, path: &str, input: &str) -> Result<(), std::io::Error> {
let parse = ra_ap_syntax::ast::SourceFile::parse(input, Edition::CURRENT);
for err in parse.errors() {
let start = self.line_index.line_col(err.range().start());
Expand All @@ -83,7 +83,7 @@ impl SourceFileTranslator {
} else {
log::warn!("Skipped {}", path);
}
self.trap.commit().ok()
self.trap.commit()
}
fn emit_else_branch(&mut self, node: ast::ElseBranch) -> Label<generated::Expr> {
match node {
Expand Down

0 comments on commit 4a19902

Please sign in to comment.