Skip to main content

Module ast_pattern

Module ast_pattern 

Source
Expand description

AST pattern search.

Parses user-provided function signature patterns (e.g., “fn(string) -> number”) and matches them against indexed CodeChunk signatures. Supports wildcards (*), optional keywords (async, pub), and fuzzy type matching.

§Pattern Syntax

[async] [pub] fn_keyword([param_type, ...]) [-> return_type]

Examples:

  • fn(string) -> number — any function taking a string, returning a number
  • fn(*) -> Result — any function returning a Result
  • async fn(*) — any async function
  • fn(*, *) -> bool — any function with 2 params returning bool
  • fn authenticate(*) — function named “authenticate” with any params
  • class User — class named User
  • struct *Config — struct whose name ends with “Config”

Structs§

AstMatch
Result of an AST pattern match.
AstPattern
A parsed AST search pattern.

Enums§

PatternKind
The kind of pattern target.

Functions§

parse_pattern
Parse a user-provided AST pattern string.
search_ast_pattern
Search chunks in the index using an AST pattern.