Skip to main content

vvv_engine/
lib.rs

1//! The engine: typed capabilities over a workspace and a language registry.
2//! [`Engine::run`] dispatches a [`Request`] and returns an in-process [`Execution`].
3//! Queries answer with concrete data; mutations retain [`Planned`] results until
4//! [`Apply`] writes and commits their history entry. [`Intent`] is the
5//! mutation description shared by history and batch.
6//!
7//! Typed clients call capability-owned `execute`, `plan`, or `apply` methods,
8//! and [`Ledger`] owns history and undo. The dispatcher orchestrates those bodies;
9//! interfaces consume [`Execution::into_answer`] only at a reporting boundary.
10//!
11//! Mutation capability types have one canonical public path, at the crate root:
12//!
13//! ```
14//! use vvv_engine::{Rename, RenameIntent, Move, MoveIntent, MoveSymbol, MoveSymbolIntent};
15//! let _: Option<(Rename, RenameIntent, Move, MoveIntent, MoveSymbol, MoveSymbolIntent)> = None;
16//! ```
17//!
18//! They are not aliases in `protocol`:
19//!
20//! ```compile_fail,E0432
21//! use vvv_engine::protocol::{Rename, RenameIntent, Move, MoveIntent, MoveSymbol, MoveSymbolIntent};
22//! ```
23//!
24//! Their owning capability modules are private:
25//!
26//! ```compile_fail,E0603
27//! use vvv_engine::capabilities::rename::Rename;
28//! ```
29
30#[cfg(test)]
31extern crate self as vvv_engine;
32
33mod batch;
34mod capabilities;
35mod change;
36mod engine;
37mod error;
38mod graph;
39mod history;
40mod plan;
41pub mod protocol;
42pub mod report;
43mod rewrite;
44mod vfs;
45mod workspace;
46
47pub use capabilities::moves::{
48    ExtractionError, Move, MoveIntent, MoveSymbol, MoveSymbolIntent, SymbolMoveCandidate,
49    SymbolMoveCandidates, SymbolMoveCandidatesQuery, SymbolMoveOwnership, SymbolMovePiece,
50    SymbolMoveUnsupported,
51};
52pub use capabilities::rename::{Rename, RenameIntent};
53pub use engine::{Engine, Execution, ExecutionKind};
54pub use error::{EngineError, RecoveryError};
55pub use graph::Retention;
56pub use history::{Applied, Apply, HistoryError, Ledger};
57pub use plan::{ApplyError, FilePreview, Planned};
58pub use protocol::{
59    Answer, Batch, BatchIntent, Call, Confidence, Consumer, Dead, DeadQuery, Definitions, Dep,
60    Deps, DepsQuery, ErrorCode, ExplainQuery, Explanation, Exposed, Failure, File, FileChange,
61    FileQuery, History, HistoryEntry, Impact, ImpactQuery, ImportSite, Importer, ImportsQuery,
62    ImportsReport, Intent, Locations, Match, MatchId, Mutation, MutationAnswer, MutationState,
63    Notice, NoticeKind, Occurrence, Outline, OutlineItem, OutlineQuery, Placed, Reach, Reason,
64    Recovery, RecoveryEffect, RecoveryIssue, RecoveryOperation, RecoveryState, RecoveryUnverified,
65    References, ReferencesQuery, Reply, Request, Respelling, Rewrite, RewriteIntent, RewriteOf,
66    Search, SearchQuery, SearchScope, Selection, SelectionError, Site, Skipped, Surface,
67    SurfaceQuery, Template, TemplateError, Undo, Unreferenced, WhereQuery, WorkspaceFiles,
68    WorkspaceFilesQuery,
69};
70pub use vfs::{
71    DiskVfs, EntryKind, MemoryVfs, MoveError, MoveState, ParentCreation, Stamp, Vfs, VfsError,
72};
73pub use workspace::Workspace;
74
75/// The nouns of the plugin contract that appear in the engine's answers, so
76/// an interface needs nothing but this crate.
77pub use vvv_core::{
78    RelPath,
79    {
80        Address, CaptureValue, Edit, Highlight, HighlightKind, ImportGroup, ImportRef, LanguageId,
81        LanguageRegistry as Languages, Modifier, ModulePath, Name, Oracle, PackageId, PathHead,
82        PathSyntax, Position, Query, QueryBuilder, QueryError, ReachKind, Referent, Role, Span,
83        Symbol, SymbolKind,
84    },
85};
86
87pub(crate) use graph::Candidate;
88pub(crate) use plan::Receipt;
89pub(crate) use vfs::Overlay;
90pub(crate) use workspace::SourceFile;
91
92pub use protocol::{
93    ContentId, DefinitionCandidate, DefinitionPreview, NavigationOrigin, NavigationOutcome,
94    NavigationQuery, NavigationReply, ResolutionEvidence, SnapshotId, SourceAnchor, SymbolRef,
95    UnavailableReason,
96};
97
98pub use capabilities::semantic::{
99    NavigationCancellation, NavigationProvider, ProviderVersion, SemanticFailure, SemanticReply,
100    SemanticRequest, SemanticTarget, SourceVersion,
101};
102
103pub use protocol::{
104    ContextBudget, ContextCandidate, ContextDetail, ContextItem, ContextOmissions, ContextOutcome,
105    ContextQuery, ContextRelation, ContextReply, ContextSignature,
106};
107
108pub use protocol::{Capability, Discovery, DiscoveryQuery, OutputLimit};
109
110pub use protocol::Command;
111#[cfg(feature = "schema")]
112pub use protocol::{SchemaContract, SchemaDocument, SchemaQuery, SchemaReferences};
113
114mod query_store;
115pub use protocol::{
116    ContextPage, ContextPageQuery, ContextUnresolved, ContextWork, ContinuationRecovery,
117    ContinueQuery, Cursor, ExpandQuery, Expansion, PageBudget, PageReply, PagedContextItem,
118    QueryLimits, SearchPage, SearchPageItem, SearchPageQuery, WorkBudget,
119};
120
121mod cancellation;
122pub use cancellation::ReadCancellation;
123
124pub use protocol::{DefinitionLocation, ResolutionOutcome, ResolutionQuery, ResolutionReply};
125
126pub use crate::capabilities::relationships::{
127    Relationship, RelationshipBudget, RelationshipCoverage, RelationshipKind, RelationshipLimit,
128    RelationshipLimitation, RelationshipResolution, Relationships, RelationshipsQuery,
129};
130
131pub use vvv_core::CallKind;
132
133mod plan_store;
134pub use plan_store::PlanLimits;
135pub use protocol::{
136    ApplyPlanQuery, DiscardPlanQuery, InspectPlanQuery, PlanId, PlanPreview, PlanReceipt,
137    PlanReview, PlanReviewCursor, PlanReviewItem, PlanReviewKind, PlanReviewPage, PlanReviewReply,
138    PlanStatus, PrepareMoveIntent, PrepareMoveQuery, PrepareMoveSymbolIntent,
139    PrepareMoveSymbolQuery, PrepareRenameQuery, PrepareRewriteQuery, ReviewMutation,
140    ReviewPlanQuery, ReviewSection, ReviewTotals,
141};
142
143pub use crate::capabilities::validation::{
144    CheckCommand, CheckFailure, CheckOperation, CheckOutcome, CheckOutput, CheckResult,
145    ValidatePlanQuery, ValidationBudget, ValidationReport, ValidationSourceState,
146};