big-code-analysis-ast 2.4.0

Parse and classification layer behind big-code-analysis (internal, version-locked)
Documentation
[package]
name = "big-code-analysis-ast"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true
documentation = "https://docs.rs/big-code-analysis-ast/"
readme = "README.md"
keywords = ["metrics", "tree-sitter"]
description = "Parse and classification layer behind big-code-analysis (internal, version-locked)"

[package.metadata.docs.rs]
all-features = true
# Mirrors the root manifest, so `make doc-check-docsrs` (which builds
# both crates with `--cfg docsrs`) reproduces what docs.rs renders.
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
aho-corasick = "^1.0"
num-derive = "^0.5"
num-format = "^0.4"
num-traits = "^0.2"
petgraph = "^0.8"
regex = "^1.7"
serde.workspace = true

tree-sitter.workspace = true
# Grammar crates are gated behind per-language Cargo features (see
# `[features]` below). The default feature set `all-languages` enables
# every grammar so a bare `cargo build` matches the historical
# behaviour; consumers that only need a subset of languages can opt
# into a narrower set with `--no-default-features --features rust,…`.
tree-sitter-bash = { workspace = true, optional = true }
tree-sitter-c-sharp = { workspace = true, optional = true }
tree-sitter-elixir = { workspace = true, optional = true }
tree-sitter-go = { workspace = true, optional = true }
dekobon-tree-sitter-groovy = { workspace = true, optional = true }
tree-sitter-irules = { workspace = true, optional = true }
tree-sitter-java = { workspace = true, optional = true }
tree-sitter-javascript = { workspace = true, optional = true }
tree-sitter-kotlin-ng = { workspace = true, optional = true }
tree-sitter-lua = { workspace = true, optional = true }
tree-sitter-objc = { workspace = true, optional = true }
tree-sitter-perl = { workspace = true, optional = true }
tree-sitter-php = { workspace = true, optional = true }
tree-sitter-python = { workspace = true, optional = true }
tree-sitter-ruby = { workspace = true, optional = true }
tree-sitter-rust = { workspace = true, optional = true }
tree-sitter-typescript = { workspace = true, optional = true }
tree-sitter-ccomment = { workspace = true, optional = true }
tree-sitter-mozcpp = { workspace = true, optional = true }
tree-sitter-cpp = { workspace = true, optional = true }
tree-sitter-c = { workspace = true, optional = true }
tree-sitter-mozjs = { workspace = true, optional = true }
tree-sitter-preproc = { workspace = true, optional = true }
tree-sitter-tcl = { workspace = true, optional = true }

# Per-language Cargo features. `default = ["all-languages"]` keeps the
# library's historical "every grammar compiled in" behaviour for
# callers that take the crate as a black box. `big-code-analysis`
# forwards each of these under the same name, so a `--features rust`
# build of either crate links exactly one grammar.
#
# Each language feature pulls in only the grammar crate(s) the
# matching `src/languages/language_*.rs` module needs at runtime — the
# token enums themselves carry no grammar-crate references and stay
# unconditionally compiled, so the `LANG` enum, the per-language
# `*Code` / `*Parser` tags, and the `Tree::new` / `analyze` dispatch
# surface remain identical across feature sets. Disabling a feature
# strips the grammar crate from the dep graph; calling into a
# disabled variant produces `Err(MetricsError::LanguageDisabled(LANG))`
# from every entry point that returns a `Result`.
#
# `cpp`, `c`, and `mozcpp` share the C-family helper crates
# (`tree-sitter-ccomment`, `tree-sitter-preproc`); listing the deps on
# each leaves their union enabled when any of those features is on.
[features]
default = ["all-languages"]
# Exposes the parse-and-inspect test helpers in `test_support` to a
# dependent crate's test target (the root crate's metric tests use them).
# Never enable it in a shipping build.
test-support = []
all-languages = [
  "bash",
  "c",
  "cpp",
  "csharp",
  "elixir",
  "go",
  "groovy",
  "irules",
  "java",
  "javascript",
  "kotlin",
  "lua",
  "mozcpp",
  "mozjs",
  "objc",
  "perl",
  "php",
  "python",
  "ruby",
  "rust",
  "tcl",
  "typescript",
]
bash = ["dep:tree-sitter-bash"]
# Since #720 the `Cpp` LANG variant uses the upstream community
# `tree-sitter-cpp` grammar (see `get_language!(tree_sitter_cpp)` in
# `src/macros.rs`); the Mozilla fork moved to the opt-in `mozcpp`
# feature / `LANG::Mozcpp` below. The `Ccomment` and `Preproc` LANG
# variants are internal C-family helpers (comment stripping +
# preprocessor directives) shared by all three C-family features, so
# `cpp`, `c` (added in #721), and `mozcpp` each pull them. NOTE: the
# `cpp` dep set changed in #720 (`tree-sitter-mozcpp` → `tree-sitter-cpp`)
# — a SemVer break for `--no-default-features` consumers, recorded in
# CHANGELOG under the 2.0 milestone.
# Internal: the C-family comment-stripping (`Ccomment`) and
# preprocessor (`Preproc`) helper variants. Enabled automatically by
# every C-family language feature below (`cpp`, `c`, `mozcpp`) so those
# helper LANG variants are compiled in whenever any C-family grammar is.
# Not meant to be selected on its own — it pulls no user-facing language.
# (Before #721 these crates were listed directly on each C-family
# feature, but the `Ccomment` / `Preproc` LANG variants were gated on
# `cpp` alone, so a `--features c` / `--features mozcpp` build without
# `cpp` had the crates yet disabled the variants — breaking `strip-comments`
# / `preproc` for C-only and Mozcpp-only builds.)
c-family-helpers = ["dep:tree-sitter-ccomment", "dep:tree-sitter-preproc"]
cpp = ["dep:tree-sitter-cpp", "c-family-helpers"]
# Dedicated C language (`LANG::C`, upstream `tree-sitter-c`), added in
# #721. Owns `.c`; shares the C-family `ccomment` / `preproc` helpers.
c = ["dep:tree-sitter-c", "c-family-helpers"]
# Opt-in Mozilla/Gecko C++ dialect (vendored `tree-sitter-mozcpp` fork,
# `LANG::Mozcpp`). Owns zero file extensions — selected only explicitly
# (`--language mozcpp`, manifest, API), mirroring `mozjs` since #507.
# Enabling `mozcpp` alone therefore analyzes no files by extension.
mozcpp = ["dep:tree-sitter-mozcpp", "c-family-helpers"]
csharp = ["dep:tree-sitter-c-sharp"]
elixir = ["dep:tree-sitter-elixir"]
go = ["dep:tree-sitter-go"]
groovy = ["dep:dekobon-tree-sitter-groovy"]
irules = ["dep:tree-sitter-irules"]
java = ["dep:tree-sitter-java"]
javascript = ["dep:tree-sitter-javascript"]
kotlin = ["dep:tree-sitter-kotlin-ng"]
lua = ["dep:tree-sitter-lua"]
mozjs = ["dep:tree-sitter-mozjs"]
# Objective-C (`LANG::Objc`, upstream `tree-sitter-objc`). Owns `.m`;
# `.mm` Objective-C++ stays on `LANG::Cpp` (the ObjC grammar parses C
# but not the C++ half of `.mm` files) — see #724.
objc = ["dep:tree-sitter-objc"]
perl = ["dep:tree-sitter-perl"]
php = ["dep:tree-sitter-php"]
python = ["dep:tree-sitter-python"]
ruby = ["dep:tree-sitter-ruby"]
rust = ["dep:tree-sitter-rust"]
tcl = ["dep:tree-sitter-tcl"]
typescript = ["dep:tree-sitter-typescript"]

[lints]
workspace = true

[dev-dependencies]
pretty_assertions = "^1.3"
serde_json.workspace = true
tempfile.workspace = true