#pragma once #include #include #include #include #include namespace vls::features::semantic_tokens { // Indices into the legend the server advertises. Only tokens the stock // observer can prove are represented; there are no keyword or guess tokens. inline constexpr std::uint32_t function_type = 0; // Bit flag in Token::modifiers, matching the server's advertised legend. inline constexpr std::uint32_t declaration_modifier = 1; struct Token { std::uint32_t line{}, character{}, length{}; std::uint32_t type{function_type}; std::uint32_t modifiers{}; auto operator<=>(const Token &) const = default; }; struct Limits { std::size_t tokens{65536}; std::size_t length{4096}; }; // Sorts by position, drops empty or overlong tokens, duplicates and tokens // that overlap an earlier one (the earlier token wins), and bounds the count. [[nodiscard]] std::vector normalize(std::span, const Limits & = Limits{}); // LSP delta encoding: [deltaLine, deltaStartChar, length, type, modifiers] // per token. Input must already be normalized. [[nodiscard]] std::vector encode(std::span); } // namespace vls::features::semantic_tokens