mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: create single Semantics object for each workspace
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use anyhow::Context;
|
||||
use archive::Archiver;
|
||||
use log::info;
|
||||
use ra_ap_hir::Semantics;
|
||||
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
|
||||
use ra_ap_project_model::ProjectManifest;
|
||||
use rust_analyzer::{ParseResult, RustAnalyzer};
|
||||
@@ -29,7 +30,6 @@ fn extract(
|
||||
text,
|
||||
errors,
|
||||
file_id,
|
||||
semantics,
|
||||
} = rust_analyzer.parse(file);
|
||||
let line_index = LineIndex::new(text.as_ref());
|
||||
let display_path = file.to_string_lossy();
|
||||
@@ -41,7 +41,7 @@ fn extract(
|
||||
label,
|
||||
line_index,
|
||||
file_id,
|
||||
semantics,
|
||||
rust_analyzer.semantics(),
|
||||
);
|
||||
|
||||
for err in errors {
|
||||
@@ -112,14 +112,20 @@ fn main() -> anyhow::Result<()> {
|
||||
if files.is_empty() {
|
||||
break;
|
||||
}
|
||||
let mut rust_analyzer = RustAnalyzer::new(manifest, &cfg.scratch_dir);
|
||||
for file in files {
|
||||
extract(&mut rust_analyzer, &archiver, &traps, file);
|
||||
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, &cfg.scratch_dir) {
|
||||
let semantics = Semantics::new(db);
|
||||
let rust_analyzer = RustAnalyzer::new(db, vfs, semantics);
|
||||
for file in files {
|
||||
extract(&rust_analyzer, &archiver, &traps, file);
|
||||
}
|
||||
} else {
|
||||
for file in files {
|
||||
extract(&RustAnalyzer::WithoutDatabase(), &archiver, &traps, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut rust_analyzer = RustAnalyzer::WithoutDatabase();
|
||||
for file in other_files {
|
||||
extract(&mut rust_analyzer, &archiver, &traps, file);
|
||||
extract(&RustAnalyzer::WithoutDatabase(), &archiver, &traps, file);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user