The server advertises willRename and answers workspace/willRenameFiles with a WorkspaceEdit. A bounded core resolves quoted includes against the document directory and replaces only the spelling (relative stays relative, absolute stays absolute, angle includes untouched), with registered tests. EditorDiagnostics converts the byte edits to negotiated positions for every open overlay; a real stdio session returned the extra.hpp -> renamed.hpp edit.
98 lines
5.3 KiB
C++
98 lines
5.3 KiB
C++
#pragma once
|
|
|
|
#include <vls/features/FileOperations.hpp>
|
|
#include <vls/features/IncludeUpdate.hpp>
|
|
#include <vls/semantic/StockCompiler.hpp>
|
|
|
|
#include <functional>
|
|
#include <span>
|
|
|
|
namespace vls::semantic {
|
|
|
|
// The input thread brackets document and workspace transitions. The analysis worker
|
|
// publishes through the same ordered output queue as request responses.
|
|
class EditorDiagnostics {
|
|
public:
|
|
using Send = std::function<bool(std::string)>;
|
|
EditorDiagnostics(const std::filesystem::path &root, std::shared_ptr<const GccProfile>,
|
|
WorkspaceSession &, const Documents::DocumentStore &, Send);
|
|
~EditorDiagnostics();
|
|
void set_version_support(bool);
|
|
// Filesystem changes from workspace file-operation notifications. Paths
|
|
// that changed or disappeared invalidate every dependent analysis context.
|
|
void files_changed(std::span<const features::file_operations::Change>);
|
|
struct RenamedFile {
|
|
std::string old_path, new_path;
|
|
};
|
|
// Workspace edit updating quoted includes in open documents that resolve
|
|
// to a renamed path. Null when nothing would change.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
renamed_files(std::span<const RenamedFile>) const;
|
|
void begin_update();
|
|
void finish_update(bool workspace_changed = false);
|
|
void stop();
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json status(std::string_view uri) const;
|
|
[[nodiscard]] bool supports_occurrences() const noexcept;
|
|
// Bounded workspace symbol search over the context-aware index.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
workspace_symbols(std::string_view query) const;
|
|
// Index-backed completion for the identifier prefix before the position.
|
|
// Items are explicitly marked incomplete until compiler-native completion
|
|
// exists; visibility is not proven by the index.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
completion(std::string_view uri, Documents::Position position) const;
|
|
// Compiler-provided call signature at the position, or null when no
|
|
// verified occurrence carries one.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
signature_help(std::string_view uri, Documents::Position position) const;
|
|
// Deferred completion detail. The item's data carries the captured
|
|
// identity and index generation; a changed generation returns the item
|
|
// without details rather than details for a different entity.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
completion_resolve(const Void::LanguageServer::Protocol::Json &item) const;
|
|
// Outline of the records the index holds for one document path.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json document_symbols(std::string_view uri) const;
|
|
// Same-binding uses within the document, or an empty list.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
document_highlights(std::string_view uri, Documents::Position position) const;
|
|
// Nested selection chains (token, line, blocks, document) per position.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
selection_ranges(std::string_view uri, std::span<const Documents::Position>) const;
|
|
// Foldable brace blocks, comments, regions and include groups.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json folding_ranges(std::string_view uri) const;
|
|
// Quick fixes suggested by the compiler for diagnostics overlapping the
|
|
// requested range. Only fixes proven in the owner snapshot are offered.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json code_actions(std::string_view uri,
|
|
Documents::Range range) const;
|
|
// Semantic tokens for the document's proven occurrences, delta-encoded.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json semantic_tokens(std::string_view uri) const;
|
|
// Parameter-type hints from the compiler signature, within the range.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json inlay_hints(std::string_view uri,
|
|
Documents::Range range) const;
|
|
|
|
struct NavigationReply {
|
|
Void::LanguageServer::Protocol::Json result;
|
|
std::optional<std::string> refusal;
|
|
};
|
|
// A refusal means the answer would be incomplete or unsafe; the result is
|
|
// retained for diagnosis but must not be presented as complete.
|
|
[[nodiscard]] NavigationReply references(std::string_view uri,
|
|
Documents::Position position) const;
|
|
[[nodiscard]] NavigationReply prepare_rename(std::string_view uri,
|
|
Documents::Position position) const;
|
|
[[nodiscard]] NavigationReply rename(std::string_view uri, Documents::Position position,
|
|
std::string_view replacement) const;
|
|
void set_transactional_rename(bool supported);
|
|
// Answers are null when no verified occurrence covers the requested position.
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json hover(std::string_view uri,
|
|
Documents::Position position) const;
|
|
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
|
definition(std::string_view uri, Documents::Position position) const;
|
|
|
|
private:
|
|
struct State;
|
|
std::unique_ptr<State> state_;
|
|
};
|
|
|
|
} // namespace vls::semantic
|