Expand description
Graph construction and caching logic for the server.
§Overview
This module is responsible for turning raw parser facts into a fully
resolved CodePropertyGraph. It supports three distinct workflows:
- build – parse a project or a single file and construct the graph from scratch.
- cache – serialise the graph to a compressed binary format using
icb_graph::cacheso that subsequent runs can skip parsing entirely. - load – restore a previously cached graph, automatically cleaning up node names.
§Incremental fact caching
When a cache directory is provided (or the default .icb_cache is
used), the module stores extracted facts for every source file together
with a SHA‑256 hash of the file content. On subsequent runs, files that
have not changed are loaded directly from the cache, skipping the parser
entirely. This can reduce the analysis time for large projects from
seconds to milliseconds.
The incremental cache is transparently used by both the Clang and tree‑sitter backends – you get fast reloads regardless of the chosen parser.
§C/C++: Clang preferred, tree‑sitter fallback
For C and C++ projects the module prefers the Clang parser when the
icb-clang crate is available. Clang provides exact semantic
analysis and never mistakes documentation, HTML, or embedded JavaScript
for C++ code. If Clang cannot be loaded (e.g. LLVM not installed), the
pipeline automatically falls back to tree‑sitter‑cpp.
§Strict file extension filtering & multi‑language support
For every known language, only a curated list of file extensions is
accepted. This eliminates noise from documentation, build artefacts,
and web assets. When build_or_load_graph_multi is called with a
specific list of languages, only those extensions are scanned.
§Auto‑detection of language
When language is "auto", the module scans the project directory
and picks the dominant language based on file extensions. Unknown
extensions fall back to the universal heuristic parser.
Structs§
Functions§
- build_
or_ load_ graph - Entry point: single-language
- build_
or_ load_ graph_ multi - Entry point: multi-language
- detect_
language_ 🔒from_ extension - detect_
language_ 🔒from_ project - extensions_
for_ 🔒language - is_
javascript_ 🔒noise - is_
type_ 🔒keyword - is_
valid_ 🔒identifier - parse_
language 🔒 - resolve_
language 🔒 - run_
pipeline 🔒 - Core pipeline executor
- strip_
comments 🔒 - try_
clang_ 🔒pipeline