#pragma once #include #include #include #include #include #include #include #include #include namespace vls::navigation { struct Position { std::uint32_t line{}, character{}; auto operator<=>(const Position &) const = default; }; struct Range { Position start, end; auto operator<=>(const Range &) const = default; }; struct Location { std::string path; Range range; auto operator<=>(const Location &) const = default; }; // Semantic identity of one binding. The definition location joins equal // symbols across analysis contexts; the name distinguishes unrelated symbols // without a proven definition. struct Binding { std::string name; std::optional definition; auto operator<=>(const Binding &) const = default; }; struct Fact { Binding binding; std::string context; std::string source; // use file std::string content; // content identity of the observed source Range use; bool editable{}; std::string provenance; }; struct ContextState { std::string context; bool complete{}; std::string reason; }; struct FactSet { std::string backend; std::uint64_t generation{}; std::vector facts; std::vector contexts; std::map current_sources; // path -> current content }; enum class Refusal { none, unknown_binding, ambiguous_binding, incomplete_coverage, stale_source, non_editable_origin, generated_name, invalid_name, unchanged_name, multi_file_without_transaction, }; struct References { std::vector locations; bool coverage_complete{}; std::vector incomplete_contexts; bool truncated{}; }; struct Edit { std::string path; Range range; std::string replacement; std::string content; // content identity the edit was prepared against }; struct RenamePlan { Refusal refusal{Refusal::none}; std::string detail; std::vector edits; [[nodiscard]] bool ready() const { return refusal == Refusal::none && !edits.empty(); } }; // Resolves the unique binding at a position. Overlapping distinct bindings are // ambiguous and never resolved by iteration order. [[nodiscard]] std::expected binding_at(const FactSet &, std::string_view path, Position); // All proven uses. Partial locations are retained for diagnosis, but // coverage_complete is false whenever any context is incomplete. [[nodiscard]] References references(const FactSet &, const Binding &, std::size_t limit = 512); // Only a ready plan may be applied. Refusals are explicit for incomplete // coverage, stale sources, non-editable origins, ambiguous bindings, // generated/invalid names and multi-file edits without a transactional client. [[nodiscard]] RenamePlan prepare_rename(const FactSet &, std::string_view path, Position, std::string_view replacement, bool transactional_client); } // namespace vls::navigation