Skip to main content

php_lsp/
lib.rs

1//! # php-lsp — domain vocabulary
2//!
3//! The terms below have one canonical meaning across the crate. Use them
4//! consistently; do not introduce synonyms.
5//!
6//! ## Core nouns
7//! - **`ParsedDoc`** — a fully parsed source file: AST program + source text +
8//!   line table, backed by a bumpalo arena. The unit a user has open.
9//! - **`FileIndex`** — the compact (~2 KB) serializable per-file *declaration
10//!   summary* used for background-indexed (unopened) files.
11//! - **`WorkspaceIndex`** (`WorkspaceIndexData`) — the aggregated cross-file
12//!   index over every `FileIndex`, with name→location reverse maps.
13//! - **`Workspace`** — the salsa input representing the project root / file set.
14//!   (There is intentionally no "Codebase" type — it would be a synonym.)
15//! - **`SymbolMap` / `SymbolEntry`** — per-file precomputed name→declarations
16//!   table for *open* files; richer than `FileIndex`.
17//! - **`Declaration`** (`resolve::Declaration`) — the AST node where a symbol is
18//!   *introduced*. Shared by both the `goto_definition` and `goto_declaration`
19//!   LSP requests (which stay distinct — see `navigation/`).
20//! - **`Docblock`** — a PHPDoc `/** … */` comment and the data parsed from it.
21//!
22//! ## Naming conventions
23//! - **verb `index` → `ingest`**: ingesting a file into the store is `ingest*`;
24//!   the noun `index` (`FileIndex`, the `file_index` query) is always a data
25//!   structure, never an action.
26//! - **`doc`** as a value/variable means a `ParsedDoc`. Docblock-derived data
27//!   uses the **`Doc`** type prefix (`DocMethod`, `DocProperty`) or a field
28//!   named `docblock`. Never name a docblock field `doc`.
29//! - **Type suffixes**: `-Def` = an owned declaration record stored in an index
30//!   (`FunctionDef`, `ClassDef`); `-Entry` = a row returned from a name-keyed
31//!   map (`SymbolEntry`); `-Ref` = an internal back-pointer/handle into an index
32//!   (`ClassRef`, `DeclRef`) — **not** an LSP reference. The spelled-out word
33//!   `Reference`/`refs` is reserved for a symbol *usage* in code (see
34//!   `navigation/references.rs`, `walk.rs`).
35//! - **`sv`** is the established local idiom for a borrowed `SourceView`.
36
37// Private items in the modules below are only reachable through main.rs/backend.rs,
38// not through this lib entry point, so rustc would flag them as dead. Pub items in
39// a lib crate are never subject to dead_code, so only genuinely-internal items are
40// suppressed — real dead code within public API surfaces will still be caught.
41#![allow(dead_code)]
42
43// ── Core concern modules ────────────────────────────────────────────────────
44mod document; // document lifecycle: parsed AST, salsa store, open-file state
45mod index; //    workspace indexing: compact FileIndex, background scan, cache
46mod lang; //     PHP-language model: config, autoload, phpstorm_meta, docblock, php_names
47mod text; //     generic text mechanics: offset, word, fuzzy, range
48mod types; //    type resolution & symbol lookup: type_map, type_query, resolve, symbol_map, stub_members
49
50// ── LSP feature capabilities ─────────────────────────────────────────────────
51pub mod actions;
52pub mod analysis;
53pub mod completion;
54pub mod editing;
55pub mod hover;
56pub mod navigation;
57
58// ── Salsa query layer ────────────────────────────────────────────────────────
59pub mod db;
60
61// ── Server entry point & cross-cutting infrastructure ────────────────────────
62pub mod backend;
63#[cfg(test)]
64mod test_utils;
65
66// Re-exports for benchmark crates that use the flat `php_lsp::X` paths.
67pub use analysis::semantic_diagnostics;
68pub use document::ast;
69pub use document::document_store;
70pub use editing::rename;
71pub use index::file_index;
72pub use lang::config;
73pub use navigation::call_hierarchy;
74pub use navigation::definition;
75pub use navigation::implementation;
76pub use navigation::references;
77pub use navigation::symbols;
78pub use types::symbol_map;
79pub use types::type_map;