#pragma once #include #include #include #include #include #include #include namespace vls::features::signature { struct Limits { std::size_t signatures{8}; std::size_t parameters{64}; std::size_t labelBytes{1024}; std::size_t parameterBytes{256}; std::size_t scanBytes{64 * 1024}; }; struct Parameter { std::string label; // Byte range of label within the signature label, when it can be located. std::optional> range; auto operator<=>(const Parameter &) const = default; }; struct Signature { std::string label; std::vector parameters; auto operator<=>(const Signature &) const = default; }; struct Result { std::vector signatures; std::uint32_t active_signature{}; std::uint32_t active_parameter{}; }; // Splits one compiler signature into a label and its parameter list. Commas // nested in (), [], {} or a plausible template argument list do not separate // parameters. A signature without a parameter list keeps an empty list. [[nodiscard]] Signature parse(std::string_view signature, const Limits & = Limits{}); // Number of the active parameter at the byte offset: top-level commas between // the innermost open parenthesis and the offset, ignoring literals, comments // and nested brackets. The backward scan is bounded by the limit. [[nodiscard]] std::uint32_t active_parameter(std::string_view text, std::size_t offset, const Limits & = Limits{}); // True when the offset lies inside the argument list opened after the callee // span [use_start, use_end): the first '(' after the span and its matching ')' // must enclose the offset. The scan is bounded and ignores literals/comments. [[nodiscard]] bool in_call(std::string_view text, std::size_t use_start, std::size_t use_end, std::size_t offset, const Limits & = Limits{}); // Complete signature help for a call site. Empty or malformed signatures are // skipped; an empty result means no signature is available. [[nodiscard]] Result build(std::span signatures, std::string_view text, std::size_t offset, const Limits & = Limits{}); } // namespace vls::features::signature