Skip to main content

ryo_analysis/
lib.rs

1#![warn(missing_docs)]
2//! # ryo-analysis: Code Graph and Discovery Engine
3//!
4//! This crate provides code exploration, relationship analysis, and pattern-based
5//! symbol discovery for the RYO project.
6//!
7//! # Key Design: AST-first approach
8//!
9//! Symbols are identified by their AST hierarchy (`SymbolPath`), and physical files
10//! are derived as a View layer. This enables file-independent symbol identification.
11//!
12//! # Core Concepts
13//!
14//! - **SymbolPath**: External representation for persistence and display. Unique across
15//!   the entire Rust ecosystem (e.g., `tokio::sync::Mutex::lock`).
16//! - **SymbolId**: Internal representation for fast processing. O(1) access via SlotMap
17//!   with generation counter for dangling detection.
18//! - **SymbolRegistry**: Central registry managing Symbol lifecycle and metadata.
19//! - **CodeGraphV2**: Symbol relationship graph for fast traversal.
20//! - **WorkspaceFilePath**: Self-contained file path (from ryo-symbol).
21//!
22//! # Usage
23//!
24//! ```rust,ignore
25//! use ryo_analysis::{SymbolPath, SymbolRegistry, SymbolKind};
26//!
27//! // Create a SymbolPath
28//! let path = SymbolPath::builder("tokio")
29//!     .push("sync")
30//!     .push("Mutex")
31//!     .build()?;
32//!
33//! // Register in the registry
34//! let mut registry = SymbolRegistry::new();
35//! let id = registry.register(path, SymbolKind::Struct)?;
36//!
37//! // Fast lookup
38//! let resolved = registry.resolve(id);
39//! ```
40
41pub mod ast;
42pub mod cascade;
43pub mod check;
44pub mod context;
45pub mod detail_store;
46pub mod discovery;
47pub mod import_map_builder;
48pub mod literal;
49pub mod pattern;
50pub mod query;
51pub mod summary;
52pub mod symbol;
53#[cfg(feature = "testing")]
54pub mod testing;
55pub mod uuid_persistence;
56
57// === Symbol ===
58pub use symbol::{
59    // Core types
60    CrateName,
61    // File types
62    FileId,
63    FileRegistry,
64    FileSpan,
65    InvalidFileId,
66    // Registry
67    InvalidSymbolId,
68    ParseError,
69    ReExportInfo,
70    RegistrationError,
71    // Registry Updates (for parallel execution)
72    RegistryUpdate,
73    RegistryUpdateBatch,
74    RenameError,
75    Segment,
76    SymbolId,
77    SymbolKind,
78    SymbolPath,
79    SymbolPathBuilder,
80    SymbolRef,
81    SymbolRegistry,
82    // Persistent ID
83    Uuid,
84    Visibility,
85    WorkspaceFilePath,
86};
87
88// === Pattern ===
89pub use pattern::{CaseOptions, Pattern};
90
91// === Query Module ===
92pub use query::{
93    // Lock V2 (VarId-based)
94    AccessKind,
95    // Borrow V2 (VarId-based)
96    ActiveBorrowV2,
97    BorrowAnalysis,
98    BorrowConflict,
99    BorrowKind,
100    BorrowStateV2,
101    BorrowTrackerV2,
102    ChainDirection,
103    // Graph types (V2: DoD-based, petgraph-free)
104    ChainNode,
105    ChainResult,
106    CodeEdgeV2,
107    CodeGraphV2,
108    // SpecFlow shared types
109    CommentDirective,
110    // SpecFlow V2 (DoD-based, SymbolId-based)
111    ConstraintData,
112    ConstraintKind,
113    CriticalSectionV2,
114    // DataFlow V2 (DoD-based, String-free)
115    DataFlowBuilderWorkspace,
116    DataFlowGraphV2,
117    DataFlowStats,
118    // TypeFlow V2 (DoD-based, String-free)
119    DefinitionData,
120    DeriveIndex,
121    DeriveIndexStats,
122    EdgeData,
123    EdgeId,
124    FieldAccessV2,
125    FlowChain,
126    FlowData,
127    FlowEdge,
128    FlowEdgeData,
129    FlowId,
130    FlowKind,
131    FlowStep,
132    GenericArgData,
133    GraphBuilderV2,
134    GroupData,
135    IntentData,
136    IntentKind,
137    LockAcquisitionV2,
138    LockGranularityAnalyzerV2,
139    LockStatsV2,
140    LockSuggestion,
141    LockTrackerV2,
142    LockType,
143    LookupTable,
144    MatchExprDataV2,
145    MatchExprId,
146    MoveError,
147    NodeKind,
148    QueryBuilder,
149    RefKind,
150    // Reference integrity analysis
151    ReferenceIntegrityChecker,
152    ReferenceIntegrityIssue,
153    ReferenceIntegrityResult,
154    SpecAliasData,
155    // Type alias registry (shared layer)
156    SpecAliasInfo,
157    SpecFlowBuilderV2,
158    SpecFlowGraphV2,
159    SpecLookupTable,
160    SpecNodeId,
161    SpecNodeKind,
162    SpecSource,
163    StdImplCache,
164    TraitBoundData,
165    TypeAliasEntry,
166    TypeAliasRegistry,
167    TypeAliasRegistryBuilder,
168    TypeDefKind,
169    TypeFlowBuilderV2,
170    TypeFlowGraphV2,
171    // Type impact analysis
172    TypeImpactChecker,
173    TypeImpactIssue,
174    TypeImpactResult,
175    TypeImpactV2,
176    TypeNodeId,
177    // Unused symbol analysis
178    UnusedSymbol,
179    UnusedSymbolChecker,
180    UnusedSymbolResult,
181    UsageContext,
182    UsageData,
183    VarData,
184    // VarId (internal variable identifier for DataFlowGraph)
185    VarId,
186    VarKind,
187    VarNode,
188    VarSymbolMapping,
189};
190
191// Re-export ryo-metadata types when workspace feature is enabled
192#[cfg(feature = "workspace")]
193pub use ryo_metadata::{ResolvedCrateName, ResolvedFile, ResolvedModulePath, WorkspaceResolver};
194
195// === Discovery Module ===
196pub use discovery::{
197    DiscoveredSymbol, DiscoveryEngine, DiscoveryQuery, DiscoveryResult, RelationGraph,
198    RelationKind, SortOrder, TypeFilter,
199};
200
201// === Context Module ===
202pub use context::{AnalysisConfig, AnalysisContext, ContextError, ExecutionContext, ImHashMap};
203
204// === Detail Store ===
205pub use detail_store::{
206    DetailStore, EnumDetail, FieldInfo, FunctionDetail, GenericInfo, ImplDetail, ParamInfo,
207    StructDetail, StructKind, TraitDetail, VariantInfo,
208};
209
210// === Summary (AI-readable output) ===
211pub use summary::{SummaryOptions, ToSummary};
212
213// === Check Module (LightGraphCheck) ===
214pub use check::{
215    cascade_add_derive, CascadeMutation, CascadeResult, CascadeStatus, CascadeStrategy, CheckError,
216    CheckResult, CheckWarning, GraphChecker, LightCheck,
217};
218
219// === Cascade Module (Generalized Cascade Engine) ===
220pub use cascade::{
221    CascadeAnalyzer, CascadeSpec, CascadeStrategy as NewCascadeStrategy, ImpactLevel, ImpactSet,
222    Visibility as CascadeVisibility,
223};
224
225// === Literal Module ===
226pub use literal::{LiteralCollector, LiteralInfo, LiteralKind};
227
228#[cfg(feature = "literal-search")]
229pub use literal::{LiteralIndex, LiteralMatch, LiteralQuery, LiteralSearchError};
230
231// === AST Module (Complete AST storage for v2 mutation engine) ===
232pub use ast::ASTRegistry;
233
234// === UUID Persistence ===
235pub use uuid_persistence::{NoOpUuidPersistence, UuidPersistence, UuidPersistenceError};