Documentation
¶
Overview ¶
Package depusage extracts dependency-usage facts from source code: which modules a file imports, which symbols of those imports are actually used, and (within a single file) who calls who.
It is built for tools that need to answer "does the user's code reach this dependency?" without committing to a full whole-program callgraph: dependency analyzers cutting noise from unreachable CVEs, SBOM enrichers tagging used-vs-transitive, SAST tools gating findings on actual call paths.
Tree-sitter does the parsing. Callers pass a Language enum and a []byte of source; the result is a typed Result with imports, optional [UsedSymbol]s, and an optional intra-file CallGraph.
No IO, no project model, no multi-file resolution — keep that in the consumer.
Index ¶
Constants ¶
const ( JavaScript = extract.JavaScript TypeScript = extract.TypeScript Python = extract.Python Go = extract.Go Rust = extract.Rust Ruby = extract.Ruby Java = extract.Java PHP = extract.PHP CSharp = extract.CSharp )
const ( ImportStatic = extract.ImportStatic ImportDynamic = extract.ImportDynamic ImportRequire = extract.ImportRequire ImportRelative = extract.ImportRelative )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImportKind ¶
type ImportKind = extract.ImportKind
type Result ¶
func Extract ¶
Extract is the top-level dispatcher. It picks the per-language extractor implementation, runs the requested passes, and returns the aggregated result.
Per-language extractors live under internal/lang/<name>. Each one owns its own tree-sitter parser pool, query, and dep-key normalizer.
Concurrency: safe for concurrent callers — every per-language extractor maintains its own pool.
type UsedSymbol ¶
type UsedSymbol = extract.UsedSymbol
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
extract
Package extract holds the shared types used by depusage's public API and its per-language sub-packages.
|
Package extract holds the shared types used by depusage's public API and its per-language sub-packages. |
|
lang/csharp
Package csharp implements the C# import extractor.
|
Package csharp implements the C# import extractor. |
|
lang/golang
Package golang implements the Go import extractor.
|
Package golang implements the Go import extractor. |
|
lang/java
Package java implements the Java import extractor.
|
Package java implements the Java import extractor. |
|
lang/javascript
Package javascript implements the JavaScript (and TypeScript) import extractor.
|
Package javascript implements the JavaScript (and TypeScript) import extractor. |
|
lang/php
Package php implements the PHP import extractor.
|
Package php implements the PHP import extractor. |
|
lang/python
Package python implements the Python import extractor.
|
Package python implements the Python import extractor. |
|
lang/ruby
Package ruby implements the Ruby import extractor.
|
Package ruby implements the Ruby import extractor. |
|
lang/rust
Package rust implements the Rust import extractor.
|
Package rust implements the Rust import extractor. |
|
tsutil
Package tsutil holds tree-sitter helpers shared across the per-language extractors: a per-language parser pool and a tiny query-compile-once wrapper.
|
Package tsutil holds tree-sitter helpers shared across the per-language extractors: a per-language parser pool and a tiny query-compile-once wrapper. |