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// Much of the library is reached only through `backend`; native clippy catches real dead code.
38#![cfg_attr(target_family = "wasm", allow(dead_code))]
39
40// ── Core concern modules ────────────────────────────────────────────────────
41mod document; // document lifecycle: parsed AST, salsa store, open-file state
42mod index; // workspace indexing: compact FileIndex, background scan, cache
43mod lang; // PHP-language model: config, autoload, docblock, php_names
44mod laravel; // Laravel framework support: project detection, string-key index (env/config/view/...)
45mod text; // generic text mechanics: offset, word, fuzzy, range
46mod types; // type resolution & symbol lookup: type_map, type_query, resolve, symbol_map, stub_members
47
48// ── LSP feature capabilities ─────────────────────────────────────────────────
49pub mod actions;
50pub mod analysis;
51pub mod completion;
52pub mod editing;
53pub mod hover;
54pub mod navigation;
55
56// ── Salsa query layer ────────────────────────────────────────────────────────
57pub mod db;
58
59// ── Server entry point & cross-cutting infrastructure ────────────────────────
60// The server needs threads, files and child processes. Everything above it builds for
61// wasm32-wasip1, so the completion, hover and analysis code can run in a browser worker.
62#[cfg(not(target_family = "wasm"))]
63pub mod backend;
64#[cfg(test)]
65mod test_utils;
66
67// Re-exports for benchmark crates and integration tests that use the flat `php_lsp::X` paths.
68pub use analysis::semantic_diagnostics;
69pub use document::ast;
70pub use document::document_store;
71pub use index::cache;
72pub use index::file_index;
73pub use lang::config;
74pub use navigation::call_hierarchy;
75pub use navigation::definition;
76pub use navigation::symbols;
77pub use types::symbol_map;