Files
Language-Server/include/vls/features/IncludeUpdate.hpp
T
faumaray b0b48d961c Update includes when files are renamed
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.
2026-12-05 16:19:52 +03:00

34 lines
1.1 KiB
C++

#pragma once
#include <compare>
#include <cstddef>
#include <string>
#include <string_view>
#include <vector>
namespace vls::features::include_update {
// One edit as byte offsets into the document text. The caller converts them to
// negotiated LSP positions with the document snapshot.
struct Edit {
std::size_t start{}, end{};
std::string replacement;
auto operator<=>(const Edit &) const = default;
};
struct Limits {
std::size_t edits{256};
std::size_t pathBytes{4096};
std::size_t scanBytes{8 * 1024 * 1024};
};
// Edits for every quoted include directive in TEXT that resolves from the
// document's directory to OLD_PATH, replacing the spelling with NEW_PATH
// relative to that directory (or absolute when it was absolute). Angle
// includes are never touched because their search roots are unknown.
[[nodiscard]] std::vector<Edit> include_edits(std::string_view text, std::string_view document_path,
std::string_view old_path, std::string_view new_path,
const Limits & = Limits{});
} // namespace vls::features::include_update