Skip to main content

ryo_pattern/
lib.rs

1#![warn(missing_docs)]
2//! RyoPattern - AST pattern matching and lint rules
3//!
4//! This crate provides declarative pattern matching for Rust AST nodes,
5//! designed for code quality checks and refactoring detection.
6//!
7//! # Architecture
8//!
9//! ```text
10//! ┌─────────────────────────────────────────────────────────────┐
11//! │  RyoPattern Core                                             │
12//! ├─────────────────────────────────────────────────────────────┤
13//! │                                                              │
14//! │  CodePattern ──────► AST node predicate                     │
15//! │       │               (structural matching)                  │
16//! │       ▼                                                      │
17//! │  Query Extension ──► Symbol filter + body + relations       │
18//! │       │                                                      │
19//! │       ▼                                                      │
20//! │  Rule ─────────────► Query + Message + Severity             │
21//! │       │                                                      │
22//! │       ▼                                                      │
23//! │  MatchResult ──────► Bool + Captures { $VAR: Node }         │
24//! │                                                              │
25//! └─────────────────────────────────────────────────────────────┘
26//! ```
27//!
28//! # Design Principles
29//!
30//! 1. **Read-only**: Pattern matching is pure detection; mutations are external
31//! 2. **Composable**: `any`/`all`/`none` logical grouping
32//! 3. **Schema-Driven**: JSON Schema enables LLM-perfect query generation
33//! 4. **Pre-built Graph**: Relation queries use pre-computed graphs
34
35mod code_pattern;
36pub mod concrete;
37mod diagnostic;
38mod engine;
39mod generator;
40mod loader;
41pub mod matcher;
42mod relation;
43mod rule;
44
45pub use code_pattern::*;
46pub use concrete::{parse_pattern, ConcreteParser, ParseError, ParseResult};
47pub use diagnostic::*;
48pub use engine::*;
49pub use generator::{
50    GeneratorLoadError, GeneratorLoader, GeneratorMeta, GeneratorTemplate, InsertPosition,
51    ParamSpec, RenderError, TemplateSpec,
52};
53pub use loader::*;
54pub use matcher::{BodyScanner, ExprMatcher, MatchContext};
55pub use relation::*;
56pub use rule::*;