Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ast/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::lang::{
};
use crate::lang::{ArrayGraph, BTreeMapGraph};
use crate::repo::Repo;
use crate::lang::call_finder::{parse_imports_for_file, IMPORT_CACHE};

use git_url_parse::GitUrl;
use lsp::{git::get_commit_hash, strip_tmp, Cmd as LspCmd, DidOpen};
Expand Down Expand Up @@ -635,6 +636,11 @@ impl Repo {
&import.file,
);
}

// Populate import cache after adding Import nodes
if let Some(import_data) = parse_imports_for_file(filename, &self.lang, graph) {
IMPORT_CACHE.insert(filename.to_string(), Some(import_data));
}
}

let mut stats = std::collections::HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions ast/src/lang/call_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::LazyLock;
use tree_sitter::QueryCursor;

type ImportCache = DashMap<String, Option<Vec<(String, Vec<String>)>>>;
static IMPORT_CACHE: LazyLock<ImportCache> = LazyLock::new(DashMap::new);
pub static IMPORT_CACHE: LazyLock<ImportCache> = LazyLock::new(DashMap::new);

pub fn clear_import_cache() {
IMPORT_CACHE.clear();
Expand Down Expand Up @@ -115,7 +115,7 @@ pub fn get_imports_for_file<G: Graph>(
result
}

fn parse_imports_for_file<G: Graph>(
pub fn parse_imports_for_file<G: Graph>(
current_file: &str,
lang: &Lang,
graph: &G,
Expand Down
Loading