Expand description
RyoPattern - AST pattern matching and lint rules
This crate provides declarative pattern matching for Rust AST nodes, designed for code quality checks and refactoring detection.
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ RyoPattern Core │
├─────────────────────────────────────────────────────────────┤
│ │
│ CodePattern ──────► AST node predicate │
│ │ (structural matching) │
│ ▼ │
│ Query Extension ──► Symbol filter + body + relations │
│ │ │
│ ▼ │
│ Rule ─────────────► Query + Message + Severity │
│ │ │
│ ▼ │
│ MatchResult ──────► Bool + Captures { $VAR: Node } │
│ │
└─────────────────────────────────────────────────────────────┘§Design Principles
- Read-only: Pattern matching is pure detection; mutations are external
- Composable:
any/all/nonelogical grouping - Schema-Driven: JSON Schema enables LLM-perfect query generation
- Pre-built Graph: Relation queries use pre-computed graphs
Re-exports§
pub use concrete::parse_pattern;pub use concrete::ConcreteParser;pub use concrete::ParseError;pub use concrete::ParseResult;pub use matcher::BodyScanner;pub use matcher::ExprMatcher;pub use matcher::MatchContext;
Modules§
Structs§
- ArmPattern
- Match arm pattern for Match expressions
- Body
Match - Body match conditions for symbol bodies
- Captured
Node - A captured AST node from pattern matching
- Code
Pattern - AST Pattern for structural matching
- Diagnostic
- A diagnostic message (Clippy-compatible)
- Generator
Loader - Generator template loader
- Generator
Meta - Generator metadata
- Generator
Template - A generator template loaded from YAML
- Lint
Config - Lint configuration file structure
- Lint
Settings - Global lint settings
- Match
Attrs - Match attributes for symbol filtering
- Match
Result - Result of pattern matching
- Name
Pattern - Pattern-based name matching
- Param
Spec - Parameter specification
- Pattern
Query - Query for pattern matching (extends RyoQL Query concept)
- Position
- Position in source code
- Relation
- Single relation condition
- Relation
Target - Simplified target for relation queries
- Relations
- Relation conditions with logical grouping
- Rule
- Lint rule definition with optional fix
- Rule
Engine - Rule execution engine
- Rule
Loader - Rule loader
- Rule
Override - Override for a specific rule
- Rule
Overrides - Rule overrides configuration
- Span
- Source span (line/column based)
- Target
Match - Target match conditions
- Template
Spec - Code template specification
Enums§
- Generator
Load Error - Errors from generator loading
- Insert
Position - Where to insert the generated code
- Load
Error - Errors from rule loading
- Name
Matcher - Name matcher for symbol/method names
- Node
Kind - AST node type to match
- Pattern
Expr - Pattern expression (recursive)
- Relation
Kind - Relation kind enumeration.
- Render
Error - Errors during template rendering
- Severity
- Severity level
- Symbol
Kind - Symbol kind for query filtering
- Target
Kind - Target symbol kind
- Traversal
Scope - Traversal scope for transitive queries
- Visibility
- Visibility level
Functions§
- interpolate_
message - Message interpolation for captured variables