diff --git a/package.json b/package.json index 1c587cfa..29521b0d 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ "update-tests": "zx scripts/update-tests.mjs", "cxx-gen-ast": "node packages/cxx-gen-ast", "cxx-gen-lsp": "node packages/cxx-gen-lsp packages/cxx-gen-lsp/metaModel.json packages/cxx-gen-lsp -o src/lsp/cxx/lsp", - "download-lsp-models": "zx scripts/download-lsp-models.mjs" + "download-lsp-model": "zx scripts/download-lsp-model.mjs" } } \ No newline at end of file diff --git a/packages/cxx-gen-lsp/src/gen_fwd_h.ts b/packages/cxx-gen-lsp/src/gen_fwd_h.ts index 45ce5835..d63c6b42 100644 --- a/packages/cxx-gen-lsp/src/gen_fwd_h.ts +++ b/packages/cxx-gen-lsp/src/gen_fwd_h.ts @@ -31,12 +31,13 @@ using Pattern = std::string; class LSPObject { public: - explicit LSPObject(json repr): repr_(std::move(repr)) {} + explicit LSPObject(json& repr): repr_(&repr) {} - [[nodiscard]] operator const json&() const { return repr_; } + [[nodiscard]] operator const json&() const { return *repr_; } + [[nodiscard]] auto get() const -> json& { return *repr_; } protected: - json repr_; + json* repr_{nullptr}; }; template @@ -44,10 +45,10 @@ class Vector final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_array(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } - [[nodiscard]] auto at(int index) const -> const T& { return repr_[index]; } + [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } + [[nodiscard]] auto at(int index) const -> const T& { return repr_->at(index); } }; namespace details { @@ -57,7 +58,7 @@ struct TryEmplace; template T> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { auto obj = T{value}; if (!obj) return false; result.template emplace(std::move(obj)); @@ -66,7 +67,7 @@ struct TryEmplace { }; template -auto try_emplace(std::variant& result, const json& value) -> bool { +auto try_emplace(std::variant& result, json& value) -> bool { return (details::TryEmplace{}(result, value) || ...); } @@ -77,7 +78,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_null()) return false; result.template emplace(nullptr); return true; @@ -86,7 +87,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_boolean()) return false; result.template emplace(value); return true; @@ -95,7 +96,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_integer()) return false; result.template emplace(value); return true; @@ -104,7 +105,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_integer()) return false; result.template emplace(value); return true; @@ -113,7 +114,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_float()) return false; result.template emplace(value); return true; @@ -122,7 +123,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_string()) return false; result.template emplace(value); return true; @@ -131,14 +132,14 @@ struct TryEmplace { template struct TryEmplace> { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { return try_emplace(result, value); } }; template struct TryEmplace> { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { lsp_runtime_error("todo: TryEmplace>"); return false; } @@ -146,7 +147,7 @@ struct TryEmplace> { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { result = value; return true; } @@ -154,8 +155,9 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { - lsp_runtime_error("todo: TextDocumentSyncKind"); + auto operator()(auto& result, json& value) const -> bool { + if (!value.is_number_integer()) return false; + result = TextDocumentSyncKind(value.get()); return true; } }; @@ -167,12 +169,12 @@ class Vector> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_array(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } + [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } [[nodiscard]] auto at(int index) const -> std::variant { std::variant result; - details::try_emplace(result, repr_[index]); + details::try_emplace(result, repr_->at(index)); return result; } }; @@ -182,10 +184,10 @@ class Map final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_object(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } - [[nodiscard]] auto at(const Key& key) const -> const Value& { return repr_[key]; } + [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } + [[nodiscard]] auto at(const Key& key) const -> const Value& { return repr_->at(key); } }; template @@ -193,13 +195,13 @@ class Map> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_object(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } + [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } [[nodiscard]] auto at(const Key& key) const -> std::variant { std::variant result; - details::try_emplace(result, repr_[key]); + details::try_emplace(result, repr_->at(key)); return result; } }; diff --git a/packages/cxx-gen-lsp/src/gen_types_cc.ts b/packages/cxx-gen-lsp/src/gen_types_cc.ts index 2da1ced6..1edd7812 100644 --- a/packages/cxx-gen-lsp/src/gen_types_cc.ts +++ b/packages/cxx-gen-lsp/src/gen_types_cc.ts @@ -113,8 +113,6 @@ class TypeGenerator { } generateGetters({ structure, properties }: { structure: Structure; properties: Property[] }) { - const typeName = structure.name; - properties.forEach((property) => { this.beginPropertyGetter({ structure, property }); this.generatePropertyGetter({ structure, property }); @@ -125,15 +123,15 @@ class TypeGenerator { generateValidator({ structure, properties }: { structure: Structure; properties: Property[] }) { this.emit(); this.emit(`${structure.name}::operator bool() const {`); - this.emit(`if (!repr_.is_object() || repr_.is_null()) return false;`); + this.emit(`if (!repr_->is_object() || repr_->is_null()) return false;`); const requiredProperties = properties.filter((p) => !p.optional); requiredProperties.forEach(({ name, type }) => { - this.emit(`if (!repr_.contains("${name}")) return false;`); + this.emit(`if (!repr_->contains("${name}")) return false;`); if (type.kind === "stringLiteral") { - this.emit(`if (repr_["${name}"] != "${type.value}")`); + this.emit(`if ((*repr_)["${name}"] != "${type.value}")`); this.emit(` return false;`); } }); @@ -149,11 +147,11 @@ class TypeGenerator { this.emit(`auto ${structure.name}::${property.name}() const -> ${returnType} {`); if (property.optional) { - this.emit(`if (!repr_.contains("${property.name}")) return std::nullopt;`); + this.emit(`if (!repr_->contains("${property.name}")) return std::nullopt;`); this.emit(); } - this.emit(`const auto& value = repr_["${property.name}"];`); + this.emit(`auto& value = (*repr_)["${property.name}"];`); this.emit(); } @@ -216,7 +214,7 @@ class TypeGenerator { this.emit(`lsp_runtime_error("${structure.name}::${property.name}: not implement yet");`); } - generatePropertyGetterBase({ structure, property }: { structure: Structure; property: Property }): boolean { + generatePropertyGetterBase({ property }: { structure: Structure; property: Property }): boolean { if (property.type.kind !== "base") return false; switch (property.type.name) { @@ -323,13 +321,117 @@ class TypeGenerator { generateSetters({ structure, properties }: { structure: Structure; properties: Property[] }) { const typeName = structure.name; - properties.forEach(({ name, type, optional }) => { - const argumentType = this.getPropertyType({ type, optional }); + properties.forEach((property) => { + const argumentType = this.getPropertyType(property); this.emit(); - this.emit(`auto ${typeName}::${name}(${argumentType} ${name})`); - this.emit(`-> ${typeName}& { return *this; }`); + this.emit(`auto ${typeName}::${property.name}(${argumentType} ${property.name})`); + this.emit(`-> ${typeName}& {`); + + if (property.optional) { + this.emit(`if (!${property.name}.has_value()) {`); + this.emit(`repr_->erase("${property.name}");`); + this.emit(`return *this;`); + this.emit(`}`); + } + + this.generatePropertySetter({ property, structure }); + + this.emit(`return *this;`); + this.emit(`}`); }); } + + private generatePropertySetter({ property, structure }: { property: Property; structure: Structure }): void { + const typeName = structure.name; + const value = property.optional ? `${property.name}.value()` : property.name; + + switch (property.type.kind) { + case "base": + this.emit(`repr_->emplace("${property.name}", std::move(${value}));`); + return; + + case "reference": + if (!this.generatePropertySetterReference({ structure, property, value })) break; + return; + + case "or": + if (!this.generatePropertySetterOr({ structure, property, value })) break; + return; + + default: + break; + } // switch + + this.emit(`lsp_runtime_error("${typeName}::${property.name}: not implement yet");`); + } + + generatePropertySetterReference({ + property, + value, + }: { + structure: Structure; + property: Property; + value: string; + }): boolean { + if (property.type.kind !== "reference") return false; + + if (this.enumByName.has(property.type.name)) { + const enumeration = this.enumByName.get(property.type.name)!; + + if (enumeration.type.name !== "string") { + const enumBaseType = toCppType(enumeration.type); + this.emit(`repr_->emplace("${property.name}", static_cast<${enumBaseType}>(${value}));`); + return true; + } + + // TODO: string-like enumeration + return false; + } + + if (this.structByName.has(property.type.name)) { + this.emit(`repr_->emplace("${property.name}", ${value});`); + return true; + } + + return false; + } + + generatePropertySetterOr({ + structure, + property, + value, + }: { + structure: Structure; + property: Property; + value: string; + }): boolean { + if (property.type.kind !== "or") return false; + + this.emit(); + this.emit("// or type"); + this.emit(); + this.emit(`struct {`); + this.emit(`json* repr_;`); + this.emit(); + this.emit(`void operator()(std::monostate) {`); + this.emit(`lsp_runtime_error("monostate is not a valid a property value");`); + this.emit(`}`); + + property.type.items.forEach((item) => { + const itemType = this.getPropertyType({ type: item }); + this.emit(); + this.emit(`void operator()(${itemType} ${property.name}) {`); + this.generatePropertySetter({ property: { name: property.name, type: item, optional: false }, structure }); + this.emit(`}`); + }); + + this.emit(`} v{repr_};`); + this.emit(); + this.emit(`std::visit(v, ${value});`); + this.emit(); + + return true; + } } export function gen_types_cc({ model, outputDirectory }: { model: MetaModel; outputDirectory: string }) { diff --git a/src/lsp/CMakeLists.txt b/src/lsp/CMakeLists.txt index 15fe6605..816bbb10 100644 --- a/src/lsp/CMakeLists.txt +++ b/src/lsp/CMakeLists.txt @@ -40,6 +40,8 @@ if (EMSCRIPTEN) target_compile_options(cxx-lsp PUBLIC -fno-exceptions) endif() +add_subdirectory(tests) + if(CXX_INSTALL_LSP) install( diff --git a/src/lsp/cxx/lsp/fwd.h b/src/lsp/cxx/lsp/fwd.h index dd4e42a6..ab31c7af 100644 --- a/src/lsp/cxx/lsp/fwd.h +++ b/src/lsp/cxx/lsp/fwd.h @@ -463,12 +463,13 @@ using Pattern = std::string; class LSPObject { public: - explicit LSPObject(json repr) : repr_(std::move(repr)) {} + explicit LSPObject(json& repr) : repr_(&repr) {} - [[nodiscard]] operator const json&() const { return repr_; } + [[nodiscard]] operator const json&() const { return *repr_; } + [[nodiscard]] auto get() const -> json& { return *repr_; } protected: - json repr_; + json* repr_{nullptr}; }; template @@ -476,10 +477,12 @@ class Vector final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_array(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } - [[nodiscard]] auto at(int index) const -> const T& { return repr_[index]; } + [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } + [[nodiscard]] auto at(int index) const -> const T& { + return repr_->at(index); + } }; namespace details { @@ -489,7 +492,7 @@ struct TryEmplace; template T> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { auto obj = T{value}; if (!obj) return false; result.template emplace(std::move(obj)); @@ -498,7 +501,7 @@ struct TryEmplace { }; template -auto try_emplace(std::variant& result, const json& value) -> bool { +auto try_emplace(std::variant& result, json& value) -> bool { return (details::TryEmplace{}(result, value) || ...); } @@ -509,7 +512,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_null()) return false; result.template emplace(nullptr); return true; @@ -518,7 +521,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_boolean()) return false; result.template emplace(value); return true; @@ -527,7 +530,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_integer()) return false; result.template emplace(value); return true; @@ -536,7 +539,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_integer()) return false; result.template emplace(value); return true; @@ -545,7 +548,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_number_float()) return false; result.template emplace(value); return true; @@ -554,7 +557,7 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { if (!value.is_string()) return false; result.template emplace(value); return true; @@ -563,14 +566,14 @@ struct TryEmplace { template struct TryEmplace> { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { return try_emplace(result, value); } }; template struct TryEmplace> { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { lsp_runtime_error("todo: TryEmplace>"); return false; } @@ -578,7 +581,7 @@ struct TryEmplace> { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { + auto operator()(auto& result, json& value) const -> bool { result = value; return true; } @@ -586,8 +589,9 @@ struct TryEmplace { template <> struct TryEmplace { - auto operator()(auto& result, const json& value) const -> bool { - lsp_runtime_error("todo: TextDocumentSyncKind"); + auto operator()(auto& result, json& value) const -> bool { + if (!value.is_number_integer()) return false; + result = TextDocumentSyncKind(value.get()); return true; } }; @@ -599,12 +603,12 @@ class Vector> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_array(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } + [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } [[nodiscard]] auto at(int index) const -> std::variant { std::variant result; - details::try_emplace(result, repr_[index]); + details::try_emplace(result, repr_->at(index)); return result; } }; @@ -614,11 +618,11 @@ class Map final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_object(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } + [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } [[nodiscard]] auto at(const Key& key) const -> const Value& { - return repr_[key]; + return repr_->at(key); } }; @@ -627,13 +631,13 @@ class Map> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_.is_object(); } - [[nodiscard]] auto size() const -> std::size_t { return repr_.size(); } - [[nodiscard]] auto empty() const -> bool { return repr_.empty(); } + [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } + [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } [[nodiscard]] auto at(const Key& key) const -> std::variant { std::variant result; - details::try_emplace(result, repr_[key]); + details::try_emplace(result, repr_->at(key)); return result; } }; diff --git a/src/lsp/cxx/lsp/types.cc b/src/lsp/cxx/lsp/types.cc index 1c20852d..fae76a2b 100644 --- a/src/lsp/cxx/lsp/types.cc +++ b/src/lsp/cxx/lsp/types.cc @@ -23,29 +23,29 @@ namespace cxx::lsp { ImplementationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto ImplementationParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto ImplementationParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto ImplementationParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -56,9 +56,9 @@ auto ImplementationParams::workDoneToken() const auto ImplementationParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -69,57 +69,76 @@ auto ImplementationParams::partialResultToken() const auto ImplementationParams::textDocument(TextDocumentIdentifier textDocument) -> ImplementationParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto ImplementationParams::position(Position position) -> ImplementationParams& { + repr_->emplace("position", position); return *this; } auto ImplementationParams::workDoneToken( std::optional workDoneToken) -> ImplementationParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("ImplementationParams::workDoneToken: not implement yet"); return *this; } auto ImplementationParams::partialResultToken( std::optional partialResultToken) -> ImplementationParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "ImplementationParams::partialResultToken: not implement yet"); return *this; } Location::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("range")) return false; return true; } auto Location::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto Location::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } -auto Location::uri(std::string uri) -> Location& { return *this; } +auto Location::uri(std::string uri) -> Location& { + repr_->emplace("uri", std::move(uri)); + return *this; +} -auto Location::range(Range range) -> Location& { return *this; } +auto Location::range(Range range) -> Location& { + repr_->emplace("range", range); + return *this; +} ImplementationRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto ImplementationRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -130,9 +149,9 @@ auto ImplementationRegistrationOptions::documentSelector() const auto ImplementationRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -140,9 +159,9 @@ auto ImplementationRegistrationOptions::workDoneProgress() const auto ImplementationRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -151,44 +170,76 @@ auto ImplementationRegistrationOptions::id() const auto ImplementationRegistrationOptions::documentSelector( std::variant documentSelector) -> ImplementationRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "ImplementationRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto ImplementationRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> ImplementationRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto ImplementationRegistrationOptions::id(std::optional id) -> ImplementationRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } TypeDefinitionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto TypeDefinitionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto TypeDefinitionParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto TypeDefinitionParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -199,9 +250,9 @@ auto TypeDefinitionParams::workDoneToken() const auto TypeDefinitionParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -212,33 +263,46 @@ auto TypeDefinitionParams::partialResultToken() const auto TypeDefinitionParams::textDocument(TextDocumentIdentifier textDocument) -> TypeDefinitionParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto TypeDefinitionParams::position(Position position) -> TypeDefinitionParams& { + repr_->emplace("position", position); return *this; } auto TypeDefinitionParams::workDoneToken( std::optional workDoneToken) -> TypeDefinitionParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("TypeDefinitionParams::workDoneToken: not implement yet"); return *this; } auto TypeDefinitionParams::partialResultToken( std::optional partialResultToken) -> TypeDefinitionParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "TypeDefinitionParams::partialResultToken: not implement yet"); return *this; } TypeDefinitionRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto TypeDefinitionRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -249,9 +313,9 @@ auto TypeDefinitionRegistrationOptions::documentSelector() const auto TypeDefinitionRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -259,9 +323,9 @@ auto TypeDefinitionRegistrationOptions::workDoneProgress() const auto TypeDefinitionRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -270,73 +334,110 @@ auto TypeDefinitionRegistrationOptions::id() const auto TypeDefinitionRegistrationOptions::documentSelector( std::variant documentSelector) -> TypeDefinitionRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "TypeDefinitionRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto TypeDefinitionRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> TypeDefinitionRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto TypeDefinitionRegistrationOptions::id(std::optional id) -> TypeDefinitionRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } WorkspaceFolder::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("name")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("name")) return false; return true; } auto WorkspaceFolder::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto WorkspaceFolder::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } -auto WorkspaceFolder::uri(std::string uri) -> WorkspaceFolder& { return *this; } +auto WorkspaceFolder::uri(std::string uri) -> WorkspaceFolder& { + repr_->emplace("uri", std::move(uri)); + return *this; +} auto WorkspaceFolder::name(std::string name) -> WorkspaceFolder& { + repr_->emplace("name", std::move(name)); return *this; } DidChangeWorkspaceFoldersParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("event")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("event")) return false; return true; } auto DidChangeWorkspaceFoldersParams::event() const -> WorkspaceFoldersChangeEvent { - const auto& value = repr_["event"]; + auto& value = (*repr_)["event"]; return WorkspaceFoldersChangeEvent(value); } auto DidChangeWorkspaceFoldersParams::event(WorkspaceFoldersChangeEvent event) -> DidChangeWorkspaceFoldersParams& { + repr_->emplace("event", event); return *this; } ConfigurationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("items")) return false; return true; } auto ConfigurationParams::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -344,26 +445,27 @@ auto ConfigurationParams::items() const -> Vector { auto ConfigurationParams::items(Vector items) -> ConfigurationParams& { + lsp_runtime_error("ConfigurationParams::items: not implement yet"); return *this; } DocumentColorParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DocumentColorParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentColorParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -374,9 +476,9 @@ auto DocumentColorParams::workDoneToken() const auto DocumentColorParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -387,51 +489,69 @@ auto DocumentColorParams::partialResultToken() const auto DocumentColorParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentColorParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentColorParams::workDoneToken( std::optional workDoneToken) -> DocumentColorParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("DocumentColorParams::workDoneToken: not implement yet"); return *this; } auto DocumentColorParams::partialResultToken( std::optional partialResultToken) -> DocumentColorParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "DocumentColorParams::partialResultToken: not implement yet"); return *this; } ColorInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("color")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("color")) return false; return true; } auto ColorInformation::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto ColorInformation::color() const -> Color { - const auto& value = repr_["color"]; + auto& value = (*repr_)["color"]; return Color(value); } -auto ColorInformation::range(Range range) -> ColorInformation& { return *this; } +auto ColorInformation::range(Range range) -> ColorInformation& { + repr_->emplace("range", range); + return *this; +} -auto ColorInformation::color(Color color) -> ColorInformation& { return *this; } +auto ColorInformation::color(Color color) -> ColorInformation& { + repr_->emplace("color", color); + return *this; +} DocumentColorRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentColorRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -442,9 +562,9 @@ auto DocumentColorRegistrationOptions::documentSelector() const auto DocumentColorRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -452,9 +572,9 @@ auto DocumentColorRegistrationOptions::workDoneProgress() const auto DocumentColorRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -463,50 +583,82 @@ auto DocumentColorRegistrationOptions::id() const auto DocumentColorRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentColorRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentColorRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentColorRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentColorRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto DocumentColorRegistrationOptions::id(std::optional id) -> DocumentColorRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } ColorPresentationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("color")) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("color")) return false; + if (!repr_->contains("range")) return false; return true; } auto ColorPresentationParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto ColorPresentationParams::color() const -> Color { - const auto& value = repr_["color"]; + auto& value = (*repr_)["color"]; return Color(value); } auto ColorPresentationParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto ColorPresentationParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -517,9 +669,9 @@ auto ColorPresentationParams::workDoneToken() const auto ColorPresentationParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -530,82 +682,109 @@ auto ColorPresentationParams::partialResultToken() const auto ColorPresentationParams::textDocument(TextDocumentIdentifier textDocument) -> ColorPresentationParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto ColorPresentationParams::color(Color color) -> ColorPresentationParams& { + repr_->emplace("color", color); return *this; } auto ColorPresentationParams::range(Range range) -> ColorPresentationParams& { + repr_->emplace("range", range); return *this; } auto ColorPresentationParams::workDoneToken( std::optional workDoneToken) -> ColorPresentationParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "ColorPresentationParams::workDoneToken: not implement yet"); return *this; } auto ColorPresentationParams::partialResultToken( std::optional partialResultToken) -> ColorPresentationParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "ColorPresentationParams::partialResultToken: not implement yet"); return *this; } ColorPresentation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("label")) return false; return true; } auto ColorPresentation::label() const -> std::string { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); } auto ColorPresentation::textEdit() const -> std::optional { - if (!repr_.contains("textEdit")) return std::nullopt; + if (!repr_->contains("textEdit")) return std::nullopt; - const auto& value = repr_["textEdit"]; + auto& value = (*repr_)["textEdit"]; return TextEdit(value); } auto ColorPresentation::additionalTextEdits() const -> std::optional> { - if (!repr_.contains("additionalTextEdits")) return std::nullopt; + if (!repr_->contains("additionalTextEdits")) return std::nullopt; - const auto& value = repr_["additionalTextEdits"]; + auto& value = (*repr_)["additionalTextEdits"]; assert(value.is_array()); return Vector(value); } auto ColorPresentation::label(std::string label) -> ColorPresentation& { + repr_->emplace("label", std::move(label)); return *this; } auto ColorPresentation::textEdit(std::optional textEdit) -> ColorPresentation& { + if (!textEdit.has_value()) { + repr_->erase("textEdit"); + return *this; + } + repr_->emplace("textEdit", textEdit.value()); return *this; } auto ColorPresentation::additionalTextEdits( std::optional> additionalTextEdits) -> ColorPresentation& { + if (!additionalTextEdits.has_value()) { + repr_->erase("additionalTextEdits"); + return *this; + } + lsp_runtime_error( + "ColorPresentation::additionalTextEdits: not implement yet"); return *this; } WorkDoneProgressOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkDoneProgressOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -613,18 +792,23 @@ auto WorkDoneProgressOptions::workDoneProgress() const -> std::optional { auto WorkDoneProgressOptions::workDoneProgress( std::optional workDoneProgress) -> WorkDoneProgressOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } TextDocumentRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto TextDocumentRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -636,25 +820,47 @@ auto TextDocumentRegistrationOptions::documentSelector() const auto TextDocumentRegistrationOptions::documentSelector( std::variant documentSelector) -> TextDocumentRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "TextDocumentRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } FoldingRangeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto FoldingRangeParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto FoldingRangeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -665,9 +871,9 @@ auto FoldingRangeParams::workDoneToken() const -> std::optional { auto FoldingRangeParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -678,107 +884,145 @@ auto FoldingRangeParams::partialResultToken() const auto FoldingRangeParams::textDocument(TextDocumentIdentifier textDocument) -> FoldingRangeParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto FoldingRangeParams::workDoneToken( std::optional workDoneToken) -> FoldingRangeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("FoldingRangeParams::workDoneToken: not implement yet"); return *this; } auto FoldingRangeParams::partialResultToken( std::optional partialResultToken) -> FoldingRangeParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "FoldingRangeParams::partialResultToken: not implement yet"); return *this; } FoldingRange::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("startLine")) return false; - if (!repr_.contains("endLine")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("startLine")) return false; + if (!repr_->contains("endLine")) return false; return true; } auto FoldingRange::startLine() const -> long { - const auto& value = repr_["startLine"]; + auto& value = (*repr_)["startLine"]; assert(value.is_number_integer()); return value.get(); } auto FoldingRange::startCharacter() const -> std::optional { - if (!repr_.contains("startCharacter")) return std::nullopt; + if (!repr_->contains("startCharacter")) return std::nullopt; - const auto& value = repr_["startCharacter"]; + auto& value = (*repr_)["startCharacter"]; assert(value.is_number_integer()); return value.get(); } auto FoldingRange::endLine() const -> long { - const auto& value = repr_["endLine"]; + auto& value = (*repr_)["endLine"]; assert(value.is_number_integer()); return value.get(); } auto FoldingRange::endCharacter() const -> std::optional { - if (!repr_.contains("endCharacter")) return std::nullopt; + if (!repr_->contains("endCharacter")) return std::nullopt; - const auto& value = repr_["endCharacter"]; + auto& value = (*repr_)["endCharacter"]; assert(value.is_number_integer()); return value.get(); } auto FoldingRange::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; lsp_runtime_error("FoldingRange::kind: not implement yet"); } auto FoldingRange::collapsedText() const -> std::optional { - if (!repr_.contains("collapsedText")) return std::nullopt; + if (!repr_->contains("collapsedText")) return std::nullopt; - const auto& value = repr_["collapsedText"]; + auto& value = (*repr_)["collapsedText"]; assert(value.is_string()); return value.get(); } -auto FoldingRange::startLine(long startLine) -> FoldingRange& { return *this; } +auto FoldingRange::startLine(long startLine) -> FoldingRange& { + repr_->emplace("startLine", std::move(startLine)); + return *this; +} auto FoldingRange::startCharacter(std::optional startCharacter) -> FoldingRange& { + if (!startCharacter.has_value()) { + repr_->erase("startCharacter"); + return *this; + } + repr_->emplace("startCharacter", std::move(startCharacter.value())); return *this; } -auto FoldingRange::endLine(long endLine) -> FoldingRange& { return *this; } +auto FoldingRange::endLine(long endLine) -> FoldingRange& { + repr_->emplace("endLine", std::move(endLine)); + return *this; +} auto FoldingRange::endCharacter(std::optional endCharacter) -> FoldingRange& { + if (!endCharacter.has_value()) { + repr_->erase("endCharacter"); + return *this; + } + repr_->emplace("endCharacter", std::move(endCharacter.value())); return *this; } auto FoldingRange::kind(std::optional kind) -> FoldingRange& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + lsp_runtime_error("FoldingRange::kind: not implement yet"); return *this; } auto FoldingRange::collapsedText(std::optional collapsedText) -> FoldingRange& { + if (!collapsedText.has_value()) { + repr_->erase("collapsedText"); + return *this; + } + repr_->emplace("collapsedText", std::move(collapsedText.value())); return *this; } FoldingRangeRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto FoldingRangeRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -789,18 +1033,18 @@ auto FoldingRangeRegistrationOptions::documentSelector() const auto FoldingRangeRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); } auto FoldingRangeRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -809,42 +1053,74 @@ auto FoldingRangeRegistrationOptions::id() const -> std::optional { auto FoldingRangeRegistrationOptions::documentSelector( std::variant documentSelector) -> FoldingRangeRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "FoldingRangeRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto FoldingRangeRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> FoldingRangeRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto FoldingRangeRegistrationOptions::id(std::optional id) -> FoldingRangeRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } DeclarationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto DeclarationParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DeclarationParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto DeclarationParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -855,9 +1131,9 @@ auto DeclarationParams::workDoneToken() const -> std::optional { auto DeclarationParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -868,34 +1144,46 @@ auto DeclarationParams::partialResultToken() const auto DeclarationParams::textDocument(TextDocumentIdentifier textDocument) -> DeclarationParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DeclarationParams::position(Position position) -> DeclarationParams& { + repr_->emplace("position", position); return *this; } auto DeclarationParams::workDoneToken( std::optional workDoneToken) -> DeclarationParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("DeclarationParams::workDoneToken: not implement yet"); return *this; } auto DeclarationParams::partialResultToken( std::optional partialResultToken) -> DeclarationParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("DeclarationParams::partialResultToken: not implement yet"); return *this; } DeclarationRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DeclarationRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -903,7 +1191,7 @@ auto DeclarationRegistrationOptions::workDoneProgress() const auto DeclarationRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -913,9 +1201,9 @@ auto DeclarationRegistrationOptions::documentSelector() const } auto DeclarationRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -923,35 +1211,67 @@ auto DeclarationRegistrationOptions::id() const -> std::optional { auto DeclarationRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DeclarationRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto DeclarationRegistrationOptions::documentSelector( std::variant documentSelector) -> DeclarationRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DeclarationRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DeclarationRegistrationOptions::id(std::optional id) -> DeclarationRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } SelectionRangeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("positions")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("positions")) return false; return true; } auto SelectionRangeParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto SelectionRangeParams::positions() const -> Vector { - const auto& value = repr_["positions"]; + auto& value = (*repr_)["positions"]; assert(value.is_array()); return Vector(value); @@ -959,9 +1279,9 @@ auto SelectionRangeParams::positions() const -> Vector { auto SelectionRangeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -972,9 +1292,9 @@ auto SelectionRangeParams::workDoneToken() const auto SelectionRangeParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -985,62 +1305,83 @@ auto SelectionRangeParams::partialResultToken() const auto SelectionRangeParams::textDocument(TextDocumentIdentifier textDocument) -> SelectionRangeParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto SelectionRangeParams::positions(Vector positions) -> SelectionRangeParams& { + lsp_runtime_error("SelectionRangeParams::positions: not implement yet"); return *this; } auto SelectionRangeParams::workDoneToken( std::optional workDoneToken) -> SelectionRangeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("SelectionRangeParams::workDoneToken: not implement yet"); return *this; } auto SelectionRangeParams::partialResultToken( std::optional partialResultToken) -> SelectionRangeParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "SelectionRangeParams::partialResultToken: not implement yet"); return *this; } SelectionRange::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; return true; } auto SelectionRange::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto SelectionRange::parent() const -> std::optional { - if (!repr_.contains("parent")) return std::nullopt; + if (!repr_->contains("parent")) return std::nullopt; - const auto& value = repr_["parent"]; + auto& value = (*repr_)["parent"]; return SelectionRange(value); } -auto SelectionRange::range(Range range) -> SelectionRange& { return *this; } +auto SelectionRange::range(Range range) -> SelectionRange& { + repr_->emplace("range", range); + return *this; +} auto SelectionRange::parent(std::optional parent) -> SelectionRange& { + if (!parent.has_value()) { + repr_->erase("parent"); + return *this; + } + repr_->emplace("parent", parent.value()); return *this; } SelectionRangeRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto SelectionRangeRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -1048,7 +1389,7 @@ auto SelectionRangeRegistrationOptions::workDoneProgress() const auto SelectionRangeRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -1059,9 +1400,9 @@ auto SelectionRangeRegistrationOptions::documentSelector() const auto SelectionRangeRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -1070,28 +1411,60 @@ auto SelectionRangeRegistrationOptions::id() const auto SelectionRangeRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> SelectionRangeRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto SelectionRangeRegistrationOptions::documentSelector( std::variant documentSelector) -> SelectionRangeRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "SelectionRangeRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto SelectionRangeRegistrationOptions::id(std::optional id) -> SelectionRangeRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } WorkDoneProgressCreateParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("token")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("token")) return false; return true; } auto WorkDoneProgressCreateParams::token() const -> ProgressToken { - const auto& value = repr_["token"]; + auto& value = (*repr_)["token"]; ProgressToken result; @@ -1102,17 +1475,18 @@ auto WorkDoneProgressCreateParams::token() const -> ProgressToken { auto WorkDoneProgressCreateParams::token(ProgressToken token) -> WorkDoneProgressCreateParams& { + lsp_runtime_error("WorkDoneProgressCreateParams::token: not implement yet"); return *this; } WorkDoneProgressCancelParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("token")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("token")) return false; return true; } auto WorkDoneProgressCancelParams::token() const -> ProgressToken { - const auto& value = repr_["token"]; + auto& value = (*repr_)["token"]; ProgressToken result; @@ -1123,34 +1497,35 @@ auto WorkDoneProgressCancelParams::token() const -> ProgressToken { auto WorkDoneProgressCancelParams::token(ProgressToken token) -> WorkDoneProgressCancelParams& { + lsp_runtime_error("WorkDoneProgressCancelParams::token: not implement yet"); return *this; } CallHierarchyPrepareParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto CallHierarchyPrepareParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto CallHierarchyPrepareParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto CallHierarchyPrepareParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1161,132 +1536,160 @@ auto CallHierarchyPrepareParams::workDoneToken() const auto CallHierarchyPrepareParams::textDocument( TextDocumentIdentifier textDocument) -> CallHierarchyPrepareParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto CallHierarchyPrepareParams::position(Position position) -> CallHierarchyPrepareParams& { + repr_->emplace("position", position); return *this; } auto CallHierarchyPrepareParams::workDoneToken( std::optional workDoneToken) -> CallHierarchyPrepareParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "CallHierarchyPrepareParams::workDoneToken: not implement yet"); return *this; } CallHierarchyItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("selectionRange")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("selectionRange")) return false; return true; } auto CallHierarchyItem::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto CallHierarchyItem::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto CallHierarchyItem::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto CallHierarchyItem::detail() const -> std::optional { - if (!repr_.contains("detail")) return std::nullopt; + if (!repr_->contains("detail")) return std::nullopt; - const auto& value = repr_["detail"]; + auto& value = (*repr_)["detail"]; assert(value.is_string()); return value.get(); } auto CallHierarchyItem::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto CallHierarchyItem::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto CallHierarchyItem::selectionRange() const -> Range { - const auto& value = repr_["selectionRange"]; + auto& value = (*repr_)["selectionRange"]; return Range(value); } auto CallHierarchyItem::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } auto CallHierarchyItem::name(std::string name) -> CallHierarchyItem& { + repr_->emplace("name", std::move(name)); return *this; } auto CallHierarchyItem::kind(SymbolKind kind) -> CallHierarchyItem& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto CallHierarchyItem::tags(std::optional> tags) -> CallHierarchyItem& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("CallHierarchyItem::tags: not implement yet"); return *this; } auto CallHierarchyItem::detail(std::optional detail) -> CallHierarchyItem& { + if (!detail.has_value()) { + repr_->erase("detail"); + return *this; + } + repr_->emplace("detail", std::move(detail.value())); return *this; } auto CallHierarchyItem::uri(std::string uri) -> CallHierarchyItem& { + repr_->emplace("uri", std::move(uri)); return *this; } auto CallHierarchyItem::range(Range range) -> CallHierarchyItem& { + repr_->emplace("range", range); return *this; } auto CallHierarchyItem::selectionRange(Range selectionRange) -> CallHierarchyItem& { + repr_->emplace("selectionRange", selectionRange); return *this; } auto CallHierarchyItem::data(std::optional data) -> CallHierarchyItem& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("CallHierarchyItem::data: not implement yet"); return *this; } CallHierarchyRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto CallHierarchyRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -1297,9 +1700,9 @@ auto CallHierarchyRegistrationOptions::documentSelector() const auto CallHierarchyRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -1307,9 +1710,9 @@ auto CallHierarchyRegistrationOptions::workDoneProgress() const auto CallHierarchyRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -1318,36 +1721,68 @@ auto CallHierarchyRegistrationOptions::id() const auto CallHierarchyRegistrationOptions::documentSelector( std::variant documentSelector) -> CallHierarchyRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "CallHierarchyRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto CallHierarchyRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> CallHierarchyRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto CallHierarchyRegistrationOptions::id(std::optional id) -> CallHierarchyRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } CallHierarchyIncomingCallsParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("item")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("item")) return false; return true; } auto CallHierarchyIncomingCallsParams::item() const -> CallHierarchyItem { - const auto& value = repr_["item"]; + auto& value = (*repr_)["item"]; return CallHierarchyItem(value); } auto CallHierarchyIncomingCallsParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1358,9 +1793,9 @@ auto CallHierarchyIncomingCallsParams::workDoneToken() const auto CallHierarchyIncomingCallsParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -1371,36 +1806,50 @@ auto CallHierarchyIncomingCallsParams::partialResultToken() const auto CallHierarchyIncomingCallsParams::item(CallHierarchyItem item) -> CallHierarchyIncomingCallsParams& { + repr_->emplace("item", item); return *this; } auto CallHierarchyIncomingCallsParams::workDoneToken( std::optional workDoneToken) -> CallHierarchyIncomingCallsParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "CallHierarchyIncomingCallsParams::workDoneToken: not implement yet"); return *this; } auto CallHierarchyIncomingCallsParams::partialResultToken( std::optional partialResultToken) -> CallHierarchyIncomingCallsParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "CallHierarchyIncomingCallsParams::partialResultToken: not implement " + "yet"); return *this; } CallHierarchyIncomingCall::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("from")) return false; - if (!repr_.contains("fromRanges")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("from")) return false; + if (!repr_->contains("fromRanges")) return false; return true; } auto CallHierarchyIncomingCall::from() const -> CallHierarchyItem { - const auto& value = repr_["from"]; + auto& value = (*repr_)["from"]; return CallHierarchyItem(value); } auto CallHierarchyIncomingCall::fromRanges() const -> Vector { - const auto& value = repr_["fromRanges"]; + auto& value = (*repr_)["fromRanges"]; assert(value.is_array()); return Vector(value); @@ -1408,31 +1857,33 @@ auto CallHierarchyIncomingCall::fromRanges() const -> Vector { auto CallHierarchyIncomingCall::from(CallHierarchyItem from) -> CallHierarchyIncomingCall& { + repr_->emplace("from", from); return *this; } auto CallHierarchyIncomingCall::fromRanges(Vector fromRanges) -> CallHierarchyIncomingCall& { + lsp_runtime_error("CallHierarchyIncomingCall::fromRanges: not implement yet"); return *this; } CallHierarchyOutgoingCallsParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("item")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("item")) return false; return true; } auto CallHierarchyOutgoingCallsParams::item() const -> CallHierarchyItem { - const auto& value = repr_["item"]; + auto& value = (*repr_)["item"]; return CallHierarchyItem(value); } auto CallHierarchyOutgoingCallsParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1443,9 +1894,9 @@ auto CallHierarchyOutgoingCallsParams::workDoneToken() const auto CallHierarchyOutgoingCallsParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -1456,36 +1907,50 @@ auto CallHierarchyOutgoingCallsParams::partialResultToken() const auto CallHierarchyOutgoingCallsParams::item(CallHierarchyItem item) -> CallHierarchyOutgoingCallsParams& { + repr_->emplace("item", item); return *this; } auto CallHierarchyOutgoingCallsParams::workDoneToken( std::optional workDoneToken) -> CallHierarchyOutgoingCallsParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "CallHierarchyOutgoingCallsParams::workDoneToken: not implement yet"); return *this; } auto CallHierarchyOutgoingCallsParams::partialResultToken( std::optional partialResultToken) -> CallHierarchyOutgoingCallsParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "CallHierarchyOutgoingCallsParams::partialResultToken: not implement " + "yet"); return *this; } CallHierarchyOutgoingCall::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("to")) return false; - if (!repr_.contains("fromRanges")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("to")) return false; + if (!repr_->contains("fromRanges")) return false; return true; } auto CallHierarchyOutgoingCall::to() const -> CallHierarchyItem { - const auto& value = repr_["to"]; + auto& value = (*repr_)["to"]; return CallHierarchyItem(value); } auto CallHierarchyOutgoingCall::fromRanges() const -> Vector { - const auto& value = repr_["fromRanges"]; + auto& value = (*repr_)["fromRanges"]; assert(value.is_array()); return Vector(value); @@ -1493,31 +1958,33 @@ auto CallHierarchyOutgoingCall::fromRanges() const -> Vector { auto CallHierarchyOutgoingCall::to(CallHierarchyItem to) -> CallHierarchyOutgoingCall& { + repr_->emplace("to", to); return *this; } auto CallHierarchyOutgoingCall::fromRanges(Vector fromRanges) -> CallHierarchyOutgoingCall& { + lsp_runtime_error("CallHierarchyOutgoingCall::fromRanges: not implement yet"); return *this; } SemanticTokensParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto SemanticTokensParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto SemanticTokensParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1528,9 +1995,9 @@ auto SemanticTokensParams::workDoneToken() const auto SemanticTokensParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -1541,36 +2008,48 @@ auto SemanticTokensParams::partialResultToken() const auto SemanticTokensParams::textDocument(TextDocumentIdentifier textDocument) -> SemanticTokensParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto SemanticTokensParams::workDoneToken( std::optional workDoneToken) -> SemanticTokensParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("SemanticTokensParams::workDoneToken: not implement yet"); return *this; } auto SemanticTokensParams::partialResultToken( std::optional partialResultToken) -> SemanticTokensParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "SemanticTokensParams::partialResultToken: not implement yet"); return *this; } SemanticTokens::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("data")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("data")) return false; return true; } auto SemanticTokens::resultId() const -> std::optional { - if (!repr_.contains("resultId")) return std::nullopt; + if (!repr_->contains("resultId")) return std::nullopt; - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); } auto SemanticTokens::data() const -> Vector { - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_array()); return Vector(value); @@ -1578,21 +2057,27 @@ auto SemanticTokens::data() const -> Vector { auto SemanticTokens::resultId(std::optional resultId) -> SemanticTokens& { + if (!resultId.has_value()) { + repr_->erase("resultId"); + return *this; + } + repr_->emplace("resultId", std::move(resultId.value())); return *this; } auto SemanticTokens::data(Vector data) -> SemanticTokens& { + lsp_runtime_error("SemanticTokens::data: not implement yet"); return *this; } SemanticTokensPartialResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("data")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("data")) return false; return true; } auto SemanticTokensPartialResult::data() const -> Vector { - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_array()); return Vector(value); @@ -1600,19 +2085,20 @@ auto SemanticTokensPartialResult::data() const -> Vector { auto SemanticTokensPartialResult::data(Vector data) -> SemanticTokensPartialResult& { + lsp_runtime_error("SemanticTokensPartialResult::data: not implement yet"); return *this; } SemanticTokensRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; - if (!repr_.contains("legend")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; + if (!repr_->contains("legend")) return false; return true; } auto SemanticTokensRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -1622,16 +2108,16 @@ auto SemanticTokensRegistrationOptions::documentSelector() const } auto SemanticTokensRegistrationOptions::legend() const -> SemanticTokensLegend { - const auto& value = repr_["legend"]; + auto& value = (*repr_)["legend"]; return SemanticTokensLegend(value); } auto SemanticTokensRegistrationOptions::range() const -> std::optional> { - if (!repr_.contains("range")) return std::nullopt; + if (!repr_->contains("range")) return std::nullopt; - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; std::variant result; @@ -1642,9 +2128,9 @@ auto SemanticTokensRegistrationOptions::range() const auto SemanticTokensRegistrationOptions::full() const -> std::optional< std::variant> { - if (!repr_.contains("full")) return std::nullopt; + if (!repr_->contains("full")) return std::nullopt; - const auto& value = repr_["full"]; + auto& value = (*repr_)["full"]; std::variant result; @@ -1655,9 +2141,9 @@ auto SemanticTokensRegistrationOptions::full() const -> std::optional< auto SemanticTokensRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -1665,9 +2151,9 @@ auto SemanticTokensRegistrationOptions::workDoneProgress() const auto SemanticTokensRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -1676,52 +2162,132 @@ auto SemanticTokensRegistrationOptions::id() const auto SemanticTokensRegistrationOptions::documentSelector( std::variant documentSelector) -> SemanticTokensRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "SemanticTokensRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto SemanticTokensRegistrationOptions::legend(SemanticTokensLegend legend) -> SemanticTokensRegistrationOptions& { + repr_->emplace("legend", legend); return *this; } auto SemanticTokensRegistrationOptions::range( std::optional> range) -> SemanticTokensRegistrationOptions& { + if (!range.has_value()) { + repr_->erase("range"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool range) { repr_->emplace("range", std::move(range)); } + + void operator()(json range) { + lsp_runtime_error( + "SemanticTokensRegistrationOptions::range: not implement yet"); + } + } v{repr_}; + + std::visit(v, range.value()); + return *this; } auto SemanticTokensRegistrationOptions::full( std::optional> full) -> SemanticTokensRegistrationOptions& { + if (!full.has_value()) { + repr_->erase("full"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool full) { repr_->emplace("full", std::move(full)); } + + void operator()(SemanticTokensFullDelta full) { + repr_->emplace("full", full); + } + } v{repr_}; + + std::visit(v, full.value()); + return *this; } auto SemanticTokensRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> SemanticTokensRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto SemanticTokensRegistrationOptions::id(std::optional id) -> SemanticTokensRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } SemanticTokensDeltaParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("previousResultId")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("previousResultId")) return false; return true; } auto SemanticTokensDeltaParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto SemanticTokensDeltaParams::previousResultId() const -> std::string { - const auto& value = repr_["previousResultId"]; + auto& value = (*repr_)["previousResultId"]; assert(value.is_string()); return value.get(); @@ -1729,9 +2295,9 @@ auto SemanticTokensDeltaParams::previousResultId() const -> std::string { auto SemanticTokensDeltaParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1742,9 +2308,9 @@ auto SemanticTokensDeltaParams::workDoneToken() const auto SemanticTokensDeltaParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -1755,42 +2321,56 @@ auto SemanticTokensDeltaParams::partialResultToken() const auto SemanticTokensDeltaParams::textDocument( TextDocumentIdentifier textDocument) -> SemanticTokensDeltaParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto SemanticTokensDeltaParams::previousResultId(std::string previousResultId) -> SemanticTokensDeltaParams& { + repr_->emplace("previousResultId", std::move(previousResultId)); return *this; } auto SemanticTokensDeltaParams::workDoneToken( std::optional workDoneToken) -> SemanticTokensDeltaParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "SemanticTokensDeltaParams::workDoneToken: not implement yet"); return *this; } auto SemanticTokensDeltaParams::partialResultToken( std::optional partialResultToken) -> SemanticTokensDeltaParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "SemanticTokensDeltaParams::partialResultToken: not implement yet"); return *this; } SemanticTokensDelta::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("edits")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("edits")) return false; return true; } auto SemanticTokensDelta::resultId() const -> std::optional { - if (!repr_.contains("resultId")) return std::nullopt; + if (!repr_->contains("resultId")) return std::nullopt; - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); } auto SemanticTokensDelta::edits() const -> Vector { - const auto& value = repr_["edits"]; + auto& value = (*repr_)["edits"]; assert(value.is_array()); return Vector(value); @@ -1798,23 +2378,29 @@ auto SemanticTokensDelta::edits() const -> Vector { auto SemanticTokensDelta::resultId(std::optional resultId) -> SemanticTokensDelta& { + if (!resultId.has_value()) { + repr_->erase("resultId"); + return *this; + } + repr_->emplace("resultId", std::move(resultId.value())); return *this; } auto SemanticTokensDelta::edits(Vector edits) -> SemanticTokensDelta& { + lsp_runtime_error("SemanticTokensDelta::edits: not implement yet"); return *this; } SemanticTokensDeltaPartialResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("edits")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("edits")) return false; return true; } auto SemanticTokensDeltaPartialResult::edits() const -> Vector { - const auto& value = repr_["edits"]; + auto& value = (*repr_)["edits"]; assert(value.is_array()); return Vector(value); @@ -1822,33 +2408,35 @@ auto SemanticTokensDeltaPartialResult::edits() const auto SemanticTokensDeltaPartialResult::edits(Vector edits) -> SemanticTokensDeltaPartialResult& { + lsp_runtime_error( + "SemanticTokensDeltaPartialResult::edits: not implement yet"); return *this; } SemanticTokensRangeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("range")) return false; return true; } auto SemanticTokensRangeParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto SemanticTokensRangeParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto SemanticTokensRangeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -1859,9 +2447,9 @@ auto SemanticTokensRangeParams::workDoneToken() const auto SemanticTokensRangeParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -1872,124 +2460,155 @@ auto SemanticTokensRangeParams::partialResultToken() const auto SemanticTokensRangeParams::textDocument( TextDocumentIdentifier textDocument) -> SemanticTokensRangeParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto SemanticTokensRangeParams::range(Range range) -> SemanticTokensRangeParams& { + repr_->emplace("range", range); return *this; } auto SemanticTokensRangeParams::workDoneToken( std::optional workDoneToken) -> SemanticTokensRangeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "SemanticTokensRangeParams::workDoneToken: not implement yet"); return *this; } auto SemanticTokensRangeParams::partialResultToken( std::optional partialResultToken) -> SemanticTokensRangeParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "SemanticTokensRangeParams::partialResultToken: not implement yet"); return *this; } ShowDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto ShowDocumentParams::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto ShowDocumentParams::external() const -> std::optional { - if (!repr_.contains("external")) return std::nullopt; + if (!repr_->contains("external")) return std::nullopt; - const auto& value = repr_["external"]; + auto& value = (*repr_)["external"]; assert(value.is_boolean()); return value.get(); } auto ShowDocumentParams::takeFocus() const -> std::optional { - if (!repr_.contains("takeFocus")) return std::nullopt; + if (!repr_->contains("takeFocus")) return std::nullopt; - const auto& value = repr_["takeFocus"]; + auto& value = (*repr_)["takeFocus"]; assert(value.is_boolean()); return value.get(); } auto ShowDocumentParams::selection() const -> std::optional { - if (!repr_.contains("selection")) return std::nullopt; + if (!repr_->contains("selection")) return std::nullopt; - const auto& value = repr_["selection"]; + auto& value = (*repr_)["selection"]; return Range(value); } auto ShowDocumentParams::uri(std::string uri) -> ShowDocumentParams& { + repr_->emplace("uri", std::move(uri)); return *this; } auto ShowDocumentParams::external(std::optional external) -> ShowDocumentParams& { + if (!external.has_value()) { + repr_->erase("external"); + return *this; + } + repr_->emplace("external", std::move(external.value())); return *this; } auto ShowDocumentParams::takeFocus(std::optional takeFocus) -> ShowDocumentParams& { + if (!takeFocus.has_value()) { + repr_->erase("takeFocus"); + return *this; + } + repr_->emplace("takeFocus", std::move(takeFocus.value())); return *this; } auto ShowDocumentParams::selection(std::optional selection) -> ShowDocumentParams& { + if (!selection.has_value()) { + repr_->erase("selection"); + return *this; + } + repr_->emplace("selection", selection.value()); return *this; } ShowDocumentResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("success")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("success")) return false; return true; } auto ShowDocumentResult::success() const -> bool { - const auto& value = repr_["success"]; + auto& value = (*repr_)["success"]; assert(value.is_boolean()); return value.get(); } auto ShowDocumentResult::success(bool success) -> ShowDocumentResult& { + repr_->emplace("success", std::move(success)); return *this; } LinkedEditingRangeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto LinkedEditingRangeParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto LinkedEditingRangeParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto LinkedEditingRangeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2000,59 +2619,73 @@ auto LinkedEditingRangeParams::workDoneToken() const auto LinkedEditingRangeParams::textDocument(TextDocumentIdentifier textDocument) -> LinkedEditingRangeParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto LinkedEditingRangeParams::position(Position position) -> LinkedEditingRangeParams& { + repr_->emplace("position", position); return *this; } auto LinkedEditingRangeParams::workDoneToken( std::optional workDoneToken) -> LinkedEditingRangeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "LinkedEditingRangeParams::workDoneToken: not implement yet"); return *this; } LinkedEditingRanges::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("ranges")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("ranges")) return false; return true; } auto LinkedEditingRanges::ranges() const -> Vector { - const auto& value = repr_["ranges"]; + auto& value = (*repr_)["ranges"]; assert(value.is_array()); return Vector(value); } auto LinkedEditingRanges::wordPattern() const -> std::optional { - if (!repr_.contains("wordPattern")) return std::nullopt; + if (!repr_->contains("wordPattern")) return std::nullopt; - const auto& value = repr_["wordPattern"]; + auto& value = (*repr_)["wordPattern"]; assert(value.is_string()); return value.get(); } auto LinkedEditingRanges::ranges(Vector ranges) -> LinkedEditingRanges& { + lsp_runtime_error("LinkedEditingRanges::ranges: not implement yet"); return *this; } auto LinkedEditingRanges::wordPattern(std::optional wordPattern) -> LinkedEditingRanges& { + if (!wordPattern.has_value()) { + repr_->erase("wordPattern"); + return *this; + } + repr_->emplace("wordPattern", std::move(wordPattern.value())); return *this; } LinkedEditingRangeRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto LinkedEditingRangeRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -2063,9 +2696,9 @@ auto LinkedEditingRangeRegistrationOptions::documentSelector() const auto LinkedEditingRangeRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -2073,9 +2706,9 @@ auto LinkedEditingRangeRegistrationOptions::workDoneProgress() const auto LinkedEditingRangeRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -2084,47 +2717,80 @@ auto LinkedEditingRangeRegistrationOptions::id() const auto LinkedEditingRangeRegistrationOptions::documentSelector( std::variant documentSelector) -> LinkedEditingRangeRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "LinkedEditingRangeRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto LinkedEditingRangeRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> LinkedEditingRangeRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto LinkedEditingRangeRegistrationOptions::id(std::optional id) -> LinkedEditingRangeRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } CreateFilesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("files")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("files")) return false; return true; } auto CreateFilesParams::files() const -> Vector { - const auto& value = repr_["files"]; + auto& value = (*repr_)["files"]; assert(value.is_array()); return Vector(value); } auto CreateFilesParams::files(Vector files) -> CreateFilesParams& { + lsp_runtime_error("CreateFilesParams::files: not implement yet"); return *this; } WorkspaceEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceEdit::changes() const -> std::optional>> { - if (!repr_.contains("changes")) return std::nullopt; + if (!repr_->contains("changes")) return std::nullopt; - const auto& value = repr_["changes"]; + auto& value = (*repr_)["changes"]; assert(value.is_object()); return Map>(value); @@ -2133,9 +2799,9 @@ auto WorkspaceEdit::changes() const auto WorkspaceEdit::documentChanges() const -> std::optional>> { - if (!repr_.contains("documentChanges")) return std::nullopt; + if (!repr_->contains("documentChanges")) return std::nullopt; - const auto& value = repr_["documentChanges"]; + auto& value = (*repr_)["documentChanges"]; assert(value.is_array()); return Vector std::optional> { - if (!repr_.contains("changeAnnotations")) return std::nullopt; + if (!repr_->contains("changeAnnotations")) return std::nullopt; - const auto& value = repr_["changeAnnotations"]; + auto& value = (*repr_)["changeAnnotations"]; assert(value.is_object()); return Map(value); @@ -2155,6 +2821,11 @@ auto WorkspaceEdit::changeAnnotations() const auto WorkspaceEdit::changes( std::optional>> changes) -> WorkspaceEdit& { + if (!changes.has_value()) { + repr_->erase("changes"); + return *this; + } + lsp_runtime_error("WorkspaceEdit::changes: not implement yet"); return *this; } @@ -2162,24 +2833,34 @@ auto WorkspaceEdit::documentChanges( std::optional>> documentChanges) -> WorkspaceEdit& { + if (!documentChanges.has_value()) { + repr_->erase("documentChanges"); + return *this; + } + lsp_runtime_error("WorkspaceEdit::documentChanges: not implement yet"); return *this; } auto WorkspaceEdit::changeAnnotations( std::optional> changeAnnotations) -> WorkspaceEdit& { + if (!changeAnnotations.has_value()) { + repr_->erase("changeAnnotations"); + return *this; + } + lsp_runtime_error("WorkspaceEdit::changeAnnotations: not implement yet"); return *this; } FileOperationRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("filters")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("filters")) return false; return true; } auto FileOperationRegistrationOptions::filters() const -> Vector { - const auto& value = repr_["filters"]; + auto& value = (*repr_)["filters"]; assert(value.is_array()); return Vector(value); @@ -2187,66 +2868,70 @@ auto FileOperationRegistrationOptions::filters() const auto FileOperationRegistrationOptions::filters( Vector filters) -> FileOperationRegistrationOptions& { + lsp_runtime_error( + "FileOperationRegistrationOptions::filters: not implement yet"); return *this; } RenameFilesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("files")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("files")) return false; return true; } auto RenameFilesParams::files() const -> Vector { - const auto& value = repr_["files"]; + auto& value = (*repr_)["files"]; assert(value.is_array()); return Vector(value); } auto RenameFilesParams::files(Vector files) -> RenameFilesParams& { + lsp_runtime_error("RenameFilesParams::files: not implement yet"); return *this; } DeleteFilesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("files")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("files")) return false; return true; } auto DeleteFilesParams::files() const -> Vector { - const auto& value = repr_["files"]; + auto& value = (*repr_)["files"]; assert(value.is_array()); return Vector(value); } auto DeleteFilesParams::files(Vector files) -> DeleteFilesParams& { + lsp_runtime_error("DeleteFilesParams::files: not implement yet"); return *this; } MonikerParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto MonikerParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto MonikerParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto MonikerParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2256,9 +2941,9 @@ auto MonikerParams::workDoneToken() const -> std::optional { } auto MonikerParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -2269,78 +2954,104 @@ auto MonikerParams::partialResultToken() const -> std::optional { auto MonikerParams::textDocument(TextDocumentIdentifier textDocument) -> MonikerParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto MonikerParams::position(Position position) -> MonikerParams& { + repr_->emplace("position", position); return *this; } auto MonikerParams::workDoneToken(std::optional workDoneToken) -> MonikerParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("MonikerParams::workDoneToken: not implement yet"); return *this; } auto MonikerParams::partialResultToken( std::optional partialResultToken) -> MonikerParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("MonikerParams::partialResultToken: not implement yet"); return *this; } Moniker::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("scheme")) return false; - if (!repr_.contains("identifier")) return false; - if (!repr_.contains("unique")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("scheme")) return false; + if (!repr_->contains("identifier")) return false; + if (!repr_->contains("unique")) return false; return true; } auto Moniker::scheme() const -> std::string { - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto Moniker::identifier() const -> std::string { - const auto& value = repr_["identifier"]; + auto& value = (*repr_)["identifier"]; assert(value.is_string()); return value.get(); } auto Moniker::unique() const -> UniquenessLevel { - const auto& value = repr_["unique"]; + auto& value = (*repr_)["unique"]; lsp_runtime_error("Moniker::unique: not implement yet"); } auto Moniker::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; lsp_runtime_error("Moniker::kind: not implement yet"); } -auto Moniker::scheme(std::string scheme) -> Moniker& { return *this; } +auto Moniker::scheme(std::string scheme) -> Moniker& { + repr_->emplace("scheme", std::move(scheme)); + return *this; +} -auto Moniker::identifier(std::string identifier) -> Moniker& { return *this; } +auto Moniker::identifier(std::string identifier) -> Moniker& { + repr_->emplace("identifier", std::move(identifier)); + return *this; +} -auto Moniker::unique(UniquenessLevel unique) -> Moniker& { return *this; } +auto Moniker::unique(UniquenessLevel unique) -> Moniker& { + lsp_runtime_error("Moniker::unique: not implement yet"); + return *this; +} auto Moniker::kind(std::optional kind) -> Moniker& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + lsp_runtime_error("Moniker::kind: not implement yet"); return *this; } MonikerRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto MonikerRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -2351,9 +3062,9 @@ auto MonikerRegistrationOptions::documentSelector() const auto MonikerRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -2362,39 +3073,65 @@ auto MonikerRegistrationOptions::workDoneProgress() const auto MonikerRegistrationOptions::documentSelector( std::variant documentSelector) -> MonikerRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "MonikerRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto MonikerRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> MonikerRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } TypeHierarchyPrepareParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto TypeHierarchyPrepareParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto TypeHierarchyPrepareParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto TypeHierarchyPrepareParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2405,132 +3142,160 @@ auto TypeHierarchyPrepareParams::workDoneToken() const auto TypeHierarchyPrepareParams::textDocument( TextDocumentIdentifier textDocument) -> TypeHierarchyPrepareParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto TypeHierarchyPrepareParams::position(Position position) -> TypeHierarchyPrepareParams& { + repr_->emplace("position", position); return *this; } auto TypeHierarchyPrepareParams::workDoneToken( std::optional workDoneToken) -> TypeHierarchyPrepareParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "TypeHierarchyPrepareParams::workDoneToken: not implement yet"); return *this; } TypeHierarchyItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("selectionRange")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("selectionRange")) return false; return true; } auto TypeHierarchyItem::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto TypeHierarchyItem::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto TypeHierarchyItem::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto TypeHierarchyItem::detail() const -> std::optional { - if (!repr_.contains("detail")) return std::nullopt; + if (!repr_->contains("detail")) return std::nullopt; - const auto& value = repr_["detail"]; + auto& value = (*repr_)["detail"]; assert(value.is_string()); return value.get(); } auto TypeHierarchyItem::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto TypeHierarchyItem::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto TypeHierarchyItem::selectionRange() const -> Range { - const auto& value = repr_["selectionRange"]; + auto& value = (*repr_)["selectionRange"]; return Range(value); } auto TypeHierarchyItem::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } auto TypeHierarchyItem::name(std::string name) -> TypeHierarchyItem& { + repr_->emplace("name", std::move(name)); return *this; } auto TypeHierarchyItem::kind(SymbolKind kind) -> TypeHierarchyItem& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto TypeHierarchyItem::tags(std::optional> tags) -> TypeHierarchyItem& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("TypeHierarchyItem::tags: not implement yet"); return *this; } auto TypeHierarchyItem::detail(std::optional detail) -> TypeHierarchyItem& { + if (!detail.has_value()) { + repr_->erase("detail"); + return *this; + } + repr_->emplace("detail", std::move(detail.value())); return *this; } auto TypeHierarchyItem::uri(std::string uri) -> TypeHierarchyItem& { + repr_->emplace("uri", std::move(uri)); return *this; } auto TypeHierarchyItem::range(Range range) -> TypeHierarchyItem& { + repr_->emplace("range", range); return *this; } auto TypeHierarchyItem::selectionRange(Range selectionRange) -> TypeHierarchyItem& { + repr_->emplace("selectionRange", selectionRange); return *this; } auto TypeHierarchyItem::data(std::optional data) -> TypeHierarchyItem& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("TypeHierarchyItem::data: not implement yet"); return *this; } TypeHierarchyRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto TypeHierarchyRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -2541,9 +3306,9 @@ auto TypeHierarchyRegistrationOptions::documentSelector() const auto TypeHierarchyRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -2551,9 +3316,9 @@ auto TypeHierarchyRegistrationOptions::workDoneProgress() const auto TypeHierarchyRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -2562,36 +3327,68 @@ auto TypeHierarchyRegistrationOptions::id() const auto TypeHierarchyRegistrationOptions::documentSelector( std::variant documentSelector) -> TypeHierarchyRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "TypeHierarchyRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto TypeHierarchyRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> TypeHierarchyRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto TypeHierarchyRegistrationOptions::id(std::optional id) -> TypeHierarchyRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } TypeHierarchySupertypesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("item")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("item")) return false; return true; } auto TypeHierarchySupertypesParams::item() const -> TypeHierarchyItem { - const auto& value = repr_["item"]; + auto& value = (*repr_)["item"]; return TypeHierarchyItem(value); } auto TypeHierarchySupertypesParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2602,9 +3399,9 @@ auto TypeHierarchySupertypesParams::workDoneToken() const auto TypeHierarchySupertypesParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -2615,38 +3412,51 @@ auto TypeHierarchySupertypesParams::partialResultToken() const auto TypeHierarchySupertypesParams::item(TypeHierarchyItem item) -> TypeHierarchySupertypesParams& { + repr_->emplace("item", item); return *this; } auto TypeHierarchySupertypesParams::workDoneToken( std::optional workDoneToken) -> TypeHierarchySupertypesParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "TypeHierarchySupertypesParams::workDoneToken: not implement yet"); return *this; } auto TypeHierarchySupertypesParams::partialResultToken( std::optional partialResultToken) -> TypeHierarchySupertypesParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "TypeHierarchySupertypesParams::partialResultToken: not implement yet"); return *this; } TypeHierarchySubtypesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("item")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("item")) return false; return true; } auto TypeHierarchySubtypesParams::item() const -> TypeHierarchyItem { - const auto& value = repr_["item"]; + auto& value = (*repr_)["item"]; return TypeHierarchyItem(value); } auto TypeHierarchySubtypesParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2657,9 +3467,9 @@ auto TypeHierarchySubtypesParams::workDoneToken() const auto TypeHierarchySubtypesParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -2670,51 +3480,64 @@ auto TypeHierarchySubtypesParams::partialResultToken() const auto TypeHierarchySubtypesParams::item(TypeHierarchyItem item) -> TypeHierarchySubtypesParams& { + repr_->emplace("item", item); return *this; } auto TypeHierarchySubtypesParams::workDoneToken( std::optional workDoneToken) -> TypeHierarchySubtypesParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "TypeHierarchySubtypesParams::workDoneToken: not implement yet"); return *this; } auto TypeHierarchySubtypesParams::partialResultToken( std::optional partialResultToken) -> TypeHierarchySubtypesParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "TypeHierarchySubtypesParams::partialResultToken: not implement yet"); return *this; } InlineValueParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("context")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("context")) return false; return true; } auto InlineValueParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto InlineValueParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlineValueParams::context() const -> InlineValueContext { - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return InlineValueContext(value); } auto InlineValueParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2725,34 +3548,42 @@ auto InlineValueParams::workDoneToken() const -> std::optional { auto InlineValueParams::textDocument(TextDocumentIdentifier textDocument) -> InlineValueParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto InlineValueParams::range(Range range) -> InlineValueParams& { + repr_->emplace("range", range); return *this; } auto InlineValueParams::context(InlineValueContext context) -> InlineValueParams& { + repr_->emplace("context", context); return *this; } auto InlineValueParams::workDoneToken( std::optional workDoneToken) -> InlineValueParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("InlineValueParams::workDoneToken: not implement yet"); return *this; } InlineValueRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto InlineValueRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -2760,7 +3591,7 @@ auto InlineValueRegistrationOptions::workDoneProgress() const auto InlineValueRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -2770,9 +3601,9 @@ auto InlineValueRegistrationOptions::documentSelector() const } auto InlineValueRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -2780,43 +3611,75 @@ auto InlineValueRegistrationOptions::id() const -> std::optional { auto InlineValueRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> InlineValueRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto InlineValueRegistrationOptions::documentSelector( std::variant documentSelector) -> InlineValueRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "InlineValueRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto InlineValueRegistrationOptions::id(std::optional id) -> InlineValueRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } InlayHintParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("range")) return false; return true; } auto InlayHintParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto InlayHintParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlayHintParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -2827,32 +3690,41 @@ auto InlayHintParams::workDoneToken() const -> std::optional { auto InlayHintParams::textDocument(TextDocumentIdentifier textDocument) -> InlayHintParams& { + repr_->emplace("textDocument", textDocument); return *this; } -auto InlayHintParams::range(Range range) -> InlayHintParams& { return *this; } +auto InlayHintParams::range(Range range) -> InlayHintParams& { + repr_->emplace("range", range); + return *this; +} auto InlayHintParams::workDoneToken(std::optional workDoneToken) -> InlayHintParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("InlayHintParams::workDoneToken: not implement yet"); return *this; } InlayHint::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("position")) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("position")) return false; + if (!repr_->contains("label")) return false; return true; } auto InlayHint::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto InlayHint::label() const -> std::variant> { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; std::variant> result; @@ -2862,17 +3734,17 @@ auto InlayHint::label() const } auto InlayHint::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return InlayHintKind(value); } auto InlayHint::textEdits() const -> std::optional> { - if (!repr_.contains("textEdits")) return std::nullopt; + if (!repr_->contains("textEdits")) return std::nullopt; - const auto& value = repr_["textEdits"]; + auto& value = (*repr_)["textEdits"]; assert(value.is_array()); return Vector(value); @@ -2880,9 +3752,9 @@ auto InlayHint::textEdits() const -> std::optional> { auto InlayHint::tooltip() const -> std::optional> { - if (!repr_.contains("tooltip")) return std::nullopt; + if (!repr_->contains("tooltip")) return std::nullopt; - const auto& value = repr_["tooltip"]; + auto& value = (*repr_)["tooltip"]; std::variant result; @@ -2892,76 +3764,151 @@ auto InlayHint::tooltip() const } auto InlayHint::paddingLeft() const -> std::optional { - if (!repr_.contains("paddingLeft")) return std::nullopt; + if (!repr_->contains("paddingLeft")) return std::nullopt; - const auto& value = repr_["paddingLeft"]; + auto& value = (*repr_)["paddingLeft"]; assert(value.is_boolean()); return value.get(); } auto InlayHint::paddingRight() const -> std::optional { - if (!repr_.contains("paddingRight")) return std::nullopt; + if (!repr_->contains("paddingRight")) return std::nullopt; - const auto& value = repr_["paddingRight"]; + auto& value = (*repr_)["paddingRight"]; assert(value.is_boolean()); return value.get(); } auto InlayHint::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } -auto InlayHint::position(Position position) -> InlayHint& { return *this; } +auto InlayHint::position(Position position) -> InlayHint& { + repr_->emplace("position", position); + return *this; +} auto InlayHint::label( std::variant> label) -> InlayHint& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string label) { + repr_->emplace("label", std::move(label)); + } + + void operator()(Vector label) { + lsp_runtime_error("InlayHint::label: not implement yet"); + } + } v{repr_}; + + std::visit(v, label); + return *this; } auto InlayHint::kind(std::optional kind) -> InlayHint& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + repr_->emplace("kind", static_cast(kind.value())); return *this; } auto InlayHint::textEdits(std::optional> textEdits) -> InlayHint& { + if (!textEdits.has_value()) { + repr_->erase("textEdits"); + return *this; + } + lsp_runtime_error("InlayHint::textEdits: not implement yet"); return *this; } auto InlayHint::tooltip( std::optional> tooltip) -> InlayHint& { + if (!tooltip.has_value()) { + repr_->erase("tooltip"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string tooltip) { + repr_->emplace("tooltip", std::move(tooltip)); + } + + void operator()(MarkupContent tooltip) { + repr_->emplace("tooltip", tooltip); + } + } v{repr_}; + + std::visit(v, tooltip.value()); + return *this; } auto InlayHint::paddingLeft(std::optional paddingLeft) -> InlayHint& { + if (!paddingLeft.has_value()) { + repr_->erase("paddingLeft"); + return *this; + } + repr_->emplace("paddingLeft", std::move(paddingLeft.value())); return *this; } auto InlayHint::paddingRight(std::optional paddingRight) -> InlayHint& { + if (!paddingRight.has_value()) { + repr_->erase("paddingRight"); + return *this; + } + repr_->emplace("paddingRight", std::move(paddingRight.value())); return *this; } -auto InlayHint::data(std::optional data) -> InlayHint& { return *this; } +auto InlayHint::data(std::optional data) -> InlayHint& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("InlayHint::data: not implement yet"); + return *this; +} InlayHintRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto InlayHintRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -2969,9 +3916,9 @@ auto InlayHintRegistrationOptions::resolveProvider() const auto InlayHintRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -2979,7 +3926,7 @@ auto InlayHintRegistrationOptions::workDoneProgress() const auto InlayHintRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -2989,9 +3936,9 @@ auto InlayHintRegistrationOptions::documentSelector() const } auto InlayHintRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -2999,42 +3946,78 @@ auto InlayHintRegistrationOptions::id() const -> std::optional { auto InlayHintRegistrationOptions::resolveProvider( std::optional resolveProvider) -> InlayHintRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto InlayHintRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> InlayHintRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto InlayHintRegistrationOptions::documentSelector( std::variant documentSelector) -> InlayHintRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "InlayHintRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto InlayHintRegistrationOptions::id(std::optional id) -> InlayHintRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } DocumentDiagnosticParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DocumentDiagnosticParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentDiagnosticParams::identifier() const -> std::optional { - if (!repr_.contains("identifier")) return std::nullopt; + if (!repr_->contains("identifier")) return std::nullopt; - const auto& value = repr_["identifier"]; + auto& value = (*repr_)["identifier"]; assert(value.is_string()); return value.get(); @@ -3042,9 +4025,9 @@ auto DocumentDiagnosticParams::identifier() const auto DocumentDiagnosticParams::previousResultId() const -> std::optional { - if (!repr_.contains("previousResultId")) return std::nullopt; + if (!repr_->contains("previousResultId")) return std::nullopt; - const auto& value = repr_["previousResultId"]; + auto& value = (*repr_)["previousResultId"]; assert(value.is_string()); return value.get(); @@ -3052,9 +4035,9 @@ auto DocumentDiagnosticParams::previousResultId() const auto DocumentDiagnosticParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -3065,9 +4048,9 @@ auto DocumentDiagnosticParams::workDoneToken() const auto DocumentDiagnosticParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -3078,33 +4061,56 @@ auto DocumentDiagnosticParams::partialResultToken() const auto DocumentDiagnosticParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentDiagnosticParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentDiagnosticParams::identifier(std::optional identifier) -> DocumentDiagnosticParams& { + if (!identifier.has_value()) { + repr_->erase("identifier"); + return *this; + } + repr_->emplace("identifier", std::move(identifier.value())); return *this; } auto DocumentDiagnosticParams::previousResultId( std::optional previousResultId) -> DocumentDiagnosticParams& { + if (!previousResultId.has_value()) { + repr_->erase("previousResultId"); + return *this; + } + repr_->emplace("previousResultId", std::move(previousResultId.value())); return *this; } auto DocumentDiagnosticParams::workDoneToken( std::optional workDoneToken) -> DocumentDiagnosticParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "DocumentDiagnosticParams::workDoneToken: not implement yet"); return *this; } auto DocumentDiagnosticParams::partialResultToken( std::optional partialResultToken) -> DocumentDiagnosticParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "DocumentDiagnosticParams::partialResultToken: not implement yet"); return *this; } DocumentDiagnosticReportPartialResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("relatedDocuments")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("relatedDocuments")) return false; return true; } @@ -3112,7 +4118,7 @@ auto DocumentDiagnosticReportPartialResult::relatedDocuments() const -> Map> { - const auto& value = repr_["relatedDocuments"]; + auto& value = (*repr_)["relatedDocuments"]; assert(value.is_object()); return Map> relatedDocuments) -> DocumentDiagnosticReportPartialResult& { + lsp_runtime_error( + "DocumentDiagnosticReportPartialResult::relatedDocuments: not implement " + "yet"); return *this; } DiagnosticServerCancellationData::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("retriggerRequest")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("retriggerRequest")) return false; return true; } auto DiagnosticServerCancellationData::retriggerRequest() const -> bool { - const auto& value = repr_["retriggerRequest"]; + auto& value = (*repr_)["retriggerRequest"]; assert(value.is_boolean()); return value.get(); @@ -3142,20 +4151,21 @@ auto DiagnosticServerCancellationData::retriggerRequest() const -> bool { auto DiagnosticServerCancellationData::retriggerRequest(bool retriggerRequest) -> DiagnosticServerCancellationData& { + repr_->emplace("retriggerRequest", std::move(retriggerRequest)); return *this; } DiagnosticRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; - if (!repr_.contains("interFileDependencies")) return false; - if (!repr_.contains("workspaceDiagnostics")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; + if (!repr_->contains("interFileDependencies")) return false; + if (!repr_->contains("workspaceDiagnostics")) return false; return true; } auto DiagnosticRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -3166,23 +4176,23 @@ auto DiagnosticRegistrationOptions::documentSelector() const auto DiagnosticRegistrationOptions::identifier() const -> std::optional { - if (!repr_.contains("identifier")) return std::nullopt; + if (!repr_->contains("identifier")) return std::nullopt; - const auto& value = repr_["identifier"]; + auto& value = (*repr_)["identifier"]; assert(value.is_string()); return value.get(); } auto DiagnosticRegistrationOptions::interFileDependencies() const -> bool { - const auto& value = repr_["interFileDependencies"]; + auto& value = (*repr_)["interFileDependencies"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticRegistrationOptions::workspaceDiagnostics() const -> bool { - const auto& value = repr_["workspaceDiagnostics"]; + auto& value = (*repr_)["workspaceDiagnostics"]; assert(value.is_boolean()); return value.get(); @@ -3190,18 +4200,18 @@ auto DiagnosticRegistrationOptions::workspaceDiagnostics() const -> bool { auto DiagnosticRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -3210,45 +4220,83 @@ auto DiagnosticRegistrationOptions::id() const -> std::optional { auto DiagnosticRegistrationOptions::documentSelector( std::variant documentSelector) -> DiagnosticRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DiagnosticRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DiagnosticRegistrationOptions::identifier( std::optional identifier) -> DiagnosticRegistrationOptions& { + if (!identifier.has_value()) { + repr_->erase("identifier"); + return *this; + } + repr_->emplace("identifier", std::move(identifier.value())); return *this; } auto DiagnosticRegistrationOptions::interFileDependencies( bool interFileDependencies) -> DiagnosticRegistrationOptions& { + repr_->emplace("interFileDependencies", std::move(interFileDependencies)); return *this; } auto DiagnosticRegistrationOptions::workspaceDiagnostics( bool workspaceDiagnostics) -> DiagnosticRegistrationOptions& { + repr_->emplace("workspaceDiagnostics", std::move(workspaceDiagnostics)); return *this; } auto DiagnosticRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DiagnosticRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto DiagnosticRegistrationOptions::id(std::optional id) -> DiagnosticRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } WorkspaceDiagnosticParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("previousResultIds")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("previousResultIds")) return false; return true; } auto WorkspaceDiagnosticParams::identifier() const -> std::optional { - if (!repr_.contains("identifier")) return std::nullopt; + if (!repr_->contains("identifier")) return std::nullopt; - const auto& value = repr_["identifier"]; + auto& value = (*repr_)["identifier"]; assert(value.is_string()); return value.get(); @@ -3256,7 +4304,7 @@ auto WorkspaceDiagnosticParams::identifier() const auto WorkspaceDiagnosticParams::previousResultIds() const -> Vector { - const auto& value = repr_["previousResultIds"]; + auto& value = (*repr_)["previousResultIds"]; assert(value.is_array()); return Vector(value); @@ -3264,9 +4312,9 @@ auto WorkspaceDiagnosticParams::previousResultIds() const auto WorkspaceDiagnosticParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -3277,9 +4325,9 @@ auto WorkspaceDiagnosticParams::workDoneToken() const auto WorkspaceDiagnosticParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -3290,34 +4338,53 @@ auto WorkspaceDiagnosticParams::partialResultToken() const auto WorkspaceDiagnosticParams::identifier( std::optional identifier) -> WorkspaceDiagnosticParams& { + if (!identifier.has_value()) { + repr_->erase("identifier"); + return *this; + } + repr_->emplace("identifier", std::move(identifier.value())); return *this; } auto WorkspaceDiagnosticParams::previousResultIds( Vector previousResultIds) -> WorkspaceDiagnosticParams& { + lsp_runtime_error( + "WorkspaceDiagnosticParams::previousResultIds: not implement yet"); return *this; } auto WorkspaceDiagnosticParams::workDoneToken( std::optional workDoneToken) -> WorkspaceDiagnosticParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "WorkspaceDiagnosticParams::workDoneToken: not implement yet"); return *this; } auto WorkspaceDiagnosticParams::partialResultToken( std::optional partialResultToken) -> WorkspaceDiagnosticParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "WorkspaceDiagnosticParams::partialResultToken: not implement yet"); return *this; } WorkspaceDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("items")) return false; return true; } auto WorkspaceDiagnosticReport::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -3326,18 +4393,19 @@ auto WorkspaceDiagnosticReport::items() const auto WorkspaceDiagnosticReport::items( Vector items) -> WorkspaceDiagnosticReport& { + lsp_runtime_error("WorkspaceDiagnosticReport::items: not implement yet"); return *this; } WorkspaceDiagnosticReportPartialResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("items")) return false; return true; } auto WorkspaceDiagnosticReportPartialResult::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -3346,26 +4414,28 @@ auto WorkspaceDiagnosticReportPartialResult::items() const auto WorkspaceDiagnosticReportPartialResult::items( Vector items) -> WorkspaceDiagnosticReportPartialResult& { + lsp_runtime_error( + "WorkspaceDiagnosticReportPartialResult::items: not implement yet"); return *this; } DidOpenNotebookDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookDocument")) return false; - if (!repr_.contains("cellTextDocuments")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookDocument")) return false; + if (!repr_->contains("cellTextDocuments")) return false; return true; } auto DidOpenNotebookDocumentParams::notebookDocument() const -> NotebookDocument { - const auto& value = repr_["notebookDocument"]; + auto& value = (*repr_)["notebookDocument"]; return NotebookDocument(value); } auto DidOpenNotebookDocumentParams::cellTextDocuments() const -> Vector { - const auto& value = repr_["cellTextDocuments"]; + auto& value = (*repr_)["cellTextDocuments"]; assert(value.is_array()); return Vector(value); @@ -3373,25 +4443,28 @@ auto DidOpenNotebookDocumentParams::cellTextDocuments() const auto DidOpenNotebookDocumentParams::notebookDocument( NotebookDocument notebookDocument) -> DidOpenNotebookDocumentParams& { + repr_->emplace("notebookDocument", notebookDocument); return *this; } auto DidOpenNotebookDocumentParams::cellTextDocuments( Vector cellTextDocuments) -> DidOpenNotebookDocumentParams& { + lsp_runtime_error( + "DidOpenNotebookDocumentParams::cellTextDocuments: not implement yet"); return *this; } NotebookDocumentSyncRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookSelector")) return false; return true; } auto NotebookDocumentSyncRegistrationOptions::notebookSelector() const -> Vector> { - const auto& value = repr_["notebookSelector"]; + auto& value = (*repr_)["notebookSelector"]; assert(value.is_array()); return Vector std::optional { - if (!repr_.contains("save")) return std::nullopt; + if (!repr_->contains("save")) return std::nullopt; - const auto& value = repr_["save"]; + auto& value = (*repr_)["save"]; assert(value.is_boolean()); return value.get(); @@ -3410,9 +4483,9 @@ auto NotebookDocumentSyncRegistrationOptions::save() const auto NotebookDocumentSyncRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -3422,36 +4495,49 @@ auto NotebookDocumentSyncRegistrationOptions::notebookSelector( Vector> notebookSelector) -> NotebookDocumentSyncRegistrationOptions& { + lsp_runtime_error( + "NotebookDocumentSyncRegistrationOptions::notebookSelector: not " + "implement yet"); return *this; } auto NotebookDocumentSyncRegistrationOptions::save(std::optional save) -> NotebookDocumentSyncRegistrationOptions& { + if (!save.has_value()) { + repr_->erase("save"); + return *this; + } + repr_->emplace("save", std::move(save.value())); return *this; } auto NotebookDocumentSyncRegistrationOptions::id(std::optional id) -> NotebookDocumentSyncRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } DidChangeNotebookDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookDocument")) return false; - if (!repr_.contains("change")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookDocument")) return false; + if (!repr_->contains("change")) return false; return true; } auto DidChangeNotebookDocumentParams::notebookDocument() const -> VersionedNotebookDocumentIdentifier { - const auto& value = repr_["notebookDocument"]; + auto& value = (*repr_)["notebookDocument"]; return VersionedNotebookDocumentIdentifier(value); } auto DidChangeNotebookDocumentParams::change() const -> NotebookDocumentChangeEvent { - const auto& value = repr_["change"]; + auto& value = (*repr_)["change"]; return NotebookDocumentChangeEvent(value); } @@ -3459,23 +4545,25 @@ auto DidChangeNotebookDocumentParams::change() const auto DidChangeNotebookDocumentParams::notebookDocument( VersionedNotebookDocumentIdentifier notebookDocument) -> DidChangeNotebookDocumentParams& { + repr_->emplace("notebookDocument", notebookDocument); return *this; } auto DidChangeNotebookDocumentParams::change(NotebookDocumentChangeEvent change) -> DidChangeNotebookDocumentParams& { + repr_->emplace("change", change); return *this; } DidSaveNotebookDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookDocument")) return false; return true; } auto DidSaveNotebookDocumentParams::notebookDocument() const -> NotebookDocumentIdentifier { - const auto& value = repr_["notebookDocument"]; + auto& value = (*repr_)["notebookDocument"]; return NotebookDocumentIdentifier(value); } @@ -3483,26 +4571,27 @@ auto DidSaveNotebookDocumentParams::notebookDocument() const auto DidSaveNotebookDocumentParams::notebookDocument( NotebookDocumentIdentifier notebookDocument) -> DidSaveNotebookDocumentParams& { + repr_->emplace("notebookDocument", notebookDocument); return *this; } DidCloseNotebookDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookDocument")) return false; - if (!repr_.contains("cellTextDocuments")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookDocument")) return false; + if (!repr_->contains("cellTextDocuments")) return false; return true; } auto DidCloseNotebookDocumentParams::notebookDocument() const -> NotebookDocumentIdentifier { - const auto& value = repr_["notebookDocument"]; + auto& value = (*repr_)["notebookDocument"]; return NotebookDocumentIdentifier(value); } auto DidCloseNotebookDocumentParams::cellTextDocuments() const -> Vector { - const auto& value = repr_["cellTextDocuments"]; + auto& value = (*repr_)["cellTextDocuments"]; assert(value.is_array()); return Vector(value); @@ -3511,46 +4600,49 @@ auto DidCloseNotebookDocumentParams::cellTextDocuments() const auto DidCloseNotebookDocumentParams::notebookDocument( NotebookDocumentIdentifier notebookDocument) -> DidCloseNotebookDocumentParams& { + repr_->emplace("notebookDocument", notebookDocument); return *this; } auto DidCloseNotebookDocumentParams::cellTextDocuments( Vector cellTextDocuments) -> DidCloseNotebookDocumentParams& { + lsp_runtime_error( + "DidCloseNotebookDocumentParams::cellTextDocuments: not implement yet"); return *this; } InlineCompletionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("context")) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("context")) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto InlineCompletionParams::context() const -> InlineCompletionContext { - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return InlineCompletionContext(value); } auto InlineCompletionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto InlineCompletionParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto InlineCompletionParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -3561,32 +4653,40 @@ auto InlineCompletionParams::workDoneToken() const auto InlineCompletionParams::context(InlineCompletionContext context) -> InlineCompletionParams& { + repr_->emplace("context", context); return *this; } auto InlineCompletionParams::textDocument(TextDocumentIdentifier textDocument) -> InlineCompletionParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto InlineCompletionParams::position(Position position) -> InlineCompletionParams& { + repr_->emplace("position", position); return *this; } auto InlineCompletionParams::workDoneToken( std::optional workDoneToken) -> InlineCompletionParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("InlineCompletionParams::workDoneToken: not implement yet"); return *this; } InlineCompletionList::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("items")) return false; return true; } auto InlineCompletionList::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -3594,18 +4694,19 @@ auto InlineCompletionList::items() const -> Vector { auto InlineCompletionList::items(Vector items) -> InlineCompletionList& { + lsp_runtime_error("InlineCompletionList::items: not implement yet"); return *this; } InlineCompletionItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("insertText")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("insertText")) return false; return true; } auto InlineCompletionItem::insertText() const -> std::variant { - const auto& value = repr_["insertText"]; + auto& value = (*repr_)["insertText"]; std::variant result; @@ -3615,26 +4716,26 @@ auto InlineCompletionItem::insertText() const } auto InlineCompletionItem::filterText() const -> std::optional { - if (!repr_.contains("filterText")) return std::nullopt; + if (!repr_->contains("filterText")) return std::nullopt; - const auto& value = repr_["filterText"]; + auto& value = (*repr_)["filterText"]; assert(value.is_string()); return value.get(); } auto InlineCompletionItem::range() const -> std::optional { - if (!repr_.contains("range")) return std::nullopt; + if (!repr_->contains("range")) return std::nullopt; - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlineCompletionItem::command() const -> std::optional { - if (!repr_.contains("command")) return std::nullopt; + if (!repr_->contains("command")) return std::nullopt; - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } @@ -3642,35 +4743,70 @@ auto InlineCompletionItem::command() const -> std::optional { auto InlineCompletionItem::insertText( std::variant insertText) -> InlineCompletionItem& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string insertText) { + repr_->emplace("insertText", std::move(insertText)); + } + + void operator()(StringValue insertText) { + repr_->emplace("insertText", insertText); + } + } v{repr_}; + + std::visit(v, insertText); + return *this; } auto InlineCompletionItem::filterText(std::optional filterText) -> InlineCompletionItem& { + if (!filterText.has_value()) { + repr_->erase("filterText"); + return *this; + } + repr_->emplace("filterText", std::move(filterText.value())); return *this; } auto InlineCompletionItem::range(std::optional range) -> InlineCompletionItem& { + if (!range.has_value()) { + repr_->erase("range"); + return *this; + } + repr_->emplace("range", range.value()); return *this; } auto InlineCompletionItem::command(std::optional command) -> InlineCompletionItem& { + if (!command.has_value()) { + repr_->erase("command"); + return *this; + } + repr_->emplace("command", command.value()); return *this; } InlineCompletionRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto InlineCompletionRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -3678,7 +4814,7 @@ auto InlineCompletionRegistrationOptions::workDoneProgress() const auto InlineCompletionRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -3689,9 +4825,9 @@ auto InlineCompletionRegistrationOptions::documentSelector() const auto InlineCompletionRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -3700,28 +4836,60 @@ auto InlineCompletionRegistrationOptions::id() const auto InlineCompletionRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> InlineCompletionRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto InlineCompletionRegistrationOptions::documentSelector( std::variant documentSelector) -> InlineCompletionRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "InlineCompletionRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto InlineCompletionRegistrationOptions::id(std::optional id) -> InlineCompletionRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } TextDocumentContentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto TextDocumentContentParams::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -3729,17 +4897,18 @@ auto TextDocumentContentParams::uri() const -> std::string { auto TextDocumentContentParams::uri(std::string uri) -> TextDocumentContentParams& { + repr_->emplace("uri", std::move(uri)); return *this; } TextDocumentContentResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("text")) return false; return true; } auto TextDocumentContentResult::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); @@ -3747,18 +4916,19 @@ auto TextDocumentContentResult::text() const -> std::string { auto TextDocumentContentResult::text(std::string text) -> TextDocumentContentResult& { + repr_->emplace("text", std::move(text)); return *this; } TextDocumentContentRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("schemes")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("schemes")) return false; return true; } auto TextDocumentContentRegistrationOptions::schemes() const -> Vector { - const auto& value = repr_["schemes"]; + auto& value = (*repr_)["schemes"]; assert(value.is_array()); return Vector(value); @@ -3766,9 +4936,9 @@ auto TextDocumentContentRegistrationOptions::schemes() const auto TextDocumentContentRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -3776,22 +4946,29 @@ auto TextDocumentContentRegistrationOptions::id() const auto TextDocumentContentRegistrationOptions::schemes( Vector schemes) -> TextDocumentContentRegistrationOptions& { + lsp_runtime_error( + "TextDocumentContentRegistrationOptions::schemes: not implement yet"); return *this; } auto TextDocumentContentRegistrationOptions::id(std::optional id) -> TextDocumentContentRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } TextDocumentContentRefreshParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto TextDocumentContentRefreshParams::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -3799,17 +4976,18 @@ auto TextDocumentContentRefreshParams::uri() const -> std::string { auto TextDocumentContentRefreshParams::uri(std::string uri) -> TextDocumentContentRefreshParams& { + repr_->emplace("uri", std::move(uri)); return *this; } RegistrationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("registrations")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("registrations")) return false; return true; } auto RegistrationParams::registrations() const -> Vector { - const auto& value = repr_["registrations"]; + auto& value = (*repr_)["registrations"]; assert(value.is_array()); return Vector(value); @@ -3817,17 +4995,18 @@ auto RegistrationParams::registrations() const -> Vector { auto RegistrationParams::registrations(Vector registrations) -> RegistrationParams& { + lsp_runtime_error("RegistrationParams::registrations: not implement yet"); return *this; } UnregistrationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("unregisterations")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("unregisterations")) return false; return true; } auto UnregistrationParams::unregisterations() const -> Vector { - const auto& value = repr_["unregisterations"]; + auto& value = (*repr_)["unregisterations"]; assert(value.is_array()); return Vector(value); @@ -3835,20 +5014,22 @@ auto UnregistrationParams::unregisterations() const -> Vector { auto UnregistrationParams::unregisterations( Vector unregisterations) -> UnregistrationParams& { + lsp_runtime_error( + "UnregistrationParams::unregisterations: not implement yet"); return *this; } InitializeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("processId")) return false; - if (!repr_.contains("rootUri")) return false; - if (!repr_.contains("capabilities")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("processId")) return false; + if (!repr_->contains("rootUri")) return false; + if (!repr_->contains("capabilities")) return false; return true; } auto InitializeParams::processId() const -> std::variant { - const auto& value = repr_["processId"]; + auto& value = (*repr_)["processId"]; std::variant result; @@ -3858,17 +5039,17 @@ auto InitializeParams::processId() const } auto InitializeParams::clientInfo() const -> std::optional { - if (!repr_.contains("clientInfo")) return std::nullopt; + if (!repr_->contains("clientInfo")) return std::nullopt; - const auto& value = repr_["clientInfo"]; + auto& value = (*repr_)["clientInfo"]; return ClientInfo(value); } auto InitializeParams::locale() const -> std::optional { - if (!repr_.contains("locale")) return std::nullopt; + if (!repr_->contains("locale")) return std::nullopt; - const auto& value = repr_["locale"]; + auto& value = (*repr_)["locale"]; assert(value.is_string()); return value.get(); @@ -3876,9 +5057,9 @@ auto InitializeParams::locale() const -> std::optional { auto InitializeParams::rootPath() const -> std::optional< std::variant> { - if (!repr_.contains("rootPath")) return std::nullopt; + if (!repr_->contains("rootPath")) return std::nullopt; - const auto& value = repr_["rootPath"]; + auto& value = (*repr_)["rootPath"]; std::variant result; @@ -3889,7 +5070,7 @@ auto InitializeParams::rootPath() const -> std::optional< auto InitializeParams::rootUri() const -> std::variant { - const auto& value = repr_["rootUri"]; + auto& value = (*repr_)["rootUri"]; std::variant result; @@ -3899,32 +5080,32 @@ auto InitializeParams::rootUri() const } auto InitializeParams::capabilities() const -> ClientCapabilities { - const auto& value = repr_["capabilities"]; + auto& value = (*repr_)["capabilities"]; return ClientCapabilities(value); } auto InitializeParams::initializationOptions() const -> std::optional { - if (!repr_.contains("initializationOptions")) return std::nullopt; + if (!repr_->contains("initializationOptions")) return std::nullopt; - const auto& value = repr_["initializationOptions"]; + auto& value = (*repr_)["initializationOptions"]; assert(value.is_object()); return LSPAny(value); } auto InitializeParams::trace() const -> std::optional { - if (!repr_.contains("trace")) return std::nullopt; + if (!repr_->contains("trace")) return std::nullopt; - const auto& value = repr_["trace"]; + auto& value = (*repr_)["trace"]; lsp_runtime_error("InitializeParams::trace: not implement yet"); } auto InitializeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -3935,9 +5116,9 @@ auto InitializeParams::workDoneToken() const -> std::optional { auto InitializeParams::workspaceFolders() const -> std::optional< std::variant, std::nullptr_t>> { - if (!repr_.contains("workspaceFolders")) return std::nullopt; + if (!repr_->contains("workspaceFolders")) return std::nullopt; - const auto& value = repr_["workspaceFolders"]; + auto& value = (*repr_)["workspaceFolders"]; std::variant, std::nullptr_t> result; @@ -3949,48 +5130,140 @@ auto InitializeParams::workspaceFolders() const -> std::optional< auto InitializeParams::processId( std::variant processId) -> InitializeParams& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int processId) { + repr_->emplace("processId", std::move(processId)); + } + + void operator()(std::nullptr_t processId) { + repr_->emplace("processId", std::move(processId)); + } + } v{repr_}; + + std::visit(v, processId); + return *this; } auto InitializeParams::clientInfo(std::optional clientInfo) -> InitializeParams& { + if (!clientInfo.has_value()) { + repr_->erase("clientInfo"); + return *this; + } + repr_->emplace("clientInfo", clientInfo.value()); return *this; } auto InitializeParams::locale(std::optional locale) -> InitializeParams& { + if (!locale.has_value()) { + repr_->erase("locale"); + return *this; + } + repr_->emplace("locale", std::move(locale.value())); return *this; } auto InitializeParams::rootPath( std::optional> rootPath) -> InitializeParams& { + if (!rootPath.has_value()) { + repr_->erase("rootPath"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string rootPath) { + repr_->emplace("rootPath", std::move(rootPath)); + } + + void operator()(std::nullptr_t rootPath) { + repr_->emplace("rootPath", std::move(rootPath)); + } + } v{repr_}; + + std::visit(v, rootPath.value()); + return *this; } auto InitializeParams::rootUri( std::variant rootUri) -> InitializeParams& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string rootUri) { + repr_->emplace("rootUri", std::move(rootUri)); + } + + void operator()(std::nullptr_t rootUri) { + repr_->emplace("rootUri", std::move(rootUri)); + } + } v{repr_}; + + std::visit(v, rootUri); + return *this; } auto InitializeParams::capabilities(ClientCapabilities capabilities) -> InitializeParams& { + repr_->emplace("capabilities", capabilities); return *this; } auto InitializeParams::initializationOptions( std::optional initializationOptions) -> InitializeParams& { + if (!initializationOptions.has_value()) { + repr_->erase("initializationOptions"); + return *this; + } + lsp_runtime_error( + "InitializeParams::initializationOptions: not implement yet"); return *this; } auto InitializeParams::trace(std::optional trace) -> InitializeParams& { + if (!trace.has_value()) { + repr_->erase("trace"); + return *this; + } + lsp_runtime_error("InitializeParams::trace: not implement yet"); return *this; } auto InitializeParams::workDoneToken(std::optional workDoneToken) -> InitializeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("InitializeParams::workDoneToken: not implement yet"); return *this; } @@ -3998,67 +5271,102 @@ auto InitializeParams::workspaceFolders( std::optional< std::variant, std::nullptr_t>> workspaceFolders) -> InitializeParams& { + if (!workspaceFolders.has_value()) { + repr_->erase("workspaceFolders"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(Vector workspaceFolders) { + lsp_runtime_error( + "InitializeParams::workspaceFolders: not implement yet"); + } + + void operator()(std::nullptr_t workspaceFolders) { + repr_->emplace("workspaceFolders", std::move(workspaceFolders)); + } + } v{repr_}; + + std::visit(v, workspaceFolders.value()); + return *this; } InitializeResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("capabilities")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("capabilities")) return false; return true; } auto InitializeResult::capabilities() const -> ServerCapabilities { - const auto& value = repr_["capabilities"]; + auto& value = (*repr_)["capabilities"]; return ServerCapabilities(value); } auto InitializeResult::serverInfo() const -> std::optional { - if (!repr_.contains("serverInfo")) return std::nullopt; + if (!repr_->contains("serverInfo")) return std::nullopt; - const auto& value = repr_["serverInfo"]; + auto& value = (*repr_)["serverInfo"]; return ServerInfo(value); } auto InitializeResult::capabilities(ServerCapabilities capabilities) -> InitializeResult& { + repr_->emplace("capabilities", capabilities); return *this; } auto InitializeResult::serverInfo(std::optional serverInfo) -> InitializeResult& { + if (!serverInfo.has_value()) { + repr_->erase("serverInfo"); + return *this; + } + repr_->emplace("serverInfo", serverInfo.value()); return *this; } InitializeError::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("retry")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("retry")) return false; return true; } auto InitializeError::retry() const -> bool { - const auto& value = repr_["retry"]; + auto& value = (*repr_)["retry"]; assert(value.is_boolean()); return value.get(); } -auto InitializeError::retry(bool retry) -> InitializeError& { return *this; } +auto InitializeError::retry(bool retry) -> InitializeError& { + repr_->emplace("retry", std::move(retry)); + return *this; +} InitializedParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } DidChangeConfigurationParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("settings")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("settings")) return false; return true; } auto DidChangeConfigurationParams::settings() const -> LSPAny { - const auto& value = repr_["settings"]; + auto& value = (*repr_)["settings"]; assert(value.is_object()); return LSPAny(value); @@ -4066,20 +5374,22 @@ auto DidChangeConfigurationParams::settings() const -> LSPAny { auto DidChangeConfigurationParams::settings(LSPAny settings) -> DidChangeConfigurationParams& { + lsp_runtime_error( + "DidChangeConfigurationParams::settings: not implement yet"); return *this; } DidChangeConfigurationRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DidChangeConfigurationRegistrationOptions::section() const -> std::optional< std::variant>> { - if (!repr_.contains("section")) return std::nullopt; + if (!repr_->contains("section")) return std::nullopt; - const auto& value = repr_["section"]; + auto& value = (*repr_)["section"]; std::variant> result; @@ -4092,52 +5402,81 @@ auto DidChangeConfigurationRegistrationOptions::section( std::optional< std::variant>> section) -> DidChangeConfigurationRegistrationOptions& { + if (!section.has_value()) { + repr_->erase("section"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string section) { + repr_->emplace("section", std::move(section)); + } + + void operator()(Vector section) { + lsp_runtime_error( + "DidChangeConfigurationRegistrationOptions::section: not implement " + "yet"); + } + } v{repr_}; + + std::visit(v, section.value()); + return *this; } ShowMessageParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("type")) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("type")) return false; + if (!repr_->contains("message")) return false; return true; } auto ShowMessageParams::type() const -> MessageType { - const auto& value = repr_["type"]; + auto& value = (*repr_)["type"]; return MessageType(value); } auto ShowMessageParams::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto ShowMessageParams::type(MessageType type) -> ShowMessageParams& { + repr_->emplace("type", static_cast(type)); return *this; } auto ShowMessageParams::message(std::string message) -> ShowMessageParams& { + repr_->emplace("message", std::move(message)); return *this; } ShowMessageRequestParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("type")) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("type")) return false; + if (!repr_->contains("message")) return false; return true; } auto ShowMessageRequestParams::type() const -> MessageType { - const auto& value = repr_["type"]; + auto& value = (*repr_)["type"]; return MessageType(value); } auto ShowMessageRequestParams::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); @@ -4145,9 +5484,9 @@ auto ShowMessageRequestParams::message() const -> std::string { auto ShowMessageRequestParams::actions() const -> std::optional> { - if (!repr_.contains("actions")) return std::nullopt; + if (!repr_->contains("actions")) return std::nullopt; - const auto& value = repr_["actions"]; + auto& value = (*repr_)["actions"]; assert(value.is_array()); return Vector(value); @@ -4155,99 +5494,110 @@ auto ShowMessageRequestParams::actions() const auto ShowMessageRequestParams::type(MessageType type) -> ShowMessageRequestParams& { + repr_->emplace("type", static_cast(type)); return *this; } auto ShowMessageRequestParams::message(std::string message) -> ShowMessageRequestParams& { + repr_->emplace("message", std::move(message)); return *this; } auto ShowMessageRequestParams::actions( std::optional> actions) -> ShowMessageRequestParams& { + if (!actions.has_value()) { + repr_->erase("actions"); + return *this; + } + lsp_runtime_error("ShowMessageRequestParams::actions: not implement yet"); return *this; } MessageActionItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("title")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("title")) return false; return true; } auto MessageActionItem::title() const -> std::string { - const auto& value = repr_["title"]; + auto& value = (*repr_)["title"]; assert(value.is_string()); return value.get(); } auto MessageActionItem::title(std::string title) -> MessageActionItem& { + repr_->emplace("title", std::move(title)); return *this; } LogMessageParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("type")) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("type")) return false; + if (!repr_->contains("message")) return false; return true; } auto LogMessageParams::type() const -> MessageType { - const auto& value = repr_["type"]; + auto& value = (*repr_)["type"]; return MessageType(value); } auto LogMessageParams::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto LogMessageParams::type(MessageType type) -> LogMessageParams& { + repr_->emplace("type", static_cast(type)); return *this; } auto LogMessageParams::message(std::string message) -> LogMessageParams& { + repr_->emplace("message", std::move(message)); return *this; } DidOpenTextDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DidOpenTextDocumentParams::textDocument() const -> TextDocumentItem { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentItem(value); } auto DidOpenTextDocumentParams::textDocument(TextDocumentItem textDocument) -> DidOpenTextDocumentParams& { + repr_->emplace("textDocument", textDocument); return *this; } DidChangeTextDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("contentChanges")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("contentChanges")) return false; return true; } auto DidChangeTextDocumentParams::textDocument() const -> VersionedTextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return VersionedTextDocumentIdentifier(value); } auto DidChangeTextDocumentParams::contentChanges() const -> Vector { - const auto& value = repr_["contentChanges"]; + auto& value = (*repr_)["contentChanges"]; assert(value.is_array()); return Vector(value); @@ -4256,32 +5606,35 @@ auto DidChangeTextDocumentParams::contentChanges() const auto DidChangeTextDocumentParams::textDocument( VersionedTextDocumentIdentifier textDocument) -> DidChangeTextDocumentParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DidChangeTextDocumentParams::contentChanges( Vector contentChanges) -> DidChangeTextDocumentParams& { + lsp_runtime_error( + "DidChangeTextDocumentParams::contentChanges: not implement yet"); return *this; } TextDocumentChangeRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("syncKind")) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("syncKind")) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto TextDocumentChangeRegistrationOptions::syncKind() const -> TextDocumentSyncKind { - const auto& value = repr_["syncKind"]; + auto& value = (*repr_)["syncKind"]; return TextDocumentSyncKind(value); } auto TextDocumentChangeRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -4292,49 +5645,73 @@ auto TextDocumentChangeRegistrationOptions::documentSelector() const auto TextDocumentChangeRegistrationOptions::syncKind( TextDocumentSyncKind syncKind) -> TextDocumentChangeRegistrationOptions& { + repr_->emplace("syncKind", static_cast(syncKind)); return *this; } auto TextDocumentChangeRegistrationOptions::documentSelector( std::variant documentSelector) -> TextDocumentChangeRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "TextDocumentChangeRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } DidCloseTextDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DidCloseTextDocumentParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DidCloseTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> DidCloseTextDocumentParams& { + repr_->emplace("textDocument", textDocument); return *this; } DidSaveTextDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DidSaveTextDocumentParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DidSaveTextDocumentParams::text() const -> std::optional { - if (!repr_.contains("text")) return std::nullopt; + if (!repr_->contains("text")) return std::nullopt; - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); @@ -4342,23 +5719,29 @@ auto DidSaveTextDocumentParams::text() const -> std::optional { auto DidSaveTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> DidSaveTextDocumentParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DidSaveTextDocumentParams::text(std::optional text) -> DidSaveTextDocumentParams& { + if (!text.has_value()) { + repr_->erase("text"); + return *this; + } + repr_->emplace("text", std::move(text.value())); return *this; } TextDocumentSaveRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto TextDocumentSaveRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -4369,9 +5752,9 @@ auto TextDocumentSaveRegistrationOptions::documentSelector() const auto TextDocumentSaveRegistrationOptions::includeText() const -> std::optional { - if (!repr_.contains("includeText")) return std::nullopt; + if (!repr_->contains("includeText")) return std::nullopt; - const auto& value = repr_["includeText"]; + auto& value = (*repr_)["includeText"]; assert(value.is_boolean()); return value.get(); @@ -4380,76 +5763,111 @@ auto TextDocumentSaveRegistrationOptions::includeText() const auto TextDocumentSaveRegistrationOptions::documentSelector( std::variant documentSelector) -> TextDocumentSaveRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "TextDocumentSaveRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto TextDocumentSaveRegistrationOptions::includeText( std::optional includeText) -> TextDocumentSaveRegistrationOptions& { + if (!includeText.has_value()) { + repr_->erase("includeText"); + return *this; + } + repr_->emplace("includeText", std::move(includeText.value())); return *this; } WillSaveTextDocumentParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("reason")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("reason")) return false; return true; } auto WillSaveTextDocumentParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto WillSaveTextDocumentParams::reason() const -> TextDocumentSaveReason { - const auto& value = repr_["reason"]; + auto& value = (*repr_)["reason"]; return TextDocumentSaveReason(value); } auto WillSaveTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> WillSaveTextDocumentParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto WillSaveTextDocumentParams::reason(TextDocumentSaveReason reason) -> WillSaveTextDocumentParams& { + repr_->emplace("reason", static_cast(reason)); return *this; } TextEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("newText")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("newText")) return false; return true; } auto TextEdit::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto TextEdit::newText() const -> std::string { - const auto& value = repr_["newText"]; + auto& value = (*repr_)["newText"]; assert(value.is_string()); return value.get(); } -auto TextEdit::range(Range range) -> TextEdit& { return *this; } +auto TextEdit::range(Range range) -> TextEdit& { + repr_->emplace("range", range); + return *this; +} -auto TextEdit::newText(std::string newText) -> TextEdit& { return *this; } +auto TextEdit::newText(std::string newText) -> TextEdit& { + repr_->emplace("newText", std::move(newText)); + return *this; +} DidChangeWatchedFilesParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("changes")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("changes")) return false; return true; } auto DidChangeWatchedFilesParams::changes() const -> Vector { - const auto& value = repr_["changes"]; + auto& value = (*repr_)["changes"]; assert(value.is_array()); return Vector(value); @@ -4457,18 +5875,19 @@ auto DidChangeWatchedFilesParams::changes() const -> Vector { auto DidChangeWatchedFilesParams::changes(Vector changes) -> DidChangeWatchedFilesParams& { + lsp_runtime_error("DidChangeWatchedFilesParams::changes: not implement yet"); return *this; } DidChangeWatchedFilesRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("watchers")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("watchers")) return false; return true; } auto DidChangeWatchedFilesRegistrationOptions::watchers() const -> Vector { - const auto& value = repr_["watchers"]; + auto& value = (*repr_)["watchers"]; assert(value.is_array()); return Vector(value); @@ -4477,34 +5896,36 @@ auto DidChangeWatchedFilesRegistrationOptions::watchers() const auto DidChangeWatchedFilesRegistrationOptions::watchers( Vector watchers) -> DidChangeWatchedFilesRegistrationOptions& { + lsp_runtime_error( + "DidChangeWatchedFilesRegistrationOptions::watchers: not implement yet"); return *this; } PublishDiagnosticsParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("diagnostics")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("diagnostics")) return false; return true; } auto PublishDiagnosticsParams::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto PublishDiagnosticsParams::version() const -> std::optional { - if (!repr_.contains("version")) return std::nullopt; + if (!repr_->contains("version")) return std::nullopt; - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_number_integer()); return value.get(); } auto PublishDiagnosticsParams::diagnostics() const -> Vector { - const auto& value = repr_["diagnostics"]; + auto& value = (*repr_)["diagnostics"]; assert(value.is_array()); return Vector(value); @@ -4512,50 +5933,57 @@ auto PublishDiagnosticsParams::diagnostics() const -> Vector { auto PublishDiagnosticsParams::uri(std::string uri) -> PublishDiagnosticsParams& { + repr_->emplace("uri", std::move(uri)); return *this; } auto PublishDiagnosticsParams::version(std::optional version) -> PublishDiagnosticsParams& { + if (!version.has_value()) { + repr_->erase("version"); + return *this; + } + repr_->emplace("version", std::move(version.value())); return *this; } auto PublishDiagnosticsParams::diagnostics(Vector diagnostics) -> PublishDiagnosticsParams& { + lsp_runtime_error("PublishDiagnosticsParams::diagnostics: not implement yet"); return *this; } CompletionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto CompletionParams::context() const -> std::optional { - if (!repr_.contains("context")) return std::nullopt; + if (!repr_->contains("context")) return std::nullopt; - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return CompletionContext(value); } auto CompletionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto CompletionParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto CompletionParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -4566,9 +5994,9 @@ auto CompletionParams::workDoneToken() const -> std::optional { auto CompletionParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -4579,36 +6007,53 @@ auto CompletionParams::partialResultToken() const auto CompletionParams::context(std::optional context) -> CompletionParams& { + if (!context.has_value()) { + repr_->erase("context"); + return *this; + } + repr_->emplace("context", context.value()); return *this; } auto CompletionParams::textDocument(TextDocumentIdentifier textDocument) -> CompletionParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto CompletionParams::position(Position position) -> CompletionParams& { + repr_->emplace("position", position); return *this; } auto CompletionParams::workDoneToken(std::optional workDoneToken) -> CompletionParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("CompletionParams::workDoneToken: not implement yet"); return *this; } auto CompletionParams::partialResultToken( std::optional partialResultToken) -> CompletionParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("CompletionParams::partialResultToken: not implement yet"); return *this; } CompletionItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("label")) return false; return true; } auto CompletionItem::label() const -> std::string { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); @@ -4616,34 +6061,34 @@ auto CompletionItem::label() const -> std::string { auto CompletionItem::labelDetails() const -> std::optional { - if (!repr_.contains("labelDetails")) return std::nullopt; + if (!repr_->contains("labelDetails")) return std::nullopt; - const auto& value = repr_["labelDetails"]; + auto& value = (*repr_)["labelDetails"]; return CompletionItemLabelDetails(value); } auto CompletionItem::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return CompletionItemKind(value); } auto CompletionItem::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto CompletionItem::detail() const -> std::optional { - if (!repr_.contains("detail")) return std::nullopt; + if (!repr_->contains("detail")) return std::nullopt; - const auto& value = repr_["detail"]; + auto& value = (*repr_)["detail"]; assert(value.is_string()); return value.get(); @@ -4651,9 +6096,9 @@ auto CompletionItem::detail() const -> std::optional { auto CompletionItem::documentation() const -> std::optional> { - if (!repr_.contains("documentation")) return std::nullopt; + if (!repr_->contains("documentation")) return std::nullopt; - const auto& value = repr_["documentation"]; + auto& value = (*repr_)["documentation"]; std::variant result; @@ -4663,45 +6108,45 @@ auto CompletionItem::documentation() const } auto CompletionItem::deprecated() const -> std::optional { - if (!repr_.contains("deprecated")) return std::nullopt; + if (!repr_->contains("deprecated")) return std::nullopt; - const auto& value = repr_["deprecated"]; + auto& value = (*repr_)["deprecated"]; assert(value.is_boolean()); return value.get(); } auto CompletionItem::preselect() const -> std::optional { - if (!repr_.contains("preselect")) return std::nullopt; + if (!repr_->contains("preselect")) return std::nullopt; - const auto& value = repr_["preselect"]; + auto& value = (*repr_)["preselect"]; assert(value.is_boolean()); return value.get(); } auto CompletionItem::sortText() const -> std::optional { - if (!repr_.contains("sortText")) return std::nullopt; + if (!repr_->contains("sortText")) return std::nullopt; - const auto& value = repr_["sortText"]; + auto& value = (*repr_)["sortText"]; assert(value.is_string()); return value.get(); } auto CompletionItem::filterText() const -> std::optional { - if (!repr_.contains("filterText")) return std::nullopt; + if (!repr_->contains("filterText")) return std::nullopt; - const auto& value = repr_["filterText"]; + auto& value = (*repr_)["filterText"]; assert(value.is_string()); return value.get(); } auto CompletionItem::insertText() const -> std::optional { - if (!repr_.contains("insertText")) return std::nullopt; + if (!repr_->contains("insertText")) return std::nullopt; - const auto& value = repr_["insertText"]; + auto& value = (*repr_)["insertText"]; assert(value.is_string()); return value.get(); @@ -4709,26 +6154,26 @@ auto CompletionItem::insertText() const -> std::optional { auto CompletionItem::insertTextFormat() const -> std::optional { - if (!repr_.contains("insertTextFormat")) return std::nullopt; + if (!repr_->contains("insertTextFormat")) return std::nullopt; - const auto& value = repr_["insertTextFormat"]; + auto& value = (*repr_)["insertTextFormat"]; return InsertTextFormat(value); } auto CompletionItem::insertTextMode() const -> std::optional { - if (!repr_.contains("insertTextMode")) return std::nullopt; + if (!repr_->contains("insertTextMode")) return std::nullopt; - const auto& value = repr_["insertTextMode"]; + auto& value = (*repr_)["insertTextMode"]; return InsertTextMode(value); } auto CompletionItem::textEdit() const -> std::optional< std::variant> { - if (!repr_.contains("textEdit")) return std::nullopt; + if (!repr_->contains("textEdit")) return std::nullopt; - const auto& value = repr_["textEdit"]; + auto& value = (*repr_)["textEdit"]; std::variant result; @@ -4738,9 +6183,9 @@ auto CompletionItem::textEdit() const -> std::optional< } auto CompletionItem::textEditText() const -> std::optional { - if (!repr_.contains("textEditText")) return std::nullopt; + if (!repr_->contains("textEditText")) return std::nullopt; - const auto& value = repr_["textEditText"]; + auto& value = (*repr_)["textEditText"]; assert(value.is_string()); return value.get(); @@ -4748,9 +6193,9 @@ auto CompletionItem::textEditText() const -> std::optional { auto CompletionItem::additionalTextEdits() const -> std::optional> { - if (!repr_.contains("additionalTextEdits")) return std::nullopt; + if (!repr_->contains("additionalTextEdits")) return std::nullopt; - const auto& value = repr_["additionalTextEdits"]; + auto& value = (*repr_)["additionalTextEdits"]; assert(value.is_array()); return Vector(value); @@ -4758,135 +6203,265 @@ auto CompletionItem::additionalTextEdits() const auto CompletionItem::commitCharacters() const -> std::optional> { - if (!repr_.contains("commitCharacters")) return std::nullopt; + if (!repr_->contains("commitCharacters")) return std::nullopt; - const auto& value = repr_["commitCharacters"]; + auto& value = (*repr_)["commitCharacters"]; assert(value.is_array()); return Vector(value); } auto CompletionItem::command() const -> std::optional { - if (!repr_.contains("command")) return std::nullopt; + if (!repr_->contains("command")) return std::nullopt; - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } auto CompletionItem::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } auto CompletionItem::label(std::string label) -> CompletionItem& { + repr_->emplace("label", std::move(label)); return *this; } auto CompletionItem::labelDetails( std::optional labelDetails) -> CompletionItem& { + if (!labelDetails.has_value()) { + repr_->erase("labelDetails"); + return *this; + } + repr_->emplace("labelDetails", labelDetails.value()); return *this; } auto CompletionItem::kind(std::optional kind) -> CompletionItem& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + repr_->emplace("kind", static_cast(kind.value())); return *this; } auto CompletionItem::tags(std::optional> tags) -> CompletionItem& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("CompletionItem::tags: not implement yet"); return *this; } auto CompletionItem::detail(std::optional detail) -> CompletionItem& { + if (!detail.has_value()) { + repr_->erase("detail"); + return *this; + } + repr_->emplace("detail", std::move(detail.value())); return *this; } auto CompletionItem::documentation( std::optional> documentation) -> CompletionItem& { - return *this; -} + if (!documentation.has_value()) { + repr_->erase("documentation"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string documentation) { + repr_->emplace("documentation", std::move(documentation)); + } + + void operator()(MarkupContent documentation) { + repr_->emplace("documentation", documentation); + } + } v{repr_}; + + std::visit(v, documentation.value()); + + return *this; +} auto CompletionItem::deprecated(std::optional deprecated) -> CompletionItem& { + if (!deprecated.has_value()) { + repr_->erase("deprecated"); + return *this; + } + repr_->emplace("deprecated", std::move(deprecated.value())); return *this; } auto CompletionItem::preselect(std::optional preselect) -> CompletionItem& { + if (!preselect.has_value()) { + repr_->erase("preselect"); + return *this; + } + repr_->emplace("preselect", std::move(preselect.value())); return *this; } auto CompletionItem::sortText(std::optional sortText) -> CompletionItem& { + if (!sortText.has_value()) { + repr_->erase("sortText"); + return *this; + } + repr_->emplace("sortText", std::move(sortText.value())); return *this; } auto CompletionItem::filterText(std::optional filterText) -> CompletionItem& { + if (!filterText.has_value()) { + repr_->erase("filterText"); + return *this; + } + repr_->emplace("filterText", std::move(filterText.value())); return *this; } auto CompletionItem::insertText(std::optional insertText) -> CompletionItem& { + if (!insertText.has_value()) { + repr_->erase("insertText"); + return *this; + } + repr_->emplace("insertText", std::move(insertText.value())); return *this; } auto CompletionItem::insertTextFormat( std::optional insertTextFormat) -> CompletionItem& { + if (!insertTextFormat.has_value()) { + repr_->erase("insertTextFormat"); + return *this; + } + repr_->emplace("insertTextFormat", + static_cast(insertTextFormat.value())); return *this; } auto CompletionItem::insertTextMode( std::optional insertTextMode) -> CompletionItem& { + if (!insertTextMode.has_value()) { + repr_->erase("insertTextMode"); + return *this; + } + repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); return *this; } auto CompletionItem::textEdit( std::optional> textEdit) -> CompletionItem& { + if (!textEdit.has_value()) { + repr_->erase("textEdit"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(TextEdit textEdit) { repr_->emplace("textEdit", textEdit); } + + void operator()(InsertReplaceEdit textEdit) { + repr_->emplace("textEdit", textEdit); + } + } v{repr_}; + + std::visit(v, textEdit.value()); + return *this; } auto CompletionItem::textEditText(std::optional textEditText) -> CompletionItem& { + if (!textEditText.has_value()) { + repr_->erase("textEditText"); + return *this; + } + repr_->emplace("textEditText", std::move(textEditText.value())); return *this; } auto CompletionItem::additionalTextEdits( std::optional> additionalTextEdits) -> CompletionItem& { + if (!additionalTextEdits.has_value()) { + repr_->erase("additionalTextEdits"); + return *this; + } + lsp_runtime_error("CompletionItem::additionalTextEdits: not implement yet"); return *this; } auto CompletionItem::commitCharacters( std::optional> commitCharacters) -> CompletionItem& { + if (!commitCharacters.has_value()) { + repr_->erase("commitCharacters"); + return *this; + } + lsp_runtime_error("CompletionItem::commitCharacters: not implement yet"); return *this; } auto CompletionItem::command(std::optional command) -> CompletionItem& { + if (!command.has_value()) { + repr_->erase("command"); + return *this; + } + repr_->emplace("command", command.value()); return *this; } auto CompletionItem::data(std::optional data) -> CompletionItem& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("CompletionItem::data: not implement yet"); return *this; } CompletionList::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("isIncomplete")) return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("isIncomplete")) return false; + if (!repr_->contains("items")) return false; return true; } auto CompletionList::isIncomplete() const -> bool { - const auto& value = repr_["isIncomplete"]; + auto& value = (*repr_)["isIncomplete"]; assert(value.is_boolean()); return value.get(); @@ -4894,56 +6469,68 @@ auto CompletionList::isIncomplete() const -> bool { auto CompletionList::itemDefaults() const -> std::optional { - if (!repr_.contains("itemDefaults")) return std::nullopt; + if (!repr_->contains("itemDefaults")) return std::nullopt; - const auto& value = repr_["itemDefaults"]; + auto& value = (*repr_)["itemDefaults"]; return CompletionItemDefaults(value); } auto CompletionList::applyKind() const -> std::optional { - if (!repr_.contains("applyKind")) return std::nullopt; + if (!repr_->contains("applyKind")) return std::nullopt; - const auto& value = repr_["applyKind"]; + auto& value = (*repr_)["applyKind"]; return CompletionItemApplyKinds(value); } auto CompletionList::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); } auto CompletionList::isIncomplete(bool isIncomplete) -> CompletionList& { + repr_->emplace("isIncomplete", std::move(isIncomplete)); return *this; } auto CompletionList::itemDefaults( std::optional itemDefaults) -> CompletionList& { + if (!itemDefaults.has_value()) { + repr_->erase("itemDefaults"); + return *this; + } + repr_->emplace("itemDefaults", itemDefaults.value()); return *this; } auto CompletionList::applyKind( std::optional applyKind) -> CompletionList& { + if (!applyKind.has_value()) { + repr_->erase("applyKind"); + return *this; + } + repr_->emplace("applyKind", applyKind.value()); return *this; } auto CompletionList::items(Vector items) -> CompletionList& { + lsp_runtime_error("CompletionList::items: not implement yet"); return *this; } CompletionRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto CompletionRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -4954,9 +6541,9 @@ auto CompletionRegistrationOptions::documentSelector() const auto CompletionRegistrationOptions::triggerCharacters() const -> std::optional> { - if (!repr_.contains("triggerCharacters")) return std::nullopt; + if (!repr_->contains("triggerCharacters")) return std::nullopt; - const auto& value = repr_["triggerCharacters"]; + auto& value = (*repr_)["triggerCharacters"]; assert(value.is_array()); return Vector(value); @@ -4964,9 +6551,9 @@ auto CompletionRegistrationOptions::triggerCharacters() const auto CompletionRegistrationOptions::allCommitCharacters() const -> std::optional> { - if (!repr_.contains("allCommitCharacters")) return std::nullopt; + if (!repr_->contains("allCommitCharacters")) return std::nullopt; - const auto& value = repr_["allCommitCharacters"]; + auto& value = (*repr_)["allCommitCharacters"]; assert(value.is_array()); return Vector(value); @@ -4974,9 +6561,9 @@ auto CompletionRegistrationOptions::allCommitCharacters() const auto CompletionRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -4984,18 +6571,18 @@ auto CompletionRegistrationOptions::resolveProvider() const auto CompletionRegistrationOptions::completionItem() const -> std::optional { - if (!repr_.contains("completionItem")) return std::nullopt; + if (!repr_->contains("completionItem")) return std::nullopt; - const auto& value = repr_["completionItem"]; + auto& value = (*repr_)["completionItem"]; return ServerCompletionItemOptions(value); } auto CompletionRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5004,60 +6591,108 @@ auto CompletionRegistrationOptions::workDoneProgress() const auto CompletionRegistrationOptions::documentSelector( std::variant documentSelector) -> CompletionRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "CompletionRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto CompletionRegistrationOptions::triggerCharacters( std::optional> triggerCharacters) -> CompletionRegistrationOptions& { + if (!triggerCharacters.has_value()) { + repr_->erase("triggerCharacters"); + return *this; + } + lsp_runtime_error( + "CompletionRegistrationOptions::triggerCharacters: not implement yet"); return *this; } auto CompletionRegistrationOptions::allCommitCharacters( std::optional> allCommitCharacters) -> CompletionRegistrationOptions& { + if (!allCommitCharacters.has_value()) { + repr_->erase("allCommitCharacters"); + return *this; + } + lsp_runtime_error( + "CompletionRegistrationOptions::allCommitCharacters: not implement yet"); return *this; } auto CompletionRegistrationOptions::resolveProvider( std::optional resolveProvider) -> CompletionRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CompletionRegistrationOptions::completionItem( std::optional completionItem) -> CompletionRegistrationOptions& { + if (!completionItem.has_value()) { + repr_->erase("completionItem"); + return *this; + } + repr_->emplace("completionItem", completionItem.value()); return *this; } auto CompletionRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> CompletionRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } HoverParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto HoverParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto HoverParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto HoverParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5068,26 +6703,35 @@ auto HoverParams::workDoneToken() const -> std::optional { auto HoverParams::textDocument(TextDocumentIdentifier textDocument) -> HoverParams& { + repr_->emplace("textDocument", textDocument); return *this; } -auto HoverParams::position(Position position) -> HoverParams& { return *this; } +auto HoverParams::position(Position position) -> HoverParams& { + repr_->emplace("position", position); + return *this; +} auto HoverParams::workDoneToken(std::optional workDoneToken) -> HoverParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("HoverParams::workDoneToken: not implement yet"); return *this; } Hover::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("contents")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("contents")) return false; return true; } auto Hover::contents() const -> std::variant> { - const auto& value = repr_["contents"]; + auto& value = (*repr_)["contents"]; std::variant> @@ -5099,9 +6743,9 @@ auto Hover::contents() const } auto Hover::range() const -> std::optional { - if (!repr_.contains("range")) return std::nullopt; + if (!repr_->contains("range")) return std::nullopt; - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } @@ -5109,20 +6753,51 @@ auto Hover::range() const -> std::optional { auto Hover::contents(std::variant> contents) -> Hover& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(MarkupContent contents) { + repr_->emplace("contents", contents); + } + + void operator()(MarkedString contents) { + lsp_runtime_error("Hover::contents: not implement yet"); + } + + void operator()(Vector contents) { + lsp_runtime_error("Hover::contents: not implement yet"); + } + } v{repr_}; + + std::visit(v, contents); + return *this; } -auto Hover::range(std::optional range) -> Hover& { return *this; } +auto Hover::range(std::optional range) -> Hover& { + if (!range.has_value()) { + repr_->erase("range"); + return *this; + } + repr_->emplace("range", range.value()); + return *this; +} HoverRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto HoverRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5132,9 +6807,9 @@ auto HoverRegistrationOptions::documentSelector() const } auto HoverRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5143,47 +6818,73 @@ auto HoverRegistrationOptions::workDoneProgress() const -> std::optional { auto HoverRegistrationOptions::documentSelector( std::variant documentSelector) -> HoverRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "HoverRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto HoverRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> HoverRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } SignatureHelpParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto SignatureHelpParams::context() const -> std::optional { - if (!repr_.contains("context")) return std::nullopt; + if (!repr_->contains("context")) return std::nullopt; - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return SignatureHelpContext(value); } auto SignatureHelpParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto SignatureHelpParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto SignatureHelpParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5194,40 +6895,52 @@ auto SignatureHelpParams::workDoneToken() const auto SignatureHelpParams::context(std::optional context) -> SignatureHelpParams& { + if (!context.has_value()) { + repr_->erase("context"); + return *this; + } + repr_->emplace("context", context.value()); return *this; } auto SignatureHelpParams::textDocument(TextDocumentIdentifier textDocument) -> SignatureHelpParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto SignatureHelpParams::position(Position position) -> SignatureHelpParams& { + repr_->emplace("position", position); return *this; } auto SignatureHelpParams::workDoneToken( std::optional workDoneToken) -> SignatureHelpParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("SignatureHelpParams::workDoneToken: not implement yet"); return *this; } SignatureHelp::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("signatures")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("signatures")) return false; return true; } auto SignatureHelp::signatures() const -> Vector { - const auto& value = repr_["signatures"]; + auto& value = (*repr_)["signatures"]; assert(value.is_array()); return Vector(value); } auto SignatureHelp::activeSignature() const -> std::optional { - if (!repr_.contains("activeSignature")) return std::nullopt; + if (!repr_->contains("activeSignature")) return std::nullopt; - const auto& value = repr_["activeSignature"]; + auto& value = (*repr_)["activeSignature"]; assert(value.is_number_integer()); return value.get(); @@ -5235,9 +6948,9 @@ auto SignatureHelp::activeSignature() const -> std::optional { auto SignatureHelp::activeParameter() const -> std::optional> { - if (!repr_.contains("activeParameter")) return std::nullopt; + if (!repr_->contains("activeParameter")) return std::nullopt; - const auto& value = repr_["activeParameter"]; + auto& value = (*repr_)["activeParameter"]; std::variant result; @@ -5248,29 +6961,60 @@ auto SignatureHelp::activeParameter() const auto SignatureHelp::signatures(Vector signatures) -> SignatureHelp& { + lsp_runtime_error("SignatureHelp::signatures: not implement yet"); return *this; } auto SignatureHelp::activeSignature(std::optional activeSignature) -> SignatureHelp& { + if (!activeSignature.has_value()) { + repr_->erase("activeSignature"); + return *this; + } + repr_->emplace("activeSignature", std::move(activeSignature.value())); return *this; } auto SignatureHelp::activeParameter( std::optional> activeParameter) -> SignatureHelp& { + if (!activeParameter.has_value()) { + repr_->erase("activeParameter"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(long activeParameter) { + repr_->emplace("activeParameter", std::move(activeParameter)); + } + + void operator()(std::nullptr_t activeParameter) { + repr_->emplace("activeParameter", std::move(activeParameter)); + } + } v{repr_}; + + std::visit(v, activeParameter.value()); + return *this; } SignatureHelpRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto SignatureHelpRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5281,9 +7025,9 @@ auto SignatureHelpRegistrationOptions::documentSelector() const auto SignatureHelpRegistrationOptions::triggerCharacters() const -> std::optional> { - if (!repr_.contains("triggerCharacters")) return std::nullopt; + if (!repr_->contains("triggerCharacters")) return std::nullopt; - const auto& value = repr_["triggerCharacters"]; + auto& value = (*repr_)["triggerCharacters"]; assert(value.is_array()); return Vector(value); @@ -5291,9 +7035,9 @@ auto SignatureHelpRegistrationOptions::triggerCharacters() const auto SignatureHelpRegistrationOptions::retriggerCharacters() const -> std::optional> { - if (!repr_.contains("retriggerCharacters")) return std::nullopt; + if (!repr_->contains("retriggerCharacters")) return std::nullopt; - const auto& value = repr_["retriggerCharacters"]; + auto& value = (*repr_)["retriggerCharacters"]; assert(value.is_array()); return Vector(value); @@ -5301,9 +7045,9 @@ auto SignatureHelpRegistrationOptions::retriggerCharacters() const auto SignatureHelpRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5312,49 +7056,89 @@ auto SignatureHelpRegistrationOptions::workDoneProgress() const auto SignatureHelpRegistrationOptions::documentSelector( std::variant documentSelector) -> SignatureHelpRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "SignatureHelpRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto SignatureHelpRegistrationOptions::triggerCharacters( std::optional> triggerCharacters) -> SignatureHelpRegistrationOptions& { + if (!triggerCharacters.has_value()) { + repr_->erase("triggerCharacters"); + return *this; + } + lsp_runtime_error( + "SignatureHelpRegistrationOptions::triggerCharacters: not implement yet"); return *this; } auto SignatureHelpRegistrationOptions::retriggerCharacters( std::optional> retriggerCharacters) -> SignatureHelpRegistrationOptions& { + if (!retriggerCharacters.has_value()) { + repr_->erase("retriggerCharacters"); + return *this; + } + lsp_runtime_error( + "SignatureHelpRegistrationOptions::retriggerCharacters: not implement " + "yet"); return *this; } auto SignatureHelpRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> SignatureHelpRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DefinitionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto DefinitionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DefinitionParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto DefinitionParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5365,9 +7149,9 @@ auto DefinitionParams::workDoneToken() const -> std::optional { auto DefinitionParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -5378,32 +7162,44 @@ auto DefinitionParams::partialResultToken() const auto DefinitionParams::textDocument(TextDocumentIdentifier textDocument) -> DefinitionParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DefinitionParams::position(Position position) -> DefinitionParams& { + repr_->emplace("position", position); return *this; } auto DefinitionParams::workDoneToken(std::optional workDoneToken) -> DefinitionParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("DefinitionParams::workDoneToken: not implement yet"); return *this; } auto DefinitionParams::partialResultToken( std::optional partialResultToken) -> DefinitionParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("DefinitionParams::partialResultToken: not implement yet"); return *this; } DefinitionRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DefinitionRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5414,9 +7210,9 @@ auto DefinitionRegistrationOptions::documentSelector() const auto DefinitionRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5425,44 +7221,70 @@ auto DefinitionRegistrationOptions::workDoneProgress() const auto DefinitionRegistrationOptions::documentSelector( std::variant documentSelector) -> DefinitionRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DefinitionRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DefinitionRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DefinitionRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } ReferenceParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("context")) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("context")) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto ReferenceParams::context() const -> ReferenceContext { - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return ReferenceContext(value); } auto ReferenceParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto ReferenceParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto ReferenceParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5473,9 +7295,9 @@ auto ReferenceParams::workDoneToken() const -> std::optional { auto ReferenceParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -5485,37 +7307,50 @@ auto ReferenceParams::partialResultToken() const } auto ReferenceParams::context(ReferenceContext context) -> ReferenceParams& { + repr_->emplace("context", context); return *this; } auto ReferenceParams::textDocument(TextDocumentIdentifier textDocument) -> ReferenceParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto ReferenceParams::position(Position position) -> ReferenceParams& { + repr_->emplace("position", position); return *this; } auto ReferenceParams::workDoneToken(std::optional workDoneToken) -> ReferenceParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("ReferenceParams::workDoneToken: not implement yet"); return *this; } auto ReferenceParams::partialResultToken( std::optional partialResultToken) -> ReferenceParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("ReferenceParams::partialResultToken: not implement yet"); return *this; } ReferenceRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto ReferenceRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5526,9 +7361,9 @@ auto ReferenceRegistrationOptions::documentSelector() const auto ReferenceRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5537,38 +7372,64 @@ auto ReferenceRegistrationOptions::workDoneProgress() const auto ReferenceRegistrationOptions::documentSelector( std::variant documentSelector) -> ReferenceRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "ReferenceRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto ReferenceRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> ReferenceRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentHighlightParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto DocumentHighlightParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentHighlightParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto DocumentHighlightParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5579,9 +7440,9 @@ auto DocumentHighlightParams::workDoneToken() const auto DocumentHighlightParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -5592,63 +7453,83 @@ auto DocumentHighlightParams::partialResultToken() const auto DocumentHighlightParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentHighlightParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentHighlightParams::position(Position position) -> DocumentHighlightParams& { + repr_->emplace("position", position); return *this; } auto DocumentHighlightParams::workDoneToken( std::optional workDoneToken) -> DocumentHighlightParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "DocumentHighlightParams::workDoneToken: not implement yet"); return *this; } auto DocumentHighlightParams::partialResultToken( std::optional partialResultToken) -> DocumentHighlightParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "DocumentHighlightParams::partialResultToken: not implement yet"); return *this; } DocumentHighlight::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; return true; } auto DocumentHighlight::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto DocumentHighlight::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return DocumentHighlightKind(value); } auto DocumentHighlight::range(Range range) -> DocumentHighlight& { + repr_->emplace("range", range); return *this; } auto DocumentHighlight::kind(std::optional kind) -> DocumentHighlight& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + repr_->emplace("kind", static_cast(kind.value())); return *this; } DocumentHighlightRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentHighlightRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5659,9 +7540,9 @@ auto DocumentHighlightRegistrationOptions::documentSelector() const auto DocumentHighlightRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5670,32 +7551,59 @@ auto DocumentHighlightRegistrationOptions::workDoneProgress() const auto DocumentHighlightRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentHighlightRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentHighlightRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentHighlightRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentHighlightRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentSymbolParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DocumentSymbolParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentSymbolParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -5706,9 +7614,9 @@ auto DocumentSymbolParams::workDoneToken() const auto DocumentSymbolParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -5719,68 +7627,80 @@ auto DocumentSymbolParams::partialResultToken() const auto DocumentSymbolParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentSymbolParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentSymbolParams::workDoneToken( std::optional workDoneToken) -> DocumentSymbolParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("DocumentSymbolParams::workDoneToken: not implement yet"); return *this; } auto DocumentSymbolParams::partialResultToken( std::optional partialResultToken) -> DocumentSymbolParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "DocumentSymbolParams::partialResultToken: not implement yet"); return *this; } SymbolInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("location")) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("location")) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; return true; } auto SymbolInformation::deprecated() const -> std::optional { - if (!repr_.contains("deprecated")) return std::nullopt; + if (!repr_->contains("deprecated")) return std::nullopt; - const auto& value = repr_["deprecated"]; + auto& value = (*repr_)["deprecated"]; assert(value.is_boolean()); return value.get(); } auto SymbolInformation::location() const -> Location { - const auto& value = repr_["location"]; + auto& value = (*repr_)["location"]; return Location(value); } auto SymbolInformation::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto SymbolInformation::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto SymbolInformation::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto SymbolInformation::containerName() const -> std::optional { - if (!repr_.contains("containerName")) return std::nullopt; + if (!repr_->contains("containerName")) return std::nullopt; - const auto& value = repr_["containerName"]; + auto& value = (*repr_)["containerName"]; assert(value.is_string()); return value.get(); @@ -5788,140 +7708,188 @@ auto SymbolInformation::containerName() const -> std::optional { auto SymbolInformation::deprecated(std::optional deprecated) -> SymbolInformation& { + if (!deprecated.has_value()) { + repr_->erase("deprecated"); + return *this; + } + repr_->emplace("deprecated", std::move(deprecated.value())); return *this; } auto SymbolInformation::location(Location location) -> SymbolInformation& { + repr_->emplace("location", location); return *this; } auto SymbolInformation::name(std::string name) -> SymbolInformation& { + repr_->emplace("name", std::move(name)); return *this; } auto SymbolInformation::kind(SymbolKind kind) -> SymbolInformation& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto SymbolInformation::tags(std::optional> tags) -> SymbolInformation& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("SymbolInformation::tags: not implement yet"); return *this; } auto SymbolInformation::containerName(std::optional containerName) -> SymbolInformation& { + if (!containerName.has_value()) { + repr_->erase("containerName"); + return *this; + } + repr_->emplace("containerName", std::move(containerName.value())); return *this; } DocumentSymbol::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("selectionRange")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("selectionRange")) return false; return true; } auto DocumentSymbol::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto DocumentSymbol::detail() const -> std::optional { - if (!repr_.contains("detail")) return std::nullopt; + if (!repr_->contains("detail")) return std::nullopt; - const auto& value = repr_["detail"]; + auto& value = (*repr_)["detail"]; assert(value.is_string()); return value.get(); } auto DocumentSymbol::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto DocumentSymbol::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto DocumentSymbol::deprecated() const -> std::optional { - if (!repr_.contains("deprecated")) return std::nullopt; + if (!repr_->contains("deprecated")) return std::nullopt; - const auto& value = repr_["deprecated"]; + auto& value = (*repr_)["deprecated"]; assert(value.is_boolean()); return value.get(); } auto DocumentSymbol::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto DocumentSymbol::selectionRange() const -> Range { - const auto& value = repr_["selectionRange"]; + auto& value = (*repr_)["selectionRange"]; return Range(value); } auto DocumentSymbol::children() const -> std::optional> { - if (!repr_.contains("children")) return std::nullopt; + if (!repr_->contains("children")) return std::nullopt; - const auto& value = repr_["children"]; + auto& value = (*repr_)["children"]; assert(value.is_array()); return Vector(value); } -auto DocumentSymbol::name(std::string name) -> DocumentSymbol& { return *this; } +auto DocumentSymbol::name(std::string name) -> DocumentSymbol& { + repr_->emplace("name", std::move(name)); + return *this; +} auto DocumentSymbol::detail(std::optional detail) -> DocumentSymbol& { + if (!detail.has_value()) { + repr_->erase("detail"); + return *this; + } + repr_->emplace("detail", std::move(detail.value())); return *this; } -auto DocumentSymbol::kind(SymbolKind kind) -> DocumentSymbol& { return *this; } +auto DocumentSymbol::kind(SymbolKind kind) -> DocumentSymbol& { + repr_->emplace("kind", static_cast(kind)); + return *this; +} auto DocumentSymbol::tags(std::optional> tags) -> DocumentSymbol& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("DocumentSymbol::tags: not implement yet"); return *this; } auto DocumentSymbol::deprecated(std::optional deprecated) -> DocumentSymbol& { + if (!deprecated.has_value()) { + repr_->erase("deprecated"); + return *this; + } + repr_->emplace("deprecated", std::move(deprecated.value())); return *this; } -auto DocumentSymbol::range(Range range) -> DocumentSymbol& { return *this; } +auto DocumentSymbol::range(Range range) -> DocumentSymbol& { + repr_->emplace("range", range); + return *this; +} auto DocumentSymbol::selectionRange(Range selectionRange) -> DocumentSymbol& { + repr_->emplace("selectionRange", selectionRange); return *this; } auto DocumentSymbol::children(std::optional> children) -> DocumentSymbol& { + if (!children.has_value()) { + repr_->erase("children"); + return *this; + } + lsp_runtime_error("DocumentSymbol::children: not implement yet"); return *this; } DocumentSymbolRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentSymbolRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -5932,9 +7900,9 @@ auto DocumentSymbolRegistrationOptions::documentSelector() const auto DocumentSymbolRegistrationOptions::label() const -> std::optional { - if (!repr_.contains("label")) return std::nullopt; + if (!repr_->contains("label")) return std::nullopt; - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); @@ -5942,9 +7910,9 @@ auto DocumentSymbolRegistrationOptions::label() const auto DocumentSymbolRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -5953,50 +7921,82 @@ auto DocumentSymbolRegistrationOptions::workDoneProgress() const auto DocumentSymbolRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentSymbolRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentSymbolRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentSymbolRegistrationOptions::label(std::optional label) -> DocumentSymbolRegistrationOptions& { + if (!label.has_value()) { + repr_->erase("label"); + return *this; + } + repr_->emplace("label", std::move(label.value())); return *this; } auto DocumentSymbolRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentSymbolRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } CodeActionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("context")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("context")) return false; return true; } auto CodeActionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto CodeActionParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto CodeActionParams::context() const -> CodeActionContext { - const auto& value = repr_["context"]; + auto& value = (*repr_)["context"]; return CodeActionContext(value); } auto CodeActionParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6007,9 +8007,9 @@ auto CodeActionParams::workDoneToken() const -> std::optional { auto CodeActionParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -6020,203 +8020,277 @@ auto CodeActionParams::partialResultToken() const auto CodeActionParams::textDocument(TextDocumentIdentifier textDocument) -> CodeActionParams& { + repr_->emplace("textDocument", textDocument); return *this; } -auto CodeActionParams::range(Range range) -> CodeActionParams& { return *this; } +auto CodeActionParams::range(Range range) -> CodeActionParams& { + repr_->emplace("range", range); + return *this; +} auto CodeActionParams::context(CodeActionContext context) -> CodeActionParams& { + repr_->emplace("context", context); return *this; } auto CodeActionParams::workDoneToken(std::optional workDoneToken) -> CodeActionParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("CodeActionParams::workDoneToken: not implement yet"); return *this; } auto CodeActionParams::partialResultToken( std::optional partialResultToken) -> CodeActionParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("CodeActionParams::partialResultToken: not implement yet"); return *this; } Command::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("title")) return false; - if (!repr_.contains("command")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("title")) return false; + if (!repr_->contains("command")) return false; return true; } auto Command::title() const -> std::string { - const auto& value = repr_["title"]; + auto& value = (*repr_)["title"]; assert(value.is_string()); return value.get(); } auto Command::tooltip() const -> std::optional { - if (!repr_.contains("tooltip")) return std::nullopt; + if (!repr_->contains("tooltip")) return std::nullopt; - const auto& value = repr_["tooltip"]; + auto& value = (*repr_)["tooltip"]; assert(value.is_string()); return value.get(); } auto Command::command() const -> std::string { - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; assert(value.is_string()); return value.get(); } auto Command::arguments() const -> std::optional> { - if (!repr_.contains("arguments")) return std::nullopt; + if (!repr_->contains("arguments")) return std::nullopt; - const auto& value = repr_["arguments"]; + auto& value = (*repr_)["arguments"]; assert(value.is_array()); return Vector(value); } -auto Command::title(std::string title) -> Command& { return *this; } +auto Command::title(std::string title) -> Command& { + repr_->emplace("title", std::move(title)); + return *this; +} auto Command::tooltip(std::optional tooltip) -> Command& { + if (!tooltip.has_value()) { + repr_->erase("tooltip"); + return *this; + } + repr_->emplace("tooltip", std::move(tooltip.value())); return *this; } -auto Command::command(std::string command) -> Command& { return *this; } +auto Command::command(std::string command) -> Command& { + repr_->emplace("command", std::move(command)); + return *this; +} auto Command::arguments(std::optional> arguments) -> Command& { + if (!arguments.has_value()) { + repr_->erase("arguments"); + return *this; + } + lsp_runtime_error("Command::arguments: not implement yet"); return *this; } CodeAction::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("title")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("title")) return false; return true; } auto CodeAction::title() const -> std::string { - const auto& value = repr_["title"]; + auto& value = (*repr_)["title"]; assert(value.is_string()); return value.get(); } auto CodeAction::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; lsp_runtime_error("CodeAction::kind: not implement yet"); } auto CodeAction::diagnostics() const -> std::optional> { - if (!repr_.contains("diagnostics")) return std::nullopt; + if (!repr_->contains("diagnostics")) return std::nullopt; - const auto& value = repr_["diagnostics"]; + auto& value = (*repr_)["diagnostics"]; assert(value.is_array()); return Vector(value); } auto CodeAction::isPreferred() const -> std::optional { - if (!repr_.contains("isPreferred")) return std::nullopt; + if (!repr_->contains("isPreferred")) return std::nullopt; - const auto& value = repr_["isPreferred"]; + auto& value = (*repr_)["isPreferred"]; assert(value.is_boolean()); return value.get(); } auto CodeAction::disabled() const -> std::optional { - if (!repr_.contains("disabled")) return std::nullopt; + if (!repr_->contains("disabled")) return std::nullopt; - const auto& value = repr_["disabled"]; + auto& value = (*repr_)["disabled"]; return CodeActionDisabled(value); } auto CodeAction::edit() const -> std::optional { - if (!repr_.contains("edit")) return std::nullopt; + if (!repr_->contains("edit")) return std::nullopt; - const auto& value = repr_["edit"]; + auto& value = (*repr_)["edit"]; return WorkspaceEdit(value); } auto CodeAction::command() const -> std::optional { - if (!repr_.contains("command")) return std::nullopt; + if (!repr_->contains("command")) return std::nullopt; - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } auto CodeAction::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } auto CodeAction::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } -auto CodeAction::title(std::string title) -> CodeAction& { return *this; } +auto CodeAction::title(std::string title) -> CodeAction& { + repr_->emplace("title", std::move(title)); + return *this; +} auto CodeAction::kind(std::optional kind) -> CodeAction& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + lsp_runtime_error("CodeAction::kind: not implement yet"); return *this; } auto CodeAction::diagnostics(std::optional> diagnostics) -> CodeAction& { + if (!diagnostics.has_value()) { + repr_->erase("diagnostics"); + return *this; + } + lsp_runtime_error("CodeAction::diagnostics: not implement yet"); return *this; } auto CodeAction::isPreferred(std::optional isPreferred) -> CodeAction& { + if (!isPreferred.has_value()) { + repr_->erase("isPreferred"); + return *this; + } + repr_->emplace("isPreferred", std::move(isPreferred.value())); return *this; } auto CodeAction::disabled(std::optional disabled) -> CodeAction& { + if (!disabled.has_value()) { + repr_->erase("disabled"); + return *this; + } + repr_->emplace("disabled", disabled.value()); return *this; } auto CodeAction::edit(std::optional edit) -> CodeAction& { + if (!edit.has_value()) { + repr_->erase("edit"); + return *this; + } + repr_->emplace("edit", edit.value()); return *this; } auto CodeAction::command(std::optional command) -> CodeAction& { + if (!command.has_value()) { + repr_->erase("command"); + return *this; + } + repr_->emplace("command", command.value()); return *this; } auto CodeAction::data(std::optional data) -> CodeAction& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("CodeAction::data: not implement yet"); return *this; } auto CodeAction::tags(std::optional> tags) -> CodeAction& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("CodeAction::tags: not implement yet"); return *this; } CodeActionRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto CodeActionRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -6227,9 +8301,9 @@ auto CodeActionRegistrationOptions::documentSelector() const auto CodeActionRegistrationOptions::codeActionKinds() const -> std::optional> { - if (!repr_.contains("codeActionKinds")) return std::nullopt; + if (!repr_->contains("codeActionKinds")) return std::nullopt; - const auto& value = repr_["codeActionKinds"]; + auto& value = (*repr_)["codeActionKinds"]; assert(value.is_array()); return Vector(value); @@ -6237,9 +8311,9 @@ auto CodeActionRegistrationOptions::codeActionKinds() const auto CodeActionRegistrationOptions::documentation() const -> std::optional> { - if (!repr_.contains("documentation")) return std::nullopt; + if (!repr_->contains("documentation")) return std::nullopt; - const auto& value = repr_["documentation"]; + auto& value = (*repr_)["documentation"]; assert(value.is_array()); return Vector(value); @@ -6247,9 +8321,9 @@ auto CodeActionRegistrationOptions::documentation() const auto CodeActionRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -6257,9 +8331,9 @@ auto CodeActionRegistrationOptions::resolveProvider() const auto CodeActionRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6268,39 +8342,82 @@ auto CodeActionRegistrationOptions::workDoneProgress() const auto CodeActionRegistrationOptions::documentSelector( std::variant documentSelector) -> CodeActionRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "CodeActionRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto CodeActionRegistrationOptions::codeActionKinds( std::optional> codeActionKinds) -> CodeActionRegistrationOptions& { + if (!codeActionKinds.has_value()) { + repr_->erase("codeActionKinds"); + return *this; + } + lsp_runtime_error( + "CodeActionRegistrationOptions::codeActionKinds: not implement yet"); return *this; } auto CodeActionRegistrationOptions::documentation( std::optional> documentation) -> CodeActionRegistrationOptions& { + if (!documentation.has_value()) { + repr_->erase("documentation"); + return *this; + } + lsp_runtime_error( + "CodeActionRegistrationOptions::documentation: not implement yet"); return *this; } auto CodeActionRegistrationOptions::resolveProvider( std::optional resolveProvider) -> CodeActionRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CodeActionRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> CodeActionRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } WorkspaceSymbolParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("query")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("query")) return false; return true; } auto WorkspaceSymbolParams::query() const -> std::string { - const auto& value = repr_["query"]; + auto& value = (*repr_)["query"]; assert(value.is_string()); return value.get(); @@ -6308,9 +8425,9 @@ auto WorkspaceSymbolParams::query() const -> std::string { auto WorkspaceSymbolParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6321,9 +8438,9 @@ auto WorkspaceSymbolParams::workDoneToken() const auto WorkspaceSymbolParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -6333,30 +8450,42 @@ auto WorkspaceSymbolParams::partialResultToken() const } auto WorkspaceSymbolParams::query(std::string query) -> WorkspaceSymbolParams& { + repr_->emplace("query", std::move(query)); return *this; } auto WorkspaceSymbolParams::workDoneToken( std::optional workDoneToken) -> WorkspaceSymbolParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("WorkspaceSymbolParams::workDoneToken: not implement yet"); return *this; } auto WorkspaceSymbolParams::partialResultToken( std::optional partialResultToken) -> WorkspaceSymbolParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "WorkspaceSymbolParams::partialResultToken: not implement yet"); return *this; } WorkspaceSymbol::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("location")) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("location")) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; return true; } auto WorkspaceSymbol::location() const -> std::variant { - const auto& value = repr_["location"]; + auto& value = (*repr_)["location"]; std::variant result; @@ -6366,40 +8495,40 @@ auto WorkspaceSymbol::location() const } auto WorkspaceSymbol::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } auto WorkspaceSymbol::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto WorkspaceSymbol::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto WorkspaceSymbol::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); } auto WorkspaceSymbol::containerName() const -> std::optional { - if (!repr_.contains("containerName")) return std::nullopt; + if (!repr_->contains("containerName")) return std::nullopt; - const auto& value = repr_["containerName"]; + auto& value = (*repr_)["containerName"]; assert(value.is_string()); return value.get(); @@ -6408,41 +8537,76 @@ auto WorkspaceSymbol::containerName() const -> std::optional { auto WorkspaceSymbol::location( std::variant location) -> WorkspaceSymbol& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(Location location) { repr_->emplace("location", location); } + + void operator()(LocationUriOnly location) { + repr_->emplace("location", location); + } + } v{repr_}; + + std::visit(v, location); + return *this; } auto WorkspaceSymbol::data(std::optional data) -> WorkspaceSymbol& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("WorkspaceSymbol::data: not implement yet"); return *this; } auto WorkspaceSymbol::name(std::string name) -> WorkspaceSymbol& { + repr_->emplace("name", std::move(name)); return *this; } auto WorkspaceSymbol::kind(SymbolKind kind) -> WorkspaceSymbol& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto WorkspaceSymbol::tags(std::optional> tags) -> WorkspaceSymbol& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("WorkspaceSymbol::tags: not implement yet"); return *this; } auto WorkspaceSymbol::containerName(std::optional containerName) -> WorkspaceSymbol& { + if (!containerName.has_value()) { + repr_->erase("containerName"); + return *this; + } + repr_->emplace("containerName", std::move(containerName.value())); return *this; } WorkspaceSymbolRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceSymbolRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -6450,9 +8614,9 @@ auto WorkspaceSymbolRegistrationOptions::resolveProvider() const auto WorkspaceSymbolRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6461,31 +8625,41 @@ auto WorkspaceSymbolRegistrationOptions::workDoneProgress() const auto WorkspaceSymbolRegistrationOptions::resolveProvider( std::optional resolveProvider) -> WorkspaceSymbolRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto WorkspaceSymbolRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> WorkspaceSymbolRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } CodeLensParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto CodeLensParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto CodeLensParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6496,9 +8670,9 @@ auto CodeLensParams::workDoneToken() const -> std::optional { auto CodeLensParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -6509,65 +8683,91 @@ auto CodeLensParams::partialResultToken() const auto CodeLensParams::textDocument(TextDocumentIdentifier textDocument) -> CodeLensParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto CodeLensParams::workDoneToken(std::optional workDoneToken) -> CodeLensParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("CodeLensParams::workDoneToken: not implement yet"); return *this; } auto CodeLensParams::partialResultToken( std::optional partialResultToken) -> CodeLensParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error("CodeLensParams::partialResultToken: not implement yet"); return *this; } CodeLens::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; return true; } auto CodeLens::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto CodeLens::command() const -> std::optional { - if (!repr_.contains("command")) return std::nullopt; + if (!repr_->contains("command")) return std::nullopt; - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } auto CodeLens::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } -auto CodeLens::range(Range range) -> CodeLens& { return *this; } +auto CodeLens::range(Range range) -> CodeLens& { + repr_->emplace("range", range); + return *this; +} auto CodeLens::command(std::optional command) -> CodeLens& { + if (!command.has_value()) { + repr_->erase("command"); + return *this; + } + repr_->emplace("command", command.value()); return *this; } -auto CodeLens::data(std::optional data) -> CodeLens& { return *this; } +auto CodeLens::data(std::optional data) -> CodeLens& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("CodeLens::data: not implement yet"); + return *this; +} CodeLensRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto CodeLensRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -6578,9 +8778,9 @@ auto CodeLensRegistrationOptions::documentSelector() const auto CodeLensRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -6588,9 +8788,9 @@ auto CodeLensRegistrationOptions::resolveProvider() const auto CodeLensRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6599,35 +8799,66 @@ auto CodeLensRegistrationOptions::workDoneProgress() const auto CodeLensRegistrationOptions::documentSelector( std::variant documentSelector) -> CodeLensRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "CodeLensRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto CodeLensRegistrationOptions::resolveProvider( std::optional resolveProvider) -> CodeLensRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CodeLensRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> CodeLensRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentLinkParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; return true; } auto DocumentLinkParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentLinkParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6638,9 +8869,9 @@ auto DocumentLinkParams::workDoneToken() const -> std::optional { auto DocumentLinkParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -6651,82 +8882,112 @@ auto DocumentLinkParams::partialResultToken() const auto DocumentLinkParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentLinkParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentLinkParams::workDoneToken( std::optional workDoneToken) -> DocumentLinkParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("DocumentLinkParams::workDoneToken: not implement yet"); return *this; } auto DocumentLinkParams::partialResultToken( std::optional partialResultToken) -> DocumentLinkParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "DocumentLinkParams::partialResultToken: not implement yet"); return *this; } DocumentLink::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; return true; } auto DocumentLink::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto DocumentLink::target() const -> std::optional { - if (!repr_.contains("target")) return std::nullopt; + if (!repr_->contains("target")) return std::nullopt; - const auto& value = repr_["target"]; + auto& value = (*repr_)["target"]; assert(value.is_string()); return value.get(); } auto DocumentLink::tooltip() const -> std::optional { - if (!repr_.contains("tooltip")) return std::nullopt; + if (!repr_->contains("tooltip")) return std::nullopt; - const auto& value = repr_["tooltip"]; + auto& value = (*repr_)["tooltip"]; assert(value.is_string()); return value.get(); } auto DocumentLink::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } -auto DocumentLink::range(Range range) -> DocumentLink& { return *this; } +auto DocumentLink::range(Range range) -> DocumentLink& { + repr_->emplace("range", range); + return *this; +} auto DocumentLink::target(std::optional target) -> DocumentLink& { + if (!target.has_value()) { + repr_->erase("target"); + return *this; + } + repr_->emplace("target", std::move(target.value())); return *this; } auto DocumentLink::tooltip(std::optional tooltip) -> DocumentLink& { + if (!tooltip.has_value()) { + repr_->erase("tooltip"); + return *this; + } + repr_->emplace("tooltip", std::move(tooltip.value())); return *this; } auto DocumentLink::data(std::optional data) -> DocumentLink& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("DocumentLink::data: not implement yet"); return *this; } DocumentLinkRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentLinkRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -6737,9 +8998,9 @@ auto DocumentLinkRegistrationOptions::documentSelector() const auto DocumentLinkRegistrationOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -6747,9 +9008,9 @@ auto DocumentLinkRegistrationOptions::resolveProvider() const auto DocumentLinkRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6758,43 +9019,75 @@ auto DocumentLinkRegistrationOptions::workDoneProgress() const auto DocumentLinkRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentLinkRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentLinkRegistrationOptions::documentSelector: not implement " + "yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentLinkRegistrationOptions::resolveProvider( std::optional resolveProvider) -> DocumentLinkRegistrationOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto DocumentLinkRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentLinkRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentFormattingParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("options")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("options")) return false; return true; } auto DocumentFormattingParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentFormattingParams::options() const -> FormattingOptions { - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return FormattingOptions(value); } auto DocumentFormattingParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6805,28 +9098,36 @@ auto DocumentFormattingParams::workDoneToken() const auto DocumentFormattingParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentFormattingParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentFormattingParams::options(FormattingOptions options) -> DocumentFormattingParams& { + repr_->emplace("options", options); return *this; } auto DocumentFormattingParams::workDoneToken( std::optional workDoneToken) -> DocumentFormattingParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "DocumentFormattingParams::workDoneToken: not implement yet"); return *this; } DocumentFormattingRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentFormattingRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -6837,9 +9138,9 @@ auto DocumentFormattingRegistrationOptions::documentSelector() const auto DocumentFormattingRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6848,47 +9149,74 @@ auto DocumentFormattingRegistrationOptions::workDoneProgress() const auto DocumentFormattingRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentFormattingRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentFormattingRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentFormattingRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentFormattingRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentRangeFormattingParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("options")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("options")) return false; return true; } auto DocumentRangeFormattingParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentRangeFormattingParams::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto DocumentRangeFormattingParams::options() const -> FormattingOptions { - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return FormattingOptions(value); } auto DocumentRangeFormattingParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -6899,34 +9227,43 @@ auto DocumentRangeFormattingParams::workDoneToken() const auto DocumentRangeFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentRangeFormattingParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentRangeFormattingParams::range(Range range) -> DocumentRangeFormattingParams& { + repr_->emplace("range", range); return *this; } auto DocumentRangeFormattingParams::options(FormattingOptions options) -> DocumentRangeFormattingParams& { + repr_->emplace("options", options); return *this; } auto DocumentRangeFormattingParams::workDoneToken( std::optional workDoneToken) -> DocumentRangeFormattingParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "DocumentRangeFormattingParams::workDoneToken: not implement yet"); return *this; } DocumentRangeFormattingRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto DocumentRangeFormattingRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -6937,9 +9274,9 @@ auto DocumentRangeFormattingRegistrationOptions::documentSelector() const auto DocumentRangeFormattingRegistrationOptions::rangesSupport() const -> std::optional { - if (!repr_.contains("rangesSupport")) return std::nullopt; + if (!repr_->contains("rangesSupport")) return std::nullopt; - const auto& value = repr_["rangesSupport"]; + auto& value = (*repr_)["rangesSupport"]; assert(value.is_boolean()); return value.get(); @@ -6947,9 +9284,9 @@ auto DocumentRangeFormattingRegistrationOptions::rangesSupport() const auto DocumentRangeFormattingRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -6958,54 +9295,86 @@ auto DocumentRangeFormattingRegistrationOptions::workDoneProgress() const auto DocumentRangeFormattingRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentRangeFormattingRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentRangeFormattingRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentRangeFormattingRegistrationOptions::rangesSupport( std::optional rangesSupport) -> DocumentRangeFormattingRegistrationOptions& { + if (!rangesSupport.has_value()) { + repr_->erase("rangesSupport"); + return *this; + } + repr_->emplace("rangesSupport", std::move(rangesSupport.value())); return *this; } auto DocumentRangeFormattingRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentRangeFormattingRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentRangesFormattingParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("ranges")) return false; - if (!repr_.contains("options")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("ranges")) return false; + if (!repr_->contains("options")) return false; return true; } auto DocumentRangesFormattingParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentRangesFormattingParams::ranges() const -> Vector { - const auto& value = repr_["ranges"]; + auto& value = (*repr_)["ranges"]; assert(value.is_array()); return Vector(value); } auto DocumentRangesFormattingParams::options() const -> FormattingOptions { - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return FormattingOptions(value); } auto DocumentRangesFormattingParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -7016,90 +9385,104 @@ auto DocumentRangesFormattingParams::workDoneToken() const auto DocumentRangesFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentRangesFormattingParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentRangesFormattingParams::ranges(Vector ranges) -> DocumentRangesFormattingParams& { + lsp_runtime_error( + "DocumentRangesFormattingParams::ranges: not implement yet"); return *this; } auto DocumentRangesFormattingParams::options(FormattingOptions options) -> DocumentRangesFormattingParams& { + repr_->emplace("options", options); return *this; } auto DocumentRangesFormattingParams::workDoneToken( std::optional workDoneToken) -> DocumentRangesFormattingParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error( + "DocumentRangesFormattingParams::workDoneToken: not implement yet"); return *this; } DocumentOnTypeFormattingParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; - if (!repr_.contains("ch")) return false; - if (!repr_.contains("options")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; + if (!repr_->contains("ch")) return false; + if (!repr_->contains("options")) return false; return true; } auto DocumentOnTypeFormattingParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto DocumentOnTypeFormattingParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto DocumentOnTypeFormattingParams::ch() const -> std::string { - const auto& value = repr_["ch"]; + auto& value = (*repr_)["ch"]; assert(value.is_string()); return value.get(); } auto DocumentOnTypeFormattingParams::options() const -> FormattingOptions { - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return FormattingOptions(value); } auto DocumentOnTypeFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentOnTypeFormattingParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto DocumentOnTypeFormattingParams::position(Position position) -> DocumentOnTypeFormattingParams& { + repr_->emplace("position", position); return *this; } auto DocumentOnTypeFormattingParams::ch(std::string ch) -> DocumentOnTypeFormattingParams& { + repr_->emplace("ch", std::move(ch)); return *this; } auto DocumentOnTypeFormattingParams::options(FormattingOptions options) -> DocumentOnTypeFormattingParams& { + repr_->emplace("options", options); return *this; } DocumentOnTypeFormattingRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; - if (!repr_.contains("firstTriggerCharacter")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; + if (!repr_->contains("firstTriggerCharacter")) return false; return true; } auto DocumentOnTypeFormattingRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -7110,7 +9493,7 @@ auto DocumentOnTypeFormattingRegistrationOptions::documentSelector() const auto DocumentOnTypeFormattingRegistrationOptions::firstTriggerCharacter() const -> std::string { - const auto& value = repr_["firstTriggerCharacter"]; + auto& value = (*repr_)["firstTriggerCharacter"]; assert(value.is_string()); return value.get(); @@ -7118,9 +9501,9 @@ auto DocumentOnTypeFormattingRegistrationOptions::firstTriggerCharacter() const auto DocumentOnTypeFormattingRegistrationOptions::moreTriggerCharacter() const -> std::optional> { - if (!repr_.contains("moreTriggerCharacter")) return std::nullopt; + if (!repr_->contains("moreTriggerCharacter")) return std::nullopt; - const auto& value = repr_["moreTriggerCharacter"]; + auto& value = (*repr_)["moreTriggerCharacter"]; assert(value.is_array()); return Vector(value); @@ -7129,52 +9512,82 @@ auto DocumentOnTypeFormattingRegistrationOptions::moreTriggerCharacter() const auto DocumentOnTypeFormattingRegistrationOptions::documentSelector( std::variant documentSelector) -> DocumentOnTypeFormattingRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "DocumentOnTypeFormattingRegistrationOptions::documentSelector: not " + "implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto DocumentOnTypeFormattingRegistrationOptions::firstTriggerCharacter( std::string firstTriggerCharacter) -> DocumentOnTypeFormattingRegistrationOptions& { + repr_->emplace("firstTriggerCharacter", std::move(firstTriggerCharacter)); return *this; } auto DocumentOnTypeFormattingRegistrationOptions::moreTriggerCharacter( std::optional> moreTriggerCharacter) -> DocumentOnTypeFormattingRegistrationOptions& { + if (!moreTriggerCharacter.has_value()) { + repr_->erase("moreTriggerCharacter"); + return *this; + } + lsp_runtime_error( + "DocumentOnTypeFormattingRegistrationOptions::moreTriggerCharacter: not " + "implement yet"); return *this; } RenameParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; - if (!repr_.contains("newName")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; + if (!repr_->contains("newName")) return false; return true; } auto RenameParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto RenameParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto RenameParams::newName() const -> std::string { - const auto& value = repr_["newName"]; + auto& value = (*repr_)["newName"]; assert(value.is_string()); return value.get(); } auto RenameParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -7185,31 +9598,39 @@ auto RenameParams::workDoneToken() const -> std::optional { auto RenameParams::textDocument(TextDocumentIdentifier textDocument) -> RenameParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto RenameParams::position(Position position) -> RenameParams& { + repr_->emplace("position", position); return *this; } auto RenameParams::newName(std::string newName) -> RenameParams& { + repr_->emplace("newName", std::move(newName)); return *this; } auto RenameParams::workDoneToken(std::optional workDoneToken) -> RenameParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("RenameParams::workDoneToken: not implement yet"); return *this; } RenameRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("documentSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("documentSelector")) return false; return true; } auto RenameRegistrationOptions::documentSelector() const -> std::variant { - const auto& value = repr_["documentSelector"]; + auto& value = (*repr_)["documentSelector"]; std::variant result; @@ -7219,9 +9640,9 @@ auto RenameRegistrationOptions::documentSelector() const } auto RenameRegistrationOptions::prepareProvider() const -> std::optional { - if (!repr_.contains("prepareProvider")) return std::nullopt; + if (!repr_->contains("prepareProvider")) return std::nullopt; - const auto& value = repr_["prepareProvider"]; + auto& value = (*repr_)["prepareProvider"]; assert(value.is_boolean()); return value.get(); @@ -7229,9 +9650,9 @@ auto RenameRegistrationOptions::prepareProvider() const -> std::optional { auto RenameRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -7240,43 +9661,74 @@ auto RenameRegistrationOptions::workDoneProgress() const auto RenameRegistrationOptions::documentSelector( std::variant documentSelector) -> RenameRegistrationOptions& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DocumentSelector documentSelector) { + lsp_runtime_error( + "RenameRegistrationOptions::documentSelector: not implement yet"); + } + + void operator()(std::nullptr_t documentSelector) { + repr_->emplace("documentSelector", std::move(documentSelector)); + } + } v{repr_}; + + std::visit(v, documentSelector); + return *this; } auto RenameRegistrationOptions::prepareProvider( std::optional prepareProvider) -> RenameRegistrationOptions& { + if (!prepareProvider.has_value()) { + repr_->erase("prepareProvider"); + return *this; + } + repr_->emplace("prepareProvider", std::move(prepareProvider.value())); return *this; } auto RenameRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> RenameRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } PrepareRenameParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto PrepareRenameParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto PrepareRenameParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto PrepareRenameParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -7287,35 +9739,42 @@ auto PrepareRenameParams::workDoneToken() const auto PrepareRenameParams::textDocument(TextDocumentIdentifier textDocument) -> PrepareRenameParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto PrepareRenameParams::position(Position position) -> PrepareRenameParams& { + repr_->emplace("position", position); return *this; } auto PrepareRenameParams::workDoneToken( std::optional workDoneToken) -> PrepareRenameParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("PrepareRenameParams::workDoneToken: not implement yet"); return *this; } ExecuteCommandParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("command")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("command")) return false; return true; } auto ExecuteCommandParams::command() const -> std::string { - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; assert(value.is_string()); return value.get(); } auto ExecuteCommandParams::arguments() const -> std::optional> { - if (!repr_.contains("arguments")) return std::nullopt; + if (!repr_->contains("arguments")) return std::nullopt; - const auto& value = repr_["arguments"]; + auto& value = (*repr_)["arguments"]; assert(value.is_array()); return Vector(value); @@ -7323,9 +9782,9 @@ auto ExecuteCommandParams::arguments() const -> std::optional> { auto ExecuteCommandParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -7336,28 +9795,39 @@ auto ExecuteCommandParams::workDoneToken() const auto ExecuteCommandParams::command(std::string command) -> ExecuteCommandParams& { + repr_->emplace("command", std::move(command)); return *this; } auto ExecuteCommandParams::arguments(std::optional> arguments) -> ExecuteCommandParams& { + if (!arguments.has_value()) { + repr_->erase("arguments"); + return *this; + } + lsp_runtime_error("ExecuteCommandParams::arguments: not implement yet"); return *this; } auto ExecuteCommandParams::workDoneToken( std::optional workDoneToken) -> ExecuteCommandParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("ExecuteCommandParams::workDoneToken: not implement yet"); return *this; } ExecuteCommandRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("commands")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("commands")) return false; return true; } auto ExecuteCommandRegistrationOptions::commands() const -> Vector { - const auto& value = repr_["commands"]; + auto& value = (*repr_)["commands"]; assert(value.is_array()); return Vector(value); @@ -7365,9 +9835,9 @@ auto ExecuteCommandRegistrationOptions::commands() const auto ExecuteCommandRegistrationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -7375,69 +9845,87 @@ auto ExecuteCommandRegistrationOptions::workDoneProgress() const auto ExecuteCommandRegistrationOptions::commands(Vector commands) -> ExecuteCommandRegistrationOptions& { + lsp_runtime_error( + "ExecuteCommandRegistrationOptions::commands: not implement yet"); return *this; } auto ExecuteCommandRegistrationOptions::workDoneProgress( std::optional workDoneProgress) -> ExecuteCommandRegistrationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } ApplyWorkspaceEditParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("edit")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("edit")) return false; return true; } auto ApplyWorkspaceEditParams::label() const -> std::optional { - if (!repr_.contains("label")) return std::nullopt; + if (!repr_->contains("label")) return std::nullopt; - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); } auto ApplyWorkspaceEditParams::edit() const -> WorkspaceEdit { - const auto& value = repr_["edit"]; + auto& value = (*repr_)["edit"]; return WorkspaceEdit(value); } auto ApplyWorkspaceEditParams::metadata() const -> std::optional { - if (!repr_.contains("metadata")) return std::nullopt; + if (!repr_->contains("metadata")) return std::nullopt; - const auto& value = repr_["metadata"]; + auto& value = (*repr_)["metadata"]; return WorkspaceEditMetadata(value); } auto ApplyWorkspaceEditParams::label(std::optional label) -> ApplyWorkspaceEditParams& { + if (!label.has_value()) { + repr_->erase("label"); + return *this; + } + repr_->emplace("label", std::move(label.value())); return *this; } auto ApplyWorkspaceEditParams::edit(WorkspaceEdit edit) -> ApplyWorkspaceEditParams& { + repr_->emplace("edit", edit); return *this; } auto ApplyWorkspaceEditParams::metadata( std::optional metadata) -> ApplyWorkspaceEditParams& { + if (!metadata.has_value()) { + repr_->erase("metadata"); + return *this; + } + repr_->emplace("metadata", metadata.value()); return *this; } ApplyWorkspaceEditResult::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("applied")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("applied")) return false; return true; } auto ApplyWorkspaceEditResult::applied() const -> bool { - const auto& value = repr_["applied"]; + auto& value = (*repr_)["applied"]; assert(value.is_boolean()); return value.get(); @@ -7445,18 +9933,18 @@ auto ApplyWorkspaceEditResult::applied() const -> bool { auto ApplyWorkspaceEditResult::failureReason() const -> std::optional { - if (!repr_.contains("failureReason")) return std::nullopt; + if (!repr_->contains("failureReason")) return std::nullopt; - const auto& value = repr_["failureReason"]; + auto& value = (*repr_)["failureReason"]; assert(value.is_string()); return value.get(); } auto ApplyWorkspaceEditResult::failedChange() const -> std::optional { - if (!repr_.contains("failedChange")) return std::nullopt; + if (!repr_->contains("failedChange")) return std::nullopt; - const auto& value = repr_["failedChange"]; + auto& value = (*repr_)["failedChange"]; assert(value.is_number_integer()); return value.get(); @@ -7464,239 +9952,296 @@ auto ApplyWorkspaceEditResult::failedChange() const -> std::optional { auto ApplyWorkspaceEditResult::applied(bool applied) -> ApplyWorkspaceEditResult& { + repr_->emplace("applied", std::move(applied)); return *this; } auto ApplyWorkspaceEditResult::failureReason( std::optional failureReason) -> ApplyWorkspaceEditResult& { + if (!failureReason.has_value()) { + repr_->erase("failureReason"); + return *this; + } + repr_->emplace("failureReason", std::move(failureReason.value())); return *this; } auto ApplyWorkspaceEditResult::failedChange(std::optional failedChange) -> ApplyWorkspaceEditResult& { + if (!failedChange.has_value()) { + repr_->erase("failedChange"); + return *this; + } + repr_->emplace("failedChange", std::move(failedChange.value())); return *this; } WorkDoneProgressBegin::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "begin") return false; - if (!repr_.contains("title")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "begin") return false; + if (!repr_->contains("title")) return false; return true; } auto WorkDoneProgressBegin::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressBegin::title() const -> std::string { - const auto& value = repr_["title"]; + auto& value = (*repr_)["title"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressBegin::cancellable() const -> std::optional { - if (!repr_.contains("cancellable")) return std::nullopt; + if (!repr_->contains("cancellable")) return std::nullopt; - const auto& value = repr_["cancellable"]; + auto& value = (*repr_)["cancellable"]; assert(value.is_boolean()); return value.get(); } auto WorkDoneProgressBegin::message() const -> std::optional { - if (!repr_.contains("message")) return std::nullopt; + if (!repr_->contains("message")) return std::nullopt; - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressBegin::percentage() const -> std::optional { - if (!repr_.contains("percentage")) return std::nullopt; + if (!repr_->contains("percentage")) return std::nullopt; - const auto& value = repr_["percentage"]; + auto& value = (*repr_)["percentage"]; assert(value.is_number_integer()); return value.get(); } auto WorkDoneProgressBegin::kind(std::string kind) -> WorkDoneProgressBegin& { + lsp_runtime_error("WorkDoneProgressBegin::kind: not implement yet"); return *this; } auto WorkDoneProgressBegin::title(std::string title) -> WorkDoneProgressBegin& { + repr_->emplace("title", std::move(title)); return *this; } auto WorkDoneProgressBegin::cancellable(std::optional cancellable) -> WorkDoneProgressBegin& { + if (!cancellable.has_value()) { + repr_->erase("cancellable"); + return *this; + } + repr_->emplace("cancellable", std::move(cancellable.value())); return *this; } auto WorkDoneProgressBegin::message(std::optional message) -> WorkDoneProgressBegin& { + if (!message.has_value()) { + repr_->erase("message"); + return *this; + } + repr_->emplace("message", std::move(message.value())); return *this; } auto WorkDoneProgressBegin::percentage(std::optional percentage) -> WorkDoneProgressBegin& { + if (!percentage.has_value()) { + repr_->erase("percentage"); + return *this; + } + repr_->emplace("percentage", std::move(percentage.value())); return *this; } WorkDoneProgressReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "report") return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "report") return false; return true; } auto WorkDoneProgressReport::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressReport::cancellable() const -> std::optional { - if (!repr_.contains("cancellable")) return std::nullopt; + if (!repr_->contains("cancellable")) return std::nullopt; - const auto& value = repr_["cancellable"]; + auto& value = (*repr_)["cancellable"]; assert(value.is_boolean()); return value.get(); } auto WorkDoneProgressReport::message() const -> std::optional { - if (!repr_.contains("message")) return std::nullopt; + if (!repr_->contains("message")) return std::nullopt; - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressReport::percentage() const -> std::optional { - if (!repr_.contains("percentage")) return std::nullopt; + if (!repr_->contains("percentage")) return std::nullopt; - const auto& value = repr_["percentage"]; + auto& value = (*repr_)["percentage"]; assert(value.is_number_integer()); return value.get(); } auto WorkDoneProgressReport::kind(std::string kind) -> WorkDoneProgressReport& { + lsp_runtime_error("WorkDoneProgressReport::kind: not implement yet"); return *this; } auto WorkDoneProgressReport::cancellable(std::optional cancellable) -> WorkDoneProgressReport& { + if (!cancellable.has_value()) { + repr_->erase("cancellable"); + return *this; + } + repr_->emplace("cancellable", std::move(cancellable.value())); return *this; } auto WorkDoneProgressReport::message(std::optional message) -> WorkDoneProgressReport& { + if (!message.has_value()) { + repr_->erase("message"); + return *this; + } + repr_->emplace("message", std::move(message.value())); return *this; } auto WorkDoneProgressReport::percentage(std::optional percentage) -> WorkDoneProgressReport& { + if (!percentage.has_value()) { + repr_->erase("percentage"); + return *this; + } + repr_->emplace("percentage", std::move(percentage.value())); return *this; } WorkDoneProgressEnd::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "end") return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "end") return false; return true; } auto WorkDoneProgressEnd::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressEnd::message() const -> std::optional { - if (!repr_.contains("message")) return std::nullopt; + if (!repr_->contains("message")) return std::nullopt; - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto WorkDoneProgressEnd::kind(std::string kind) -> WorkDoneProgressEnd& { + lsp_runtime_error("WorkDoneProgressEnd::kind: not implement yet"); return *this; } auto WorkDoneProgressEnd::message(std::optional message) -> WorkDoneProgressEnd& { + if (!message.has_value()) { + repr_->erase("message"); + return *this; + } + repr_->emplace("message", std::move(message.value())); return *this; } SetTraceParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("value")) return false; return true; } auto SetTraceParams::value() const -> TraceValue { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; lsp_runtime_error("SetTraceParams::value: not implement yet"); } auto SetTraceParams::value(TraceValue value) -> SetTraceParams& { + lsp_runtime_error("SetTraceParams::value: not implement yet"); return *this; } LogTraceParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("message")) return false; return true; } auto LogTraceParams::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto LogTraceParams::verbose() const -> std::optional { - if (!repr_.contains("verbose")) return std::nullopt; + if (!repr_->contains("verbose")) return std::nullopt; - const auto& value = repr_["verbose"]; + auto& value = (*repr_)["verbose"]; assert(value.is_string()); return value.get(); } auto LogTraceParams::message(std::string message) -> LogTraceParams& { + repr_->emplace("message", std::move(message)); return *this; } auto LogTraceParams::verbose(std::optional verbose) -> LogTraceParams& { + if (!verbose.has_value()) { + repr_->erase("verbose"); + return *this; + } + repr_->emplace("verbose", std::move(verbose.value())); return *this; } CancelParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("id")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("id")) return false; return true; } auto CancelParams::id() const -> std::variant { - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; std::variant result; @@ -7707,18 +10252,34 @@ auto CancelParams::id() const auto CancelParams::id(std::variant id) -> CancelParams& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int id) { repr_->emplace("id", std::move(id)); } + + void operator()(std::string id) { repr_->emplace("id", std::move(id)); } + } v{repr_}; + + std::visit(v, id); + return *this; } ProgressParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("token")) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("token")) return false; + if (!repr_->contains("value")) return false; return true; } auto ProgressParams::token() const -> ProgressToken { - const auto& value = repr_["token"]; + auto& value = (*repr_)["token"]; ProgressToken result; @@ -7728,58 +10289,64 @@ auto ProgressParams::token() const -> ProgressToken { } auto ProgressParams::value() const -> LSPAny { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_object()); return LSPAny(value); } auto ProgressParams::token(ProgressToken token) -> ProgressParams& { + lsp_runtime_error("ProgressParams::token: not implement yet"); return *this; } -auto ProgressParams::value(LSPAny value) -> ProgressParams& { return *this; } +auto ProgressParams::value(LSPAny value) -> ProgressParams& { + lsp_runtime_error("ProgressParams::value: not implement yet"); + return *this; +} TextDocumentPositionParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("position")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("position")) return false; return true; } auto TextDocumentPositionParams::textDocument() const -> TextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentIdentifier(value); } auto TextDocumentPositionParams::position() const -> Position { - const auto& value = repr_["position"]; + auto& value = (*repr_)["position"]; return Position(value); } auto TextDocumentPositionParams::textDocument( TextDocumentIdentifier textDocument) -> TextDocumentPositionParams& { + repr_->emplace("textDocument", textDocument); return *this; } auto TextDocumentPositionParams::position(Position position) -> TextDocumentPositionParams& { + repr_->emplace("position", position); return *this; } WorkDoneProgressParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkDoneProgressParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -7790,19 +10357,24 @@ auto WorkDoneProgressParams::workDoneToken() const auto WorkDoneProgressParams::workDoneToken( std::optional workDoneToken) -> WorkDoneProgressParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("WorkDoneProgressParams::workDoneToken: not implement yet"); return *this; } PartialResultParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto PartialResultParams::partialResultToken() const -> std::optional { - if (!repr_.contains("partialResultToken")) return std::nullopt; + if (!repr_->contains("partialResultToken")) return std::nullopt; - const auto& value = repr_["partialResultToken"]; + auto& value = (*repr_)["partialResultToken"]; ProgressToken result; @@ -7813,94 +10385,114 @@ auto PartialResultParams::partialResultToken() const auto PartialResultParams::partialResultToken( std::optional partialResultToken) -> PartialResultParams& { + if (!partialResultToken.has_value()) { + repr_->erase("partialResultToken"); + return *this; + } + lsp_runtime_error( + "PartialResultParams::partialResultToken: not implement yet"); return *this; } LocationLink::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("targetUri")) return false; - if (!repr_.contains("targetRange")) return false; - if (!repr_.contains("targetSelectionRange")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("targetUri")) return false; + if (!repr_->contains("targetRange")) return false; + if (!repr_->contains("targetSelectionRange")) return false; return true; } auto LocationLink::originSelectionRange() const -> std::optional { - if (!repr_.contains("originSelectionRange")) return std::nullopt; + if (!repr_->contains("originSelectionRange")) return std::nullopt; - const auto& value = repr_["originSelectionRange"]; + auto& value = (*repr_)["originSelectionRange"]; return Range(value); } auto LocationLink::targetUri() const -> std::string { - const auto& value = repr_["targetUri"]; + auto& value = (*repr_)["targetUri"]; assert(value.is_string()); return value.get(); } auto LocationLink::targetRange() const -> Range { - const auto& value = repr_["targetRange"]; + auto& value = (*repr_)["targetRange"]; return Range(value); } auto LocationLink::targetSelectionRange() const -> Range { - const auto& value = repr_["targetSelectionRange"]; + auto& value = (*repr_)["targetSelectionRange"]; return Range(value); } auto LocationLink::originSelectionRange( std::optional originSelectionRange) -> LocationLink& { + if (!originSelectionRange.has_value()) { + repr_->erase("originSelectionRange"); + return *this; + } + repr_->emplace("originSelectionRange", originSelectionRange.value()); return *this; } auto LocationLink::targetUri(std::string targetUri) -> LocationLink& { + repr_->emplace("targetUri", std::move(targetUri)); return *this; } auto LocationLink::targetRange(Range targetRange) -> LocationLink& { + repr_->emplace("targetRange", targetRange); return *this; } auto LocationLink::targetSelectionRange(Range targetSelectionRange) -> LocationLink& { + repr_->emplace("targetSelectionRange", targetSelectionRange); return *this; } Range::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("start")) return false; - if (!repr_.contains("end")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("start")) return false; + if (!repr_->contains("end")) return false; return true; } auto Range::start() const -> Position { - const auto& value = repr_["start"]; + auto& value = (*repr_)["start"]; return Position(value); } auto Range::end() const -> Position { - const auto& value = repr_["end"]; + auto& value = (*repr_)["end"]; return Position(value); } -auto Range::start(Position start) -> Range& { return *this; } +auto Range::start(Position start) -> Range& { + repr_->emplace("start", start); + return *this; +} -auto Range::end(Position end) -> Range& { return *this; } +auto Range::end(Position end) -> Range& { + repr_->emplace("end", end); + return *this; +} ImplementationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ImplementationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -7908,18 +10500,23 @@ auto ImplementationOptions::workDoneProgress() const -> std::optional { auto ImplementationOptions::workDoneProgress( std::optional workDoneProgress) -> ImplementationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } StaticRegistrationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto StaticRegistrationOptions::id() const -> std::optional { - if (!repr_.contains("id")) return std::nullopt; + if (!repr_->contains("id")) return std::nullopt; - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); @@ -7927,18 +10524,23 @@ auto StaticRegistrationOptions::id() const -> std::optional { auto StaticRegistrationOptions::id(std::optional id) -> StaticRegistrationOptions& { + if (!id.has_value()) { + repr_->erase("id"); + return *this; + } + repr_->emplace("id", std::move(id.value())); return *this; } TypeDefinitionOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TypeDefinitionOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -7946,25 +10548,30 @@ auto TypeDefinitionOptions::workDoneProgress() const -> std::optional { auto TypeDefinitionOptions::workDoneProgress( std::optional workDoneProgress) -> TypeDefinitionOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } WorkspaceFoldersChangeEvent::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("added")) return false; - if (!repr_.contains("removed")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("added")) return false; + if (!repr_->contains("removed")) return false; return true; } auto WorkspaceFoldersChangeEvent::added() const -> Vector { - const auto& value = repr_["added"]; + auto& value = (*repr_)["added"]; assert(value.is_array()); return Vector(value); } auto WorkspaceFoldersChangeEvent::removed() const -> Vector { - const auto& value = repr_["removed"]; + auto& value = (*repr_)["removed"]; assert(value.is_array()); return Vector(value); @@ -7972,32 +10579,34 @@ auto WorkspaceFoldersChangeEvent::removed() const -> Vector { auto WorkspaceFoldersChangeEvent::added(Vector added) -> WorkspaceFoldersChangeEvent& { + lsp_runtime_error("WorkspaceFoldersChangeEvent::added: not implement yet"); return *this; } auto WorkspaceFoldersChangeEvent::removed(Vector removed) -> WorkspaceFoldersChangeEvent& { + lsp_runtime_error("WorkspaceFoldersChangeEvent::removed: not implement yet"); return *this; } ConfigurationItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ConfigurationItem::scopeUri() const -> std::optional { - if (!repr_.contains("scopeUri")) return std::nullopt; + if (!repr_->contains("scopeUri")) return std::nullopt; - const auto& value = repr_["scopeUri"]; + auto& value = (*repr_)["scopeUri"]; assert(value.is_string()); return value.get(); } auto ConfigurationItem::section() const -> std::optional { - if (!repr_.contains("section")) return std::nullopt; + if (!repr_->contains("section")) return std::nullopt; - const auto& value = repr_["section"]; + auto& value = (*repr_)["section"]; assert(value.is_string()); return value.get(); @@ -8005,85 +10614,108 @@ auto ConfigurationItem::section() const -> std::optional { auto ConfigurationItem::scopeUri(std::optional scopeUri) -> ConfigurationItem& { + if (!scopeUri.has_value()) { + repr_->erase("scopeUri"); + return *this; + } + repr_->emplace("scopeUri", std::move(scopeUri.value())); return *this; } auto ConfigurationItem::section(std::optional section) -> ConfigurationItem& { + if (!section.has_value()) { + repr_->erase("section"); + return *this; + } + repr_->emplace("section", std::move(section.value())); return *this; } TextDocumentIdentifier::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto TextDocumentIdentifier::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto TextDocumentIdentifier::uri(std::string uri) -> TextDocumentIdentifier& { + repr_->emplace("uri", std::move(uri)); return *this; } Color::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("red")) return false; - if (!repr_.contains("green")) return false; - if (!repr_.contains("blue")) return false; - if (!repr_.contains("alpha")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("red")) return false; + if (!repr_->contains("green")) return false; + if (!repr_->contains("blue")) return false; + if (!repr_->contains("alpha")) return false; return true; } auto Color::red() const -> double { - const auto& value = repr_["red"]; + auto& value = (*repr_)["red"]; assert(value.is_number()); return value.get(); } auto Color::green() const -> double { - const auto& value = repr_["green"]; + auto& value = (*repr_)["green"]; assert(value.is_number()); return value.get(); } auto Color::blue() const -> double { - const auto& value = repr_["blue"]; + auto& value = (*repr_)["blue"]; assert(value.is_number()); return value.get(); } auto Color::alpha() const -> double { - const auto& value = repr_["alpha"]; + auto& value = (*repr_)["alpha"]; assert(value.is_number()); return value.get(); } -auto Color::red(double red) -> Color& { return *this; } +auto Color::red(double red) -> Color& { + repr_->emplace("red", std::move(red)); + return *this; +} -auto Color::green(double green) -> Color& { return *this; } +auto Color::green(double green) -> Color& { + repr_->emplace("green", std::move(green)); + return *this; +} -auto Color::blue(double blue) -> Color& { return *this; } +auto Color::blue(double blue) -> Color& { + repr_->emplace("blue", std::move(blue)); + return *this; +} -auto Color::alpha(double alpha) -> Color& { return *this; } +auto Color::alpha(double alpha) -> Color& { + repr_->emplace("alpha", std::move(alpha)); + return *this; +} DocumentColorOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentColorOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8091,18 +10723,23 @@ auto DocumentColorOptions::workDoneProgress() const -> std::optional { auto DocumentColorOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentColorOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } FoldingRangeOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FoldingRangeOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8110,18 +10747,23 @@ auto FoldingRangeOptions::workDoneProgress() const -> std::optional { auto FoldingRangeOptions::workDoneProgress(std::optional workDoneProgress) -> FoldingRangeOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DeclarationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DeclarationOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8129,43 +10771,54 @@ auto DeclarationOptions::workDoneProgress() const -> std::optional { auto DeclarationOptions::workDoneProgress(std::optional workDoneProgress) -> DeclarationOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } Position::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("line")) return false; - if (!repr_.contains("character")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("line")) return false; + if (!repr_->contains("character")) return false; return true; } auto Position::line() const -> long { - const auto& value = repr_["line"]; + auto& value = (*repr_)["line"]; assert(value.is_number_integer()); return value.get(); } auto Position::character() const -> long { - const auto& value = repr_["character"]; + auto& value = (*repr_)["character"]; assert(value.is_number_integer()); return value.get(); } -auto Position::line(long line) -> Position& { return *this; } +auto Position::line(long line) -> Position& { + repr_->emplace("line", std::move(line)); + return *this; +} -auto Position::character(long character) -> Position& { return *this; } +auto Position::character(long character) -> Position& { + repr_->emplace("character", std::move(character)); + return *this; +} SelectionRangeOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SelectionRangeOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8173,18 +10826,23 @@ auto SelectionRangeOptions::workDoneProgress() const -> std::optional { auto SelectionRangeOptions::workDoneProgress( std::optional workDoneProgress) -> SelectionRangeOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } CallHierarchyOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CallHierarchyOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8192,26 +10850,31 @@ auto CallHierarchyOptions::workDoneProgress() const -> std::optional { auto CallHierarchyOptions::workDoneProgress( std::optional workDoneProgress) -> CallHierarchyOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } SemanticTokensOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("legend")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("legend")) return false; return true; } auto SemanticTokensOptions::legend() const -> SemanticTokensLegend { - const auto& value = repr_["legend"]; + auto& value = (*repr_)["legend"]; return SemanticTokensLegend(value); } auto SemanticTokensOptions::range() const -> std::optional> { - if (!repr_.contains("range")) return std::nullopt; + if (!repr_->contains("range")) return std::nullopt; - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; std::variant result; @@ -8222,9 +10885,9 @@ auto SemanticTokensOptions::range() const auto SemanticTokensOptions::full() const -> std::optional< std::variant> { - if (!repr_.contains("full")) return std::nullopt; + if (!repr_->contains("full")) return std::nullopt; - const auto& value = repr_["full"]; + auto& value = (*repr_)["full"]; std::variant result; @@ -8234,9 +10897,9 @@ auto SemanticTokensOptions::full() const -> std::optional< } auto SemanticTokensOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8244,79 +10907,138 @@ auto SemanticTokensOptions::workDoneProgress() const -> std::optional { auto SemanticTokensOptions::legend(SemanticTokensLegend legend) -> SemanticTokensOptions& { + repr_->emplace("legend", legend); return *this; } auto SemanticTokensOptions::range( std::optional> range) -> SemanticTokensOptions& { + if (!range.has_value()) { + repr_->erase("range"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool range) { repr_->emplace("range", std::move(range)); } + + void operator()(json range) { + lsp_runtime_error("SemanticTokensOptions::range: not implement yet"); + } + } v{repr_}; + + std::visit(v, range.value()); + return *this; } auto SemanticTokensOptions::full( std::optional> full) -> SemanticTokensOptions& { + if (!full.has_value()) { + repr_->erase("full"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool full) { repr_->emplace("full", std::move(full)); } + + void operator()(SemanticTokensFullDelta full) { + repr_->emplace("full", full); + } + } v{repr_}; + + std::visit(v, full.value()); + return *this; } auto SemanticTokensOptions::workDoneProgress( std::optional workDoneProgress) -> SemanticTokensOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } SemanticTokensEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("start")) return false; - if (!repr_.contains("deleteCount")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("start")) return false; + if (!repr_->contains("deleteCount")) return false; return true; } auto SemanticTokensEdit::start() const -> long { - const auto& value = repr_["start"]; + auto& value = (*repr_)["start"]; assert(value.is_number_integer()); return value.get(); } auto SemanticTokensEdit::deleteCount() const -> long { - const auto& value = repr_["deleteCount"]; + auto& value = (*repr_)["deleteCount"]; assert(value.is_number_integer()); return value.get(); } auto SemanticTokensEdit::data() const -> std::optional> { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_array()); return Vector(value); } auto SemanticTokensEdit::start(long start) -> SemanticTokensEdit& { + repr_->emplace("start", std::move(start)); return *this; } auto SemanticTokensEdit::deleteCount(long deleteCount) -> SemanticTokensEdit& { + repr_->emplace("deleteCount", std::move(deleteCount)); return *this; } auto SemanticTokensEdit::data(std::optional> data) -> SemanticTokensEdit& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("SemanticTokensEdit::data: not implement yet"); return *this; } LinkedEditingRangeOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto LinkedEditingRangeOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8324,34 +11046,42 @@ auto LinkedEditingRangeOptions::workDoneProgress() const auto LinkedEditingRangeOptions::workDoneProgress( std::optional workDoneProgress) -> LinkedEditingRangeOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } FileCreate::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto FileCreate::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } -auto FileCreate::uri(std::string uri) -> FileCreate& { return *this; } +auto FileCreate::uri(std::string uri) -> FileCreate& { + repr_->emplace("uri", std::move(uri)); + return *this; +} TextDocumentEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("textDocument")) return false; - if (!repr_.contains("edits")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("textDocument")) return false; + if (!repr_->contains("edits")) return false; return true; } auto TextDocumentEdit::textDocument() const -> OptionalVersionedTextDocumentIdentifier { - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return OptionalVersionedTextDocumentIdentifier(value); } @@ -8359,7 +11089,7 @@ auto TextDocumentEdit::textDocument() const auto TextDocumentEdit::edits() const -> Vector> { - const auto& value = repr_["edits"]; + auto& value = (*repr_)["edits"]; assert(value.is_array()); return Vector TextDocumentEdit& { + repr_->emplace("textDocument", textDocument); return *this; } @@ -8375,306 +11106,384 @@ auto TextDocumentEdit::edits( Vector> edits) -> TextDocumentEdit& { + lsp_runtime_error("TextDocumentEdit::edits: not implement yet"); return *this; } CreateFile::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "create") return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "create") return false; + if (!repr_->contains("uri")) return false; return true; } auto CreateFile::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto CreateFile::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto CreateFile::options() const -> std::optional { - if (!repr_.contains("options")) return std::nullopt; + if (!repr_->contains("options")) return std::nullopt; - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return CreateFileOptions(value); } auto CreateFile::annotationId() const -> std::optional { - if (!repr_.contains("annotationId")) return std::nullopt; + if (!repr_->contains("annotationId")) return std::nullopt; - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } -auto CreateFile::kind(std::string kind) -> CreateFile& { return *this; } +auto CreateFile::kind(std::string kind) -> CreateFile& { + lsp_runtime_error("CreateFile::kind: not implement yet"); + return *this; +} -auto CreateFile::uri(std::string uri) -> CreateFile& { return *this; } +auto CreateFile::uri(std::string uri) -> CreateFile& { + repr_->emplace("uri", std::move(uri)); + return *this; +} auto CreateFile::options(std::optional options) -> CreateFile& { + if (!options.has_value()) { + repr_->erase("options"); + return *this; + } + repr_->emplace("options", options.value()); return *this; } auto CreateFile::annotationId( std::optional annotationId) -> CreateFile& { + if (!annotationId.has_value()) { + repr_->erase("annotationId"); + return *this; + } + lsp_runtime_error("CreateFile::annotationId: not implement yet"); return *this; } RenameFile::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "rename") return false; - if (!repr_.contains("oldUri")) return false; - if (!repr_.contains("newUri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "rename") return false; + if (!repr_->contains("oldUri")) return false; + if (!repr_->contains("newUri")) return false; return true; } auto RenameFile::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto RenameFile::oldUri() const -> std::string { - const auto& value = repr_["oldUri"]; + auto& value = (*repr_)["oldUri"]; assert(value.is_string()); return value.get(); } auto RenameFile::newUri() const -> std::string { - const auto& value = repr_["newUri"]; + auto& value = (*repr_)["newUri"]; assert(value.is_string()); return value.get(); } auto RenameFile::options() const -> std::optional { - if (!repr_.contains("options")) return std::nullopt; + if (!repr_->contains("options")) return std::nullopt; - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return RenameFileOptions(value); } auto RenameFile::annotationId() const -> std::optional { - if (!repr_.contains("annotationId")) return std::nullopt; + if (!repr_->contains("annotationId")) return std::nullopt; - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } -auto RenameFile::kind(std::string kind) -> RenameFile& { return *this; } +auto RenameFile::kind(std::string kind) -> RenameFile& { + lsp_runtime_error("RenameFile::kind: not implement yet"); + return *this; +} -auto RenameFile::oldUri(std::string oldUri) -> RenameFile& { return *this; } +auto RenameFile::oldUri(std::string oldUri) -> RenameFile& { + repr_->emplace("oldUri", std::move(oldUri)); + return *this; +} -auto RenameFile::newUri(std::string newUri) -> RenameFile& { return *this; } +auto RenameFile::newUri(std::string newUri) -> RenameFile& { + repr_->emplace("newUri", std::move(newUri)); + return *this; +} auto RenameFile::options(std::optional options) -> RenameFile& { + if (!options.has_value()) { + repr_->erase("options"); + return *this; + } + repr_->emplace("options", options.value()); return *this; } auto RenameFile::annotationId( std::optional annotationId) -> RenameFile& { + if (!annotationId.has_value()) { + repr_->erase("annotationId"); + return *this; + } + lsp_runtime_error("RenameFile::annotationId: not implement yet"); return *this; } DeleteFile::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "delete") return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "delete") return false; + if (!repr_->contains("uri")) return false; return true; } auto DeleteFile::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto DeleteFile::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto DeleteFile::options() const -> std::optional { - if (!repr_.contains("options")) return std::nullopt; + if (!repr_->contains("options")) return std::nullopt; - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return DeleteFileOptions(value); } auto DeleteFile::annotationId() const -> std::optional { - if (!repr_.contains("annotationId")) return std::nullopt; + if (!repr_->contains("annotationId")) return std::nullopt; - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } -auto DeleteFile::kind(std::string kind) -> DeleteFile& { return *this; } +auto DeleteFile::kind(std::string kind) -> DeleteFile& { + lsp_runtime_error("DeleteFile::kind: not implement yet"); + return *this; +} -auto DeleteFile::uri(std::string uri) -> DeleteFile& { return *this; } +auto DeleteFile::uri(std::string uri) -> DeleteFile& { + repr_->emplace("uri", std::move(uri)); + return *this; +} auto DeleteFile::options(std::optional options) -> DeleteFile& { + if (!options.has_value()) { + repr_->erase("options"); + return *this; + } + repr_->emplace("options", options.value()); return *this; } auto DeleteFile::annotationId( std::optional annotationId) -> DeleteFile& { + if (!annotationId.has_value()) { + repr_->erase("annotationId"); + return *this; + } + lsp_runtime_error("DeleteFile::annotationId: not implement yet"); return *this; } ChangeAnnotation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("label")) return false; return true; } auto ChangeAnnotation::label() const -> std::string { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); } auto ChangeAnnotation::needsConfirmation() const -> std::optional { - if (!repr_.contains("needsConfirmation")) return std::nullopt; + if (!repr_->contains("needsConfirmation")) return std::nullopt; - const auto& value = repr_["needsConfirmation"]; + auto& value = (*repr_)["needsConfirmation"]; assert(value.is_boolean()); return value.get(); } auto ChangeAnnotation::description() const -> std::optional { - if (!repr_.contains("description")) return std::nullopt; + if (!repr_->contains("description")) return std::nullopt; - const auto& value = repr_["description"]; + auto& value = (*repr_)["description"]; assert(value.is_string()); return value.get(); } auto ChangeAnnotation::label(std::string label) -> ChangeAnnotation& { + repr_->emplace("label", std::move(label)); return *this; } auto ChangeAnnotation::needsConfirmation(std::optional needsConfirmation) -> ChangeAnnotation& { + if (!needsConfirmation.has_value()) { + repr_->erase("needsConfirmation"); + return *this; + } + repr_->emplace("needsConfirmation", std::move(needsConfirmation.value())); return *this; } auto ChangeAnnotation::description(std::optional description) -> ChangeAnnotation& { + if (!description.has_value()) { + repr_->erase("description"); + return *this; + } + repr_->emplace("description", std::move(description.value())); return *this; } FileOperationFilter::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("pattern")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("pattern")) return false; return true; } auto FileOperationFilter::scheme() const -> std::optional { - if (!repr_.contains("scheme")) return std::nullopt; + if (!repr_->contains("scheme")) return std::nullopt; - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto FileOperationFilter::pattern() const -> FileOperationPattern { - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; return FileOperationPattern(value); } auto FileOperationFilter::scheme(std::optional scheme) -> FileOperationFilter& { + if (!scheme.has_value()) { + repr_->erase("scheme"); + return *this; + } + repr_->emplace("scheme", std::move(scheme.value())); return *this; } auto FileOperationFilter::pattern(FileOperationPattern pattern) -> FileOperationFilter& { + repr_->emplace("pattern", pattern); return *this; } FileRename::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("oldUri")) return false; - if (!repr_.contains("newUri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("oldUri")) return false; + if (!repr_->contains("newUri")) return false; return true; } auto FileRename::oldUri() const -> std::string { - const auto& value = repr_["oldUri"]; + auto& value = (*repr_)["oldUri"]; assert(value.is_string()); return value.get(); } auto FileRename::newUri() const -> std::string { - const auto& value = repr_["newUri"]; + auto& value = (*repr_)["newUri"]; assert(value.is_string()); return value.get(); } -auto FileRename::oldUri(std::string oldUri) -> FileRename& { return *this; } +auto FileRename::oldUri(std::string oldUri) -> FileRename& { + repr_->emplace("oldUri", std::move(oldUri)); + return *this; +} -auto FileRename::newUri(std::string newUri) -> FileRename& { return *this; } +auto FileRename::newUri(std::string newUri) -> FileRename& { + repr_->emplace("newUri", std::move(newUri)); + return *this; +} FileDelete::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto FileDelete::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } -auto FileDelete::uri(std::string uri) -> FileDelete& { return *this; } +auto FileDelete::uri(std::string uri) -> FileDelete& { + repr_->emplace("uri", std::move(uri)); + return *this; +} MonikerOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto MonikerOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8682,18 +11491,23 @@ auto MonikerOptions::workDoneProgress() const -> std::optional { auto MonikerOptions::workDoneProgress(std::optional workDoneProgress) -> MonikerOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } TypeHierarchyOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TypeHierarchyOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8701,89 +11515,100 @@ auto TypeHierarchyOptions::workDoneProgress() const -> std::optional { auto TypeHierarchyOptions::workDoneProgress( std::optional workDoneProgress) -> TypeHierarchyOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } InlineValueContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("frameId")) return false; - if (!repr_.contains("stoppedLocation")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("frameId")) return false; + if (!repr_->contains("stoppedLocation")) return false; return true; } auto InlineValueContext::frameId() const -> int { - const auto& value = repr_["frameId"]; + auto& value = (*repr_)["frameId"]; assert(value.is_number_integer()); return value.get(); } auto InlineValueContext::stoppedLocation() const -> Range { - const auto& value = repr_["stoppedLocation"]; + auto& value = (*repr_)["stoppedLocation"]; return Range(value); } auto InlineValueContext::frameId(int frameId) -> InlineValueContext& { + repr_->emplace("frameId", std::move(frameId)); return *this; } auto InlineValueContext::stoppedLocation(Range stoppedLocation) -> InlineValueContext& { + repr_->emplace("stoppedLocation", stoppedLocation); return *this; } InlineValueText::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("text")) return false; return true; } auto InlineValueText::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlineValueText::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); } -auto InlineValueText::range(Range range) -> InlineValueText& { return *this; } +auto InlineValueText::range(Range range) -> InlineValueText& { + repr_->emplace("range", range); + return *this; +} auto InlineValueText::text(std::string text) -> InlineValueText& { + repr_->emplace("text", std::move(text)); return *this; } InlineValueVariableLookup::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("caseSensitiveLookup")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("caseSensitiveLookup")) return false; return true; } auto InlineValueVariableLookup::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlineValueVariableLookup::variableName() const -> std::optional { - if (!repr_.contains("variableName")) return std::nullopt; + if (!repr_->contains("variableName")) return std::nullopt; - const auto& value = repr_["variableName"]; + auto& value = (*repr_)["variableName"]; assert(value.is_string()); return value.get(); } auto InlineValueVariableLookup::caseSensitiveLookup() const -> bool { - const auto& value = repr_["caseSensitiveLookup"]; + auto& value = (*repr_)["caseSensitiveLookup"]; assert(value.is_boolean()); return value.get(); @@ -8791,36 +11616,43 @@ auto InlineValueVariableLookup::caseSensitiveLookup() const -> bool { auto InlineValueVariableLookup::range(Range range) -> InlineValueVariableLookup& { + repr_->emplace("range", range); return *this; } auto InlineValueVariableLookup::variableName( std::optional variableName) -> InlineValueVariableLookup& { + if (!variableName.has_value()) { + repr_->erase("variableName"); + return *this; + } + repr_->emplace("variableName", std::move(variableName.value())); return *this; } auto InlineValueVariableLookup::caseSensitiveLookup(bool caseSensitiveLookup) -> InlineValueVariableLookup& { + repr_->emplace("caseSensitiveLookup", std::move(caseSensitiveLookup)); return *this; } InlineValueEvaluatableExpression::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; return true; } auto InlineValueEvaluatableExpression::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto InlineValueEvaluatableExpression::expression() const -> std::optional { - if (!repr_.contains("expression")) return std::nullopt; + if (!repr_->contains("expression")) return std::nullopt; - const auto& value = repr_["expression"]; + auto& value = (*repr_)["expression"]; assert(value.is_string()); return value.get(); @@ -8828,24 +11660,30 @@ auto InlineValueEvaluatableExpression::expression() const auto InlineValueEvaluatableExpression::range(Range range) -> InlineValueEvaluatableExpression& { + repr_->emplace("range", range); return *this; } auto InlineValueEvaluatableExpression::expression( std::optional expression) -> InlineValueEvaluatableExpression& { + if (!expression.has_value()) { + repr_->erase("expression"); + return *this; + } + repr_->emplace("expression", std::move(expression.value())); return *this; } InlineValueOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlineValueOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8853,17 +11691,22 @@ auto InlineValueOptions::workDoneProgress() const -> std::optional { auto InlineValueOptions::workDoneProgress(std::optional workDoneProgress) -> InlineValueOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } InlayHintLabelPart::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("value")) return false; return true; } auto InlayHintLabelPart::value() const -> std::string { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_string()); return value.get(); @@ -8871,9 +11714,9 @@ auto InlayHintLabelPart::value() const -> std::string { auto InlayHintLabelPart::tooltip() const -> std::optional> { - if (!repr_.contains("tooltip")) return std::nullopt; + if (!repr_->contains("tooltip")) return std::nullopt; - const auto& value = repr_["tooltip"]; + auto& value = (*repr_)["tooltip"]; std::variant result; @@ -8883,83 +11726,125 @@ auto InlayHintLabelPart::tooltip() const } auto InlayHintLabelPart::location() const -> std::optional { - if (!repr_.contains("location")) return std::nullopt; + if (!repr_->contains("location")) return std::nullopt; - const auto& value = repr_["location"]; + auto& value = (*repr_)["location"]; return Location(value); } auto InlayHintLabelPart::command() const -> std::optional { - if (!repr_.contains("command")) return std::nullopt; + if (!repr_->contains("command")) return std::nullopt; - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } auto InlayHintLabelPart::value(std::string value) -> InlayHintLabelPart& { + repr_->emplace("value", std::move(value)); return *this; } auto InlayHintLabelPart::tooltip( std::optional> tooltip) -> InlayHintLabelPart& { + if (!tooltip.has_value()) { + repr_->erase("tooltip"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string tooltip) { + repr_->emplace("tooltip", std::move(tooltip)); + } + + void operator()(MarkupContent tooltip) { + repr_->emplace("tooltip", tooltip); + } + } v{repr_}; + + std::visit(v, tooltip.value()); + return *this; } auto InlayHintLabelPart::location(std::optional location) -> InlayHintLabelPart& { + if (!location.has_value()) { + repr_->erase("location"); + return *this; + } + repr_->emplace("location", location.value()); return *this; } auto InlayHintLabelPart::command(std::optional command) -> InlayHintLabelPart& { + if (!command.has_value()) { + repr_->erase("command"); + return *this; + } + repr_->emplace("command", command.value()); return *this; } MarkupContent::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("value")) return false; return true; } auto MarkupContent::kind() const -> MarkupKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; lsp_runtime_error("MarkupContent::kind: not implement yet"); } auto MarkupContent::value() const -> std::string { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_string()); return value.get(); } -auto MarkupContent::kind(MarkupKind kind) -> MarkupContent& { return *this; } +auto MarkupContent::kind(MarkupKind kind) -> MarkupContent& { + lsp_runtime_error("MarkupContent::kind: not implement yet"); + return *this; +} -auto MarkupContent::value(std::string value) -> MarkupContent& { return *this; } +auto MarkupContent::value(std::string value) -> MarkupContent& { + repr_->emplace("value", std::move(value)); + return *this; +} InlayHintOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlayHintOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); } auto InlayHintOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -8967,19 +11852,29 @@ auto InlayHintOptions::workDoneProgress() const -> std::optional { auto InlayHintOptions::resolveProvider(std::optional resolveProvider) -> InlayHintOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto InlayHintOptions::workDoneProgress(std::optional workDoneProgress) -> InlayHintOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } RelatedFullDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "full") return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "full") return false; + if (!repr_->contains("items")) return false; return true; } @@ -8987,9 +11882,9 @@ auto RelatedFullDocumentDiagnosticReport::relatedDocuments() const -> std::optional>> { - if (!repr_.contains("relatedDocuments")) return std::nullopt; + if (!repr_->contains("relatedDocuments")) return std::nullopt; - const auto& value = repr_["relatedDocuments"]; + auto& value = (*repr_)["relatedDocuments"]; assert(value.is_object()); return Map std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); @@ -9006,16 +11901,16 @@ auto RelatedFullDocumentDiagnosticReport::kind() const -> std::string { auto RelatedFullDocumentDiagnosticReport::resultId() const -> std::optional { - if (!repr_.contains("resultId")) return std::nullopt; + if (!repr_->contains("resultId")) return std::nullopt; - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); } auto RelatedFullDocumentDiagnosticReport::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -9026,30 +11921,46 @@ auto RelatedFullDocumentDiagnosticReport::relatedDocuments( std::variant>> relatedDocuments) -> RelatedFullDocumentDiagnosticReport& { + if (!relatedDocuments.has_value()) { + repr_->erase("relatedDocuments"); + return *this; + } + lsp_runtime_error( + "RelatedFullDocumentDiagnosticReport::relatedDocuments: not implement " + "yet"); return *this; } auto RelatedFullDocumentDiagnosticReport::kind(std::string kind) -> RelatedFullDocumentDiagnosticReport& { + lsp_runtime_error( + "RelatedFullDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto RelatedFullDocumentDiagnosticReport::resultId( std::optional resultId) -> RelatedFullDocumentDiagnosticReport& { + if (!resultId.has_value()) { + repr_->erase("resultId"); + return *this; + } + repr_->emplace("resultId", std::move(resultId.value())); return *this; } auto RelatedFullDocumentDiagnosticReport::items(Vector items) -> RelatedFullDocumentDiagnosticReport& { + lsp_runtime_error( + "RelatedFullDocumentDiagnosticReport::items: not implement yet"); return *this; } RelatedUnchangedDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "unchanged") return false; - if (!repr_.contains("resultId")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "unchanged") return false; + if (!repr_->contains("resultId")) return false; return true; } @@ -9057,9 +11968,9 @@ auto RelatedUnchangedDocumentDiagnosticReport::relatedDocuments() const -> std::optional>> { - if (!repr_.contains("relatedDocuments")) return std::nullopt; + if (!repr_->contains("relatedDocuments")) return std::nullopt; - const auto& value = repr_["relatedDocuments"]; + auto& value = (*repr_)["relatedDocuments"]; assert(value.is_object()); return Map std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto RelatedUnchangedDocumentDiagnosticReport::resultId() const -> std::string { - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); @@ -9086,29 +11997,39 @@ auto RelatedUnchangedDocumentDiagnosticReport::relatedDocuments( std::variant>> relatedDocuments) -> RelatedUnchangedDocumentDiagnosticReport& { + if (!relatedDocuments.has_value()) { + repr_->erase("relatedDocuments"); + return *this; + } + lsp_runtime_error( + "RelatedUnchangedDocumentDiagnosticReport::relatedDocuments: not " + "implement yet"); return *this; } auto RelatedUnchangedDocumentDiagnosticReport::kind(std::string kind) -> RelatedUnchangedDocumentDiagnosticReport& { + lsp_runtime_error( + "RelatedUnchangedDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto RelatedUnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> RelatedUnchangedDocumentDiagnosticReport& { + repr_->emplace("resultId", std::move(resultId)); return *this; } FullDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "full") return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "full") return false; + if (!repr_->contains("items")) return false; return true; } auto FullDocumentDiagnosticReport::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); @@ -9116,16 +12037,16 @@ auto FullDocumentDiagnosticReport::kind() const -> std::string { auto FullDocumentDiagnosticReport::resultId() const -> std::optional { - if (!repr_.contains("resultId")) return std::nullopt; + if (!repr_->contains("resultId")) return std::nullopt; - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); } auto FullDocumentDiagnosticReport::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -9133,36 +12054,43 @@ auto FullDocumentDiagnosticReport::items() const -> Vector { auto FullDocumentDiagnosticReport::kind(std::string kind) -> FullDocumentDiagnosticReport& { + lsp_runtime_error("FullDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto FullDocumentDiagnosticReport::resultId(std::optional resultId) -> FullDocumentDiagnosticReport& { + if (!resultId.has_value()) { + repr_->erase("resultId"); + return *this; + } + repr_->emplace("resultId", std::move(resultId.value())); return *this; } auto FullDocumentDiagnosticReport::items(Vector items) -> FullDocumentDiagnosticReport& { + lsp_runtime_error("FullDocumentDiagnosticReport::items: not implement yet"); return *this; } UnchangedDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "unchanged") return false; - if (!repr_.contains("resultId")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "unchanged") return false; + if (!repr_->contains("resultId")) return false; return true; } auto UnchangedDocumentDiagnosticReport::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto UnchangedDocumentDiagnosticReport::resultId() const -> std::string { - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); @@ -9170,48 +12098,51 @@ auto UnchangedDocumentDiagnosticReport::resultId() const -> std::string { auto UnchangedDocumentDiagnosticReport::kind(std::string kind) -> UnchangedDocumentDiagnosticReport& { + lsp_runtime_error( + "UnchangedDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto UnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> UnchangedDocumentDiagnosticReport& { + repr_->emplace("resultId", std::move(resultId)); return *this; } DiagnosticOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("interFileDependencies")) return false; - if (!repr_.contains("workspaceDiagnostics")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("interFileDependencies")) return false; + if (!repr_->contains("workspaceDiagnostics")) return false; return true; } auto DiagnosticOptions::identifier() const -> std::optional { - if (!repr_.contains("identifier")) return std::nullopt; + if (!repr_->contains("identifier")) return std::nullopt; - const auto& value = repr_["identifier"]; + auto& value = (*repr_)["identifier"]; assert(value.is_string()); return value.get(); } auto DiagnosticOptions::interFileDependencies() const -> bool { - const auto& value = repr_["interFileDependencies"]; + auto& value = (*repr_)["interFileDependencies"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticOptions::workspaceDiagnostics() const -> bool { - const auto& value = repr_["workspaceDiagnostics"]; + auto& value = (*repr_)["workspaceDiagnostics"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -9219,184 +12150,211 @@ auto DiagnosticOptions::workDoneProgress() const -> std::optional { auto DiagnosticOptions::identifier(std::optional identifier) -> DiagnosticOptions& { + if (!identifier.has_value()) { + repr_->erase("identifier"); + return *this; + } + repr_->emplace("identifier", std::move(identifier.value())); return *this; } auto DiagnosticOptions::interFileDependencies(bool interFileDependencies) -> DiagnosticOptions& { + repr_->emplace("interFileDependencies", std::move(interFileDependencies)); return *this; } auto DiagnosticOptions::workspaceDiagnostics(bool workspaceDiagnostics) -> DiagnosticOptions& { + repr_->emplace("workspaceDiagnostics", std::move(workspaceDiagnostics)); return *this; } auto DiagnosticOptions::workDoneProgress(std::optional workDoneProgress) -> DiagnosticOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } PreviousResultId::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("value")) return false; return true; } auto PreviousResultId::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto PreviousResultId::value() const -> std::string { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_string()); return value.get(); } auto PreviousResultId::uri(std::string uri) -> PreviousResultId& { + repr_->emplace("uri", std::move(uri)); return *this; } auto PreviousResultId::value(std::string value) -> PreviousResultId& { + repr_->emplace("value", std::move(value)); return *this; } NotebookDocument::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("notebookType")) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("cells")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("notebookType")) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("cells")) return false; return true; } auto NotebookDocument::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto NotebookDocument::notebookType() const -> std::string { - const auto& value = repr_["notebookType"]; + auto& value = (*repr_)["notebookType"]; assert(value.is_string()); return value.get(); } auto NotebookDocument::version() const -> int { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_number_integer()); return value.get(); } auto NotebookDocument::metadata() const -> std::optional { - if (!repr_.contains("metadata")) return std::nullopt; + if (!repr_->contains("metadata")) return std::nullopt; - const auto& value = repr_["metadata"]; + auto& value = (*repr_)["metadata"]; assert(value.is_object()); return LSPObject(value); } auto NotebookDocument::cells() const -> Vector { - const auto& value = repr_["cells"]; + auto& value = (*repr_)["cells"]; assert(value.is_array()); return Vector(value); } auto NotebookDocument::uri(std::string uri) -> NotebookDocument& { + repr_->emplace("uri", std::move(uri)); return *this; } auto NotebookDocument::notebookType(std::string notebookType) -> NotebookDocument& { + repr_->emplace("notebookType", std::move(notebookType)); return *this; } auto NotebookDocument::version(int version) -> NotebookDocument& { + repr_->emplace("version", std::move(version)); return *this; } auto NotebookDocument::metadata(std::optional metadata) -> NotebookDocument& { + if (!metadata.has_value()) { + repr_->erase("metadata"); + return *this; + } + lsp_runtime_error("NotebookDocument::metadata: not implement yet"); return *this; } auto NotebookDocument::cells(Vector cells) -> NotebookDocument& { + lsp_runtime_error("NotebookDocument::cells: not implement yet"); return *this; } TextDocumentItem::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("languageId")) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("languageId")) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("text")) return false; return true; } auto TextDocumentItem::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto TextDocumentItem::languageId() const -> LanguageKind { - const auto& value = repr_["languageId"]; + auto& value = (*repr_)["languageId"]; lsp_runtime_error("TextDocumentItem::languageId: not implement yet"); } auto TextDocumentItem::version() const -> int { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_number_integer()); return value.get(); } auto TextDocumentItem::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); } auto TextDocumentItem::uri(std::string uri) -> TextDocumentItem& { + repr_->emplace("uri", std::move(uri)); return *this; } auto TextDocumentItem::languageId(LanguageKind languageId) -> TextDocumentItem& { + lsp_runtime_error("TextDocumentItem::languageId: not implement yet"); return *this; } auto TextDocumentItem::version(int version) -> TextDocumentItem& { + repr_->emplace("version", std::move(version)); return *this; } auto TextDocumentItem::text(std::string text) -> TextDocumentItem& { + repr_->emplace("text", std::move(text)); return *this; } NotebookDocumentSyncOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookSelector")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookSelector")) return false; return true; } auto NotebookDocumentSyncOptions::notebookSelector() const -> Vector> { - const auto& value = repr_["notebookSelector"]; + auto& value = (*repr_)["notebookSelector"]; assert(value.is_array()); return Vector std::optional { - if (!repr_.contains("save")) return std::nullopt; + if (!repr_->contains("save")) return std::nullopt; - const auto& value = repr_["save"]; + auto& value = (*repr_)["save"]; assert(value.is_boolean()); return value.get(); @@ -9416,30 +12374,37 @@ auto NotebookDocumentSyncOptions::notebookSelector( Vector> notebookSelector) -> NotebookDocumentSyncOptions& { + lsp_runtime_error( + "NotebookDocumentSyncOptions::notebookSelector: not implement yet"); return *this; } auto NotebookDocumentSyncOptions::save(std::optional save) -> NotebookDocumentSyncOptions& { + if (!save.has_value()) { + repr_->erase("save"); + return *this; + } + repr_->emplace("save", std::move(save.value())); return *this; } VersionedNotebookDocumentIdentifier::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("uri")) return false; return true; } auto VersionedNotebookDocumentIdentifier::version() const -> int { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_number_integer()); return value.get(); } auto VersionedNotebookDocumentIdentifier::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -9447,23 +12412,25 @@ auto VersionedNotebookDocumentIdentifier::uri() const -> std::string { auto VersionedNotebookDocumentIdentifier::version(int version) -> VersionedNotebookDocumentIdentifier& { + repr_->emplace("version", std::move(version)); return *this; } auto VersionedNotebookDocumentIdentifier::uri(std::string uri) -> VersionedNotebookDocumentIdentifier& { + repr_->emplace("uri", std::move(uri)); return *this; } NotebookDocumentChangeEvent::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto NotebookDocumentChangeEvent::metadata() const -> std::optional { - if (!repr_.contains("metadata")) return std::nullopt; + if (!repr_->contains("metadata")) return std::nullopt; - const auto& value = repr_["metadata"]; + auto& value = (*repr_)["metadata"]; assert(value.is_object()); return LSPObject(value); @@ -9471,32 +12438,42 @@ auto NotebookDocumentChangeEvent::metadata() const -> std::optional { auto NotebookDocumentChangeEvent::cells() const -> std::optional { - if (!repr_.contains("cells")) return std::nullopt; + if (!repr_->contains("cells")) return std::nullopt; - const auto& value = repr_["cells"]; + auto& value = (*repr_)["cells"]; return NotebookDocumentCellChanges(value); } auto NotebookDocumentChangeEvent::metadata(std::optional metadata) -> NotebookDocumentChangeEvent& { + if (!metadata.has_value()) { + repr_->erase("metadata"); + return *this; + } + lsp_runtime_error("NotebookDocumentChangeEvent::metadata: not implement yet"); return *this; } auto NotebookDocumentChangeEvent::cells( std::optional cells) -> NotebookDocumentChangeEvent& { + if (!cells.has_value()) { + repr_->erase("cells"); + return *this; + } + repr_->emplace("cells", cells.value()); return *this; } NotebookDocumentIdentifier::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto NotebookDocumentIdentifier::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -9504,77 +12481,90 @@ auto NotebookDocumentIdentifier::uri() const -> std::string { auto NotebookDocumentIdentifier::uri(std::string uri) -> NotebookDocumentIdentifier& { + repr_->emplace("uri", std::move(uri)); return *this; } InlineCompletionContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("triggerKind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("triggerKind")) return false; return true; } auto InlineCompletionContext::triggerKind() const -> InlineCompletionTriggerKind { - const auto& value = repr_["triggerKind"]; + auto& value = (*repr_)["triggerKind"]; return InlineCompletionTriggerKind(value); } auto InlineCompletionContext::selectedCompletionInfo() const -> std::optional { - if (!repr_.contains("selectedCompletionInfo")) return std::nullopt; + if (!repr_->contains("selectedCompletionInfo")) return std::nullopt; - const auto& value = repr_["selectedCompletionInfo"]; + auto& value = (*repr_)["selectedCompletionInfo"]; return SelectedCompletionInfo(value); } auto InlineCompletionContext::triggerKind( InlineCompletionTriggerKind triggerKind) -> InlineCompletionContext& { + repr_->emplace("triggerKind", static_cast(triggerKind)); return *this; } auto InlineCompletionContext::selectedCompletionInfo( std::optional selectedCompletionInfo) -> InlineCompletionContext& { + if (!selectedCompletionInfo.has_value()) { + repr_->erase("selectedCompletionInfo"); + return *this; + } + repr_->emplace("selectedCompletionInfo", selectedCompletionInfo.value()); return *this; } StringValue::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "snippet") return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "snippet") return false; + if (!repr_->contains("value")) return false; return true; } auto StringValue::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); } auto StringValue::value() const -> std::string { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_string()); return value.get(); } -auto StringValue::kind(std::string kind) -> StringValue& { return *this; } +auto StringValue::kind(std::string kind) -> StringValue& { + lsp_runtime_error("StringValue::kind: not implement yet"); + return *this; +} -auto StringValue::value(std::string value) -> StringValue& { return *this; } +auto StringValue::value(std::string value) -> StringValue& { + repr_->emplace("value", std::move(value)); + return *this; +} InlineCompletionOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlineCompletionOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -9582,17 +12572,22 @@ auto InlineCompletionOptions::workDoneProgress() const -> std::optional { auto InlineCompletionOptions::workDoneProgress( std::optional workDoneProgress) -> InlineCompletionOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } TextDocumentContentOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("schemes")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("schemes")) return false; return true; } auto TextDocumentContentOptions::schemes() const -> Vector { - const auto& value = repr_["schemes"]; + auto& value = (*repr_)["schemes"]; assert(value.is_array()); return Vector(value); @@ -9600,86 +12595,102 @@ auto TextDocumentContentOptions::schemes() const -> Vector { auto TextDocumentContentOptions::schemes(Vector schemes) -> TextDocumentContentOptions& { + lsp_runtime_error("TextDocumentContentOptions::schemes: not implement yet"); return *this; } Registration::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("id")) return false; - if (!repr_.contains("method")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("id")) return false; + if (!repr_->contains("method")) return false; return true; } auto Registration::id() const -> std::string { - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); } auto Registration::method() const -> std::string { - const auto& value = repr_["method"]; + auto& value = (*repr_)["method"]; assert(value.is_string()); return value.get(); } auto Registration::registerOptions() const -> std::optional { - if (!repr_.contains("registerOptions")) return std::nullopt; + if (!repr_->contains("registerOptions")) return std::nullopt; - const auto& value = repr_["registerOptions"]; + auto& value = (*repr_)["registerOptions"]; assert(value.is_object()); return LSPAny(value); } -auto Registration::id(std::string id) -> Registration& { return *this; } +auto Registration::id(std::string id) -> Registration& { + repr_->emplace("id", std::move(id)); + return *this; +} -auto Registration::method(std::string method) -> Registration& { return *this; } +auto Registration::method(std::string method) -> Registration& { + repr_->emplace("method", std::move(method)); + return *this; +} auto Registration::registerOptions(std::optional registerOptions) -> Registration& { + if (!registerOptions.has_value()) { + repr_->erase("registerOptions"); + return *this; + } + lsp_runtime_error("Registration::registerOptions: not implement yet"); return *this; } Unregistration::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("id")) return false; - if (!repr_.contains("method")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("id")) return false; + if (!repr_->contains("method")) return false; return true; } auto Unregistration::id() const -> std::string { - const auto& value = repr_["id"]; + auto& value = (*repr_)["id"]; assert(value.is_string()); return value.get(); } auto Unregistration::method() const -> std::string { - const auto& value = repr_["method"]; + auto& value = (*repr_)["method"]; assert(value.is_string()); return value.get(); } -auto Unregistration::id(std::string id) -> Unregistration& { return *this; } +auto Unregistration::id(std::string id) -> Unregistration& { + repr_->emplace("id", std::move(id)); + return *this; +} auto Unregistration::method(std::string method) -> Unregistration& { + repr_->emplace("method", std::move(method)); return *this; } _InitializeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("processId")) return false; - if (!repr_.contains("rootUri")) return false; - if (!repr_.contains("capabilities")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("processId")) return false; + if (!repr_->contains("rootUri")) return false; + if (!repr_->contains("capabilities")) return false; return true; } auto _InitializeParams::processId() const -> std::variant { - const auto& value = repr_["processId"]; + auto& value = (*repr_)["processId"]; std::variant result; @@ -9689,17 +12700,17 @@ auto _InitializeParams::processId() const } auto _InitializeParams::clientInfo() const -> std::optional { - if (!repr_.contains("clientInfo")) return std::nullopt; + if (!repr_->contains("clientInfo")) return std::nullopt; - const auto& value = repr_["clientInfo"]; + auto& value = (*repr_)["clientInfo"]; return ClientInfo(value); } auto _InitializeParams::locale() const -> std::optional { - if (!repr_.contains("locale")) return std::nullopt; + if (!repr_->contains("locale")) return std::nullopt; - const auto& value = repr_["locale"]; + auto& value = (*repr_)["locale"]; assert(value.is_string()); return value.get(); @@ -9707,9 +12718,9 @@ auto _InitializeParams::locale() const -> std::optional { auto _InitializeParams::rootPath() const -> std::optional< std::variant> { - if (!repr_.contains("rootPath")) return std::nullopt; + if (!repr_->contains("rootPath")) return std::nullopt; - const auto& value = repr_["rootPath"]; + auto& value = (*repr_)["rootPath"]; std::variant result; @@ -9720,7 +12731,7 @@ auto _InitializeParams::rootPath() const -> std::optional< auto _InitializeParams::rootUri() const -> std::variant { - const auto& value = repr_["rootUri"]; + auto& value = (*repr_)["rootUri"]; std::variant result; @@ -9730,32 +12741,32 @@ auto _InitializeParams::rootUri() const } auto _InitializeParams::capabilities() const -> ClientCapabilities { - const auto& value = repr_["capabilities"]; + auto& value = (*repr_)["capabilities"]; return ClientCapabilities(value); } auto _InitializeParams::initializationOptions() const -> std::optional { - if (!repr_.contains("initializationOptions")) return std::nullopt; + if (!repr_->contains("initializationOptions")) return std::nullopt; - const auto& value = repr_["initializationOptions"]; + auto& value = (*repr_)["initializationOptions"]; assert(value.is_object()); return LSPAny(value); } auto _InitializeParams::trace() const -> std::optional { - if (!repr_.contains("trace")) return std::nullopt; + if (!repr_->contains("trace")) return std::nullopt; - const auto& value = repr_["trace"]; + auto& value = (*repr_)["trace"]; lsp_runtime_error("_InitializeParams::trace: not implement yet"); } auto _InitializeParams::workDoneToken() const -> std::optional { - if (!repr_.contains("workDoneToken")) return std::nullopt; + if (!repr_->contains("workDoneToken")) return std::nullopt; - const auto& value = repr_["workDoneToken"]; + auto& value = (*repr_)["workDoneToken"]; ProgressToken result; @@ -9767,62 +12778,154 @@ auto _InitializeParams::workDoneToken() const -> std::optional { auto _InitializeParams::processId( std::variant processId) -> _InitializeParams& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int processId) { + repr_->emplace("processId", std::move(processId)); + } + + void operator()(std::nullptr_t processId) { + repr_->emplace("processId", std::move(processId)); + } + } v{repr_}; + + std::visit(v, processId); + return *this; } auto _InitializeParams::clientInfo(std::optional clientInfo) -> _InitializeParams& { + if (!clientInfo.has_value()) { + repr_->erase("clientInfo"); + return *this; + } + repr_->emplace("clientInfo", clientInfo.value()); return *this; } auto _InitializeParams::locale(std::optional locale) -> _InitializeParams& { + if (!locale.has_value()) { + repr_->erase("locale"); + return *this; + } + repr_->emplace("locale", std::move(locale.value())); return *this; } auto _InitializeParams::rootPath( std::optional> rootPath) -> _InitializeParams& { + if (!rootPath.has_value()) { + repr_->erase("rootPath"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string rootPath) { + repr_->emplace("rootPath", std::move(rootPath)); + } + + void operator()(std::nullptr_t rootPath) { + repr_->emplace("rootPath", std::move(rootPath)); + } + } v{repr_}; + + std::visit(v, rootPath.value()); + return *this; } auto _InitializeParams::rootUri( std::variant rootUri) -> _InitializeParams& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string rootUri) { + repr_->emplace("rootUri", std::move(rootUri)); + } + + void operator()(std::nullptr_t rootUri) { + repr_->emplace("rootUri", std::move(rootUri)); + } + } v{repr_}; + + std::visit(v, rootUri); + return *this; } auto _InitializeParams::capabilities(ClientCapabilities capabilities) -> _InitializeParams& { + repr_->emplace("capabilities", capabilities); return *this; } auto _InitializeParams::initializationOptions( std::optional initializationOptions) -> _InitializeParams& { + if (!initializationOptions.has_value()) { + repr_->erase("initializationOptions"); + return *this; + } + lsp_runtime_error( + "_InitializeParams::initializationOptions: not implement yet"); return *this; } auto _InitializeParams::trace(std::optional trace) -> _InitializeParams& { + if (!trace.has_value()) { + repr_->erase("trace"); + return *this; + } + lsp_runtime_error("_InitializeParams::trace: not implement yet"); return *this; } auto _InitializeParams::workDoneToken( std::optional workDoneToken) -> _InitializeParams& { + if (!workDoneToken.has_value()) { + repr_->erase("workDoneToken"); + return *this; + } + lsp_runtime_error("_InitializeParams::workDoneToken: not implement yet"); return *this; } WorkspaceFoldersInitializeParams::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceFoldersInitializeParams::workspaceFolders() const -> std::optional< std::variant, std::nullptr_t>> { - if (!repr_.contains("workspaceFolders")) return std::nullopt; + if (!repr_->contains("workspaceFolders")) return std::nullopt; - const auto& value = repr_["workspaceFolders"]; + auto& value = (*repr_)["workspaceFolders"]; std::variant, std::nullptr_t> result; @@ -9835,19 +12938,46 @@ auto WorkspaceFoldersInitializeParams::workspaceFolders( std::optional< std::variant, std::nullptr_t>> workspaceFolders) -> WorkspaceFoldersInitializeParams& { + if (!workspaceFolders.has_value()) { + repr_->erase("workspaceFolders"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(Vector workspaceFolders) { + lsp_runtime_error( + "WorkspaceFoldersInitializeParams::workspaceFolders: not implement " + "yet"); + } + + void operator()(std::nullptr_t workspaceFolders) { + repr_->emplace("workspaceFolders", std::move(workspaceFolders)); + } + } v{repr_}; + + std::visit(v, workspaceFolders.value()); + return *this; } ServerCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ServerCapabilities::positionEncoding() const -> std::optional { - if (!repr_.contains("positionEncoding")) return std::nullopt; + if (!repr_->contains("positionEncoding")) return std::nullopt; - const auto& value = repr_["positionEncoding"]; + auto& value = (*repr_)["positionEncoding"]; lsp_runtime_error("ServerCapabilities::positionEncoding: not implement yet"); } @@ -9855,9 +12985,9 @@ auto ServerCapabilities::positionEncoding() const auto ServerCapabilities::textDocumentSync() const -> std::optional> { - if (!repr_.contains("textDocumentSync")) return std::nullopt; + if (!repr_->contains("textDocumentSync")) return std::nullopt; - const auto& value = repr_["textDocumentSync"]; + auto& value = (*repr_)["textDocumentSync"]; std::variant result; @@ -9870,9 +13000,9 @@ auto ServerCapabilities::textDocumentSync() const auto ServerCapabilities::notebookDocumentSync() const -> std::optional> { - if (!repr_.contains("notebookDocumentSync")) return std::nullopt; + if (!repr_->contains("notebookDocumentSync")) return std::nullopt; - const auto& value = repr_["notebookDocumentSync"]; + auto& value = (*repr_)["notebookDocumentSync"]; std::variant @@ -9885,18 +13015,18 @@ auto ServerCapabilities::notebookDocumentSync() const auto ServerCapabilities::completionProvider() const -> std::optional { - if (!repr_.contains("completionProvider")) return std::nullopt; + if (!repr_->contains("completionProvider")) return std::nullopt; - const auto& value = repr_["completionProvider"]; + auto& value = (*repr_)["completionProvider"]; return CompletionOptions(value); } auto ServerCapabilities::hoverProvider() const -> std::optional> { - if (!repr_.contains("hoverProvider")) return std::nullopt; + if (!repr_->contains("hoverProvider")) return std::nullopt; - const auto& value = repr_["hoverProvider"]; + auto& value = (*repr_)["hoverProvider"]; std::variant result; @@ -9907,9 +13037,9 @@ auto ServerCapabilities::hoverProvider() const auto ServerCapabilities::signatureHelpProvider() const -> std::optional { - if (!repr_.contains("signatureHelpProvider")) return std::nullopt; + if (!repr_->contains("signatureHelpProvider")) return std::nullopt; - const auto& value = repr_["signatureHelpProvider"]; + auto& value = (*repr_)["signatureHelpProvider"]; return SignatureHelpOptions(value); } @@ -9917,9 +13047,9 @@ auto ServerCapabilities::signatureHelpProvider() const auto ServerCapabilities::declarationProvider() const -> std::optional> { - if (!repr_.contains("declarationProvider")) return std::nullopt; + if (!repr_->contains("declarationProvider")) return std::nullopt; - const auto& value = repr_["declarationProvider"]; + auto& value = (*repr_)["declarationProvider"]; std::variant @@ -9932,9 +13062,9 @@ auto ServerCapabilities::declarationProvider() const auto ServerCapabilities::definitionProvider() const -> std::optional> { - if (!repr_.contains("definitionProvider")) return std::nullopt; + if (!repr_->contains("definitionProvider")) return std::nullopt; - const auto& value = repr_["definitionProvider"]; + auto& value = (*repr_)["definitionProvider"]; std::variant result; @@ -9946,9 +13076,9 @@ auto ServerCapabilities::definitionProvider() const auto ServerCapabilities::typeDefinitionProvider() const -> std::optional> { - if (!repr_.contains("typeDefinitionProvider")) return std::nullopt; + if (!repr_->contains("typeDefinitionProvider")) return std::nullopt; - const auto& value = repr_["typeDefinitionProvider"]; + auto& value = (*repr_)["typeDefinitionProvider"]; std::variant @@ -9962,9 +13092,9 @@ auto ServerCapabilities::typeDefinitionProvider() const auto ServerCapabilities::implementationProvider() const -> std::optional> { - if (!repr_.contains("implementationProvider")) return std::nullopt; + if (!repr_->contains("implementationProvider")) return std::nullopt; - const auto& value = repr_["implementationProvider"]; + auto& value = (*repr_)["implementationProvider"]; std::variant @@ -9977,9 +13107,9 @@ auto ServerCapabilities::implementationProvider() const auto ServerCapabilities::referencesProvider() const -> std::optional> { - if (!repr_.contains("referencesProvider")) return std::nullopt; + if (!repr_->contains("referencesProvider")) return std::nullopt; - const auto& value = repr_["referencesProvider"]; + auto& value = (*repr_)["referencesProvider"]; std::variant result; @@ -9990,9 +13120,9 @@ auto ServerCapabilities::referencesProvider() const auto ServerCapabilities::documentHighlightProvider() const -> std::optional< std::variant> { - if (!repr_.contains("documentHighlightProvider")) return std::nullopt; + if (!repr_->contains("documentHighlightProvider")) return std::nullopt; - const auto& value = repr_["documentHighlightProvider"]; + auto& value = (*repr_)["documentHighlightProvider"]; std::variant result; @@ -10003,9 +13133,9 @@ auto ServerCapabilities::documentHighlightProvider() const -> std::optional< auto ServerCapabilities::documentSymbolProvider() const -> std::optional< std::variant> { - if (!repr_.contains("documentSymbolProvider")) return std::nullopt; + if (!repr_->contains("documentSymbolProvider")) return std::nullopt; - const auto& value = repr_["documentSymbolProvider"]; + auto& value = (*repr_)["documentSymbolProvider"]; std::variant result; @@ -10016,9 +13146,9 @@ auto ServerCapabilities::documentSymbolProvider() const -> std::optional< auto ServerCapabilities::codeActionProvider() const -> std::optional> { - if (!repr_.contains("codeActionProvider")) return std::nullopt; + if (!repr_->contains("codeActionProvider")) return std::nullopt; - const auto& value = repr_["codeActionProvider"]; + auto& value = (*repr_)["codeActionProvider"]; std::variant result; @@ -10029,18 +13159,18 @@ auto ServerCapabilities::codeActionProvider() const auto ServerCapabilities::codeLensProvider() const -> std::optional { - if (!repr_.contains("codeLensProvider")) return std::nullopt; + if (!repr_->contains("codeLensProvider")) return std::nullopt; - const auto& value = repr_["codeLensProvider"]; + auto& value = (*repr_)["codeLensProvider"]; return CodeLensOptions(value); } auto ServerCapabilities::documentLinkProvider() const -> std::optional { - if (!repr_.contains("documentLinkProvider")) return std::nullopt; + if (!repr_->contains("documentLinkProvider")) return std::nullopt; - const auto& value = repr_["documentLinkProvider"]; + auto& value = (*repr_)["documentLinkProvider"]; return DocumentLinkOptions(value); } @@ -10048,9 +13178,9 @@ auto ServerCapabilities::documentLinkProvider() const auto ServerCapabilities::colorProvider() const -> std::optional> { - if (!repr_.contains("colorProvider")) return std::nullopt; + if (!repr_->contains("colorProvider")) return std::nullopt; - const auto& value = repr_["colorProvider"]; + auto& value = (*repr_)["colorProvider"]; std::variant @@ -10063,9 +13193,9 @@ auto ServerCapabilities::colorProvider() const auto ServerCapabilities::workspaceSymbolProvider() const -> std::optional< std::variant> { - if (!repr_.contains("workspaceSymbolProvider")) return std::nullopt; + if (!repr_->contains("workspaceSymbolProvider")) return std::nullopt; - const auto& value = repr_["workspaceSymbolProvider"]; + auto& value = (*repr_)["workspaceSymbolProvider"]; std::variant result; @@ -10076,9 +13206,9 @@ auto ServerCapabilities::workspaceSymbolProvider() const -> std::optional< auto ServerCapabilities::documentFormattingProvider() const -> std::optional< std::variant> { - if (!repr_.contains("documentFormattingProvider")) return std::nullopt; + if (!repr_->contains("documentFormattingProvider")) return std::nullopt; - const auto& value = repr_["documentFormattingProvider"]; + auto& value = (*repr_)["documentFormattingProvider"]; std::variant result; @@ -10090,9 +13220,9 @@ auto ServerCapabilities::documentFormattingProvider() const -> std::optional< auto ServerCapabilities::documentRangeFormattingProvider() const -> std::optional< std::variant> { - if (!repr_.contains("documentRangeFormattingProvider")) return std::nullopt; + if (!repr_->contains("documentRangeFormattingProvider")) return std::nullopt; - const auto& value = repr_["documentRangeFormattingProvider"]; + auto& value = (*repr_)["documentRangeFormattingProvider"]; std::variant result; @@ -10103,18 +13233,18 @@ auto ServerCapabilities::documentRangeFormattingProvider() const auto ServerCapabilities::documentOnTypeFormattingProvider() const -> std::optional { - if (!repr_.contains("documentOnTypeFormattingProvider")) return std::nullopt; + if (!repr_->contains("documentOnTypeFormattingProvider")) return std::nullopt; - const auto& value = repr_["documentOnTypeFormattingProvider"]; + auto& value = (*repr_)["documentOnTypeFormattingProvider"]; return DocumentOnTypeFormattingOptions(value); } auto ServerCapabilities::renameProvider() const -> std::optional> { - if (!repr_.contains("renameProvider")) return std::nullopt; + if (!repr_->contains("renameProvider")) return std::nullopt; - const auto& value = repr_["renameProvider"]; + auto& value = (*repr_)["renameProvider"]; std::variant result; @@ -10126,9 +13256,9 @@ auto ServerCapabilities::renameProvider() const auto ServerCapabilities::foldingRangeProvider() const -> std::optional> { - if (!repr_.contains("foldingRangeProvider")) return std::nullopt; + if (!repr_->contains("foldingRangeProvider")) return std::nullopt; - const auto& value = repr_["foldingRangeProvider"]; + auto& value = (*repr_)["foldingRangeProvider"]; std::variant @@ -10142,9 +13272,9 @@ auto ServerCapabilities::foldingRangeProvider() const auto ServerCapabilities::selectionRangeProvider() const -> std::optional> { - if (!repr_.contains("selectionRangeProvider")) return std::nullopt; + if (!repr_->contains("selectionRangeProvider")) return std::nullopt; - const auto& value = repr_["selectionRangeProvider"]; + auto& value = (*repr_)["selectionRangeProvider"]; std::variant @@ -10157,9 +13287,9 @@ auto ServerCapabilities::selectionRangeProvider() const auto ServerCapabilities::executeCommandProvider() const -> std::optional { - if (!repr_.contains("executeCommandProvider")) return std::nullopt; + if (!repr_->contains("executeCommandProvider")) return std::nullopt; - const auto& value = repr_["executeCommandProvider"]; + auto& value = (*repr_)["executeCommandProvider"]; return ExecuteCommandOptions(value); } @@ -10167,9 +13297,9 @@ auto ServerCapabilities::executeCommandProvider() const auto ServerCapabilities::callHierarchyProvider() const -> std::optional> { - if (!repr_.contains("callHierarchyProvider")) return std::nullopt; + if (!repr_->contains("callHierarchyProvider")) return std::nullopt; - const auto& value = repr_["callHierarchyProvider"]; + auto& value = (*repr_)["callHierarchyProvider"]; std::variant @@ -10183,9 +13313,9 @@ auto ServerCapabilities::callHierarchyProvider() const auto ServerCapabilities::linkedEditingRangeProvider() const -> std::optional< std::variant> { - if (!repr_.contains("linkedEditingRangeProvider")) return std::nullopt; + if (!repr_->contains("linkedEditingRangeProvider")) return std::nullopt; - const auto& value = repr_["linkedEditingRangeProvider"]; + auto& value = (*repr_)["linkedEditingRangeProvider"]; std::variant @@ -10199,9 +13329,9 @@ auto ServerCapabilities::linkedEditingRangeProvider() const -> std::optional< auto ServerCapabilities::semanticTokensProvider() const -> std::optional> { - if (!repr_.contains("semanticTokensProvider")) return std::nullopt; + if (!repr_->contains("semanticTokensProvider")) return std::nullopt; - const auto& value = repr_["semanticTokensProvider"]; + auto& value = (*repr_)["semanticTokensProvider"]; std::variant @@ -10215,9 +13345,9 @@ auto ServerCapabilities::semanticTokensProvider() const auto ServerCapabilities::monikerProvider() const -> std::optional> { - if (!repr_.contains("monikerProvider")) return std::nullopt; + if (!repr_->contains("monikerProvider")) return std::nullopt; - const auto& value = repr_["monikerProvider"]; + auto& value = (*repr_)["monikerProvider"]; std::variant result; @@ -10230,9 +13360,9 @@ auto ServerCapabilities::monikerProvider() const auto ServerCapabilities::typeHierarchyProvider() const -> std::optional> { - if (!repr_.contains("typeHierarchyProvider")) return std::nullopt; + if (!repr_->contains("typeHierarchyProvider")) return std::nullopt; - const auto& value = repr_["typeHierarchyProvider"]; + auto& value = (*repr_)["typeHierarchyProvider"]; std::variant @@ -10246,9 +13376,9 @@ auto ServerCapabilities::typeHierarchyProvider() const auto ServerCapabilities::inlineValueProvider() const -> std::optional> { - if (!repr_.contains("inlineValueProvider")) return std::nullopt; + if (!repr_->contains("inlineValueProvider")) return std::nullopt; - const auto& value = repr_["inlineValueProvider"]; + auto& value = (*repr_)["inlineValueProvider"]; std::variant @@ -10262,9 +13392,9 @@ auto ServerCapabilities::inlineValueProvider() const auto ServerCapabilities::inlayHintProvider() const -> std::optional> { - if (!repr_.contains("inlayHintProvider")) return std::nullopt; + if (!repr_->contains("inlayHintProvider")) return std::nullopt; - const auto& value = repr_["inlayHintProvider"]; + auto& value = (*repr_)["inlayHintProvider"]; std::variant @@ -10278,9 +13408,9 @@ auto ServerCapabilities::inlayHintProvider() const auto ServerCapabilities::diagnosticProvider() const -> std::optional> { - if (!repr_.contains("diagnosticProvider")) return std::nullopt; + if (!repr_->contains("diagnosticProvider")) return std::nullopt; - const auto& value = repr_["diagnosticProvider"]; + auto& value = (*repr_)["diagnosticProvider"]; std::variant result; @@ -10292,9 +13422,9 @@ auto ServerCapabilities::diagnosticProvider() const auto ServerCapabilities::inlineCompletionProvider() const -> std::optional< std::variant> { - if (!repr_.contains("inlineCompletionProvider")) return std::nullopt; + if (!repr_->contains("inlineCompletionProvider")) return std::nullopt; - const auto& value = repr_["inlineCompletionProvider"]; + auto& value = (*repr_)["inlineCompletionProvider"]; std::variant result; @@ -10304,17 +13434,17 @@ auto ServerCapabilities::inlineCompletionProvider() const -> std::optional< } auto ServerCapabilities::workspace() const -> std::optional { - if (!repr_.contains("workspace")) return std::nullopt; + if (!repr_->contains("workspace")) return std::nullopt; - const auto& value = repr_["workspace"]; + auto& value = (*repr_)["workspace"]; return WorkspaceOptions(value); } auto ServerCapabilities::experimental() const -> std::optional { - if (!repr_.contains("experimental")) return std::nullopt; + if (!repr_->contains("experimental")) return std::nullopt; - const auto& value = repr_["experimental"]; + auto& value = (*repr_)["experimental"]; assert(value.is_object()); return LSPAny(value); @@ -10323,6 +13453,11 @@ auto ServerCapabilities::experimental() const -> std::optional { auto ServerCapabilities::positionEncoding( std::optional positionEncoding) -> ServerCapabilities& { + if (!positionEncoding.has_value()) { + repr_->erase("positionEncoding"); + return *this; + } + lsp_runtime_error("ServerCapabilities::positionEncoding: not implement yet"); return *this; } @@ -10330,6 +13465,31 @@ auto ServerCapabilities::textDocumentSync( std::optional> textDocumentSync) -> ServerCapabilities& { + if (!textDocumentSync.has_value()) { + repr_->erase("textDocumentSync"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(TextDocumentSyncOptions textDocumentSync) { + repr_->emplace("textDocumentSync", textDocumentSync); + } + + void operator()(TextDocumentSyncKind textDocumentSync) { + repr_->emplace("textDocumentSync", static_cast(textDocumentSync)); + } + } v{repr_}; + + std::visit(v, textDocumentSync.value()); + return *this; } @@ -10337,24 +13497,85 @@ auto ServerCapabilities::notebookDocumentSync( std::optional> notebookDocumentSync) -> ServerCapabilities& { + if (!notebookDocumentSync.has_value()) { + repr_->erase("notebookDocumentSync"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(NotebookDocumentSyncOptions notebookDocumentSync) { + repr_->emplace("notebookDocumentSync", notebookDocumentSync); + } + + void operator()( + NotebookDocumentSyncRegistrationOptions notebookDocumentSync) { + repr_->emplace("notebookDocumentSync", notebookDocumentSync); + } + } v{repr_}; + + std::visit(v, notebookDocumentSync.value()); + return *this; } auto ServerCapabilities::completionProvider( std::optional completionProvider) -> ServerCapabilities& { + if (!completionProvider.has_value()) { + repr_->erase("completionProvider"); + return *this; + } + repr_->emplace("completionProvider", completionProvider.value()); return *this; } auto ServerCapabilities::hoverProvider( std::optional> hoverProvider) -> ServerCapabilities& { + if (!hoverProvider.has_value()) { + repr_->erase("hoverProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool hoverProvider) { + repr_->emplace("hoverProvider", std::move(hoverProvider)); + } + + void operator()(HoverOptions hoverProvider) { + repr_->emplace("hoverProvider", hoverProvider); + } + } v{repr_}; + + std::visit(v, hoverProvider.value()); + return *this; } auto ServerCapabilities::signatureHelpProvider( std::optional signatureHelpProvider) -> ServerCapabilities& { + if (!signatureHelpProvider.has_value()) { + repr_->erase("signatureHelpProvider"); + return *this; + } + repr_->emplace("signatureHelpProvider", signatureHelpProvider.value()); return *this; } @@ -10362,12 +13583,66 @@ auto ServerCapabilities::declarationProvider( std::optional> declarationProvider) -> ServerCapabilities& { + if (!declarationProvider.has_value()) { + repr_->erase("declarationProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool declarationProvider) { + repr_->emplace("declarationProvider", std::move(declarationProvider)); + } + + void operator()(DeclarationOptions declarationProvider) { + repr_->emplace("declarationProvider", declarationProvider); + } + + void operator()(DeclarationRegistrationOptions declarationProvider) { + repr_->emplace("declarationProvider", declarationProvider); + } + } v{repr_}; + + std::visit(v, declarationProvider.value()); + return *this; } auto ServerCapabilities::definitionProvider( std::optional> definitionProvider) -> ServerCapabilities& { + if (!definitionProvider.has_value()) { + repr_->erase("definitionProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool definitionProvider) { + repr_->emplace("definitionProvider", std::move(definitionProvider)); + } + + void operator()(DefinitionOptions definitionProvider) { + repr_->emplace("definitionProvider", definitionProvider); + } + } v{repr_}; + + std::visit(v, definitionProvider.value()); + return *this; } @@ -10375,6 +13650,36 @@ auto ServerCapabilities::typeDefinitionProvider( std::optional> typeDefinitionProvider) -> ServerCapabilities& { + if (!typeDefinitionProvider.has_value()) { + repr_->erase("typeDefinitionProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool typeDefinitionProvider) { + repr_->emplace("typeDefinitionProvider", + std::move(typeDefinitionProvider)); + } + + void operator()(TypeDefinitionOptions typeDefinitionProvider) { + repr_->emplace("typeDefinitionProvider", typeDefinitionProvider); + } + + void operator()(TypeDefinitionRegistrationOptions typeDefinitionProvider) { + repr_->emplace("typeDefinitionProvider", typeDefinitionProvider); + } + } v{repr_}; + + std::visit(v, typeDefinitionProvider.value()); + return *this; } @@ -10382,41 +13687,183 @@ auto ServerCapabilities::implementationProvider( std::optional> implementationProvider) -> ServerCapabilities& { + if (!implementationProvider.has_value()) { + repr_->erase("implementationProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool implementationProvider) { + repr_->emplace("implementationProvider", + std::move(implementationProvider)); + } + + void operator()(ImplementationOptions implementationProvider) { + repr_->emplace("implementationProvider", implementationProvider); + } + + void operator()(ImplementationRegistrationOptions implementationProvider) { + repr_->emplace("implementationProvider", implementationProvider); + } + } v{repr_}; + + std::visit(v, implementationProvider.value()); + return *this; } auto ServerCapabilities::referencesProvider( std::optional> referencesProvider) -> ServerCapabilities& { + if (!referencesProvider.has_value()) { + repr_->erase("referencesProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool referencesProvider) { + repr_->emplace("referencesProvider", std::move(referencesProvider)); + } + + void operator()(ReferenceOptions referencesProvider) { + repr_->emplace("referencesProvider", referencesProvider); + } + } v{repr_}; + + std::visit(v, referencesProvider.value()); + return *this; } auto ServerCapabilities::documentHighlightProvider( std::optional> documentHighlightProvider) -> ServerCapabilities& { + if (!documentHighlightProvider.has_value()) { + repr_->erase("documentHighlightProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool documentHighlightProvider) { + repr_->emplace("documentHighlightProvider", + std::move(documentHighlightProvider)); + } + + void operator()(DocumentHighlightOptions documentHighlightProvider) { + repr_->emplace("documentHighlightProvider", documentHighlightProvider); + } + } v{repr_}; + + std::visit(v, documentHighlightProvider.value()); + return *this; } auto ServerCapabilities::documentSymbolProvider( std::optional> documentSymbolProvider) -> ServerCapabilities& { + if (!documentSymbolProvider.has_value()) { + repr_->erase("documentSymbolProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool documentSymbolProvider) { + repr_->emplace("documentSymbolProvider", + std::move(documentSymbolProvider)); + } + + void operator()(DocumentSymbolOptions documentSymbolProvider) { + repr_->emplace("documentSymbolProvider", documentSymbolProvider); + } + } v{repr_}; + + std::visit(v, documentSymbolProvider.value()); + return *this; } auto ServerCapabilities::codeActionProvider( std::optional> codeActionProvider) -> ServerCapabilities& { + if (!codeActionProvider.has_value()) { + repr_->erase("codeActionProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool codeActionProvider) { + repr_->emplace("codeActionProvider", std::move(codeActionProvider)); + } + + void operator()(CodeActionOptions codeActionProvider) { + repr_->emplace("codeActionProvider", codeActionProvider); + } + } v{repr_}; + + std::visit(v, codeActionProvider.value()); + return *this; } auto ServerCapabilities::codeLensProvider( std::optional codeLensProvider) -> ServerCapabilities& { + if (!codeLensProvider.has_value()) { + repr_->erase("codeLensProvider"); + return *this; + } + repr_->emplace("codeLensProvider", codeLensProvider.value()); return *this; } auto ServerCapabilities::documentLinkProvider( std::optional documentLinkProvider) -> ServerCapabilities& { + if (!documentLinkProvider.has_value()) { + repr_->erase("documentLinkProvider"); + return *this; + } + repr_->emplace("documentLinkProvider", documentLinkProvider.value()); return *this; } @@ -10424,18 +13871,99 @@ auto ServerCapabilities::colorProvider( std::optional> colorProvider) -> ServerCapabilities& { + if (!colorProvider.has_value()) { + repr_->erase("colorProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool colorProvider) { + repr_->emplace("colorProvider", std::move(colorProvider)); + } + + void operator()(DocumentColorOptions colorProvider) { + repr_->emplace("colorProvider", colorProvider); + } + + void operator()(DocumentColorRegistrationOptions colorProvider) { + repr_->emplace("colorProvider", colorProvider); + } + } v{repr_}; + + std::visit(v, colorProvider.value()); + return *this; } auto ServerCapabilities::workspaceSymbolProvider( std::optional> workspaceSymbolProvider) -> ServerCapabilities& { + if (!workspaceSymbolProvider.has_value()) { + repr_->erase("workspaceSymbolProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool workspaceSymbolProvider) { + repr_->emplace("workspaceSymbolProvider", + std::move(workspaceSymbolProvider)); + } + + void operator()(WorkspaceSymbolOptions workspaceSymbolProvider) { + repr_->emplace("workspaceSymbolProvider", workspaceSymbolProvider); + } + } v{repr_}; + + std::visit(v, workspaceSymbolProvider.value()); + return *this; } auto ServerCapabilities::documentFormattingProvider( std::optional> documentFormattingProvider) -> ServerCapabilities& { + if (!documentFormattingProvider.has_value()) { + repr_->erase("documentFormattingProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool documentFormattingProvider) { + repr_->emplace("documentFormattingProvider", + std::move(documentFormattingProvider)); + } + + void operator()(DocumentFormattingOptions documentFormattingProvider) { + repr_->emplace("documentFormattingProvider", documentFormattingProvider); + } + } v{repr_}; + + std::visit(v, documentFormattingProvider.value()); + return *this; } @@ -10443,25 +13971,113 @@ auto ServerCapabilities::documentRangeFormattingProvider( std::optional< std::variant> documentRangeFormattingProvider) -> ServerCapabilities& { + if (!documentRangeFormattingProvider.has_value()) { + repr_->erase("documentRangeFormattingProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool documentRangeFormattingProvider) { + repr_->emplace("documentRangeFormattingProvider", + std::move(documentRangeFormattingProvider)); + } + + void operator()( + DocumentRangeFormattingOptions documentRangeFormattingProvider) { + repr_->emplace("documentRangeFormattingProvider", + documentRangeFormattingProvider); + } + } v{repr_}; + + std::visit(v, documentRangeFormattingProvider.value()); + return *this; } auto ServerCapabilities::documentOnTypeFormattingProvider( std::optional documentOnTypeFormattingProvider) -> ServerCapabilities& { + if (!documentOnTypeFormattingProvider.has_value()) { + repr_->erase("documentOnTypeFormattingProvider"); + return *this; + } + repr_->emplace("documentOnTypeFormattingProvider", + documentOnTypeFormattingProvider.value()); return *this; } auto ServerCapabilities::renameProvider( std::optional> renameProvider) -> ServerCapabilities& { + if (!renameProvider.has_value()) { + repr_->erase("renameProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool renameProvider) { + repr_->emplace("renameProvider", std::move(renameProvider)); + } + + void operator()(RenameOptions renameProvider) { + repr_->emplace("renameProvider", renameProvider); + } + } v{repr_}; + + std::visit(v, renameProvider.value()); + return *this; } -auto ServerCapabilities::foldingRangeProvider( - std::optional> - foldingRangeProvider) -> ServerCapabilities& { +auto ServerCapabilities::foldingRangeProvider( + std::optional> + foldingRangeProvider) -> ServerCapabilities& { + if (!foldingRangeProvider.has_value()) { + repr_->erase("foldingRangeProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool foldingRangeProvider) { + repr_->emplace("foldingRangeProvider", std::move(foldingRangeProvider)); + } + + void operator()(FoldingRangeOptions foldingRangeProvider) { + repr_->emplace("foldingRangeProvider", foldingRangeProvider); + } + + void operator()(FoldingRangeRegistrationOptions foldingRangeProvider) { + repr_->emplace("foldingRangeProvider", foldingRangeProvider); + } + } v{repr_}; + + std::visit(v, foldingRangeProvider.value()); + return *this; } @@ -10469,12 +14085,47 @@ auto ServerCapabilities::selectionRangeProvider( std::optional> selectionRangeProvider) -> ServerCapabilities& { + if (!selectionRangeProvider.has_value()) { + repr_->erase("selectionRangeProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool selectionRangeProvider) { + repr_->emplace("selectionRangeProvider", + std::move(selectionRangeProvider)); + } + + void operator()(SelectionRangeOptions selectionRangeProvider) { + repr_->emplace("selectionRangeProvider", selectionRangeProvider); + } + + void operator()(SelectionRangeRegistrationOptions selectionRangeProvider) { + repr_->emplace("selectionRangeProvider", selectionRangeProvider); + } + } v{repr_}; + + std::visit(v, selectionRangeProvider.value()); + return *this; } auto ServerCapabilities::executeCommandProvider( std::optional executeCommandProvider) -> ServerCapabilities& { + if (!executeCommandProvider.has_value()) { + repr_->erase("executeCommandProvider"); + return *this; + } + repr_->emplace("executeCommandProvider", executeCommandProvider.value()); return *this; } @@ -10482,6 +14133,35 @@ auto ServerCapabilities::callHierarchyProvider( std::optional> callHierarchyProvider) -> ServerCapabilities& { + if (!callHierarchyProvider.has_value()) { + repr_->erase("callHierarchyProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool callHierarchyProvider) { + repr_->emplace("callHierarchyProvider", std::move(callHierarchyProvider)); + } + + void operator()(CallHierarchyOptions callHierarchyProvider) { + repr_->emplace("callHierarchyProvider", callHierarchyProvider); + } + + void operator()(CallHierarchyRegistrationOptions callHierarchyProvider) { + repr_->emplace("callHierarchyProvider", callHierarchyProvider); + } + } v{repr_}; + + std::visit(v, callHierarchyProvider.value()); + return *this; } @@ -10489,6 +14169,37 @@ auto ServerCapabilities::linkedEditingRangeProvider( std::optional> linkedEditingRangeProvider) -> ServerCapabilities& { + if (!linkedEditingRangeProvider.has_value()) { + repr_->erase("linkedEditingRangeProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool linkedEditingRangeProvider) { + repr_->emplace("linkedEditingRangeProvider", + std::move(linkedEditingRangeProvider)); + } + + void operator()(LinkedEditingRangeOptions linkedEditingRangeProvider) { + repr_->emplace("linkedEditingRangeProvider", linkedEditingRangeProvider); + } + + void operator()( + LinkedEditingRangeRegistrationOptions linkedEditingRangeProvider) { + repr_->emplace("linkedEditingRangeProvider", linkedEditingRangeProvider); + } + } v{repr_}; + + std::visit(v, linkedEditingRangeProvider.value()); + return *this; } @@ -10496,6 +14207,31 @@ auto ServerCapabilities::semanticTokensProvider( std::optional> semanticTokensProvider) -> ServerCapabilities& { + if (!semanticTokensProvider.has_value()) { + repr_->erase("semanticTokensProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(SemanticTokensOptions semanticTokensProvider) { + repr_->emplace("semanticTokensProvider", semanticTokensProvider); + } + + void operator()(SemanticTokensRegistrationOptions semanticTokensProvider) { + repr_->emplace("semanticTokensProvider", semanticTokensProvider); + } + } v{repr_}; + + std::visit(v, semanticTokensProvider.value()); + return *this; } @@ -10503,6 +14239,35 @@ auto ServerCapabilities::monikerProvider( std::optional> monikerProvider) -> ServerCapabilities& { + if (!monikerProvider.has_value()) { + repr_->erase("monikerProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool monikerProvider) { + repr_->emplace("monikerProvider", std::move(monikerProvider)); + } + + void operator()(MonikerOptions monikerProvider) { + repr_->emplace("monikerProvider", monikerProvider); + } + + void operator()(MonikerRegistrationOptions monikerProvider) { + repr_->emplace("monikerProvider", monikerProvider); + } + } v{repr_}; + + std::visit(v, monikerProvider.value()); + return *this; } @@ -10510,6 +14275,35 @@ auto ServerCapabilities::typeHierarchyProvider( std::optional> typeHierarchyProvider) -> ServerCapabilities& { + if (!typeHierarchyProvider.has_value()) { + repr_->erase("typeHierarchyProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool typeHierarchyProvider) { + repr_->emplace("typeHierarchyProvider", std::move(typeHierarchyProvider)); + } + + void operator()(TypeHierarchyOptions typeHierarchyProvider) { + repr_->emplace("typeHierarchyProvider", typeHierarchyProvider); + } + + void operator()(TypeHierarchyRegistrationOptions typeHierarchyProvider) { + repr_->emplace("typeHierarchyProvider", typeHierarchyProvider); + } + } v{repr_}; + + std::visit(v, typeHierarchyProvider.value()); + return *this; } @@ -10517,6 +14311,35 @@ auto ServerCapabilities::inlineValueProvider( std::optional> inlineValueProvider) -> ServerCapabilities& { + if (!inlineValueProvider.has_value()) { + repr_->erase("inlineValueProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool inlineValueProvider) { + repr_->emplace("inlineValueProvider", std::move(inlineValueProvider)); + } + + void operator()(InlineValueOptions inlineValueProvider) { + repr_->emplace("inlineValueProvider", inlineValueProvider); + } + + void operator()(InlineValueRegistrationOptions inlineValueProvider) { + repr_->emplace("inlineValueProvider", inlineValueProvider); + } + } v{repr_}; + + std::visit(v, inlineValueProvider.value()); + return *this; } @@ -10524,6 +14347,35 @@ auto ServerCapabilities::inlayHintProvider( std::optional> inlayHintProvider) -> ServerCapabilities& { + if (!inlayHintProvider.has_value()) { + repr_->erase("inlayHintProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool inlayHintProvider) { + repr_->emplace("inlayHintProvider", std::move(inlayHintProvider)); + } + + void operator()(InlayHintOptions inlayHintProvider) { + repr_->emplace("inlayHintProvider", inlayHintProvider); + } + + void operator()(InlayHintRegistrationOptions inlayHintProvider) { + repr_->emplace("inlayHintProvider", inlayHintProvider); + } + } v{repr_}; + + std::visit(v, inlayHintProvider.value()); + return *this; } @@ -10531,69 +14383,138 @@ auto ServerCapabilities::diagnosticProvider( std::optional> diagnosticProvider) -> ServerCapabilities& { + if (!diagnosticProvider.has_value()) { + repr_->erase("diagnosticProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(DiagnosticOptions diagnosticProvider) { + repr_->emplace("diagnosticProvider", diagnosticProvider); + } + + void operator()(DiagnosticRegistrationOptions diagnosticProvider) { + repr_->emplace("diagnosticProvider", diagnosticProvider); + } + } v{repr_}; + + std::visit(v, diagnosticProvider.value()); + return *this; } auto ServerCapabilities::inlineCompletionProvider( std::optional> inlineCompletionProvider) -> ServerCapabilities& { + if (!inlineCompletionProvider.has_value()) { + repr_->erase("inlineCompletionProvider"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool inlineCompletionProvider) { + repr_->emplace("inlineCompletionProvider", + std::move(inlineCompletionProvider)); + } + + void operator()(InlineCompletionOptions inlineCompletionProvider) { + repr_->emplace("inlineCompletionProvider", inlineCompletionProvider); + } + } v{repr_}; + + std::visit(v, inlineCompletionProvider.value()); + return *this; } auto ServerCapabilities::workspace(std::optional workspace) -> ServerCapabilities& { + if (!workspace.has_value()) { + repr_->erase("workspace"); + return *this; + } + repr_->emplace("workspace", workspace.value()); return *this; } auto ServerCapabilities::experimental(std::optional experimental) -> ServerCapabilities& { + if (!experimental.has_value()) { + repr_->erase("experimental"); + return *this; + } + lsp_runtime_error("ServerCapabilities::experimental: not implement yet"); return *this; } ServerInfo::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; return true; } auto ServerInfo::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto ServerInfo::version() const -> std::optional { - if (!repr_.contains("version")) return std::nullopt; + if (!repr_->contains("version")) return std::nullopt; - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_string()); return value.get(); } -auto ServerInfo::name(std::string name) -> ServerInfo& { return *this; } +auto ServerInfo::name(std::string name) -> ServerInfo& { + repr_->emplace("name", std::move(name)); + return *this; +} auto ServerInfo::version(std::optional version) -> ServerInfo& { + if (!version.has_value()) { + repr_->erase("version"); + return *this; + } + repr_->emplace("version", std::move(version.value())); return *this; } VersionedTextDocumentIdentifier::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("uri")) return false; return true; } auto VersionedTextDocumentIdentifier::version() const -> int { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_number_integer()); return value.get(); } auto VersionedTextDocumentIdentifier::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -10601,64 +14522,77 @@ auto VersionedTextDocumentIdentifier::uri() const -> std::string { auto VersionedTextDocumentIdentifier::version(int version) -> VersionedTextDocumentIdentifier& { + repr_->emplace("version", std::move(version)); return *this; } auto VersionedTextDocumentIdentifier::uri(std::string uri) -> VersionedTextDocumentIdentifier& { + repr_->emplace("uri", std::move(uri)); return *this; } SaveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SaveOptions::includeText() const -> std::optional { - if (!repr_.contains("includeText")) return std::nullopt; + if (!repr_->contains("includeText")) return std::nullopt; - const auto& value = repr_["includeText"]; + auto& value = (*repr_)["includeText"]; assert(value.is_boolean()); return value.get(); } auto SaveOptions::includeText(std::optional includeText) -> SaveOptions& { + if (!includeText.has_value()) { + repr_->erase("includeText"); + return *this; + } + repr_->emplace("includeText", std::move(includeText.value())); return *this; } FileEvent::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("type")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("type")) return false; return true; } auto FileEvent::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } auto FileEvent::type() const -> FileChangeType { - const auto& value = repr_["type"]; + auto& value = (*repr_)["type"]; return FileChangeType(value); } -auto FileEvent::uri(std::string uri) -> FileEvent& { return *this; } +auto FileEvent::uri(std::string uri) -> FileEvent& { + repr_->emplace("uri", std::move(uri)); + return *this; +} -auto FileEvent::type(FileChangeType type) -> FileEvent& { return *this; } +auto FileEvent::type(FileChangeType type) -> FileEvent& { + repr_->emplace("type", static_cast(type)); + return *this; +} FileSystemWatcher::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("globPattern")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("globPattern")) return false; return true; } auto FileSystemWatcher::globPattern() const -> GlobPattern { - const auto& value = repr_["globPattern"]; + auto& value = (*repr_)["globPattern"]; GlobPattern result; @@ -10668,49 +14602,55 @@ auto FileSystemWatcher::globPattern() const -> GlobPattern { } auto FileSystemWatcher::kind() const -> std::optional { - if (!repr_.contains("kind")) return std::nullopt; + if (!repr_->contains("kind")) return std::nullopt; - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return WatchKind(value); } auto FileSystemWatcher::globPattern(GlobPattern globPattern) -> FileSystemWatcher& { + lsp_runtime_error("FileSystemWatcher::globPattern: not implement yet"); return *this; } auto FileSystemWatcher::kind(std::optional kind) -> FileSystemWatcher& { + if (!kind.has_value()) { + repr_->erase("kind"); + return *this; + } + repr_->emplace("kind", static_cast(kind.value())); return *this; } Diagnostic::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("message")) return false; return true; } auto Diagnostic::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto Diagnostic::severity() const -> std::optional { - if (!repr_.contains("severity")) return std::nullopt; + if (!repr_->contains("severity")) return std::nullopt; - const auto& value = repr_["severity"]; + auto& value = (*repr_)["severity"]; return DiagnosticSeverity(value); } auto Diagnostic::code() const -> std::optional> { - if (!repr_.contains("code")) return std::nullopt; + if (!repr_->contains("code")) return std::nullopt; - const auto& value = repr_["code"]; + auto& value = (*repr_)["code"]; std::variant result; @@ -10720,33 +14660,33 @@ auto Diagnostic::code() const } auto Diagnostic::codeDescription() const -> std::optional { - if (!repr_.contains("codeDescription")) return std::nullopt; + if (!repr_->contains("codeDescription")) return std::nullopt; - const auto& value = repr_["codeDescription"]; + auto& value = (*repr_)["codeDescription"]; return CodeDescription(value); } auto Diagnostic::source() const -> std::optional { - if (!repr_.contains("source")) return std::nullopt; + if (!repr_->contains("source")) return std::nullopt; - const auto& value = repr_["source"]; + auto& value = (*repr_)["source"]; assert(value.is_string()); return value.get(); } auto Diagnostic::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); } auto Diagnostic::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); @@ -10754,78 +14694,137 @@ auto Diagnostic::tags() const -> std::optional> { auto Diagnostic::relatedInformation() const -> std::optional> { - if (!repr_.contains("relatedInformation")) return std::nullopt; + if (!repr_->contains("relatedInformation")) return std::nullopt; - const auto& value = repr_["relatedInformation"]; + auto& value = (*repr_)["relatedInformation"]; assert(value.is_array()); return Vector(value); } auto Diagnostic::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); } -auto Diagnostic::range(Range range) -> Diagnostic& { return *this; } +auto Diagnostic::range(Range range) -> Diagnostic& { + repr_->emplace("range", range); + return *this; +} auto Diagnostic::severity(std::optional severity) -> Diagnostic& { + if (!severity.has_value()) { + repr_->erase("severity"); + return *this; + } + repr_->emplace("severity", static_cast(severity.value())); return *this; } auto Diagnostic::code( std::optional> code) -> Diagnostic& { + if (!code.has_value()) { + repr_->erase("code"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int code) { repr_->emplace("code", std::move(code)); } + + void operator()(std::string code) { + repr_->emplace("code", std::move(code)); + } + } v{repr_}; + + std::visit(v, code.value()); + return *this; } auto Diagnostic::codeDescription(std::optional codeDescription) -> Diagnostic& { + if (!codeDescription.has_value()) { + repr_->erase("codeDescription"); + return *this; + } + repr_->emplace("codeDescription", codeDescription.value()); return *this; } auto Diagnostic::source(std::optional source) -> Diagnostic& { + if (!source.has_value()) { + repr_->erase("source"); + return *this; + } + repr_->emplace("source", std::move(source.value())); return *this; } -auto Diagnostic::message(std::string message) -> Diagnostic& { return *this; } +auto Diagnostic::message(std::string message) -> Diagnostic& { + repr_->emplace("message", std::move(message)); + return *this; +} auto Diagnostic::tags(std::optional> tags) -> Diagnostic& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("Diagnostic::tags: not implement yet"); return *this; } auto Diagnostic::relatedInformation( std::optional> relatedInformation) -> Diagnostic& { + if (!relatedInformation.has_value()) { + repr_->erase("relatedInformation"); + return *this; + } + lsp_runtime_error("Diagnostic::relatedInformation: not implement yet"); return *this; } auto Diagnostic::data(std::optional data) -> Diagnostic& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("Diagnostic::data: not implement yet"); return *this; } CompletionContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("triggerKind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("triggerKind")) return false; return true; } auto CompletionContext::triggerKind() const -> CompletionTriggerKind { - const auto& value = repr_["triggerKind"]; + auto& value = (*repr_)["triggerKind"]; return CompletionTriggerKind(value); } auto CompletionContext::triggerCharacter() const -> std::optional { - if (!repr_.contains("triggerCharacter")) return std::nullopt; + if (!repr_->contains("triggerCharacter")) return std::nullopt; - const auto& value = repr_["triggerCharacter"]; + auto& value = (*repr_)["triggerCharacter"]; assert(value.is_string()); return value.get(); @@ -10833,23 +14832,29 @@ auto CompletionContext::triggerCharacter() const -> std::optional { auto CompletionContext::triggerKind(CompletionTriggerKind triggerKind) -> CompletionContext& { + repr_->emplace("triggerKind", static_cast(triggerKind)); return *this; } auto CompletionContext::triggerCharacter( std::optional triggerCharacter) -> CompletionContext& { + if (!triggerCharacter.has_value()) { + repr_->erase("triggerCharacter"); + return *this; + } + repr_->emplace("triggerCharacter", std::move(triggerCharacter.value())); return *this; } CompletionItemLabelDetails::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionItemLabelDetails::detail() const -> std::optional { - if (!repr_.contains("detail")) return std::nullopt; + if (!repr_->contains("detail")) return std::nullopt; - const auto& value = repr_["detail"]; + auto& value = (*repr_)["detail"]; assert(value.is_string()); return value.get(); @@ -10857,9 +14862,9 @@ auto CompletionItemLabelDetails::detail() const -> std::optional { auto CompletionItemLabelDetails::description() const -> std::optional { - if (!repr_.contains("description")) return std::nullopt; + if (!repr_->contains("description")) return std::nullopt; - const auto& value = repr_["description"]; + auto& value = (*repr_)["description"]; assert(value.is_string()); return value.get(); @@ -10867,63 +14872,76 @@ auto CompletionItemLabelDetails::description() const auto CompletionItemLabelDetails::detail(std::optional detail) -> CompletionItemLabelDetails& { + if (!detail.has_value()) { + repr_->erase("detail"); + return *this; + } + repr_->emplace("detail", std::move(detail.value())); return *this; } auto CompletionItemLabelDetails::description( std::optional description) -> CompletionItemLabelDetails& { + if (!description.has_value()) { + repr_->erase("description"); + return *this; + } + repr_->emplace("description", std::move(description.value())); return *this; } InsertReplaceEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("newText")) return false; - if (!repr_.contains("insert")) return false; - if (!repr_.contains("replace")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("newText")) return false; + if (!repr_->contains("insert")) return false; + if (!repr_->contains("replace")) return false; return true; } auto InsertReplaceEdit::newText() const -> std::string { - const auto& value = repr_["newText"]; + auto& value = (*repr_)["newText"]; assert(value.is_string()); return value.get(); } auto InsertReplaceEdit::insert() const -> Range { - const auto& value = repr_["insert"]; + auto& value = (*repr_)["insert"]; return Range(value); } auto InsertReplaceEdit::replace() const -> Range { - const auto& value = repr_["replace"]; + auto& value = (*repr_)["replace"]; return Range(value); } auto InsertReplaceEdit::newText(std::string newText) -> InsertReplaceEdit& { + repr_->emplace("newText", std::move(newText)); return *this; } auto InsertReplaceEdit::insert(Range insert) -> InsertReplaceEdit& { + repr_->emplace("insert", insert); return *this; } auto InsertReplaceEdit::replace(Range replace) -> InsertReplaceEdit& { + repr_->emplace("replace", replace); return *this; } CompletionItemDefaults::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionItemDefaults::commitCharacters() const -> std::optional> { - if (!repr_.contains("commitCharacters")) return std::nullopt; + if (!repr_->contains("commitCharacters")) return std::nullopt; - const auto& value = repr_["commitCharacters"]; + auto& value = (*repr_)["commitCharacters"]; assert(value.is_array()); return Vector(value); @@ -10931,9 +14949,9 @@ auto CompletionItemDefaults::commitCharacters() const auto CompletionItemDefaults::editRange() const -> std::optional< std::variant> { - if (!repr_.contains("editRange")) return std::nullopt; + if (!repr_->contains("editRange")) return std::nullopt; - const auto& value = repr_["editRange"]; + auto& value = (*repr_)["editRange"]; std::variant result; @@ -10944,26 +14962,26 @@ auto CompletionItemDefaults::editRange() const -> std::optional< auto CompletionItemDefaults::insertTextFormat() const -> std::optional { - if (!repr_.contains("insertTextFormat")) return std::nullopt; + if (!repr_->contains("insertTextFormat")) return std::nullopt; - const auto& value = repr_["insertTextFormat"]; + auto& value = (*repr_)["insertTextFormat"]; return InsertTextFormat(value); } auto CompletionItemDefaults::insertTextMode() const -> std::optional { - if (!repr_.contains("insertTextMode")) return std::nullopt; + if (!repr_->contains("insertTextMode")) return std::nullopt; - const auto& value = repr_["insertTextMode"]; + auto& value = (*repr_)["insertTextMode"]; return InsertTextMode(value); } auto CompletionItemDefaults::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_object()); return LSPAny(value); @@ -10972,6 +14990,12 @@ auto CompletionItemDefaults::data() const -> std::optional { auto CompletionItemDefaults::commitCharacters( std::optional> commitCharacters) -> CompletionItemDefaults& { + if (!commitCharacters.has_value()) { + repr_->erase("commitCharacters"); + return *this; + } + lsp_runtime_error( + "CompletionItemDefaults::commitCharacters: not implement yet"); return *this; } @@ -10979,67 +15003,117 @@ auto CompletionItemDefaults::editRange( std::optional< std::variant> editRange) -> CompletionItemDefaults& { + if (!editRange.has_value()) { + repr_->erase("editRange"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(Range editRange) { repr_->emplace("editRange", editRange); } + + void operator()(EditRangeWithInsertReplace editRange) { + repr_->emplace("editRange", editRange); + } + } v{repr_}; + + std::visit(v, editRange.value()); + return *this; } auto CompletionItemDefaults::insertTextFormat( std::optional insertTextFormat) -> CompletionItemDefaults& { + if (!insertTextFormat.has_value()) { + repr_->erase("insertTextFormat"); + return *this; + } + repr_->emplace("insertTextFormat", + static_cast(insertTextFormat.value())); return *this; } auto CompletionItemDefaults::insertTextMode( std::optional insertTextMode) -> CompletionItemDefaults& { + if (!insertTextMode.has_value()) { + repr_->erase("insertTextMode"); + return *this; + } + repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); return *this; } auto CompletionItemDefaults::data(std::optional data) -> CompletionItemDefaults& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("CompletionItemDefaults::data: not implement yet"); return *this; } CompletionItemApplyKinds::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionItemApplyKinds::commitCharacters() const -> std::optional { - if (!repr_.contains("commitCharacters")) return std::nullopt; + if (!repr_->contains("commitCharacters")) return std::nullopt; - const auto& value = repr_["commitCharacters"]; + auto& value = (*repr_)["commitCharacters"]; return ApplyKind(value); } auto CompletionItemApplyKinds::data() const -> std::optional { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; return ApplyKind(value); } auto CompletionItemApplyKinds::commitCharacters( std::optional commitCharacters) -> CompletionItemApplyKinds& { + if (!commitCharacters.has_value()) { + repr_->erase("commitCharacters"); + return *this; + } + repr_->emplace("commitCharacters", + static_cast(commitCharacters.value())); return *this; } auto CompletionItemApplyKinds::data(std::optional data) -> CompletionItemApplyKinds& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + repr_->emplace("data", static_cast(data.value())); return *this; } CompletionOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionOptions::triggerCharacters() const -> std::optional> { - if (!repr_.contains("triggerCharacters")) return std::nullopt; + if (!repr_->contains("triggerCharacters")) return std::nullopt; - const auto& value = repr_["triggerCharacters"]; + auto& value = (*repr_)["triggerCharacters"]; assert(value.is_array()); return Vector(value); @@ -11047,18 +15121,18 @@ auto CompletionOptions::triggerCharacters() const auto CompletionOptions::allCommitCharacters() const -> std::optional> { - if (!repr_.contains("allCommitCharacters")) return std::nullopt; + if (!repr_->contains("allCommitCharacters")) return std::nullopt; - const auto& value = repr_["allCommitCharacters"]; + auto& value = (*repr_)["allCommitCharacters"]; assert(value.is_array()); return Vector(value); } auto CompletionOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); @@ -11066,17 +15140,17 @@ auto CompletionOptions::resolveProvider() const -> std::optional { auto CompletionOptions::completionItem() const -> std::optional { - if (!repr_.contains("completionItem")) return std::nullopt; + if (!repr_->contains("completionItem")) return std::nullopt; - const auto& value = repr_["completionItem"]; + auto& value = (*repr_)["completionItem"]; return ServerCompletionItemOptions(value); } auto CompletionOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11085,40 +15159,66 @@ auto CompletionOptions::workDoneProgress() const -> std::optional { auto CompletionOptions::triggerCharacters( std::optional> triggerCharacters) -> CompletionOptions& { + if (!triggerCharacters.has_value()) { + repr_->erase("triggerCharacters"); + return *this; + } + lsp_runtime_error("CompletionOptions::triggerCharacters: not implement yet"); return *this; } auto CompletionOptions::allCommitCharacters( std::optional> allCommitCharacters) -> CompletionOptions& { + if (!allCommitCharacters.has_value()) { + repr_->erase("allCommitCharacters"); + return *this; + } + lsp_runtime_error( + "CompletionOptions::allCommitCharacters: not implement yet"); return *this; } auto CompletionOptions::resolveProvider(std::optional resolveProvider) -> CompletionOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CompletionOptions::completionItem( std::optional completionItem) -> CompletionOptions& { + if (!completionItem.has_value()) { + repr_->erase("completionItem"); + return *this; + } + repr_->emplace("completionItem", completionItem.value()); return *this; } auto CompletionOptions::workDoneProgress(std::optional workDoneProgress) -> CompletionOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } HoverOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto HoverOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11126,34 +15226,39 @@ auto HoverOptions::workDoneProgress() const -> std::optional { auto HoverOptions::workDoneProgress(std::optional workDoneProgress) -> HoverOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } SignatureHelpContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("triggerKind")) return false; - if (!repr_.contains("isRetrigger")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("triggerKind")) return false; + if (!repr_->contains("isRetrigger")) return false; return true; } auto SignatureHelpContext::triggerKind() const -> SignatureHelpTriggerKind { - const auto& value = repr_["triggerKind"]; + auto& value = (*repr_)["triggerKind"]; return SignatureHelpTriggerKind(value); } auto SignatureHelpContext::triggerCharacter() const -> std::optional { - if (!repr_.contains("triggerCharacter")) return std::nullopt; + if (!repr_->contains("triggerCharacter")) return std::nullopt; - const auto& value = repr_["triggerCharacter"]; + auto& value = (*repr_)["triggerCharacter"]; assert(value.is_string()); return value.get(); } auto SignatureHelpContext::isRetrigger() const -> bool { - const auto& value = repr_["isRetrigger"]; + auto& value = (*repr_)["isRetrigger"]; assert(value.is_boolean()); return value.get(); @@ -11161,41 +15266,53 @@ auto SignatureHelpContext::isRetrigger() const -> bool { auto SignatureHelpContext::activeSignatureHelp() const -> std::optional { - if (!repr_.contains("activeSignatureHelp")) return std::nullopt; + if (!repr_->contains("activeSignatureHelp")) return std::nullopt; - const auto& value = repr_["activeSignatureHelp"]; + auto& value = (*repr_)["activeSignatureHelp"]; return SignatureHelp(value); } auto SignatureHelpContext::triggerKind(SignatureHelpTriggerKind triggerKind) -> SignatureHelpContext& { + repr_->emplace("triggerKind", static_cast(triggerKind)); return *this; } auto SignatureHelpContext::triggerCharacter( std::optional triggerCharacter) -> SignatureHelpContext& { + if (!triggerCharacter.has_value()) { + repr_->erase("triggerCharacter"); + return *this; + } + repr_->emplace("triggerCharacter", std::move(triggerCharacter.value())); return *this; } auto SignatureHelpContext::isRetrigger(bool isRetrigger) -> SignatureHelpContext& { + repr_->emplace("isRetrigger", std::move(isRetrigger)); return *this; } auto SignatureHelpContext::activeSignatureHelp( std::optional activeSignatureHelp) -> SignatureHelpContext& { + if (!activeSignatureHelp.has_value()) { + repr_->erase("activeSignatureHelp"); + return *this; + } + repr_->emplace("activeSignatureHelp", activeSignatureHelp.value()); return *this; } SignatureInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("label")) return false; return true; } auto SignatureInformation::label() const -> std::string { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); @@ -11203,9 +15320,9 @@ auto SignatureInformation::label() const -> std::string { auto SignatureInformation::documentation() const -> std::optional> { - if (!repr_.contains("documentation")) return std::nullopt; + if (!repr_->contains("documentation")) return std::nullopt; - const auto& value = repr_["documentation"]; + auto& value = (*repr_)["documentation"]; std::variant result; @@ -11216,9 +15333,9 @@ auto SignatureInformation::documentation() const auto SignatureInformation::parameters() const -> std::optional> { - if (!repr_.contains("parameters")) return std::nullopt; + if (!repr_->contains("parameters")) return std::nullopt; - const auto& value = repr_["parameters"]; + auto& value = (*repr_)["parameters"]; assert(value.is_array()); return Vector(value); @@ -11226,9 +15343,9 @@ auto SignatureInformation::parameters() const auto SignatureInformation::activeParameter() const -> std::optional> { - if (!repr_.contains("activeParameter")) return std::nullopt; + if (!repr_->contains("activeParameter")) return std::nullopt; - const auto& value = repr_["activeParameter"]; + auto& value = (*repr_)["activeParameter"]; std::variant result; @@ -11238,37 +15355,93 @@ auto SignatureInformation::activeParameter() const } auto SignatureInformation::label(std::string label) -> SignatureInformation& { + repr_->emplace("label", std::move(label)); return *this; } auto SignatureInformation::documentation( std::optional> documentation) -> SignatureInformation& { + if (!documentation.has_value()) { + repr_->erase("documentation"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string documentation) { + repr_->emplace("documentation", std::move(documentation)); + } + + void operator()(MarkupContent documentation) { + repr_->emplace("documentation", documentation); + } + } v{repr_}; + + std::visit(v, documentation.value()); + return *this; } auto SignatureInformation::parameters( std::optional> parameters) -> SignatureInformation& { + if (!parameters.has_value()) { + repr_->erase("parameters"); + return *this; + } + lsp_runtime_error("SignatureInformation::parameters: not implement yet"); return *this; } auto SignatureInformation::activeParameter( std::optional> activeParameter) -> SignatureInformation& { + if (!activeParameter.has_value()) { + repr_->erase("activeParameter"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(long activeParameter) { + repr_->emplace("activeParameter", std::move(activeParameter)); + } + + void operator()(std::nullptr_t activeParameter) { + repr_->emplace("activeParameter", std::move(activeParameter)); + } + } v{repr_}; + + std::visit(v, activeParameter.value()); + return *this; } SignatureHelpOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SignatureHelpOptions::triggerCharacters() const -> std::optional> { - if (!repr_.contains("triggerCharacters")) return std::nullopt; + if (!repr_->contains("triggerCharacters")) return std::nullopt; - const auto& value = repr_["triggerCharacters"]; + auto& value = (*repr_)["triggerCharacters"]; assert(value.is_array()); return Vector(value); @@ -11276,18 +15449,18 @@ auto SignatureHelpOptions::triggerCharacters() const auto SignatureHelpOptions::retriggerCharacters() const -> std::optional> { - if (!repr_.contains("retriggerCharacters")) return std::nullopt; + if (!repr_->contains("retriggerCharacters")) return std::nullopt; - const auto& value = repr_["retriggerCharacters"]; + auto& value = (*repr_)["retriggerCharacters"]; assert(value.is_array()); return Vector(value); } auto SignatureHelpOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11296,29 +15469,46 @@ auto SignatureHelpOptions::workDoneProgress() const -> std::optional { auto SignatureHelpOptions::triggerCharacters( std::optional> triggerCharacters) -> SignatureHelpOptions& { + if (!triggerCharacters.has_value()) { + repr_->erase("triggerCharacters"); + return *this; + } + lsp_runtime_error( + "SignatureHelpOptions::triggerCharacters: not implement yet"); return *this; } auto SignatureHelpOptions::retriggerCharacters( std::optional> retriggerCharacters) -> SignatureHelpOptions& { + if (!retriggerCharacters.has_value()) { + repr_->erase("retriggerCharacters"); + return *this; + } + lsp_runtime_error( + "SignatureHelpOptions::retriggerCharacters: not implement yet"); return *this; } auto SignatureHelpOptions::workDoneProgress( std::optional workDoneProgress) -> SignatureHelpOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DefinitionOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DefinitionOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11326,17 +15516,22 @@ auto DefinitionOptions::workDoneProgress() const -> std::optional { auto DefinitionOptions::workDoneProgress(std::optional workDoneProgress) -> DefinitionOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } ReferenceContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("includeDeclaration")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("includeDeclaration")) return false; return true; } auto ReferenceContext::includeDeclaration() const -> bool { - const auto& value = repr_["includeDeclaration"]; + auto& value = (*repr_)["includeDeclaration"]; assert(value.is_boolean()); return value.get(); @@ -11344,18 +15539,19 @@ auto ReferenceContext::includeDeclaration() const -> bool { auto ReferenceContext::includeDeclaration(bool includeDeclaration) -> ReferenceContext& { + repr_->emplace("includeDeclaration", std::move(includeDeclaration)); return *this; } ReferenceOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ReferenceOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11363,18 +15559,23 @@ auto ReferenceOptions::workDoneProgress() const -> std::optional { auto ReferenceOptions::workDoneProgress(std::optional workDoneProgress) -> ReferenceOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentHighlightOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentHighlightOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11382,33 +15583,38 @@ auto DocumentHighlightOptions::workDoneProgress() const -> std::optional { auto DocumentHighlightOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentHighlightOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } BaseSymbolInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; - if (!repr_.contains("kind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; + if (!repr_->contains("kind")) return false; return true; } auto BaseSymbolInformation::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto BaseSymbolInformation::kind() const -> SymbolKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return SymbolKind(value); } auto BaseSymbolInformation::tags() const -> std::optional> { - if (!repr_.contains("tags")) return std::nullopt; + if (!repr_->contains("tags")) return std::nullopt; - const auto& value = repr_["tags"]; + auto& value = (*repr_)["tags"]; assert(value.is_array()); return Vector(value); @@ -11416,50 +15622,62 @@ auto BaseSymbolInformation::tags() const -> std::optional> { auto BaseSymbolInformation::containerName() const -> std::optional { - if (!repr_.contains("containerName")) return std::nullopt; + if (!repr_->contains("containerName")) return std::nullopt; - const auto& value = repr_["containerName"]; + auto& value = (*repr_)["containerName"]; assert(value.is_string()); return value.get(); } auto BaseSymbolInformation::name(std::string name) -> BaseSymbolInformation& { + repr_->emplace("name", std::move(name)); return *this; } auto BaseSymbolInformation::kind(SymbolKind kind) -> BaseSymbolInformation& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto BaseSymbolInformation::tags(std::optional> tags) -> BaseSymbolInformation& { + if (!tags.has_value()) { + repr_->erase("tags"); + return *this; + } + lsp_runtime_error("BaseSymbolInformation::tags: not implement yet"); return *this; } auto BaseSymbolInformation::containerName( std::optional containerName) -> BaseSymbolInformation& { + if (!containerName.has_value()) { + repr_->erase("containerName"); + return *this; + } + repr_->emplace("containerName", std::move(containerName.value())); return *this; } DocumentSymbolOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentSymbolOptions::label() const -> std::optional { - if (!repr_.contains("label")) return std::nullopt; + if (!repr_->contains("label")) return std::nullopt; - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; assert(value.is_string()); return value.get(); } auto DocumentSymbolOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11467,31 +15685,41 @@ auto DocumentSymbolOptions::workDoneProgress() const -> std::optional { auto DocumentSymbolOptions::label(std::optional label) -> DocumentSymbolOptions& { + if (!label.has_value()) { + repr_->erase("label"); + return *this; + } + repr_->emplace("label", std::move(label.value())); return *this; } auto DocumentSymbolOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentSymbolOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } CodeActionContext::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("diagnostics")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("diagnostics")) return false; return true; } auto CodeActionContext::diagnostics() const -> Vector { - const auto& value = repr_["diagnostics"]; + auto& value = (*repr_)["diagnostics"]; assert(value.is_array()); return Vector(value); } auto CodeActionContext::only() const -> std::optional> { - if (!repr_.contains("only")) return std::nullopt; + if (!repr_->contains("only")) return std::nullopt; - const auto& value = repr_["only"]; + auto& value = (*repr_)["only"]; assert(value.is_array()); return Vector(value); @@ -11499,55 +15727,67 @@ auto CodeActionContext::only() const -> std::optional> { auto CodeActionContext::triggerKind() const -> std::optional { - if (!repr_.contains("triggerKind")) return std::nullopt; + if (!repr_->contains("triggerKind")) return std::nullopt; - const auto& value = repr_["triggerKind"]; + auto& value = (*repr_)["triggerKind"]; return CodeActionTriggerKind(value); } auto CodeActionContext::diagnostics(Vector diagnostics) -> CodeActionContext& { + lsp_runtime_error("CodeActionContext::diagnostics: not implement yet"); return *this; } auto CodeActionContext::only(std::optional> only) -> CodeActionContext& { + if (!only.has_value()) { + repr_->erase("only"); + return *this; + } + lsp_runtime_error("CodeActionContext::only: not implement yet"); return *this; } auto CodeActionContext::triggerKind( std::optional triggerKind) -> CodeActionContext& { + if (!triggerKind.has_value()) { + repr_->erase("triggerKind"); + return *this; + } + repr_->emplace("triggerKind", static_cast(triggerKind.value())); return *this; } CodeActionDisabled::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("reason")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("reason")) return false; return true; } auto CodeActionDisabled::reason() const -> std::string { - const auto& value = repr_["reason"]; + auto& value = (*repr_)["reason"]; assert(value.is_string()); return value.get(); } auto CodeActionDisabled::reason(std::string reason) -> CodeActionDisabled& { + repr_->emplace("reason", std::move(reason)); return *this; } CodeActionOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CodeActionOptions::codeActionKinds() const -> std::optional> { - if (!repr_.contains("codeActionKinds")) return std::nullopt; + if (!repr_->contains("codeActionKinds")) return std::nullopt; - const auto& value = repr_["codeActionKinds"]; + auto& value = (*repr_)["codeActionKinds"]; assert(value.is_array()); return Vector(value); @@ -11555,27 +15795,27 @@ auto CodeActionOptions::codeActionKinds() const auto CodeActionOptions::documentation() const -> std::optional> { - if (!repr_.contains("documentation")) return std::nullopt; + if (!repr_->contains("documentation")) return std::nullopt; - const auto& value = repr_["documentation"]; + auto& value = (*repr_)["documentation"]; assert(value.is_array()); return Vector(value); } auto CodeActionOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); } auto CodeActionOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11584,58 +15824,81 @@ auto CodeActionOptions::workDoneProgress() const -> std::optional { auto CodeActionOptions::codeActionKinds( std::optional> codeActionKinds) -> CodeActionOptions& { + if (!codeActionKinds.has_value()) { + repr_->erase("codeActionKinds"); + return *this; + } + lsp_runtime_error("CodeActionOptions::codeActionKinds: not implement yet"); return *this; } auto CodeActionOptions::documentation( std::optional> documentation) -> CodeActionOptions& { + if (!documentation.has_value()) { + repr_->erase("documentation"); + return *this; + } + lsp_runtime_error("CodeActionOptions::documentation: not implement yet"); return *this; } auto CodeActionOptions::resolveProvider(std::optional resolveProvider) -> CodeActionOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CodeActionOptions::workDoneProgress(std::optional workDoneProgress) -> CodeActionOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } LocationUriOnly::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; return true; } auto LocationUriOnly::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); } -auto LocationUriOnly::uri(std::string uri) -> LocationUriOnly& { return *this; } +auto LocationUriOnly::uri(std::string uri) -> LocationUriOnly& { + repr_->emplace("uri", std::move(uri)); + return *this; +} WorkspaceSymbolOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceSymbolOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); } auto WorkspaceSymbolOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11643,32 +15906,42 @@ auto WorkspaceSymbolOptions::workDoneProgress() const -> std::optional { auto WorkspaceSymbolOptions::resolveProvider( std::optional resolveProvider) -> WorkspaceSymbolOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto WorkspaceSymbolOptions::workDoneProgress( std::optional workDoneProgress) -> WorkspaceSymbolOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } CodeLensOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CodeLensOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); } auto CodeLensOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11676,32 +15949,42 @@ auto CodeLensOptions::workDoneProgress() const -> std::optional { auto CodeLensOptions::resolveProvider(std::optional resolveProvider) -> CodeLensOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto CodeLensOptions::workDoneProgress(std::optional workDoneProgress) -> CodeLensOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentLinkOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentLinkOptions::resolveProvider() const -> std::optional { - if (!repr_.contains("resolveProvider")) return std::nullopt; + if (!repr_->contains("resolveProvider")) return std::nullopt; - const auto& value = repr_["resolveProvider"]; + auto& value = (*repr_)["resolveProvider"]; assert(value.is_boolean()); return value.get(); } auto DocumentLinkOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11709,95 +15992,123 @@ auto DocumentLinkOptions::workDoneProgress() const -> std::optional { auto DocumentLinkOptions::resolveProvider(std::optional resolveProvider) -> DocumentLinkOptions& { + if (!resolveProvider.has_value()) { + repr_->erase("resolveProvider"); + return *this; + } + repr_->emplace("resolveProvider", std::move(resolveProvider.value())); return *this; } auto DocumentLinkOptions::workDoneProgress(std::optional workDoneProgress) -> DocumentLinkOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } FormattingOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("tabSize")) return false; - if (!repr_.contains("insertSpaces")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("tabSize")) return false; + if (!repr_->contains("insertSpaces")) return false; return true; } auto FormattingOptions::tabSize() const -> long { - const auto& value = repr_["tabSize"]; + auto& value = (*repr_)["tabSize"]; assert(value.is_number_integer()); return value.get(); } auto FormattingOptions::insertSpaces() const -> bool { - const auto& value = repr_["insertSpaces"]; + auto& value = (*repr_)["insertSpaces"]; assert(value.is_boolean()); return value.get(); } auto FormattingOptions::trimTrailingWhitespace() const -> std::optional { - if (!repr_.contains("trimTrailingWhitespace")) return std::nullopt; + if (!repr_->contains("trimTrailingWhitespace")) return std::nullopt; - const auto& value = repr_["trimTrailingWhitespace"]; + auto& value = (*repr_)["trimTrailingWhitespace"]; assert(value.is_boolean()); return value.get(); } auto FormattingOptions::insertFinalNewline() const -> std::optional { - if (!repr_.contains("insertFinalNewline")) return std::nullopt; + if (!repr_->contains("insertFinalNewline")) return std::nullopt; - const auto& value = repr_["insertFinalNewline"]; + auto& value = (*repr_)["insertFinalNewline"]; assert(value.is_boolean()); return value.get(); } auto FormattingOptions::trimFinalNewlines() const -> std::optional { - if (!repr_.contains("trimFinalNewlines")) return std::nullopt; + if (!repr_->contains("trimFinalNewlines")) return std::nullopt; - const auto& value = repr_["trimFinalNewlines"]; + auto& value = (*repr_)["trimFinalNewlines"]; assert(value.is_boolean()); return value.get(); } auto FormattingOptions::tabSize(long tabSize) -> FormattingOptions& { + repr_->emplace("tabSize", std::move(tabSize)); return *this; } auto FormattingOptions::insertSpaces(bool insertSpaces) -> FormattingOptions& { + repr_->emplace("insertSpaces", std::move(insertSpaces)); return *this; } auto FormattingOptions::trimTrailingWhitespace( std::optional trimTrailingWhitespace) -> FormattingOptions& { + if (!trimTrailingWhitespace.has_value()) { + repr_->erase("trimTrailingWhitespace"); + return *this; + } + repr_->emplace("trimTrailingWhitespace", + std::move(trimTrailingWhitespace.value())); return *this; } auto FormattingOptions::insertFinalNewline( std::optional insertFinalNewline) -> FormattingOptions& { + if (!insertFinalNewline.has_value()) { + repr_->erase("insertFinalNewline"); + return *this; + } + repr_->emplace("insertFinalNewline", std::move(insertFinalNewline.value())); return *this; } auto FormattingOptions::trimFinalNewlines(std::optional trimFinalNewlines) -> FormattingOptions& { + if (!trimFinalNewlines.has_value()) { + repr_->erase("trimFinalNewlines"); + return *this; + } + repr_->emplace("trimFinalNewlines", std::move(trimFinalNewlines.value())); return *this; } DocumentFormattingOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentFormattingOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11805,19 +16116,24 @@ auto DocumentFormattingOptions::workDoneProgress() const auto DocumentFormattingOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentFormattingOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentRangeFormattingOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentRangeFormattingOptions::rangesSupport() const -> std::optional { - if (!repr_.contains("rangesSupport")) return std::nullopt; + if (!repr_->contains("rangesSupport")) return std::nullopt; - const auto& value = repr_["rangesSupport"]; + auto& value = (*repr_)["rangesSupport"]; assert(value.is_boolean()); return value.get(); @@ -11825,9 +16141,9 @@ auto DocumentRangeFormattingOptions::rangesSupport() const auto DocumentRangeFormattingOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11835,23 +16151,33 @@ auto DocumentRangeFormattingOptions::workDoneProgress() const auto DocumentRangeFormattingOptions::rangesSupport( std::optional rangesSupport) -> DocumentRangeFormattingOptions& { + if (!rangesSupport.has_value()) { + repr_->erase("rangesSupport"); + return *this; + } + repr_->emplace("rangesSupport", std::move(rangesSupport.value())); return *this; } auto DocumentRangeFormattingOptions::workDoneProgress( std::optional workDoneProgress) -> DocumentRangeFormattingOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } DocumentOnTypeFormattingOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("firstTriggerCharacter")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("firstTriggerCharacter")) return false; return true; } auto DocumentOnTypeFormattingOptions::firstTriggerCharacter() const -> std::string { - const auto& value = repr_["firstTriggerCharacter"]; + auto& value = (*repr_)["firstTriggerCharacter"]; assert(value.is_string()); return value.get(); @@ -11859,9 +16185,9 @@ auto DocumentOnTypeFormattingOptions::firstTriggerCharacter() const auto DocumentOnTypeFormattingOptions::moreTriggerCharacter() const -> std::optional> { - if (!repr_.contains("moreTriggerCharacter")) return std::nullopt; + if (!repr_->contains("moreTriggerCharacter")) return std::nullopt; - const auto& value = repr_["moreTriggerCharacter"]; + auto& value = (*repr_)["moreTriggerCharacter"]; assert(value.is_array()); return Vector(value); @@ -11869,33 +16195,41 @@ auto DocumentOnTypeFormattingOptions::moreTriggerCharacter() const auto DocumentOnTypeFormattingOptions::firstTriggerCharacter( std::string firstTriggerCharacter) -> DocumentOnTypeFormattingOptions& { + repr_->emplace("firstTriggerCharacter", std::move(firstTriggerCharacter)); return *this; } auto DocumentOnTypeFormattingOptions::moreTriggerCharacter( std::optional> moreTriggerCharacter) -> DocumentOnTypeFormattingOptions& { + if (!moreTriggerCharacter.has_value()) { + repr_->erase("moreTriggerCharacter"); + return *this; + } + lsp_runtime_error( + "DocumentOnTypeFormattingOptions::moreTriggerCharacter: not implement " + "yet"); return *this; } RenameOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto RenameOptions::prepareProvider() const -> std::optional { - if (!repr_.contains("prepareProvider")) return std::nullopt; + if (!repr_->contains("prepareProvider")) return std::nullopt; - const auto& value = repr_["prepareProvider"]; + auto& value = (*repr_)["prepareProvider"]; assert(value.is_boolean()); return value.get(); } auto RenameOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11903,51 +16237,63 @@ auto RenameOptions::workDoneProgress() const -> std::optional { auto RenameOptions::prepareProvider(std::optional prepareProvider) -> RenameOptions& { + if (!prepareProvider.has_value()) { + repr_->erase("prepareProvider"); + return *this; + } + repr_->emplace("prepareProvider", std::move(prepareProvider.value())); return *this; } auto RenameOptions::workDoneProgress(std::optional workDoneProgress) -> RenameOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } PrepareRenamePlaceholder::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("placeholder")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("placeholder")) return false; return true; } auto PrepareRenamePlaceholder::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto PrepareRenamePlaceholder::placeholder() const -> std::string { - const auto& value = repr_["placeholder"]; + auto& value = (*repr_)["placeholder"]; assert(value.is_string()); return value.get(); } auto PrepareRenamePlaceholder::range(Range range) -> PrepareRenamePlaceholder& { + repr_->emplace("range", range); return *this; } auto PrepareRenamePlaceholder::placeholder(std::string placeholder) -> PrepareRenamePlaceholder& { + repr_->emplace("placeholder", std::move(placeholder)); return *this; } PrepareRenameDefaultBehavior::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("defaultBehavior")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("defaultBehavior")) return false; return true; } auto PrepareRenameDefaultBehavior::defaultBehavior() const -> bool { - const auto& value = repr_["defaultBehavior"]; + auto& value = (*repr_)["defaultBehavior"]; assert(value.is_boolean()); return value.get(); @@ -11955,26 +16301,27 @@ auto PrepareRenameDefaultBehavior::defaultBehavior() const -> bool { auto PrepareRenameDefaultBehavior::defaultBehavior(bool defaultBehavior) -> PrepareRenameDefaultBehavior& { + repr_->emplace("defaultBehavior", std::move(defaultBehavior)); return *this; } ExecuteCommandOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("commands")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("commands")) return false; return true; } auto ExecuteCommandOptions::commands() const -> Vector { - const auto& value = repr_["commands"]; + auto& value = (*repr_)["commands"]; assert(value.is_array()); return Vector(value); } auto ExecuteCommandOptions::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -11982,23 +16329,29 @@ auto ExecuteCommandOptions::workDoneProgress() const -> std::optional { auto ExecuteCommandOptions::commands(Vector commands) -> ExecuteCommandOptions& { + lsp_runtime_error("ExecuteCommandOptions::commands: not implement yet"); return *this; } auto ExecuteCommandOptions::workDoneProgress( std::optional workDoneProgress) -> ExecuteCommandOptions& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } WorkspaceEditMetadata::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceEditMetadata::isRefactoring() const -> std::optional { - if (!repr_.contains("isRefactoring")) return std::nullopt; + if (!repr_->contains("isRefactoring")) return std::nullopt; - const auto& value = repr_["isRefactoring"]; + auto& value = (*repr_)["isRefactoring"]; assert(value.is_boolean()); return value.get(); @@ -12006,25 +16359,30 @@ auto WorkspaceEditMetadata::isRefactoring() const -> std::optional { auto WorkspaceEditMetadata::isRefactoring(std::optional isRefactoring) -> WorkspaceEditMetadata& { + if (!isRefactoring.has_value()) { + repr_->erase("isRefactoring"); + return *this; + } + repr_->emplace("isRefactoring", std::move(isRefactoring.value())); return *this; } SemanticTokensLegend::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("tokenTypes")) return false; - if (!repr_.contains("tokenModifiers")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("tokenTypes")) return false; + if (!repr_->contains("tokenModifiers")) return false; return true; } auto SemanticTokensLegend::tokenTypes() const -> Vector { - const auto& value = repr_["tokenTypes"]; + auto& value = (*repr_)["tokenTypes"]; assert(value.is_array()); return Vector(value); } auto SemanticTokensLegend::tokenModifiers() const -> Vector { - const auto& value = repr_["tokenModifiers"]; + auto& value = (*repr_)["tokenModifiers"]; assert(value.is_array()); return Vector(value); @@ -12032,23 +16390,25 @@ auto SemanticTokensLegend::tokenModifiers() const -> Vector { auto SemanticTokensLegend::tokenTypes(Vector tokenTypes) -> SemanticTokensLegend& { + lsp_runtime_error("SemanticTokensLegend::tokenTypes: not implement yet"); return *this; } auto SemanticTokensLegend::tokenModifiers(Vector tokenModifiers) -> SemanticTokensLegend& { + lsp_runtime_error("SemanticTokensLegend::tokenModifiers: not implement yet"); return *this; } SemanticTokensFullDelta::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SemanticTokensFullDelta::delta() const -> std::optional { - if (!repr_.contains("delta")) return std::nullopt; + if (!repr_->contains("delta")) return std::nullopt; - const auto& value = repr_["delta"]; + auto& value = (*repr_)["delta"]; assert(value.is_boolean()); return value.get(); @@ -12056,19 +16416,24 @@ auto SemanticTokensFullDelta::delta() const -> std::optional { auto SemanticTokensFullDelta::delta(std::optional delta) -> SemanticTokensFullDelta& { + if (!delta.has_value()) { + repr_->erase("delta"); + return *this; + } + repr_->emplace("delta", std::move(delta.value())); return *this; } OptionalVersionedTextDocumentIdentifier::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("uri")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("uri")) return false; return true; } auto OptionalVersionedTextDocumentIdentifier::version() const -> std::variant { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; std::variant result; @@ -12078,7 +16443,7 @@ auto OptionalVersionedTextDocumentIdentifier::version() const } auto OptionalVersionedTextDocumentIdentifier::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -12087,37 +16452,58 @@ auto OptionalVersionedTextDocumentIdentifier::uri() const -> std::string { auto OptionalVersionedTextDocumentIdentifier::version( std::variant version) -> OptionalVersionedTextDocumentIdentifier& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int version) { + repr_->emplace("version", std::move(version)); + } + + void operator()(std::nullptr_t version) { + repr_->emplace("version", std::move(version)); + } + } v{repr_}; + + std::visit(v, version); + return *this; } auto OptionalVersionedTextDocumentIdentifier::uri(std::string uri) -> OptionalVersionedTextDocumentIdentifier& { + repr_->emplace("uri", std::move(uri)); return *this; } AnnotatedTextEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("annotationId")) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("newText")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("annotationId")) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("newText")) return false; return true; } auto AnnotatedTextEdit::annotationId() const -> ChangeAnnotationIdentifier { - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } auto AnnotatedTextEdit::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto AnnotatedTextEdit::newText() const -> std::string { - const auto& value = repr_["newText"]; + auto& value = (*repr_)["newText"]; assert(value.is_string()); return value.get(); @@ -12125,66 +16511,78 @@ auto AnnotatedTextEdit::newText() const -> std::string { auto AnnotatedTextEdit::annotationId(ChangeAnnotationIdentifier annotationId) -> AnnotatedTextEdit& { + lsp_runtime_error("AnnotatedTextEdit::annotationId: not implement yet"); return *this; } auto AnnotatedTextEdit::range(Range range) -> AnnotatedTextEdit& { + repr_->emplace("range", range); return *this; } auto AnnotatedTextEdit::newText(std::string newText) -> AnnotatedTextEdit& { + repr_->emplace("newText", std::move(newText)); return *this; } SnippetTextEdit::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("snippet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("snippet")) return false; return true; } auto SnippetTextEdit::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto SnippetTextEdit::snippet() const -> StringValue { - const auto& value = repr_["snippet"]; + auto& value = (*repr_)["snippet"]; return StringValue(value); } auto SnippetTextEdit::annotationId() const -> std::optional { - if (!repr_.contains("annotationId")) return std::nullopt; + if (!repr_->contains("annotationId")) return std::nullopt; - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } -auto SnippetTextEdit::range(Range range) -> SnippetTextEdit& { return *this; } +auto SnippetTextEdit::range(Range range) -> SnippetTextEdit& { + repr_->emplace("range", range); + return *this; +} auto SnippetTextEdit::snippet(StringValue snippet) -> SnippetTextEdit& { + repr_->emplace("snippet", snippet); return *this; } auto SnippetTextEdit::annotationId( std::optional annotationId) -> SnippetTextEdit& { + if (!annotationId.has_value()) { + repr_->erase("annotationId"); + return *this; + } + lsp_runtime_error("SnippetTextEdit::annotationId: not implement yet"); return *this; } ResourceOperation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; return true; } auto ResourceOperation::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); @@ -12192,42 +16590,48 @@ auto ResourceOperation::kind() const -> std::string { auto ResourceOperation::annotationId() const -> std::optional { - if (!repr_.contains("annotationId")) return std::nullopt; + if (!repr_->contains("annotationId")) return std::nullopt; - const auto& value = repr_["annotationId"]; + auto& value = (*repr_)["annotationId"]; assert(value.is_string()); return value.get(); } auto ResourceOperation::kind(std::string kind) -> ResourceOperation& { + repr_->emplace("kind", std::move(kind)); return *this; } auto ResourceOperation::annotationId( std::optional annotationId) -> ResourceOperation& { + if (!annotationId.has_value()) { + repr_->erase("annotationId"); + return *this; + } + lsp_runtime_error("ResourceOperation::annotationId: not implement yet"); return *this; } CreateFileOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CreateFileOptions::overwrite() const -> std::optional { - if (!repr_.contains("overwrite")) return std::nullopt; + if (!repr_->contains("overwrite")) return std::nullopt; - const auto& value = repr_["overwrite"]; + auto& value = (*repr_)["overwrite"]; assert(value.is_boolean()); return value.get(); } auto CreateFileOptions::ignoreIfExists() const -> std::optional { - if (!repr_.contains("ignoreIfExists")) return std::nullopt; + if (!repr_->contains("ignoreIfExists")) return std::nullopt; - const auto& value = repr_["ignoreIfExists"]; + auto& value = (*repr_)["ignoreIfExists"]; assert(value.is_boolean()); return value.get(); @@ -12235,32 +16639,42 @@ auto CreateFileOptions::ignoreIfExists() const -> std::optional { auto CreateFileOptions::overwrite(std::optional overwrite) -> CreateFileOptions& { + if (!overwrite.has_value()) { + repr_->erase("overwrite"); + return *this; + } + repr_->emplace("overwrite", std::move(overwrite.value())); return *this; } auto CreateFileOptions::ignoreIfExists(std::optional ignoreIfExists) -> CreateFileOptions& { + if (!ignoreIfExists.has_value()) { + repr_->erase("ignoreIfExists"); + return *this; + } + repr_->emplace("ignoreIfExists", std::move(ignoreIfExists.value())); return *this; } RenameFileOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto RenameFileOptions::overwrite() const -> std::optional { - if (!repr_.contains("overwrite")) return std::nullopt; + if (!repr_->contains("overwrite")) return std::nullopt; - const auto& value = repr_["overwrite"]; + auto& value = (*repr_)["overwrite"]; assert(value.is_boolean()); return value.get(); } auto RenameFileOptions::ignoreIfExists() const -> std::optional { - if (!repr_.contains("ignoreIfExists")) return std::nullopt; + if (!repr_->contains("ignoreIfExists")) return std::nullopt; - const auto& value = repr_["ignoreIfExists"]; + auto& value = (*repr_)["ignoreIfExists"]; assert(value.is_boolean()); return value.get(); @@ -12268,32 +16682,42 @@ auto RenameFileOptions::ignoreIfExists() const -> std::optional { auto RenameFileOptions::overwrite(std::optional overwrite) -> RenameFileOptions& { + if (!overwrite.has_value()) { + repr_->erase("overwrite"); + return *this; + } + repr_->emplace("overwrite", std::move(overwrite.value())); return *this; } auto RenameFileOptions::ignoreIfExists(std::optional ignoreIfExists) -> RenameFileOptions& { + if (!ignoreIfExists.has_value()) { + repr_->erase("ignoreIfExists"); + return *this; + } + repr_->emplace("ignoreIfExists", std::move(ignoreIfExists.value())); return *this; } DeleteFileOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DeleteFileOptions::recursive() const -> std::optional { - if (!repr_.contains("recursive")) return std::nullopt; + if (!repr_->contains("recursive")) return std::nullopt; - const auto& value = repr_["recursive"]; + auto& value = (*repr_)["recursive"]; assert(value.is_boolean()); return value.get(); } auto DeleteFileOptions::ignoreIfNotExists() const -> std::optional { - if (!repr_.contains("ignoreIfNotExists")) return std::nullopt; + if (!repr_->contains("ignoreIfNotExists")) return std::nullopt; - const auto& value = repr_["ignoreIfNotExists"]; + auto& value = (*repr_)["ignoreIfNotExists"]; assert(value.is_boolean()); return value.get(); @@ -12301,22 +16725,32 @@ auto DeleteFileOptions::ignoreIfNotExists() const -> std::optional { auto DeleteFileOptions::recursive(std::optional recursive) -> DeleteFileOptions& { + if (!recursive.has_value()) { + repr_->erase("recursive"); + return *this; + } + repr_->emplace("recursive", std::move(recursive.value())); return *this; } auto DeleteFileOptions::ignoreIfNotExists(std::optional ignoreIfNotExists) -> DeleteFileOptions& { + if (!ignoreIfNotExists.has_value()) { + repr_->erase("ignoreIfNotExists"); + return *this; + } + repr_->emplace("ignoreIfNotExists", std::move(ignoreIfNotExists.value())); return *this; } FileOperationPattern::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("glob")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("glob")) return false; return true; } auto FileOperationPattern::glob() const -> std::string { - const auto& value = repr_["glob"]; + auto& value = (*repr_)["glob"]; assert(value.is_string()); return value.get(); @@ -12324,49 +16758,60 @@ auto FileOperationPattern::glob() const -> std::string { auto FileOperationPattern::matches() const -> std::optional { - if (!repr_.contains("matches")) return std::nullopt; + if (!repr_->contains("matches")) return std::nullopt; - const auto& value = repr_["matches"]; + auto& value = (*repr_)["matches"]; lsp_runtime_error("FileOperationPattern::matches: not implement yet"); } auto FileOperationPattern::options() const -> std::optional { - if (!repr_.contains("options")) return std::nullopt; + if (!repr_->contains("options")) return std::nullopt; - const auto& value = repr_["options"]; + auto& value = (*repr_)["options"]; return FileOperationPatternOptions(value); } auto FileOperationPattern::glob(std::string glob) -> FileOperationPattern& { + repr_->emplace("glob", std::move(glob)); return *this; } auto FileOperationPattern::matches( std::optional matches) -> FileOperationPattern& { + if (!matches.has_value()) { + repr_->erase("matches"); + return *this; + } + lsp_runtime_error("FileOperationPattern::matches: not implement yet"); return *this; } auto FileOperationPattern::options( std::optional options) -> FileOperationPattern& { + if (!options.has_value()) { + repr_->erase("options"); + return *this; + } + repr_->emplace("options", options.value()); return *this; } WorkspaceFullDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "full") return false; - if (!repr_.contains("items")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "full") return false; + if (!repr_->contains("items")) return false; return true; } auto WorkspaceFullDocumentDiagnosticReport::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -12374,7 +16819,7 @@ auto WorkspaceFullDocumentDiagnosticReport::uri() const -> std::string { auto WorkspaceFullDocumentDiagnosticReport::version() const -> std::variant { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; std::variant result; @@ -12384,7 +16829,7 @@ auto WorkspaceFullDocumentDiagnosticReport::version() const } auto WorkspaceFullDocumentDiagnosticReport::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); @@ -12392,9 +16837,9 @@ auto WorkspaceFullDocumentDiagnosticReport::kind() const -> std::string { auto WorkspaceFullDocumentDiagnosticReport::resultId() const -> std::optional { - if (!repr_.contains("resultId")) return std::nullopt; + if (!repr_->contains("resultId")) return std::nullopt; - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); @@ -12402,7 +16847,7 @@ auto WorkspaceFullDocumentDiagnosticReport::resultId() const auto WorkspaceFullDocumentDiagnosticReport::items() const -> Vector { - const auto& value = repr_["items"]; + auto& value = (*repr_)["items"]; assert(value.is_array()); return Vector(value); @@ -12410,43 +16855,73 @@ auto WorkspaceFullDocumentDiagnosticReport::items() const auto WorkspaceFullDocumentDiagnosticReport::uri(std::string uri) -> WorkspaceFullDocumentDiagnosticReport& { + repr_->emplace("uri", std::move(uri)); return *this; } auto WorkspaceFullDocumentDiagnosticReport::version( std::variant version) -> WorkspaceFullDocumentDiagnosticReport& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int version) { + repr_->emplace("version", std::move(version)); + } + + void operator()(std::nullptr_t version) { + repr_->emplace("version", std::move(version)); + } + } v{repr_}; + + std::visit(v, version); + return *this; } auto WorkspaceFullDocumentDiagnosticReport::kind(std::string kind) -> WorkspaceFullDocumentDiagnosticReport& { + lsp_runtime_error( + "WorkspaceFullDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto WorkspaceFullDocumentDiagnosticReport::resultId( std::optional resultId) -> WorkspaceFullDocumentDiagnosticReport& { + if (!resultId.has_value()) { + repr_->erase("resultId"); + return *this; + } + repr_->emplace("resultId", std::move(resultId.value())); return *this; } auto WorkspaceFullDocumentDiagnosticReport::items(Vector items) -> WorkspaceFullDocumentDiagnosticReport& { + lsp_runtime_error( + "WorkspaceFullDocumentDiagnosticReport::items: not implement yet"); return *this; } WorkspaceUnchangedDocumentDiagnosticReport::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("uri")) return false; - if (!repr_.contains("version")) return false; - if (!repr_.contains("kind")) return false; - if (repr_["kind"] != "unchanged") return false; - if (!repr_.contains("resultId")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("uri")) return false; + if (!repr_->contains("version")) return false; + if (!repr_->contains("kind")) return false; + if ((*repr_)["kind"] != "unchanged") return false; + if (!repr_->contains("resultId")) return false; return true; } auto WorkspaceUnchangedDocumentDiagnosticReport::uri() const -> std::string { - const auto& value = repr_["uri"]; + auto& value = (*repr_)["uri"]; assert(value.is_string()); return value.get(); @@ -12454,7 +16929,7 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::uri() const -> std::string { auto WorkspaceUnchangedDocumentDiagnosticReport::version() const -> std::variant { - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; std::variant result; @@ -12464,7 +16939,7 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::version() const } auto WorkspaceUnchangedDocumentDiagnosticReport::kind() const -> std::string { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; assert(value.is_string()); return value.get(); @@ -12472,7 +16947,7 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::kind() const -> std::string { auto WorkspaceUnchangedDocumentDiagnosticReport::resultId() const -> std::string { - const auto& value = repr_["resultId"]; + auto& value = (*repr_)["resultId"]; assert(value.is_string()); return value.get(); @@ -12480,89 +16955,125 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::resultId() const auto WorkspaceUnchangedDocumentDiagnosticReport::uri(std::string uri) -> WorkspaceUnchangedDocumentDiagnosticReport& { + repr_->emplace("uri", std::move(uri)); return *this; } auto WorkspaceUnchangedDocumentDiagnosticReport::version( std::variant version) -> WorkspaceUnchangedDocumentDiagnosticReport& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(int version) { + repr_->emplace("version", std::move(version)); + } + + void operator()(std::nullptr_t version) { + repr_->emplace("version", std::move(version)); + } + } v{repr_}; + + std::visit(v, version); + return *this; } auto WorkspaceUnchangedDocumentDiagnosticReport::kind(std::string kind) -> WorkspaceUnchangedDocumentDiagnosticReport& { + lsp_runtime_error( + "WorkspaceUnchangedDocumentDiagnosticReport::kind: not implement yet"); return *this; } auto WorkspaceUnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> WorkspaceUnchangedDocumentDiagnosticReport& { + repr_->emplace("resultId", std::move(resultId)); return *this; } NotebookCell::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("document")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("document")) return false; return true; } auto NotebookCell::kind() const -> NotebookCellKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; return NotebookCellKind(value); } auto NotebookCell::document() const -> std::string { - const auto& value = repr_["document"]; + auto& value = (*repr_)["document"]; assert(value.is_string()); return value.get(); } auto NotebookCell::metadata() const -> std::optional { - if (!repr_.contains("metadata")) return std::nullopt; + if (!repr_->contains("metadata")) return std::nullopt; - const auto& value = repr_["metadata"]; + auto& value = (*repr_)["metadata"]; assert(value.is_object()); return LSPObject(value); } auto NotebookCell::executionSummary() const -> std::optional { - if (!repr_.contains("executionSummary")) return std::nullopt; + if (!repr_->contains("executionSummary")) return std::nullopt; - const auto& value = repr_["executionSummary"]; + auto& value = (*repr_)["executionSummary"]; return ExecutionSummary(value); } auto NotebookCell::kind(NotebookCellKind kind) -> NotebookCell& { + repr_->emplace("kind", static_cast(kind)); return *this; } auto NotebookCell::document(std::string document) -> NotebookCell& { + repr_->emplace("document", std::move(document)); return *this; } auto NotebookCell::metadata(std::optional metadata) -> NotebookCell& { + if (!metadata.has_value()) { + repr_->erase("metadata"); + return *this; + } + lsp_runtime_error("NotebookCell::metadata: not implement yet"); return *this; } auto NotebookCell::executionSummary( std::optional executionSummary) -> NotebookCell& { + if (!executionSummary.has_value()) { + repr_->erase("executionSummary"); + return *this; + } + repr_->emplace("executionSummary", executionSummary.value()); return *this; } NotebookDocumentFilterWithNotebook::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebook")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebook")) return false; return true; } auto NotebookDocumentFilterWithNotebook::notebook() const -> std::variant { - const auto& value = repr_["notebook"]; + auto& value = (*repr_)["notebook"]; std::variant result; @@ -12573,9 +17084,9 @@ auto NotebookDocumentFilterWithNotebook::notebook() const auto NotebookDocumentFilterWithNotebook::cells() const -> std::optional> { - if (!repr_.contains("cells")) return std::nullopt; + if (!repr_->contains("cells")) return std::nullopt; - const auto& value = repr_["cells"]; + auto& value = (*repr_)["cells"]; assert(value.is_array()); return Vector(value); @@ -12584,26 +17095,53 @@ auto NotebookDocumentFilterWithNotebook::cells() const auto NotebookDocumentFilterWithNotebook::notebook( std::variant notebook) -> NotebookDocumentFilterWithNotebook& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string notebook) { + repr_->emplace("notebook", std::move(notebook)); + } + + void operator()(NotebookDocumentFilter notebook) { + lsp_runtime_error( + "NotebookDocumentFilterWithNotebook::notebook: not implement yet"); + } + } v{repr_}; + + std::visit(v, notebook); + return *this; } auto NotebookDocumentFilterWithNotebook::cells( std::optional> cells) -> NotebookDocumentFilterWithNotebook& { + if (!cells.has_value()) { + repr_->erase("cells"); + return *this; + } + lsp_runtime_error( + "NotebookDocumentFilterWithNotebook::cells: not implement yet"); return *this; } NotebookDocumentFilterWithCells::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("cells")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("cells")) return false; return true; } auto NotebookDocumentFilterWithCells::notebook() const -> std::optional< std::variant> { - if (!repr_.contains("notebook")) return std::nullopt; + if (!repr_->contains("notebook")) return std::nullopt; - const auto& value = repr_["notebook"]; + auto& value = (*repr_)["notebook"]; std::variant result; @@ -12614,7 +17152,7 @@ auto NotebookDocumentFilterWithCells::notebook() const -> std::optional< auto NotebookDocumentFilterWithCells::cells() const -> Vector { - const auto& value = repr_["cells"]; + auto& value = (*repr_)["cells"]; assert(value.is_array()); return Vector(value); @@ -12624,33 +17162,61 @@ auto NotebookDocumentFilterWithCells::notebook( std::optional< std::variant> notebook) -> NotebookDocumentFilterWithCells& { + if (!notebook.has_value()) { + repr_->erase("notebook"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string notebook) { + repr_->emplace("notebook", std::move(notebook)); + } + + void operator()(NotebookDocumentFilter notebook) { + lsp_runtime_error( + "NotebookDocumentFilterWithCells::notebook: not implement yet"); + } + } v{repr_}; + + std::visit(v, notebook.value()); + return *this; } auto NotebookDocumentFilterWithCells::cells(Vector cells) -> NotebookDocumentFilterWithCells& { + lsp_runtime_error( + "NotebookDocumentFilterWithCells::cells: not implement yet"); return *this; } NotebookDocumentCellChanges::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto NotebookDocumentCellChanges::structure() const -> std::optional { - if (!repr_.contains("structure")) return std::nullopt; + if (!repr_->contains("structure")) return std::nullopt; - const auto& value = repr_["structure"]; + auto& value = (*repr_)["structure"]; return NotebookDocumentCellChangeStructure(value); } auto NotebookDocumentCellChanges::data() const -> std::optional> { - if (!repr_.contains("data")) return std::nullopt; + if (!repr_->contains("data")) return std::nullopt; - const auto& value = repr_["data"]; + auto& value = (*repr_)["data"]; assert(value.is_array()); return Vector(value); @@ -12658,9 +17224,9 @@ auto NotebookDocumentCellChanges::data() const auto NotebookDocumentCellChanges::textContent() const -> std::optional> { - if (!repr_.contains("textContent")) return std::nullopt; + if (!repr_->contains("textContent")) return std::nullopt; - const auto& value = repr_["textContent"]; + auto& value = (*repr_)["textContent"]; assert(value.is_array()); return Vector(value); @@ -12669,130 +17235,156 @@ auto NotebookDocumentCellChanges::textContent() const auto NotebookDocumentCellChanges::structure( std::optional structure) -> NotebookDocumentCellChanges& { + if (!structure.has_value()) { + repr_->erase("structure"); + return *this; + } + repr_->emplace("structure", structure.value()); return *this; } auto NotebookDocumentCellChanges::data(std::optional> data) -> NotebookDocumentCellChanges& { + if (!data.has_value()) { + repr_->erase("data"); + return *this; + } + lsp_runtime_error("NotebookDocumentCellChanges::data: not implement yet"); return *this; } auto NotebookDocumentCellChanges::textContent( std::optional> textContent) -> NotebookDocumentCellChanges& { + if (!textContent.has_value()) { + repr_->erase("textContent"); + return *this; + } + lsp_runtime_error( + "NotebookDocumentCellChanges::textContent: not implement yet"); return *this; } SelectedCompletionInfo::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("text")) return false; return true; } auto SelectedCompletionInfo::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto SelectedCompletionInfo::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); } auto SelectedCompletionInfo::range(Range range) -> SelectedCompletionInfo& { + repr_->emplace("range", range); return *this; } auto SelectedCompletionInfo::text(std::string text) -> SelectedCompletionInfo& { + repr_->emplace("text", std::move(text)); return *this; } ClientInfo::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("name")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("name")) return false; return true; } auto ClientInfo::name() const -> std::string { - const auto& value = repr_["name"]; + auto& value = (*repr_)["name"]; assert(value.is_string()); return value.get(); } auto ClientInfo::version() const -> std::optional { - if (!repr_.contains("version")) return std::nullopt; + if (!repr_->contains("version")) return std::nullopt; - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_string()); return value.get(); } -auto ClientInfo::name(std::string name) -> ClientInfo& { return *this; } +auto ClientInfo::name(std::string name) -> ClientInfo& { + repr_->emplace("name", std::move(name)); + return *this; +} auto ClientInfo::version(std::optional version) -> ClientInfo& { + if (!version.has_value()) { + repr_->erase("version"); + return *this; + } + repr_->emplace("version", std::move(version.value())); return *this; } ClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientCapabilities::workspace() const -> std::optional { - if (!repr_.contains("workspace")) return std::nullopt; + if (!repr_->contains("workspace")) return std::nullopt; - const auto& value = repr_["workspace"]; + auto& value = (*repr_)["workspace"]; return WorkspaceClientCapabilities(value); } auto ClientCapabilities::textDocument() const -> std::optional { - if (!repr_.contains("textDocument")) return std::nullopt; + if (!repr_->contains("textDocument")) return std::nullopt; - const auto& value = repr_["textDocument"]; + auto& value = (*repr_)["textDocument"]; return TextDocumentClientCapabilities(value); } auto ClientCapabilities::notebookDocument() const -> std::optional { - if (!repr_.contains("notebookDocument")) return std::nullopt; + if (!repr_->contains("notebookDocument")) return std::nullopt; - const auto& value = repr_["notebookDocument"]; + auto& value = (*repr_)["notebookDocument"]; return NotebookDocumentClientCapabilities(value); } auto ClientCapabilities::window() const -> std::optional { - if (!repr_.contains("window")) return std::nullopt; + if (!repr_->contains("window")) return std::nullopt; - const auto& value = repr_["window"]; + auto& value = (*repr_)["window"]; return WindowClientCapabilities(value); } auto ClientCapabilities::general() const -> std::optional { - if (!repr_.contains("general")) return std::nullopt; + if (!repr_->contains("general")) return std::nullopt; - const auto& value = repr_["general"]; + auto& value = (*repr_)["general"]; return GeneralClientCapabilities(value); } auto ClientCapabilities::experimental() const -> std::optional { - if (!repr_.contains("experimental")) return std::nullopt; + if (!repr_->contains("experimental")) return std::nullopt; - const auto& value = repr_["experimental"]; + auto& value = (*repr_)["experimental"]; assert(value.is_object()); return LSPAny(value); @@ -12801,45 +17393,75 @@ auto ClientCapabilities::experimental() const -> std::optional { auto ClientCapabilities::workspace( std::optional workspace) -> ClientCapabilities& { + if (!workspace.has_value()) { + repr_->erase("workspace"); + return *this; + } + repr_->emplace("workspace", workspace.value()); return *this; } auto ClientCapabilities::textDocument( std::optional textDocument) -> ClientCapabilities& { + if (!textDocument.has_value()) { + repr_->erase("textDocument"); + return *this; + } + repr_->emplace("textDocument", textDocument.value()); return *this; } auto ClientCapabilities::notebookDocument( std::optional notebookDocument) -> ClientCapabilities& { + if (!notebookDocument.has_value()) { + repr_->erase("notebookDocument"); + return *this; + } + repr_->emplace("notebookDocument", notebookDocument.value()); return *this; } auto ClientCapabilities::window(std::optional window) -> ClientCapabilities& { + if (!window.has_value()) { + repr_->erase("window"); + return *this; + } + repr_->emplace("window", window.value()); return *this; } auto ClientCapabilities::general( std::optional general) -> ClientCapabilities& { + if (!general.has_value()) { + repr_->erase("general"); + return *this; + } + repr_->emplace("general", general.value()); return *this; } auto ClientCapabilities::experimental(std::optional experimental) -> ClientCapabilities& { + if (!experimental.has_value()) { + repr_->erase("experimental"); + return *this; + } + lsp_runtime_error("ClientCapabilities::experimental: not implement yet"); return *this; } TextDocumentSyncOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TextDocumentSyncOptions::openClose() const -> std::optional { - if (!repr_.contains("openClose")) return std::nullopt; + if (!repr_->contains("openClose")) return std::nullopt; - const auto& value = repr_["openClose"]; + auto& value = (*repr_)["openClose"]; assert(value.is_boolean()); return value.get(); @@ -12847,26 +17469,26 @@ auto TextDocumentSyncOptions::openClose() const -> std::optional { auto TextDocumentSyncOptions::change() const -> std::optional { - if (!repr_.contains("change")) return std::nullopt; + if (!repr_->contains("change")) return std::nullopt; - const auto& value = repr_["change"]; + auto& value = (*repr_)["change"]; return TextDocumentSyncKind(value); } auto TextDocumentSyncOptions::willSave() const -> std::optional { - if (!repr_.contains("willSave")) return std::nullopt; + if (!repr_->contains("willSave")) return std::nullopt; - const auto& value = repr_["willSave"]; + auto& value = (*repr_)["willSave"]; assert(value.is_boolean()); return value.get(); } auto TextDocumentSyncOptions::willSaveWaitUntil() const -> std::optional { - if (!repr_.contains("willSaveWaitUntil")) return std::nullopt; + if (!repr_->contains("willSaveWaitUntil")) return std::nullopt; - const auto& value = repr_["willSaveWaitUntil"]; + auto& value = (*repr_)["willSaveWaitUntil"]; assert(value.is_boolean()); return value.get(); @@ -12874,9 +17496,9 @@ auto TextDocumentSyncOptions::willSaveWaitUntil() const -> std::optional { auto TextDocumentSyncOptions::save() const -> std::optional> { - if (!repr_.contains("save")) return std::nullopt; + if (!repr_->contains("save")) return std::nullopt; - const auto& value = repr_["save"]; + auto& value = (*repr_)["save"]; std::variant result; @@ -12887,49 +17509,90 @@ auto TextDocumentSyncOptions::save() const auto TextDocumentSyncOptions::openClose(std::optional openClose) -> TextDocumentSyncOptions& { + if (!openClose.has_value()) { + repr_->erase("openClose"); + return *this; + } + repr_->emplace("openClose", std::move(openClose.value())); return *this; } auto TextDocumentSyncOptions::change(std::optional change) -> TextDocumentSyncOptions& { + if (!change.has_value()) { + repr_->erase("change"); + return *this; + } + repr_->emplace("change", static_cast(change.value())); return *this; } auto TextDocumentSyncOptions::willSave(std::optional willSave) -> TextDocumentSyncOptions& { + if (!willSave.has_value()) { + repr_->erase("willSave"); + return *this; + } + repr_->emplace("willSave", std::move(willSave.value())); return *this; } auto TextDocumentSyncOptions::willSaveWaitUntil( std::optional willSaveWaitUntil) -> TextDocumentSyncOptions& { + if (!willSaveWaitUntil.has_value()) { + repr_->erase("willSaveWaitUntil"); + return *this; + } + repr_->emplace("willSaveWaitUntil", std::move(willSaveWaitUntil.value())); return *this; } auto TextDocumentSyncOptions::save( std::optional> save) -> TextDocumentSyncOptions& { + if (!save.has_value()) { + repr_->erase("save"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool save) { repr_->emplace("save", std::move(save)); } + + void operator()(SaveOptions save) { repr_->emplace("save", save); } + } v{repr_}; + + std::visit(v, save.value()); + return *this; } WorkspaceOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceOptions::workspaceFolders() const -> std::optional { - if (!repr_.contains("workspaceFolders")) return std::nullopt; + if (!repr_->contains("workspaceFolders")) return std::nullopt; - const auto& value = repr_["workspaceFolders"]; + auto& value = (*repr_)["workspaceFolders"]; return WorkspaceFoldersServerCapabilities(value); } auto WorkspaceOptions::fileOperations() const -> std::optional { - if (!repr_.contains("fileOperations")) return std::nullopt; + if (!repr_->contains("fileOperations")) return std::nullopt; - const auto& value = repr_["fileOperations"]; + auto& value = (*repr_)["fileOperations"]; return FileOperationOptions(value); } @@ -12937,9 +17600,9 @@ auto WorkspaceOptions::fileOperations() const auto WorkspaceOptions::textDocumentContent() const -> std::optional> { - if (!repr_.contains("textDocumentContent")) return std::nullopt; + if (!repr_->contains("textDocumentContent")) return std::nullopt; - const auto& value = repr_["textDocumentContent"]; + auto& value = (*repr_)["textDocumentContent"]; std::variant @@ -12953,11 +17616,21 @@ auto WorkspaceOptions::textDocumentContent() const auto WorkspaceOptions::workspaceFolders( std::optional workspaceFolders) -> WorkspaceOptions& { + if (!workspaceFolders.has_value()) { + repr_->erase("workspaceFolders"); + return *this; + } + repr_->emplace("workspaceFolders", workspaceFolders.value()); return *this; } auto WorkspaceOptions::fileOperations( std::optional fileOperations) -> WorkspaceOptions& { + if (!fileOperations.has_value()) { + repr_->erase("fileOperations"); + return *this; + } + repr_->emplace("fileOperations", fileOperations.value()); return *this; } @@ -12965,34 +17638,60 @@ auto WorkspaceOptions::textDocumentContent( std::optional> textDocumentContent) -> WorkspaceOptions& { + if (!textDocumentContent.has_value()) { + repr_->erase("textDocumentContent"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(TextDocumentContentOptions textDocumentContent) { + repr_->emplace("textDocumentContent", textDocumentContent); + } + + void operator()( + TextDocumentContentRegistrationOptions textDocumentContent) { + repr_->emplace("textDocumentContent", textDocumentContent); + } + } v{repr_}; + + std::visit(v, textDocumentContent.value()); + return *this; } TextDocumentContentChangePartial::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("range")) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("range")) return false; + if (!repr_->contains("text")) return false; return true; } auto TextDocumentContentChangePartial::range() const -> Range { - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; return Range(value); } auto TextDocumentContentChangePartial::rangeLength() const -> std::optional { - if (!repr_.contains("rangeLength")) return std::nullopt; + if (!repr_->contains("rangeLength")) return std::nullopt; - const auto& value = repr_["rangeLength"]; + auto& value = (*repr_)["rangeLength"]; assert(value.is_number_integer()); return value.get(); } auto TextDocumentContentChangePartial::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); @@ -13000,27 +17699,34 @@ auto TextDocumentContentChangePartial::text() const -> std::string { auto TextDocumentContentChangePartial::range(Range range) -> TextDocumentContentChangePartial& { + repr_->emplace("range", range); return *this; } auto TextDocumentContentChangePartial::rangeLength( std::optional rangeLength) -> TextDocumentContentChangePartial& { + if (!rangeLength.has_value()) { + repr_->erase("rangeLength"); + return *this; + } + repr_->emplace("rangeLength", std::move(rangeLength.value())); return *this; } auto TextDocumentContentChangePartial::text(std::string text) -> TextDocumentContentChangePartial& { + repr_->emplace("text", std::move(text)); return *this; } TextDocumentContentChangeWholeDocument::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("text")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("text")) return false; return true; } auto TextDocumentContentChangeWholeDocument::text() const -> std::string { - const auto& value = repr_["text"]; + auto& value = (*repr_)["text"]; assert(value.is_string()); return value.get(); @@ -13028,41 +17734,43 @@ auto TextDocumentContentChangeWholeDocument::text() const -> std::string { auto TextDocumentContentChangeWholeDocument::text(std::string text) -> TextDocumentContentChangeWholeDocument& { + repr_->emplace("text", std::move(text)); return *this; } CodeDescription::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("href")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("href")) return false; return true; } auto CodeDescription::href() const -> std::string { - const auto& value = repr_["href"]; + auto& value = (*repr_)["href"]; assert(value.is_string()); return value.get(); } auto CodeDescription::href(std::string href) -> CodeDescription& { + repr_->emplace("href", std::move(href)); return *this; } DiagnosticRelatedInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("location")) return false; - if (!repr_.contains("message")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("location")) return false; + if (!repr_->contains("message")) return false; return true; } auto DiagnosticRelatedInformation::location() const -> Location { - const auto& value = repr_["location"]; + auto& value = (*repr_)["location"]; return Location(value); } auto DiagnosticRelatedInformation::message() const -> std::string { - const auto& value = repr_["message"]; + auto& value = (*repr_)["message"]; assert(value.is_string()); return value.get(); @@ -13070,53 +17778,57 @@ auto DiagnosticRelatedInformation::message() const -> std::string { auto DiagnosticRelatedInformation::location(Location location) -> DiagnosticRelatedInformation& { + repr_->emplace("location", location); return *this; } auto DiagnosticRelatedInformation::message(std::string message) -> DiagnosticRelatedInformation& { + repr_->emplace("message", std::move(message)); return *this; } EditRangeWithInsertReplace::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("insert")) return false; - if (!repr_.contains("replace")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("insert")) return false; + if (!repr_->contains("replace")) return false; return true; } auto EditRangeWithInsertReplace::insert() const -> Range { - const auto& value = repr_["insert"]; + auto& value = (*repr_)["insert"]; return Range(value); } auto EditRangeWithInsertReplace::replace() const -> Range { - const auto& value = repr_["replace"]; + auto& value = (*repr_)["replace"]; return Range(value); } auto EditRangeWithInsertReplace::insert(Range insert) -> EditRangeWithInsertReplace& { + repr_->emplace("insert", insert); return *this; } auto EditRangeWithInsertReplace::replace(Range replace) -> EditRangeWithInsertReplace& { + repr_->emplace("replace", replace); return *this; } ServerCompletionItemOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ServerCompletionItemOptions::labelDetailsSupport() const -> std::optional { - if (!repr_.contains("labelDetailsSupport")) return std::nullopt; + if (!repr_->contains("labelDetailsSupport")) return std::nullopt; - const auto& value = repr_["labelDetailsSupport"]; + auto& value = (*repr_)["labelDetailsSupport"]; assert(value.is_boolean()); return value.get(); @@ -13124,25 +17836,30 @@ auto ServerCompletionItemOptions::labelDetailsSupport() const auto ServerCompletionItemOptions::labelDetailsSupport( std::optional labelDetailsSupport) -> ServerCompletionItemOptions& { + if (!labelDetailsSupport.has_value()) { + repr_->erase("labelDetailsSupport"); + return *this; + } + repr_->emplace("labelDetailsSupport", std::move(labelDetailsSupport.value())); return *this; } MarkedStringWithLanguage::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("language")) return false; - if (!repr_.contains("value")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("language")) return false; + if (!repr_->contains("value")) return false; return true; } auto MarkedStringWithLanguage::language() const -> std::string { - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); } auto MarkedStringWithLanguage::value() const -> std::string { - const auto& value = repr_["value"]; + auto& value = (*repr_)["value"]; assert(value.is_string()); return value.get(); @@ -13150,23 +17867,25 @@ auto MarkedStringWithLanguage::value() const -> std::string { auto MarkedStringWithLanguage::language(std::string language) -> MarkedStringWithLanguage& { + repr_->emplace("language", std::move(language)); return *this; } auto MarkedStringWithLanguage::value(std::string value) -> MarkedStringWithLanguage& { + repr_->emplace("value", std::move(value)); return *this; } ParameterInformation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("label")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("label")) return false; return true; } auto ParameterInformation::label() const -> std::variant> { - const auto& value = repr_["label"]; + auto& value = (*repr_)["label"]; std::variant> result; @@ -13177,9 +17896,9 @@ auto ParameterInformation::label() const auto ParameterInformation::documentation() const -> std::optional> { - if (!repr_.contains("documentation")) return std::nullopt; + if (!repr_->contains("documentation")) return std::nullopt; - const auto& value = repr_["documentation"]; + auto& value = (*repr_)["documentation"]; std::variant result; @@ -13191,53 +17910,100 @@ auto ParameterInformation::documentation() const auto ParameterInformation::label( std::variant> label) -> ParameterInformation& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string label) { + repr_->emplace("label", std::move(label)); + } + + void operator()(std::tuple label) { + lsp_runtime_error("ParameterInformation::label: not implement yet"); + } + } v{repr_}; + + std::visit(v, label); + return *this; } auto ParameterInformation::documentation( std::optional> documentation) -> ParameterInformation& { + if (!documentation.has_value()) { + repr_->erase("documentation"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string documentation) { + repr_->emplace("documentation", std::move(documentation)); + } + + void operator()(MarkupContent documentation) { + repr_->emplace("documentation", documentation); + } + } v{repr_}; + + std::visit(v, documentation.value()); + return *this; } CodeActionKindDocumentation::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("kind")) return false; - if (!repr_.contains("command")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("kind")) return false; + if (!repr_->contains("command")) return false; return true; } auto CodeActionKindDocumentation::kind() const -> CodeActionKind { - const auto& value = repr_["kind"]; + auto& value = (*repr_)["kind"]; lsp_runtime_error("CodeActionKindDocumentation::kind: not implement yet"); } auto CodeActionKindDocumentation::command() const -> Command { - const auto& value = repr_["command"]; + auto& value = (*repr_)["command"]; return Command(value); } auto CodeActionKindDocumentation::kind(CodeActionKind kind) -> CodeActionKindDocumentation& { + lsp_runtime_error("CodeActionKindDocumentation::kind: not implement yet"); return *this; } auto CodeActionKindDocumentation::command(Command command) -> CodeActionKindDocumentation& { + repr_->emplace("command", command); return *this; } NotebookCellTextDocumentFilter::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebook")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebook")) return false; return true; } auto NotebookCellTextDocumentFilter::notebook() const -> std::variant { - const auto& value = repr_["notebook"]; + auto& value = (*repr_)["notebook"]; std::variant result; @@ -13248,9 +18014,9 @@ auto NotebookCellTextDocumentFilter::notebook() const auto NotebookCellTextDocumentFilter::language() const -> std::optional { - if (!repr_.contains("language")) return std::nullopt; + if (!repr_->contains("language")) return std::nullopt; - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); @@ -13259,23 +18025,49 @@ auto NotebookCellTextDocumentFilter::language() const auto NotebookCellTextDocumentFilter::notebook( std::variant notebook) -> NotebookCellTextDocumentFilter& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string notebook) { + repr_->emplace("notebook", std::move(notebook)); + } + + void operator()(NotebookDocumentFilter notebook) { + lsp_runtime_error( + "NotebookCellTextDocumentFilter::notebook: not implement yet"); + } + } v{repr_}; + + std::visit(v, notebook); + return *this; } auto NotebookCellTextDocumentFilter::language( std::optional language) -> NotebookCellTextDocumentFilter& { + if (!language.has_value()) { + repr_->erase("language"); + return *this; + } + repr_->emplace("language", std::move(language.value())); return *this; } FileOperationPatternOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FileOperationPatternOptions::ignoreCase() const -> std::optional { - if (!repr_.contains("ignoreCase")) return std::nullopt; + if (!repr_->contains("ignoreCase")) return std::nullopt; - const auto& value = repr_["ignoreCase"]; + auto& value = (*repr_)["ignoreCase"]; assert(value.is_boolean()); return value.get(); @@ -13283,26 +18075,31 @@ auto FileOperationPatternOptions::ignoreCase() const -> std::optional { auto FileOperationPatternOptions::ignoreCase(std::optional ignoreCase) -> FileOperationPatternOptions& { + if (!ignoreCase.has_value()) { + repr_->erase("ignoreCase"); + return *this; + } + repr_->emplace("ignoreCase", std::move(ignoreCase.value())); return *this; } ExecutionSummary::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("executionOrder")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("executionOrder")) return false; return true; } auto ExecutionSummary::executionOrder() const -> long { - const auto& value = repr_["executionOrder"]; + auto& value = (*repr_)["executionOrder"]; assert(value.is_number_integer()); return value.get(); } auto ExecutionSummary::success() const -> std::optional { - if (!repr_.contains("success")) return std::nullopt; + if (!repr_->contains("success")) return std::nullopt; - const auto& value = repr_["success"]; + auto& value = (*repr_)["success"]; assert(value.is_boolean()); return value.get(); @@ -13310,22 +18107,28 @@ auto ExecutionSummary::success() const -> std::optional { auto ExecutionSummary::executionOrder(long executionOrder) -> ExecutionSummary& { + repr_->emplace("executionOrder", std::move(executionOrder)); return *this; } auto ExecutionSummary::success(std::optional success) -> ExecutionSummary& { + if (!success.has_value()) { + repr_->erase("success"); + return *this; + } + repr_->emplace("success", std::move(success.value())); return *this; } NotebookCellLanguage::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("language")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("language")) return false; return true; } auto NotebookCellLanguage::language() const -> std::string { - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); @@ -13333,27 +18136,28 @@ auto NotebookCellLanguage::language() const -> std::string { auto NotebookCellLanguage::language(std::string language) -> NotebookCellLanguage& { + repr_->emplace("language", std::move(language)); return *this; } NotebookDocumentCellChangeStructure::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("array")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("array")) return false; return true; } auto NotebookDocumentCellChangeStructure::array() const -> NotebookCellArrayChange { - const auto& value = repr_["array"]; + auto& value = (*repr_)["array"]; return NotebookCellArrayChange(value); } auto NotebookDocumentCellChangeStructure::didOpen() const -> std::optional> { - if (!repr_.contains("didOpen")) return std::nullopt; + if (!repr_->contains("didOpen")) return std::nullopt; - const auto& value = repr_["didOpen"]; + auto& value = (*repr_)["didOpen"]; assert(value.is_array()); return Vector(value); @@ -13361,9 +18165,9 @@ auto NotebookDocumentCellChangeStructure::didOpen() const auto NotebookDocumentCellChangeStructure::didClose() const -> std::optional> { - if (!repr_.contains("didClose")) return std::nullopt; + if (!repr_->contains("didClose")) return std::nullopt; - const auto& value = repr_["didClose"]; + auto& value = (*repr_)["didClose"]; assert(value.is_array()); return Vector(value); @@ -13371,38 +18175,51 @@ auto NotebookDocumentCellChangeStructure::didClose() const auto NotebookDocumentCellChangeStructure::array(NotebookCellArrayChange array) -> NotebookDocumentCellChangeStructure& { + repr_->emplace("array", array); return *this; } auto NotebookDocumentCellChangeStructure::didOpen( std::optional> didOpen) -> NotebookDocumentCellChangeStructure& { + if (!didOpen.has_value()) { + repr_->erase("didOpen"); + return *this; + } + lsp_runtime_error( + "NotebookDocumentCellChangeStructure::didOpen: not implement yet"); return *this; } auto NotebookDocumentCellChangeStructure::didClose( std::optional> didClose) -> NotebookDocumentCellChangeStructure& { + if (!didClose.has_value()) { + repr_->erase("didClose"); + return *this; + } + lsp_runtime_error( + "NotebookDocumentCellChangeStructure::didClose: not implement yet"); return *this; } NotebookDocumentCellContentChanges::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("document")) return false; - if (!repr_.contains("changes")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("document")) return false; + if (!repr_->contains("changes")) return false; return true; } auto NotebookDocumentCellContentChanges::document() const -> VersionedTextDocumentIdentifier { - const auto& value = repr_["document"]; + auto& value = (*repr_)["document"]; return VersionedTextDocumentIdentifier(value); } auto NotebookDocumentCellContentChanges::changes() const -> Vector { - const auto& value = repr_["changes"]; + auto& value = (*repr_)["changes"]; assert(value.is_array()); return Vector(value); @@ -13411,24 +18228,27 @@ auto NotebookDocumentCellContentChanges::changes() const auto NotebookDocumentCellContentChanges::document( VersionedTextDocumentIdentifier document) -> NotebookDocumentCellContentChanges& { + repr_->emplace("document", document); return *this; } auto NotebookDocumentCellContentChanges::changes( Vector changes) -> NotebookDocumentCellContentChanges& { + lsp_runtime_error( + "NotebookDocumentCellContentChanges::changes: not implement yet"); return *this; } WorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceClientCapabilities::applyEdit() const -> std::optional { - if (!repr_.contains("applyEdit")) return std::nullopt; + if (!repr_->contains("applyEdit")) return std::nullopt; - const auto& value = repr_["applyEdit"]; + auto& value = (*repr_)["applyEdit"]; assert(value.is_boolean()); return value.get(); @@ -13436,63 +18256,63 @@ auto WorkspaceClientCapabilities::applyEdit() const -> std::optional { auto WorkspaceClientCapabilities::workspaceEdit() const -> std::optional { - if (!repr_.contains("workspaceEdit")) return std::nullopt; + if (!repr_->contains("workspaceEdit")) return std::nullopt; - const auto& value = repr_["workspaceEdit"]; + auto& value = (*repr_)["workspaceEdit"]; return WorkspaceEditClientCapabilities(value); } auto WorkspaceClientCapabilities::didChangeConfiguration() const -> std::optional { - if (!repr_.contains("didChangeConfiguration")) return std::nullopt; + if (!repr_->contains("didChangeConfiguration")) return std::nullopt; - const auto& value = repr_["didChangeConfiguration"]; + auto& value = (*repr_)["didChangeConfiguration"]; return DidChangeConfigurationClientCapabilities(value); } auto WorkspaceClientCapabilities::didChangeWatchedFiles() const -> std::optional { - if (!repr_.contains("didChangeWatchedFiles")) return std::nullopt; + if (!repr_->contains("didChangeWatchedFiles")) return std::nullopt; - const auto& value = repr_["didChangeWatchedFiles"]; + auto& value = (*repr_)["didChangeWatchedFiles"]; return DidChangeWatchedFilesClientCapabilities(value); } auto WorkspaceClientCapabilities::symbol() const -> std::optional { - if (!repr_.contains("symbol")) return std::nullopt; + if (!repr_->contains("symbol")) return std::nullopt; - const auto& value = repr_["symbol"]; + auto& value = (*repr_)["symbol"]; return WorkspaceSymbolClientCapabilities(value); } auto WorkspaceClientCapabilities::executeCommand() const -> std::optional { - if (!repr_.contains("executeCommand")) return std::nullopt; + if (!repr_->contains("executeCommand")) return std::nullopt; - const auto& value = repr_["executeCommand"]; + auto& value = (*repr_)["executeCommand"]; return ExecuteCommandClientCapabilities(value); } auto WorkspaceClientCapabilities::workspaceFolders() const -> std::optional { - if (!repr_.contains("workspaceFolders")) return std::nullopt; + if (!repr_->contains("workspaceFolders")) return std::nullopt; - const auto& value = repr_["workspaceFolders"]; + auto& value = (*repr_)["workspaceFolders"]; assert(value.is_boolean()); return value.get(); } auto WorkspaceClientCapabilities::configuration() const -> std::optional { - if (!repr_.contains("configuration")) return std::nullopt; + if (!repr_->contains("configuration")) return std::nullopt; - const auto& value = repr_["configuration"]; + auto& value = (*repr_)["configuration"]; assert(value.is_boolean()); return value.get(); @@ -13500,458 +18320,538 @@ auto WorkspaceClientCapabilities::configuration() const -> std::optional { auto WorkspaceClientCapabilities::semanticTokens() const -> std::optional { - if (!repr_.contains("semanticTokens")) return std::nullopt; + if (!repr_->contains("semanticTokens")) return std::nullopt; - const auto& value = repr_["semanticTokens"]; + auto& value = (*repr_)["semanticTokens"]; return SemanticTokensWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::codeLens() const -> std::optional { - if (!repr_.contains("codeLens")) return std::nullopt; + if (!repr_->contains("codeLens")) return std::nullopt; - const auto& value = repr_["codeLens"]; + auto& value = (*repr_)["codeLens"]; return CodeLensWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::fileOperations() const -> std::optional { - if (!repr_.contains("fileOperations")) return std::nullopt; + if (!repr_->contains("fileOperations")) return std::nullopt; - const auto& value = repr_["fileOperations"]; + auto& value = (*repr_)["fileOperations"]; return FileOperationClientCapabilities(value); } auto WorkspaceClientCapabilities::inlineValue() const -> std::optional { - if (!repr_.contains("inlineValue")) return std::nullopt; + if (!repr_->contains("inlineValue")) return std::nullopt; - const auto& value = repr_["inlineValue"]; + auto& value = (*repr_)["inlineValue"]; return InlineValueWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::inlayHint() const -> std::optional { - if (!repr_.contains("inlayHint")) return std::nullopt; + if (!repr_->contains("inlayHint")) return std::nullopt; - const auto& value = repr_["inlayHint"]; + auto& value = (*repr_)["inlayHint"]; return InlayHintWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::diagnostics() const -> std::optional { - if (!repr_.contains("diagnostics")) return std::nullopt; + if (!repr_->contains("diagnostics")) return std::nullopt; - const auto& value = repr_["diagnostics"]; + auto& value = (*repr_)["diagnostics"]; return DiagnosticWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::foldingRange() const -> std::optional { - if (!repr_.contains("foldingRange")) return std::nullopt; + if (!repr_->contains("foldingRange")) return std::nullopt; - const auto& value = repr_["foldingRange"]; + auto& value = (*repr_)["foldingRange"]; return FoldingRangeWorkspaceClientCapabilities(value); } auto WorkspaceClientCapabilities::textDocumentContent() const -> std::optional { - if (!repr_.contains("textDocumentContent")) return std::nullopt; + if (!repr_->contains("textDocumentContent")) return std::nullopt; - const auto& value = repr_["textDocumentContent"]; + auto& value = (*repr_)["textDocumentContent"]; return TextDocumentContentClientCapabilities(value); } auto WorkspaceClientCapabilities::applyEdit(std::optional applyEdit) -> WorkspaceClientCapabilities& { + if (!applyEdit.has_value()) { + repr_->erase("applyEdit"); + return *this; + } + repr_->emplace("applyEdit", std::move(applyEdit.value())); return *this; } auto WorkspaceClientCapabilities::workspaceEdit( std::optional workspaceEdit) -> WorkspaceClientCapabilities& { + if (!workspaceEdit.has_value()) { + repr_->erase("workspaceEdit"); + return *this; + } + repr_->emplace("workspaceEdit", workspaceEdit.value()); return *this; } auto WorkspaceClientCapabilities::didChangeConfiguration( std::optional didChangeConfiguration) -> WorkspaceClientCapabilities& { + if (!didChangeConfiguration.has_value()) { + repr_->erase("didChangeConfiguration"); + return *this; + } + repr_->emplace("didChangeConfiguration", didChangeConfiguration.value()); return *this; } auto WorkspaceClientCapabilities::didChangeWatchedFiles( std::optional didChangeWatchedFiles) -> WorkspaceClientCapabilities& { + if (!didChangeWatchedFiles.has_value()) { + repr_->erase("didChangeWatchedFiles"); + return *this; + } + repr_->emplace("didChangeWatchedFiles", didChangeWatchedFiles.value()); return *this; } auto WorkspaceClientCapabilities::symbol( std::optional symbol) -> WorkspaceClientCapabilities& { + if (!symbol.has_value()) { + repr_->erase("symbol"); + return *this; + } + repr_->emplace("symbol", symbol.value()); return *this; } auto WorkspaceClientCapabilities::executeCommand( std::optional executeCommand) -> WorkspaceClientCapabilities& { + if (!executeCommand.has_value()) { + repr_->erase("executeCommand"); + return *this; + } + repr_->emplace("executeCommand", executeCommand.value()); return *this; } auto WorkspaceClientCapabilities::workspaceFolders( std::optional workspaceFolders) -> WorkspaceClientCapabilities& { + if (!workspaceFolders.has_value()) { + repr_->erase("workspaceFolders"); + return *this; + } + repr_->emplace("workspaceFolders", std::move(workspaceFolders.value())); return *this; } auto WorkspaceClientCapabilities::configuration( std::optional configuration) -> WorkspaceClientCapabilities& { + if (!configuration.has_value()) { + repr_->erase("configuration"); + return *this; + } + repr_->emplace("configuration", std::move(configuration.value())); return *this; } auto WorkspaceClientCapabilities::semanticTokens( std::optional semanticTokens) -> WorkspaceClientCapabilities& { + if (!semanticTokens.has_value()) { + repr_->erase("semanticTokens"); + return *this; + } + repr_->emplace("semanticTokens", semanticTokens.value()); return *this; } auto WorkspaceClientCapabilities::codeLens( std::optional codeLens) -> WorkspaceClientCapabilities& { + if (!codeLens.has_value()) { + repr_->erase("codeLens"); + return *this; + } + repr_->emplace("codeLens", codeLens.value()); return *this; } auto WorkspaceClientCapabilities::fileOperations( std::optional fileOperations) -> WorkspaceClientCapabilities& { + if (!fileOperations.has_value()) { + repr_->erase("fileOperations"); + return *this; + } + repr_->emplace("fileOperations", fileOperations.value()); return *this; } auto WorkspaceClientCapabilities::inlineValue( std::optional inlineValue) -> WorkspaceClientCapabilities& { + if (!inlineValue.has_value()) { + repr_->erase("inlineValue"); + return *this; + } + repr_->emplace("inlineValue", inlineValue.value()); return *this; } auto WorkspaceClientCapabilities::inlayHint( std::optional inlayHint) -> WorkspaceClientCapabilities& { + if (!inlayHint.has_value()) { + repr_->erase("inlayHint"); + return *this; + } + repr_->emplace("inlayHint", inlayHint.value()); return *this; } auto WorkspaceClientCapabilities::diagnostics( std::optional diagnostics) -> WorkspaceClientCapabilities& { + if (!diagnostics.has_value()) { + repr_->erase("diagnostics"); + return *this; + } + repr_->emplace("diagnostics", diagnostics.value()); return *this; } auto WorkspaceClientCapabilities::foldingRange( std::optional foldingRange) -> WorkspaceClientCapabilities& { + if (!foldingRange.has_value()) { + repr_->erase("foldingRange"); + return *this; + } + repr_->emplace("foldingRange", foldingRange.value()); return *this; } auto WorkspaceClientCapabilities::textDocumentContent( std::optional textDocumentContent) -> WorkspaceClientCapabilities& { + if (!textDocumentContent.has_value()) { + repr_->erase("textDocumentContent"); + return *this; + } + repr_->emplace("textDocumentContent", textDocumentContent.value()); return *this; } TextDocumentClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TextDocumentClientCapabilities::synchronization() const -> std::optional { - if (!repr_.contains("synchronization")) return std::nullopt; + if (!repr_->contains("synchronization")) return std::nullopt; - const auto& value = repr_["synchronization"]; + auto& value = (*repr_)["synchronization"]; return TextDocumentSyncClientCapabilities(value); } auto TextDocumentClientCapabilities::filters() const -> std::optional { - if (!repr_.contains("filters")) return std::nullopt; + if (!repr_->contains("filters")) return std::nullopt; - const auto& value = repr_["filters"]; + auto& value = (*repr_)["filters"]; return TextDocumentFilterClientCapabilities(value); } auto TextDocumentClientCapabilities::completion() const -> std::optional { - if (!repr_.contains("completion")) return std::nullopt; + if (!repr_->contains("completion")) return std::nullopt; - const auto& value = repr_["completion"]; + auto& value = (*repr_)["completion"]; return CompletionClientCapabilities(value); } auto TextDocumentClientCapabilities::hover() const -> std::optional { - if (!repr_.contains("hover")) return std::nullopt; + if (!repr_->contains("hover")) return std::nullopt; - const auto& value = repr_["hover"]; + auto& value = (*repr_)["hover"]; return HoverClientCapabilities(value); } auto TextDocumentClientCapabilities::signatureHelp() const -> std::optional { - if (!repr_.contains("signatureHelp")) return std::nullopt; + if (!repr_->contains("signatureHelp")) return std::nullopt; - const auto& value = repr_["signatureHelp"]; + auto& value = (*repr_)["signatureHelp"]; return SignatureHelpClientCapabilities(value); } auto TextDocumentClientCapabilities::declaration() const -> std::optional { - if (!repr_.contains("declaration")) return std::nullopt; + if (!repr_->contains("declaration")) return std::nullopt; - const auto& value = repr_["declaration"]; + auto& value = (*repr_)["declaration"]; return DeclarationClientCapabilities(value); } auto TextDocumentClientCapabilities::definition() const -> std::optional { - if (!repr_.contains("definition")) return std::nullopt; + if (!repr_->contains("definition")) return std::nullopt; - const auto& value = repr_["definition"]; + auto& value = (*repr_)["definition"]; return DefinitionClientCapabilities(value); } auto TextDocumentClientCapabilities::typeDefinition() const -> std::optional { - if (!repr_.contains("typeDefinition")) return std::nullopt; + if (!repr_->contains("typeDefinition")) return std::nullopt; - const auto& value = repr_["typeDefinition"]; + auto& value = (*repr_)["typeDefinition"]; return TypeDefinitionClientCapabilities(value); } auto TextDocumentClientCapabilities::implementation() const -> std::optional { - if (!repr_.contains("implementation")) return std::nullopt; + if (!repr_->contains("implementation")) return std::nullopt; - const auto& value = repr_["implementation"]; + auto& value = (*repr_)["implementation"]; return ImplementationClientCapabilities(value); } auto TextDocumentClientCapabilities::references() const -> std::optional { - if (!repr_.contains("references")) return std::nullopt; + if (!repr_->contains("references")) return std::nullopt; - const auto& value = repr_["references"]; + auto& value = (*repr_)["references"]; return ReferenceClientCapabilities(value); } auto TextDocumentClientCapabilities::documentHighlight() const -> std::optional { - if (!repr_.contains("documentHighlight")) return std::nullopt; + if (!repr_->contains("documentHighlight")) return std::nullopt; - const auto& value = repr_["documentHighlight"]; + auto& value = (*repr_)["documentHighlight"]; return DocumentHighlightClientCapabilities(value); } auto TextDocumentClientCapabilities::documentSymbol() const -> std::optional { - if (!repr_.contains("documentSymbol")) return std::nullopt; + if (!repr_->contains("documentSymbol")) return std::nullopt; - const auto& value = repr_["documentSymbol"]; + auto& value = (*repr_)["documentSymbol"]; return DocumentSymbolClientCapabilities(value); } auto TextDocumentClientCapabilities::codeAction() const -> std::optional { - if (!repr_.contains("codeAction")) return std::nullopt; + if (!repr_->contains("codeAction")) return std::nullopt; - const auto& value = repr_["codeAction"]; + auto& value = (*repr_)["codeAction"]; return CodeActionClientCapabilities(value); } auto TextDocumentClientCapabilities::codeLens() const -> std::optional { - if (!repr_.contains("codeLens")) return std::nullopt; + if (!repr_->contains("codeLens")) return std::nullopt; - const auto& value = repr_["codeLens"]; + auto& value = (*repr_)["codeLens"]; return CodeLensClientCapabilities(value); } auto TextDocumentClientCapabilities::documentLink() const -> std::optional { - if (!repr_.contains("documentLink")) return std::nullopt; + if (!repr_->contains("documentLink")) return std::nullopt; - const auto& value = repr_["documentLink"]; + auto& value = (*repr_)["documentLink"]; return DocumentLinkClientCapabilities(value); } auto TextDocumentClientCapabilities::colorProvider() const -> std::optional { - if (!repr_.contains("colorProvider")) return std::nullopt; + if (!repr_->contains("colorProvider")) return std::nullopt; - const auto& value = repr_["colorProvider"]; + auto& value = (*repr_)["colorProvider"]; return DocumentColorClientCapabilities(value); } auto TextDocumentClientCapabilities::formatting() const -> std::optional { - if (!repr_.contains("formatting")) return std::nullopt; + if (!repr_->contains("formatting")) return std::nullopt; - const auto& value = repr_["formatting"]; + auto& value = (*repr_)["formatting"]; return DocumentFormattingClientCapabilities(value); } auto TextDocumentClientCapabilities::rangeFormatting() const -> std::optional { - if (!repr_.contains("rangeFormatting")) return std::nullopt; + if (!repr_->contains("rangeFormatting")) return std::nullopt; - const auto& value = repr_["rangeFormatting"]; + auto& value = (*repr_)["rangeFormatting"]; return DocumentRangeFormattingClientCapabilities(value); } auto TextDocumentClientCapabilities::onTypeFormatting() const -> std::optional { - if (!repr_.contains("onTypeFormatting")) return std::nullopt; + if (!repr_->contains("onTypeFormatting")) return std::nullopt; - const auto& value = repr_["onTypeFormatting"]; + auto& value = (*repr_)["onTypeFormatting"]; return DocumentOnTypeFormattingClientCapabilities(value); } auto TextDocumentClientCapabilities::rename() const -> std::optional { - if (!repr_.contains("rename")) return std::nullopt; + if (!repr_->contains("rename")) return std::nullopt; - const auto& value = repr_["rename"]; + auto& value = (*repr_)["rename"]; return RenameClientCapabilities(value); } auto TextDocumentClientCapabilities::foldingRange() const -> std::optional { - if (!repr_.contains("foldingRange")) return std::nullopt; + if (!repr_->contains("foldingRange")) return std::nullopt; - const auto& value = repr_["foldingRange"]; + auto& value = (*repr_)["foldingRange"]; return FoldingRangeClientCapabilities(value); } auto TextDocumentClientCapabilities::selectionRange() const -> std::optional { - if (!repr_.contains("selectionRange")) return std::nullopt; + if (!repr_->contains("selectionRange")) return std::nullopt; - const auto& value = repr_["selectionRange"]; + auto& value = (*repr_)["selectionRange"]; return SelectionRangeClientCapabilities(value); } auto TextDocumentClientCapabilities::publishDiagnostics() const -> std::optional { - if (!repr_.contains("publishDiagnostics")) return std::nullopt; + if (!repr_->contains("publishDiagnostics")) return std::nullopt; - const auto& value = repr_["publishDiagnostics"]; + auto& value = (*repr_)["publishDiagnostics"]; return PublishDiagnosticsClientCapabilities(value); } auto TextDocumentClientCapabilities::callHierarchy() const -> std::optional { - if (!repr_.contains("callHierarchy")) return std::nullopt; + if (!repr_->contains("callHierarchy")) return std::nullopt; - const auto& value = repr_["callHierarchy"]; + auto& value = (*repr_)["callHierarchy"]; return CallHierarchyClientCapabilities(value); } auto TextDocumentClientCapabilities::semanticTokens() const -> std::optional { - if (!repr_.contains("semanticTokens")) return std::nullopt; + if (!repr_->contains("semanticTokens")) return std::nullopt; - const auto& value = repr_["semanticTokens"]; + auto& value = (*repr_)["semanticTokens"]; return SemanticTokensClientCapabilities(value); } auto TextDocumentClientCapabilities::linkedEditingRange() const -> std::optional { - if (!repr_.contains("linkedEditingRange")) return std::nullopt; + if (!repr_->contains("linkedEditingRange")) return std::nullopt; - const auto& value = repr_["linkedEditingRange"]; + auto& value = (*repr_)["linkedEditingRange"]; return LinkedEditingRangeClientCapabilities(value); } auto TextDocumentClientCapabilities::moniker() const -> std::optional { - if (!repr_.contains("moniker")) return std::nullopt; + if (!repr_->contains("moniker")) return std::nullopt; - const auto& value = repr_["moniker"]; + auto& value = (*repr_)["moniker"]; return MonikerClientCapabilities(value); } auto TextDocumentClientCapabilities::typeHierarchy() const -> std::optional { - if (!repr_.contains("typeHierarchy")) return std::nullopt; + if (!repr_->contains("typeHierarchy")) return std::nullopt; - const auto& value = repr_["typeHierarchy"]; + auto& value = (*repr_)["typeHierarchy"]; return TypeHierarchyClientCapabilities(value); } auto TextDocumentClientCapabilities::inlineValue() const -> std::optional { - if (!repr_.contains("inlineValue")) return std::nullopt; + if (!repr_->contains("inlineValue")) return std::nullopt; - const auto& value = repr_["inlineValue"]; + auto& value = (*repr_)["inlineValue"]; return InlineValueClientCapabilities(value); } auto TextDocumentClientCapabilities::inlayHint() const -> std::optional { - if (!repr_.contains("inlayHint")) return std::nullopt; + if (!repr_->contains("inlayHint")) return std::nullopt; - const auto& value = repr_["inlayHint"]; + auto& value = (*repr_)["inlayHint"]; return InlayHintClientCapabilities(value); } auto TextDocumentClientCapabilities::diagnostic() const -> std::optional { - if (!repr_.contains("diagnostic")) return std::nullopt; + if (!repr_->contains("diagnostic")) return std::nullopt; - const auto& value = repr_["diagnostic"]; + auto& value = (*repr_)["diagnostic"]; return DiagnosticClientCapabilities(value); } auto TextDocumentClientCapabilities::inlineCompletion() const -> std::optional { - if (!repr_.contains("inlineCompletion")) return std::nullopt; + if (!repr_->contains("inlineCompletion")) return std::nullopt; - const auto& value = repr_["inlineCompletion"]; + auto& value = (*repr_)["inlineCompletion"]; return InlineCompletionClientCapabilities(value); } @@ -13959,204 +18859,364 @@ auto TextDocumentClientCapabilities::inlineCompletion() const auto TextDocumentClientCapabilities::synchronization( std::optional synchronization) -> TextDocumentClientCapabilities& { + if (!synchronization.has_value()) { + repr_->erase("synchronization"); + return *this; + } + repr_->emplace("synchronization", synchronization.value()); return *this; } auto TextDocumentClientCapabilities::filters( std::optional filters) -> TextDocumentClientCapabilities& { + if (!filters.has_value()) { + repr_->erase("filters"); + return *this; + } + repr_->emplace("filters", filters.value()); return *this; } auto TextDocumentClientCapabilities::completion( std::optional completion) -> TextDocumentClientCapabilities& { + if (!completion.has_value()) { + repr_->erase("completion"); + return *this; + } + repr_->emplace("completion", completion.value()); return *this; } auto TextDocumentClientCapabilities::hover( std::optional hover) -> TextDocumentClientCapabilities& { + if (!hover.has_value()) { + repr_->erase("hover"); + return *this; + } + repr_->emplace("hover", hover.value()); return *this; } auto TextDocumentClientCapabilities::signatureHelp( std::optional signatureHelp) -> TextDocumentClientCapabilities& { + if (!signatureHelp.has_value()) { + repr_->erase("signatureHelp"); + return *this; + } + repr_->emplace("signatureHelp", signatureHelp.value()); return *this; } auto TextDocumentClientCapabilities::declaration( std::optional declaration) -> TextDocumentClientCapabilities& { + if (!declaration.has_value()) { + repr_->erase("declaration"); + return *this; + } + repr_->emplace("declaration", declaration.value()); return *this; } auto TextDocumentClientCapabilities::definition( std::optional definition) -> TextDocumentClientCapabilities& { + if (!definition.has_value()) { + repr_->erase("definition"); + return *this; + } + repr_->emplace("definition", definition.value()); return *this; } auto TextDocumentClientCapabilities::typeDefinition( std::optional typeDefinition) -> TextDocumentClientCapabilities& { + if (!typeDefinition.has_value()) { + repr_->erase("typeDefinition"); + return *this; + } + repr_->emplace("typeDefinition", typeDefinition.value()); return *this; } auto TextDocumentClientCapabilities::implementation( std::optional implementation) -> TextDocumentClientCapabilities& { + if (!implementation.has_value()) { + repr_->erase("implementation"); + return *this; + } + repr_->emplace("implementation", implementation.value()); return *this; } auto TextDocumentClientCapabilities::references( std::optional references) -> TextDocumentClientCapabilities& { + if (!references.has_value()) { + repr_->erase("references"); + return *this; + } + repr_->emplace("references", references.value()); return *this; } auto TextDocumentClientCapabilities::documentHighlight( std::optional documentHighlight) -> TextDocumentClientCapabilities& { + if (!documentHighlight.has_value()) { + repr_->erase("documentHighlight"); + return *this; + } + repr_->emplace("documentHighlight", documentHighlight.value()); return *this; } auto TextDocumentClientCapabilities::documentSymbol( std::optional documentSymbol) -> TextDocumentClientCapabilities& { + if (!documentSymbol.has_value()) { + repr_->erase("documentSymbol"); + return *this; + } + repr_->emplace("documentSymbol", documentSymbol.value()); return *this; } auto TextDocumentClientCapabilities::codeAction( std::optional codeAction) -> TextDocumentClientCapabilities& { + if (!codeAction.has_value()) { + repr_->erase("codeAction"); + return *this; + } + repr_->emplace("codeAction", codeAction.value()); return *this; } auto TextDocumentClientCapabilities::codeLens( std::optional codeLens) -> TextDocumentClientCapabilities& { + if (!codeLens.has_value()) { + repr_->erase("codeLens"); + return *this; + } + repr_->emplace("codeLens", codeLens.value()); return *this; } auto TextDocumentClientCapabilities::documentLink( std::optional documentLink) -> TextDocumentClientCapabilities& { + if (!documentLink.has_value()) { + repr_->erase("documentLink"); + return *this; + } + repr_->emplace("documentLink", documentLink.value()); return *this; } auto TextDocumentClientCapabilities::colorProvider( std::optional colorProvider) -> TextDocumentClientCapabilities& { + if (!colorProvider.has_value()) { + repr_->erase("colorProvider"); + return *this; + } + repr_->emplace("colorProvider", colorProvider.value()); return *this; } auto TextDocumentClientCapabilities::formatting( std::optional formatting) -> TextDocumentClientCapabilities& { + if (!formatting.has_value()) { + repr_->erase("formatting"); + return *this; + } + repr_->emplace("formatting", formatting.value()); return *this; } auto TextDocumentClientCapabilities::rangeFormatting( std::optional rangeFormatting) -> TextDocumentClientCapabilities& { + if (!rangeFormatting.has_value()) { + repr_->erase("rangeFormatting"); + return *this; + } + repr_->emplace("rangeFormatting", rangeFormatting.value()); return *this; } auto TextDocumentClientCapabilities::onTypeFormatting( std::optional onTypeFormatting) -> TextDocumentClientCapabilities& { + if (!onTypeFormatting.has_value()) { + repr_->erase("onTypeFormatting"); + return *this; + } + repr_->emplace("onTypeFormatting", onTypeFormatting.value()); return *this; } auto TextDocumentClientCapabilities::rename( std::optional rename) -> TextDocumentClientCapabilities& { + if (!rename.has_value()) { + repr_->erase("rename"); + return *this; + } + repr_->emplace("rename", rename.value()); return *this; } auto TextDocumentClientCapabilities::foldingRange( std::optional foldingRange) -> TextDocumentClientCapabilities& { + if (!foldingRange.has_value()) { + repr_->erase("foldingRange"); + return *this; + } + repr_->emplace("foldingRange", foldingRange.value()); return *this; } auto TextDocumentClientCapabilities::selectionRange( std::optional selectionRange) -> TextDocumentClientCapabilities& { + if (!selectionRange.has_value()) { + repr_->erase("selectionRange"); + return *this; + } + repr_->emplace("selectionRange", selectionRange.value()); return *this; } auto TextDocumentClientCapabilities::publishDiagnostics( std::optional publishDiagnostics) -> TextDocumentClientCapabilities& { + if (!publishDiagnostics.has_value()) { + repr_->erase("publishDiagnostics"); + return *this; + } + repr_->emplace("publishDiagnostics", publishDiagnostics.value()); return *this; } auto TextDocumentClientCapabilities::callHierarchy( std::optional callHierarchy) -> TextDocumentClientCapabilities& { + if (!callHierarchy.has_value()) { + repr_->erase("callHierarchy"); + return *this; + } + repr_->emplace("callHierarchy", callHierarchy.value()); return *this; } auto TextDocumentClientCapabilities::semanticTokens( std::optional semanticTokens) -> TextDocumentClientCapabilities& { + if (!semanticTokens.has_value()) { + repr_->erase("semanticTokens"); + return *this; + } + repr_->emplace("semanticTokens", semanticTokens.value()); return *this; } auto TextDocumentClientCapabilities::linkedEditingRange( std::optional linkedEditingRange) -> TextDocumentClientCapabilities& { + if (!linkedEditingRange.has_value()) { + repr_->erase("linkedEditingRange"); + return *this; + } + repr_->emplace("linkedEditingRange", linkedEditingRange.value()); return *this; } auto TextDocumentClientCapabilities::moniker( std::optional moniker) -> TextDocumentClientCapabilities& { + if (!moniker.has_value()) { + repr_->erase("moniker"); + return *this; + } + repr_->emplace("moniker", moniker.value()); return *this; } auto TextDocumentClientCapabilities::typeHierarchy( std::optional typeHierarchy) -> TextDocumentClientCapabilities& { + if (!typeHierarchy.has_value()) { + repr_->erase("typeHierarchy"); + return *this; + } + repr_->emplace("typeHierarchy", typeHierarchy.value()); return *this; } auto TextDocumentClientCapabilities::inlineValue( std::optional inlineValue) -> TextDocumentClientCapabilities& { + if (!inlineValue.has_value()) { + repr_->erase("inlineValue"); + return *this; + } + repr_->emplace("inlineValue", inlineValue.value()); return *this; } auto TextDocumentClientCapabilities::inlayHint( std::optional inlayHint) -> TextDocumentClientCapabilities& { + if (!inlayHint.has_value()) { + repr_->erase("inlayHint"); + return *this; + } + repr_->emplace("inlayHint", inlayHint.value()); return *this; } auto TextDocumentClientCapabilities::diagnostic( std::optional diagnostic) -> TextDocumentClientCapabilities& { + if (!diagnostic.has_value()) { + repr_->erase("diagnostic"); + return *this; + } + repr_->emplace("diagnostic", diagnostic.value()); return *this; } auto TextDocumentClientCapabilities::inlineCompletion( std::optional inlineCompletion) -> TextDocumentClientCapabilities& { + if (!inlineCompletion.has_value()) { + repr_->erase("inlineCompletion"); + return *this; + } + repr_->emplace("inlineCompletion", inlineCompletion.value()); return *this; } NotebookDocumentClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("synchronization")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("synchronization")) return false; return true; } auto NotebookDocumentClientCapabilities::synchronization() const -> NotebookDocumentSyncClientCapabilities { - const auto& value = repr_["synchronization"]; + auto& value = (*repr_)["synchronization"]; return NotebookDocumentSyncClientCapabilities(value); } @@ -14164,18 +19224,19 @@ auto NotebookDocumentClientCapabilities::synchronization() const auto NotebookDocumentClientCapabilities::synchronization( NotebookDocumentSyncClientCapabilities synchronization) -> NotebookDocumentClientCapabilities& { + repr_->emplace("synchronization", synchronization); return *this; } WindowClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WindowClientCapabilities::workDoneProgress() const -> std::optional { - if (!repr_.contains("workDoneProgress")) return std::nullopt; + if (!repr_->contains("workDoneProgress")) return std::nullopt; - const auto& value = repr_["workDoneProgress"]; + auto& value = (*repr_)["workDoneProgress"]; assert(value.is_boolean()); return value.get(); @@ -14183,76 +19244,91 @@ auto WindowClientCapabilities::workDoneProgress() const -> std::optional { auto WindowClientCapabilities::showMessage() const -> std::optional { - if (!repr_.contains("showMessage")) return std::nullopt; + if (!repr_->contains("showMessage")) return std::nullopt; - const auto& value = repr_["showMessage"]; + auto& value = (*repr_)["showMessage"]; return ShowMessageRequestClientCapabilities(value); } auto WindowClientCapabilities::showDocument() const -> std::optional { - if (!repr_.contains("showDocument")) return std::nullopt; + if (!repr_->contains("showDocument")) return std::nullopt; - const auto& value = repr_["showDocument"]; + auto& value = (*repr_)["showDocument"]; return ShowDocumentClientCapabilities(value); } auto WindowClientCapabilities::workDoneProgress( std::optional workDoneProgress) -> WindowClientCapabilities& { + if (!workDoneProgress.has_value()) { + repr_->erase("workDoneProgress"); + return *this; + } + repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); return *this; } auto WindowClientCapabilities::showMessage( std::optional showMessage) -> WindowClientCapabilities& { + if (!showMessage.has_value()) { + repr_->erase("showMessage"); + return *this; + } + repr_->emplace("showMessage", showMessage.value()); return *this; } auto WindowClientCapabilities::showDocument( std::optional showDocument) -> WindowClientCapabilities& { + if (!showDocument.has_value()) { + repr_->erase("showDocument"); + return *this; + } + repr_->emplace("showDocument", showDocument.value()); return *this; } GeneralClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto GeneralClientCapabilities::staleRequestSupport() const -> std::optional { - if (!repr_.contains("staleRequestSupport")) return std::nullopt; + if (!repr_->contains("staleRequestSupport")) return std::nullopt; - const auto& value = repr_["staleRequestSupport"]; + auto& value = (*repr_)["staleRequestSupport"]; return StaleRequestSupportOptions(value); } auto GeneralClientCapabilities::regularExpressions() const -> std::optional { - if (!repr_.contains("regularExpressions")) return std::nullopt; + if (!repr_->contains("regularExpressions")) return std::nullopt; - const auto& value = repr_["regularExpressions"]; + auto& value = (*repr_)["regularExpressions"]; return RegularExpressionsClientCapabilities(value); } auto GeneralClientCapabilities::markdown() const -> std::optional { - if (!repr_.contains("markdown")) return std::nullopt; + if (!repr_->contains("markdown")) return std::nullopt; - const auto& value = repr_["markdown"]; + auto& value = (*repr_)["markdown"]; return MarkdownClientCapabilities(value); } auto GeneralClientCapabilities::positionEncodings() const -> std::optional> { - if (!repr_.contains("positionEncodings")) return std::nullopt; + if (!repr_->contains("positionEncodings")) return std::nullopt; - const auto& value = repr_["positionEncodings"]; + auto& value = (*repr_)["positionEncodings"]; assert(value.is_array()); return Vector(value); @@ -14261,37 +19337,58 @@ auto GeneralClientCapabilities::positionEncodings() const auto GeneralClientCapabilities::staleRequestSupport( std::optional staleRequestSupport) -> GeneralClientCapabilities& { + if (!staleRequestSupport.has_value()) { + repr_->erase("staleRequestSupport"); + return *this; + } + repr_->emplace("staleRequestSupport", staleRequestSupport.value()); return *this; } auto GeneralClientCapabilities::regularExpressions( std::optional regularExpressions) -> GeneralClientCapabilities& { + if (!regularExpressions.has_value()) { + repr_->erase("regularExpressions"); + return *this; + } + repr_->emplace("regularExpressions", regularExpressions.value()); return *this; } auto GeneralClientCapabilities::markdown( std::optional markdown) -> GeneralClientCapabilities& { + if (!markdown.has_value()) { + repr_->erase("markdown"); + return *this; + } + repr_->emplace("markdown", markdown.value()); return *this; } auto GeneralClientCapabilities::positionEncodings( std::optional> positionEncodings) -> GeneralClientCapabilities& { + if (!positionEncodings.has_value()) { + repr_->erase("positionEncodings"); + return *this; + } + lsp_runtime_error( + "GeneralClientCapabilities::positionEncodings: not implement yet"); return *this; } WorkspaceFoldersServerCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceFoldersServerCapabilities::supported() const -> std::optional { - if (!repr_.contains("supported")) return std::nullopt; + if (!repr_->contains("supported")) return std::nullopt; - const auto& value = repr_["supported"]; + auto& value = (*repr_)["supported"]; assert(value.is_boolean()); return value.get(); @@ -14299,9 +19396,9 @@ auto WorkspaceFoldersServerCapabilities::supported() const auto WorkspaceFoldersServerCapabilities::changeNotifications() const -> std::optional> { - if (!repr_.contains("changeNotifications")) return std::nullopt; + if (!repr_->contains("changeNotifications")) return std::nullopt; - const auto& value = repr_["changeNotifications"]; + auto& value = (*repr_)["changeNotifications"]; std::variant result; @@ -14312,70 +19409,100 @@ auto WorkspaceFoldersServerCapabilities::changeNotifications() const auto WorkspaceFoldersServerCapabilities::supported( std::optional supported) -> WorkspaceFoldersServerCapabilities& { + if (!supported.has_value()) { + repr_->erase("supported"); + return *this; + } + repr_->emplace("supported", std::move(supported.value())); return *this; } auto WorkspaceFoldersServerCapabilities::changeNotifications( std::optional> changeNotifications) -> WorkspaceFoldersServerCapabilities& { + if (!changeNotifications.has_value()) { + repr_->erase("changeNotifications"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(std::string changeNotifications) { + repr_->emplace("changeNotifications", std::move(changeNotifications)); + } + + void operator()(bool changeNotifications) { + repr_->emplace("changeNotifications", std::move(changeNotifications)); + } + } v{repr_}; + + std::visit(v, changeNotifications.value()); + return *this; } FileOperationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FileOperationOptions::didCreate() const -> std::optional { - if (!repr_.contains("didCreate")) return std::nullopt; + if (!repr_->contains("didCreate")) return std::nullopt; - const auto& value = repr_["didCreate"]; + auto& value = (*repr_)["didCreate"]; return FileOperationRegistrationOptions(value); } auto FileOperationOptions::willCreate() const -> std::optional { - if (!repr_.contains("willCreate")) return std::nullopt; + if (!repr_->contains("willCreate")) return std::nullopt; - const auto& value = repr_["willCreate"]; + auto& value = (*repr_)["willCreate"]; return FileOperationRegistrationOptions(value); } auto FileOperationOptions::didRename() const -> std::optional { - if (!repr_.contains("didRename")) return std::nullopt; + if (!repr_->contains("didRename")) return std::nullopt; - const auto& value = repr_["didRename"]; + auto& value = (*repr_)["didRename"]; return FileOperationRegistrationOptions(value); } auto FileOperationOptions::willRename() const -> std::optional { - if (!repr_.contains("willRename")) return std::nullopt; + if (!repr_->contains("willRename")) return std::nullopt; - const auto& value = repr_["willRename"]; + auto& value = (*repr_)["willRename"]; return FileOperationRegistrationOptions(value); } auto FileOperationOptions::didDelete() const -> std::optional { - if (!repr_.contains("didDelete")) return std::nullopt; + if (!repr_->contains("didDelete")) return std::nullopt; - const auto& value = repr_["didDelete"]; + auto& value = (*repr_)["didDelete"]; return FileOperationRegistrationOptions(value); } auto FileOperationOptions::willDelete() const -> std::optional { - if (!repr_.contains("willDelete")) return std::nullopt; + if (!repr_->contains("willDelete")) return std::nullopt; - const auto& value = repr_["willDelete"]; + auto& value = (*repr_)["willDelete"]; return FileOperationRegistrationOptions(value); } @@ -14383,49 +19510,79 @@ auto FileOperationOptions::willDelete() const auto FileOperationOptions::didCreate( std::optional didCreate) -> FileOperationOptions& { + if (!didCreate.has_value()) { + repr_->erase("didCreate"); + return *this; + } + repr_->emplace("didCreate", didCreate.value()); return *this; } auto FileOperationOptions::willCreate( std::optional willCreate) -> FileOperationOptions& { + if (!willCreate.has_value()) { + repr_->erase("willCreate"); + return *this; + } + repr_->emplace("willCreate", willCreate.value()); return *this; } auto FileOperationOptions::didRename( std::optional didRename) -> FileOperationOptions& { + if (!didRename.has_value()) { + repr_->erase("didRename"); + return *this; + } + repr_->emplace("didRename", didRename.value()); return *this; } auto FileOperationOptions::willRename( std::optional willRename) -> FileOperationOptions& { + if (!willRename.has_value()) { + repr_->erase("willRename"); + return *this; + } + repr_->emplace("willRename", willRename.value()); return *this; } auto FileOperationOptions::didDelete( std::optional didDelete) -> FileOperationOptions& { + if (!didDelete.has_value()) { + repr_->erase("didDelete"); + return *this; + } + repr_->emplace("didDelete", didDelete.value()); return *this; } auto FileOperationOptions::willDelete( std::optional willDelete) -> FileOperationOptions& { + if (!willDelete.has_value()) { + repr_->erase("willDelete"); + return *this; + } + repr_->emplace("willDelete", willDelete.value()); return *this; } RelativePattern::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("baseUri")) return false; - if (!repr_.contains("pattern")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("baseUri")) return false; + if (!repr_->contains("pattern")) return false; return true; } auto RelativePattern::baseUri() const -> std::variant { - const auto& value = repr_["baseUri"]; + auto& value = (*repr_)["baseUri"]; std::variant result; @@ -14435,7 +19592,7 @@ auto RelativePattern::baseUri() const } auto RelativePattern::pattern() const -> Pattern { - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; assert(value.is_string()); return value.get(); @@ -14444,39 +19601,60 @@ auto RelativePattern::pattern() const -> Pattern { auto RelativePattern::baseUri( std::variant baseUri) -> RelativePattern& { + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(WorkspaceFolder baseUri) { + repr_->emplace("baseUri", baseUri); + } + + void operator()(std::string baseUri) { + repr_->emplace("baseUri", std::move(baseUri)); + } + } v{repr_}; + + std::visit(v, baseUri); + return *this; } auto RelativePattern::pattern(Pattern pattern) -> RelativePattern& { + lsp_runtime_error("RelativePattern::pattern: not implement yet"); return *this; } TextDocumentFilterLanguage::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("language")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("language")) return false; return true; } auto TextDocumentFilterLanguage::language() const -> std::string { - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterLanguage::scheme() const -> std::optional { - if (!repr_.contains("scheme")) return std::nullopt; + if (!repr_->contains("scheme")) return std::nullopt; - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterLanguage::pattern() const -> std::optional { - if (!repr_.contains("pattern")) return std::nullopt; + if (!repr_->contains("pattern")) return std::nullopt; - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14487,45 +19665,56 @@ auto TextDocumentFilterLanguage::pattern() const -> std::optional { auto TextDocumentFilterLanguage::language(std::string language) -> TextDocumentFilterLanguage& { + repr_->emplace("language", std::move(language)); return *this; } auto TextDocumentFilterLanguage::scheme(std::optional scheme) -> TextDocumentFilterLanguage& { + if (!scheme.has_value()) { + repr_->erase("scheme"); + return *this; + } + repr_->emplace("scheme", std::move(scheme.value())); return *this; } auto TextDocumentFilterLanguage::pattern(std::optional pattern) -> TextDocumentFilterLanguage& { + if (!pattern.has_value()) { + repr_->erase("pattern"); + return *this; + } + lsp_runtime_error("TextDocumentFilterLanguage::pattern: not implement yet"); return *this; } TextDocumentFilterScheme::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("scheme")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("scheme")) return false; return true; } auto TextDocumentFilterScheme::language() const -> std::optional { - if (!repr_.contains("language")) return std::nullopt; + if (!repr_->contains("language")) return std::nullopt; - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterScheme::scheme() const -> std::string { - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterScheme::pattern() const -> std::optional { - if (!repr_.contains("pattern")) return std::nullopt; + if (!repr_->contains("pattern")) return std::nullopt; - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14536,45 +19725,56 @@ auto TextDocumentFilterScheme::pattern() const -> std::optional { auto TextDocumentFilterScheme::language(std::optional language) -> TextDocumentFilterScheme& { + if (!language.has_value()) { + repr_->erase("language"); + return *this; + } + repr_->emplace("language", std::move(language.value())); return *this; } auto TextDocumentFilterScheme::scheme(std::string scheme) -> TextDocumentFilterScheme& { + repr_->emplace("scheme", std::move(scheme)); return *this; } auto TextDocumentFilterScheme::pattern(std::optional pattern) -> TextDocumentFilterScheme& { + if (!pattern.has_value()) { + repr_->erase("pattern"); + return *this; + } + lsp_runtime_error("TextDocumentFilterScheme::pattern: not implement yet"); return *this; } TextDocumentFilterPattern::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("pattern")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("pattern")) return false; return true; } auto TextDocumentFilterPattern::language() const -> std::optional { - if (!repr_.contains("language")) return std::nullopt; + if (!repr_->contains("language")) return std::nullopt; - const auto& value = repr_["language"]; + auto& value = (*repr_)["language"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterPattern::scheme() const -> std::optional { - if (!repr_.contains("scheme")) return std::nullopt; + if (!repr_->contains("scheme")) return std::nullopt; - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto TextDocumentFilterPattern::pattern() const -> GlobPattern { - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14585,27 +19785,38 @@ auto TextDocumentFilterPattern::pattern() const -> GlobPattern { auto TextDocumentFilterPattern::language(std::optional language) -> TextDocumentFilterPattern& { + if (!language.has_value()) { + repr_->erase("language"); + return *this; + } + repr_->emplace("language", std::move(language.value())); return *this; } auto TextDocumentFilterPattern::scheme(std::optional scheme) -> TextDocumentFilterPattern& { + if (!scheme.has_value()) { + repr_->erase("scheme"); + return *this; + } + repr_->emplace("scheme", std::move(scheme.value())); return *this; } auto TextDocumentFilterPattern::pattern(GlobPattern pattern) -> TextDocumentFilterPattern& { + lsp_runtime_error("TextDocumentFilterPattern::pattern: not implement yet"); return *this; } NotebookDocumentFilterNotebookType::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("notebookType")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("notebookType")) return false; return true; } auto NotebookDocumentFilterNotebookType::notebookType() const -> std::string { - const auto& value = repr_["notebookType"]; + auto& value = (*repr_)["notebookType"]; assert(value.is_string()); return value.get(); @@ -14613,9 +19824,9 @@ auto NotebookDocumentFilterNotebookType::notebookType() const -> std::string { auto NotebookDocumentFilterNotebookType::scheme() const -> std::optional { - if (!repr_.contains("scheme")) return std::nullopt; + if (!repr_->contains("scheme")) return std::nullopt; - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); @@ -14623,9 +19834,9 @@ auto NotebookDocumentFilterNotebookType::scheme() const auto NotebookDocumentFilterNotebookType::pattern() const -> std::optional { - if (!repr_.contains("pattern")) return std::nullopt; + if (!repr_->contains("pattern")) return std::nullopt; - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14636,37 +19847,49 @@ auto NotebookDocumentFilterNotebookType::pattern() const auto NotebookDocumentFilterNotebookType::notebookType(std::string notebookType) -> NotebookDocumentFilterNotebookType& { + repr_->emplace("notebookType", std::move(notebookType)); return *this; } auto NotebookDocumentFilterNotebookType::scheme( std::optional scheme) -> NotebookDocumentFilterNotebookType& { + if (!scheme.has_value()) { + repr_->erase("scheme"); + return *this; + } + repr_->emplace("scheme", std::move(scheme.value())); return *this; } auto NotebookDocumentFilterNotebookType::pattern( std::optional pattern) -> NotebookDocumentFilterNotebookType& { + if (!pattern.has_value()) { + repr_->erase("pattern"); + return *this; + } + lsp_runtime_error( + "NotebookDocumentFilterNotebookType::pattern: not implement yet"); return *this; } NotebookDocumentFilterScheme::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("scheme")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("scheme")) return false; return true; } auto NotebookDocumentFilterScheme::notebookType() const -> std::optional { - if (!repr_.contains("notebookType")) return std::nullopt; + if (!repr_->contains("notebookType")) return std::nullopt; - const auto& value = repr_["notebookType"]; + auto& value = (*repr_)["notebookType"]; assert(value.is_string()); return value.get(); } auto NotebookDocumentFilterScheme::scheme() const -> std::string { - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); @@ -14674,9 +19897,9 @@ auto NotebookDocumentFilterScheme::scheme() const -> std::string { auto NotebookDocumentFilterScheme::pattern() const -> std::optional { - if (!repr_.contains("pattern")) return std::nullopt; + if (!repr_->contains("pattern")) return std::nullopt; - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14687,30 +19910,41 @@ auto NotebookDocumentFilterScheme::pattern() const auto NotebookDocumentFilterScheme::notebookType( std::optional notebookType) -> NotebookDocumentFilterScheme& { + if (!notebookType.has_value()) { + repr_->erase("notebookType"); + return *this; + } + repr_->emplace("notebookType", std::move(notebookType.value())); return *this; } auto NotebookDocumentFilterScheme::scheme(std::string scheme) -> NotebookDocumentFilterScheme& { + repr_->emplace("scheme", std::move(scheme)); return *this; } auto NotebookDocumentFilterScheme::pattern(std::optional pattern) -> NotebookDocumentFilterScheme& { + if (!pattern.has_value()) { + repr_->erase("pattern"); + return *this; + } + lsp_runtime_error("NotebookDocumentFilterScheme::pattern: not implement yet"); return *this; } NotebookDocumentFilterPattern::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("pattern")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("pattern")) return false; return true; } auto NotebookDocumentFilterPattern::notebookType() const -> std::optional { - if (!repr_.contains("notebookType")) return std::nullopt; + if (!repr_->contains("notebookType")) return std::nullopt; - const auto& value = repr_["notebookType"]; + auto& value = (*repr_)["notebookType"]; assert(value.is_string()); return value.get(); @@ -14718,16 +19952,16 @@ auto NotebookDocumentFilterPattern::notebookType() const auto NotebookDocumentFilterPattern::scheme() const -> std::optional { - if (!repr_.contains("scheme")) return std::nullopt; + if (!repr_->contains("scheme")) return std::nullopt; - const auto& value = repr_["scheme"]; + auto& value = (*repr_)["scheme"]; assert(value.is_string()); return value.get(); } auto NotebookDocumentFilterPattern::pattern() const -> GlobPattern { - const auto& value = repr_["pattern"]; + auto& value = (*repr_)["pattern"]; GlobPattern result; @@ -14738,35 +19972,47 @@ auto NotebookDocumentFilterPattern::pattern() const -> GlobPattern { auto NotebookDocumentFilterPattern::notebookType( std::optional notebookType) -> NotebookDocumentFilterPattern& { + if (!notebookType.has_value()) { + repr_->erase("notebookType"); + return *this; + } + repr_->emplace("notebookType", std::move(notebookType.value())); return *this; } auto NotebookDocumentFilterPattern::scheme(std::optional scheme) -> NotebookDocumentFilterPattern& { + if (!scheme.has_value()) { + repr_->erase("scheme"); + return *this; + } + repr_->emplace("scheme", std::move(scheme.value())); return *this; } auto NotebookDocumentFilterPattern::pattern(GlobPattern pattern) -> NotebookDocumentFilterPattern& { + lsp_runtime_error( + "NotebookDocumentFilterPattern::pattern: not implement yet"); return *this; } NotebookCellArrayChange::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("start")) return false; - if (!repr_.contains("deleteCount")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("start")) return false; + if (!repr_->contains("deleteCount")) return false; return true; } auto NotebookCellArrayChange::start() const -> long { - const auto& value = repr_["start"]; + auto& value = (*repr_)["start"]; assert(value.is_number_integer()); return value.get(); } auto NotebookCellArrayChange::deleteCount() const -> long { - const auto& value = repr_["deleteCount"]; + auto& value = (*repr_)["deleteCount"]; assert(value.is_number_integer()); return value.get(); @@ -14774,38 +20020,45 @@ auto NotebookCellArrayChange::deleteCount() const -> long { auto NotebookCellArrayChange::cells() const -> std::optional> { - if (!repr_.contains("cells")) return std::nullopt; + if (!repr_->contains("cells")) return std::nullopt; - const auto& value = repr_["cells"]; + auto& value = (*repr_)["cells"]; assert(value.is_array()); return Vector(value); } auto NotebookCellArrayChange::start(long start) -> NotebookCellArrayChange& { + repr_->emplace("start", std::move(start)); return *this; } auto NotebookCellArrayChange::deleteCount(long deleteCount) -> NotebookCellArrayChange& { + repr_->emplace("deleteCount", std::move(deleteCount)); return *this; } auto NotebookCellArrayChange::cells(std::optional> cells) -> NotebookCellArrayChange& { + if (!cells.has_value()) { + repr_->erase("cells"); + return *this; + } + lsp_runtime_error("NotebookCellArrayChange::cells: not implement yet"); return *this; } WorkspaceEditClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceEditClientCapabilities::documentChanges() const -> std::optional { - if (!repr_.contains("documentChanges")) return std::nullopt; + if (!repr_->contains("documentChanges")) return std::nullopt; - const auto& value = repr_["documentChanges"]; + auto& value = (*repr_)["documentChanges"]; assert(value.is_boolean()); return value.get(); @@ -14813,9 +20066,9 @@ auto WorkspaceEditClientCapabilities::documentChanges() const auto WorkspaceEditClientCapabilities::resourceOperations() const -> std::optional> { - if (!repr_.contains("resourceOperations")) return std::nullopt; + if (!repr_->contains("resourceOperations")) return std::nullopt; - const auto& value = repr_["resourceOperations"]; + auto& value = (*repr_)["resourceOperations"]; assert(value.is_array()); return Vector(value); @@ -14823,9 +20076,9 @@ auto WorkspaceEditClientCapabilities::resourceOperations() const auto WorkspaceEditClientCapabilities::failureHandling() const -> std::optional { - if (!repr_.contains("failureHandling")) return std::nullopt; + if (!repr_->contains("failureHandling")) return std::nullopt; - const auto& value = repr_["failureHandling"]; + auto& value = (*repr_)["failureHandling"]; lsp_runtime_error( "WorkspaceEditClientCapabilities::failureHandling: not implement yet"); @@ -14833,9 +20086,9 @@ auto WorkspaceEditClientCapabilities::failureHandling() const auto WorkspaceEditClientCapabilities::normalizesLineEndings() const -> std::optional { - if (!repr_.contains("normalizesLineEndings")) return std::nullopt; + if (!repr_->contains("normalizesLineEndings")) return std::nullopt; - const auto& value = repr_["normalizesLineEndings"]; + auto& value = (*repr_)["normalizesLineEndings"]; assert(value.is_boolean()); return value.get(); @@ -14843,18 +20096,18 @@ auto WorkspaceEditClientCapabilities::normalizesLineEndings() const auto WorkspaceEditClientCapabilities::changeAnnotationSupport() const -> std::optional { - if (!repr_.contains("changeAnnotationSupport")) return std::nullopt; + if (!repr_->contains("changeAnnotationSupport")) return std::nullopt; - const auto& value = repr_["changeAnnotationSupport"]; + auto& value = (*repr_)["changeAnnotationSupport"]; return ChangeAnnotationsSupportOptions(value); } auto WorkspaceEditClientCapabilities::metadataSupport() const -> std::optional { - if (!repr_.contains("metadataSupport")) return std::nullopt; + if (!repr_->contains("metadataSupport")) return std::nullopt; - const auto& value = repr_["metadataSupport"]; + auto& value = (*repr_)["metadataSupport"]; assert(value.is_boolean()); return value.get(); @@ -14862,9 +20115,9 @@ auto WorkspaceEditClientCapabilities::metadataSupport() const auto WorkspaceEditClientCapabilities::snippetEditSupport() const -> std::optional { - if (!repr_.contains("snippetEditSupport")) return std::nullopt; + if (!repr_->contains("snippetEditSupport")) return std::nullopt; - const auto& value = repr_["snippetEditSupport"]; + auto& value = (*repr_)["snippetEditSupport"]; assert(value.is_boolean()); return value.get(); @@ -14872,54 +20125,92 @@ auto WorkspaceEditClientCapabilities::snippetEditSupport() const auto WorkspaceEditClientCapabilities::documentChanges( std::optional documentChanges) -> WorkspaceEditClientCapabilities& { + if (!documentChanges.has_value()) { + repr_->erase("documentChanges"); + return *this; + } + repr_->emplace("documentChanges", std::move(documentChanges.value())); return *this; } auto WorkspaceEditClientCapabilities::resourceOperations( std::optional> resourceOperations) -> WorkspaceEditClientCapabilities& { + if (!resourceOperations.has_value()) { + repr_->erase("resourceOperations"); + return *this; + } + lsp_runtime_error( + "WorkspaceEditClientCapabilities::resourceOperations: not implement yet"); return *this; } auto WorkspaceEditClientCapabilities::failureHandling( std::optional failureHandling) -> WorkspaceEditClientCapabilities& { + if (!failureHandling.has_value()) { + repr_->erase("failureHandling"); + return *this; + } + lsp_runtime_error( + "WorkspaceEditClientCapabilities::failureHandling: not implement yet"); return *this; } auto WorkspaceEditClientCapabilities::normalizesLineEndings( std::optional normalizesLineEndings) -> WorkspaceEditClientCapabilities& { + if (!normalizesLineEndings.has_value()) { + repr_->erase("normalizesLineEndings"); + return *this; + } + repr_->emplace("normalizesLineEndings", + std::move(normalizesLineEndings.value())); return *this; } auto WorkspaceEditClientCapabilities::changeAnnotationSupport( std::optional changeAnnotationSupport) -> WorkspaceEditClientCapabilities& { + if (!changeAnnotationSupport.has_value()) { + repr_->erase("changeAnnotationSupport"); + return *this; + } + repr_->emplace("changeAnnotationSupport", changeAnnotationSupport.value()); return *this; } auto WorkspaceEditClientCapabilities::metadataSupport( std::optional metadataSupport) -> WorkspaceEditClientCapabilities& { + if (!metadataSupport.has_value()) { + repr_->erase("metadataSupport"); + return *this; + } + repr_->emplace("metadataSupport", std::move(metadataSupport.value())); return *this; } auto WorkspaceEditClientCapabilities::snippetEditSupport( std::optional snippetEditSupport) -> WorkspaceEditClientCapabilities& { + if (!snippetEditSupport.has_value()) { + repr_->erase("snippetEditSupport"); + return *this; + } + repr_->emplace("snippetEditSupport", std::move(snippetEditSupport.value())); return *this; } DidChangeConfigurationClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DidChangeConfigurationClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -14928,19 +20219,24 @@ auto DidChangeConfigurationClientCapabilities::dynamicRegistration() const auto DidChangeConfigurationClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DidChangeConfigurationClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } DidChangeWatchedFilesClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DidChangeWatchedFilesClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -14948,9 +20244,9 @@ auto DidChangeWatchedFilesClientCapabilities::dynamicRegistration() const auto DidChangeWatchedFilesClientCapabilities::relativePatternSupport() const -> std::optional { - if (!repr_.contains("relativePatternSupport")) return std::nullopt; + if (!repr_->contains("relativePatternSupport")) return std::nullopt; - const auto& value = repr_["relativePatternSupport"]; + auto& value = (*repr_)["relativePatternSupport"]; assert(value.is_boolean()); return value.get(); @@ -14959,25 +20255,36 @@ auto DidChangeWatchedFilesClientCapabilities::relativePatternSupport() const auto DidChangeWatchedFilesClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DidChangeWatchedFilesClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DidChangeWatchedFilesClientCapabilities::relativePatternSupport( std::optional relativePatternSupport) -> DidChangeWatchedFilesClientCapabilities& { + if (!relativePatternSupport.has_value()) { + repr_->erase("relativePatternSupport"); + return *this; + } + repr_->emplace("relativePatternSupport", + std::move(relativePatternSupport.value())); return *this; } WorkspaceSymbolClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto WorkspaceSymbolClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -14985,27 +20292,27 @@ auto WorkspaceSymbolClientCapabilities::dynamicRegistration() const auto WorkspaceSymbolClientCapabilities::symbolKind() const -> std::optional { - if (!repr_.contains("symbolKind")) return std::nullopt; + if (!repr_->contains("symbolKind")) return std::nullopt; - const auto& value = repr_["symbolKind"]; + auto& value = (*repr_)["symbolKind"]; return ClientSymbolKindOptions(value); } auto WorkspaceSymbolClientCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return ClientSymbolTagOptions(value); } auto WorkspaceSymbolClientCapabilities::resolveSupport() const -> std::optional { - if (!repr_.contains("resolveSupport")) return std::nullopt; + if (!repr_->contains("resolveSupport")) return std::nullopt; - const auto& value = repr_["resolveSupport"]; + auto& value = (*repr_)["resolveSupport"]; return ClientSymbolResolveOptions(value); } @@ -15013,37 +20320,57 @@ auto WorkspaceSymbolClientCapabilities::resolveSupport() const auto WorkspaceSymbolClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> WorkspaceSymbolClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto WorkspaceSymbolClientCapabilities::symbolKind( std::optional symbolKind) -> WorkspaceSymbolClientCapabilities& { + if (!symbolKind.has_value()) { + repr_->erase("symbolKind"); + return *this; + } + repr_->emplace("symbolKind", symbolKind.value()); return *this; } auto WorkspaceSymbolClientCapabilities::tagSupport( std::optional tagSupport) -> WorkspaceSymbolClientCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto WorkspaceSymbolClientCapabilities::resolveSupport( std::optional resolveSupport) -> WorkspaceSymbolClientCapabilities& { + if (!resolveSupport.has_value()) { + repr_->erase("resolveSupport"); + return *this; + } + repr_->emplace("resolveSupport", resolveSupport.value()); return *this; } ExecuteCommandClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ExecuteCommandClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15052,19 +20379,24 @@ auto ExecuteCommandClientCapabilities::dynamicRegistration() const auto ExecuteCommandClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> ExecuteCommandClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } SemanticTokensWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SemanticTokensWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15073,19 +20405,24 @@ auto SemanticTokensWorkspaceClientCapabilities::refreshSupport() const auto SemanticTokensWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> SemanticTokensWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } CodeLensWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CodeLensWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15094,28 +20431,33 @@ auto CodeLensWorkspaceClientCapabilities::refreshSupport() const auto CodeLensWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> CodeLensWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } FileOperationClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FileOperationClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); } auto FileOperationClientCapabilities::didCreate() const -> std::optional { - if (!repr_.contains("didCreate")) return std::nullopt; + if (!repr_->contains("didCreate")) return std::nullopt; - const auto& value = repr_["didCreate"]; + auto& value = (*repr_)["didCreate"]; assert(value.is_boolean()); return value.get(); @@ -15123,18 +20465,18 @@ auto FileOperationClientCapabilities::didCreate() const -> std::optional { auto FileOperationClientCapabilities::willCreate() const -> std::optional { - if (!repr_.contains("willCreate")) return std::nullopt; + if (!repr_->contains("willCreate")) return std::nullopt; - const auto& value = repr_["willCreate"]; + auto& value = (*repr_)["willCreate"]; assert(value.is_boolean()); return value.get(); } auto FileOperationClientCapabilities::didRename() const -> std::optional { - if (!repr_.contains("didRename")) return std::nullopt; + if (!repr_->contains("didRename")) return std::nullopt; - const auto& value = repr_["didRename"]; + auto& value = (*repr_)["didRename"]; assert(value.is_boolean()); return value.get(); @@ -15142,18 +20484,18 @@ auto FileOperationClientCapabilities::didRename() const -> std::optional { auto FileOperationClientCapabilities::willRename() const -> std::optional { - if (!repr_.contains("willRename")) return std::nullopt; + if (!repr_->contains("willRename")) return std::nullopt; - const auto& value = repr_["willRename"]; + auto& value = (*repr_)["willRename"]; assert(value.is_boolean()); return value.get(); } auto FileOperationClientCapabilities::didDelete() const -> std::optional { - if (!repr_.contains("didDelete")) return std::nullopt; + if (!repr_->contains("didDelete")) return std::nullopt; - const auto& value = repr_["didDelete"]; + auto& value = (*repr_)["didDelete"]; assert(value.is_boolean()); return value.get(); @@ -15161,9 +20503,9 @@ auto FileOperationClientCapabilities::didDelete() const -> std::optional { auto FileOperationClientCapabilities::willDelete() const -> std::optional { - if (!repr_.contains("willDelete")) return std::nullopt; + if (!repr_->contains("willDelete")) return std::nullopt; - const auto& value = repr_["willDelete"]; + auto& value = (*repr_)["willDelete"]; assert(value.is_boolean()); return value.get(); @@ -15172,49 +20514,84 @@ auto FileOperationClientCapabilities::willDelete() const auto FileOperationClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> FileOperationClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto FileOperationClientCapabilities::didCreate(std::optional didCreate) -> FileOperationClientCapabilities& { + if (!didCreate.has_value()) { + repr_->erase("didCreate"); + return *this; + } + repr_->emplace("didCreate", std::move(didCreate.value())); return *this; } auto FileOperationClientCapabilities::willCreate(std::optional willCreate) -> FileOperationClientCapabilities& { + if (!willCreate.has_value()) { + repr_->erase("willCreate"); + return *this; + } + repr_->emplace("willCreate", std::move(willCreate.value())); return *this; } auto FileOperationClientCapabilities::didRename(std::optional didRename) -> FileOperationClientCapabilities& { + if (!didRename.has_value()) { + repr_->erase("didRename"); + return *this; + } + repr_->emplace("didRename", std::move(didRename.value())); return *this; } auto FileOperationClientCapabilities::willRename(std::optional willRename) -> FileOperationClientCapabilities& { + if (!willRename.has_value()) { + repr_->erase("willRename"); + return *this; + } + repr_->emplace("willRename", std::move(willRename.value())); return *this; } auto FileOperationClientCapabilities::didDelete(std::optional didDelete) -> FileOperationClientCapabilities& { + if (!didDelete.has_value()) { + repr_->erase("didDelete"); + return *this; + } + repr_->emplace("didDelete", std::move(didDelete.value())); return *this; } auto FileOperationClientCapabilities::willDelete(std::optional willDelete) -> FileOperationClientCapabilities& { + if (!willDelete.has_value()) { + repr_->erase("willDelete"); + return *this; + } + repr_->emplace("willDelete", std::move(willDelete.value())); return *this; } InlineValueWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlineValueWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15223,19 +20600,24 @@ auto InlineValueWorkspaceClientCapabilities::refreshSupport() const auto InlineValueWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> InlineValueWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } InlayHintWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlayHintWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15244,19 +20626,24 @@ auto InlayHintWorkspaceClientCapabilities::refreshSupport() const auto InlayHintWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> InlayHintWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } DiagnosticWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DiagnosticWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15265,19 +20652,24 @@ auto DiagnosticWorkspaceClientCapabilities::refreshSupport() const auto DiagnosticWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> DiagnosticWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } FoldingRangeWorkspaceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FoldingRangeWorkspaceClientCapabilities::refreshSupport() const -> std::optional { - if (!repr_.contains("refreshSupport")) return std::nullopt; + if (!repr_->contains("refreshSupport")) return std::nullopt; - const auto& value = repr_["refreshSupport"]; + auto& value = (*repr_)["refreshSupport"]; assert(value.is_boolean()); return value.get(); @@ -15286,19 +20678,24 @@ auto FoldingRangeWorkspaceClientCapabilities::refreshSupport() const auto FoldingRangeWorkspaceClientCapabilities::refreshSupport( std::optional refreshSupport) -> FoldingRangeWorkspaceClientCapabilities& { + if (!refreshSupport.has_value()) { + repr_->erase("refreshSupport"); + return *this; + } + repr_->emplace("refreshSupport", std::move(refreshSupport.value())); return *this; } TextDocumentContentClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TextDocumentContentClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15307,19 +20704,24 @@ auto TextDocumentContentClientCapabilities::dynamicRegistration() const auto TextDocumentContentClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> TextDocumentContentClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } TextDocumentSyncClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TextDocumentSyncClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15327,9 +20729,9 @@ auto TextDocumentSyncClientCapabilities::dynamicRegistration() const auto TextDocumentSyncClientCapabilities::willSave() const -> std::optional { - if (!repr_.contains("willSave")) return std::nullopt; + if (!repr_->contains("willSave")) return std::nullopt; - const auto& value = repr_["willSave"]; + auto& value = (*repr_)["willSave"]; assert(value.is_boolean()); return value.get(); @@ -15337,9 +20739,9 @@ auto TextDocumentSyncClientCapabilities::willSave() const auto TextDocumentSyncClientCapabilities::willSaveWaitUntil() const -> std::optional { - if (!repr_.contains("willSaveWaitUntil")) return std::nullopt; + if (!repr_->contains("willSaveWaitUntil")) return std::nullopt; - const auto& value = repr_["willSaveWaitUntil"]; + auto& value = (*repr_)["willSaveWaitUntil"]; assert(value.is_boolean()); return value.get(); @@ -15347,9 +20749,9 @@ auto TextDocumentSyncClientCapabilities::willSaveWaitUntil() const auto TextDocumentSyncClientCapabilities::didSave() const -> std::optional { - if (!repr_.contains("didSave")) return std::nullopt; + if (!repr_->contains("didSave")) return std::nullopt; - const auto& value = repr_["didSave"]; + auto& value = (*repr_)["didSave"]; assert(value.is_boolean()); return value.get(); @@ -15358,35 +20760,55 @@ auto TextDocumentSyncClientCapabilities::didSave() const auto TextDocumentSyncClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> TextDocumentSyncClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto TextDocumentSyncClientCapabilities::willSave(std::optional willSave) -> TextDocumentSyncClientCapabilities& { + if (!willSave.has_value()) { + repr_->erase("willSave"); + return *this; + } + repr_->emplace("willSave", std::move(willSave.value())); return *this; } auto TextDocumentSyncClientCapabilities::willSaveWaitUntil( std::optional willSaveWaitUntil) -> TextDocumentSyncClientCapabilities& { + if (!willSaveWaitUntil.has_value()) { + repr_->erase("willSaveWaitUntil"); + return *this; + } + repr_->emplace("willSaveWaitUntil", std::move(willSaveWaitUntil.value())); return *this; } auto TextDocumentSyncClientCapabilities::didSave(std::optional didSave) -> TextDocumentSyncClientCapabilities& { + if (!didSave.has_value()) { + repr_->erase("didSave"); + return *this; + } + repr_->emplace("didSave", std::move(didSave.value())); return *this; } TextDocumentFilterClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TextDocumentFilterClientCapabilities::relativePatternSupport() const -> std::optional { - if (!repr_.contains("relativePatternSupport")) return std::nullopt; + if (!repr_->contains("relativePatternSupport")) return std::nullopt; - const auto& value = repr_["relativePatternSupport"]; + auto& value = (*repr_)["relativePatternSupport"]; assert(value.is_boolean()); return value.get(); @@ -15395,19 +20817,25 @@ auto TextDocumentFilterClientCapabilities::relativePatternSupport() const auto TextDocumentFilterClientCapabilities::relativePatternSupport( std::optional relativePatternSupport) -> TextDocumentFilterClientCapabilities& { + if (!relativePatternSupport.has_value()) { + repr_->erase("relativePatternSupport"); + return *this; + } + repr_->emplace("relativePatternSupport", + std::move(relativePatternSupport.value())); return *this; } CompletionClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15415,36 +20843,36 @@ auto CompletionClientCapabilities::dynamicRegistration() const auto CompletionClientCapabilities::completionItem() const -> std::optional { - if (!repr_.contains("completionItem")) return std::nullopt; + if (!repr_->contains("completionItem")) return std::nullopt; - const auto& value = repr_["completionItem"]; + auto& value = (*repr_)["completionItem"]; return ClientCompletionItemOptions(value); } auto CompletionClientCapabilities::completionItemKind() const -> std::optional { - if (!repr_.contains("completionItemKind")) return std::nullopt; + if (!repr_->contains("completionItemKind")) return std::nullopt; - const auto& value = repr_["completionItemKind"]; + auto& value = (*repr_)["completionItemKind"]; return ClientCompletionItemOptionsKind(value); } auto CompletionClientCapabilities::insertTextMode() const -> std::optional { - if (!repr_.contains("insertTextMode")) return std::nullopt; + if (!repr_->contains("insertTextMode")) return std::nullopt; - const auto& value = repr_["insertTextMode"]; + auto& value = (*repr_)["insertTextMode"]; return InsertTextMode(value); } auto CompletionClientCapabilities::contextSupport() const -> std::optional { - if (!repr_.contains("contextSupport")) return std::nullopt; + if (!repr_->contains("contextSupport")) return std::nullopt; - const auto& value = repr_["contextSupport"]; + auto& value = (*repr_)["contextSupport"]; assert(value.is_boolean()); return value.get(); @@ -15452,57 +20880,87 @@ auto CompletionClientCapabilities::contextSupport() const auto CompletionClientCapabilities::completionList() const -> std::optional { - if (!repr_.contains("completionList")) return std::nullopt; + if (!repr_->contains("completionList")) return std::nullopt; - const auto& value = repr_["completionList"]; + auto& value = (*repr_)["completionList"]; return CompletionListCapabilities(value); } auto CompletionClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> CompletionClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto CompletionClientCapabilities::completionItem( std::optional completionItem) -> CompletionClientCapabilities& { + if (!completionItem.has_value()) { + repr_->erase("completionItem"); + return *this; + } + repr_->emplace("completionItem", completionItem.value()); return *this; } auto CompletionClientCapabilities::completionItemKind( std::optional completionItemKind) -> CompletionClientCapabilities& { + if (!completionItemKind.has_value()) { + repr_->erase("completionItemKind"); + return *this; + } + repr_->emplace("completionItemKind", completionItemKind.value()); return *this; } auto CompletionClientCapabilities::insertTextMode( std::optional insertTextMode) -> CompletionClientCapabilities& { + if (!insertTextMode.has_value()) { + repr_->erase("insertTextMode"); + return *this; + } + repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); return *this; } auto CompletionClientCapabilities::contextSupport( std::optional contextSupport) -> CompletionClientCapabilities& { + if (!contextSupport.has_value()) { + repr_->erase("contextSupport"); + return *this; + } + repr_->emplace("contextSupport", std::move(contextSupport.value())); return *this; } auto CompletionClientCapabilities::completionList( std::optional completionList) -> CompletionClientCapabilities& { + if (!completionList.has_value()) { + repr_->erase("completionList"); + return *this; + } + repr_->emplace("completionList", completionList.value()); return *this; } HoverClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto HoverClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15510,9 +20968,9 @@ auto HoverClientCapabilities::dynamicRegistration() const auto HoverClientCapabilities::contentFormat() const -> std::optional> { - if (!repr_.contains("contentFormat")) return std::nullopt; + if (!repr_->contains("contentFormat")) return std::nullopt; - const auto& value = repr_["contentFormat"]; + auto& value = (*repr_)["contentFormat"]; assert(value.is_array()); return Vector(value); @@ -15520,25 +20978,36 @@ auto HoverClientCapabilities::contentFormat() const auto HoverClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> HoverClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto HoverClientCapabilities::contentFormat( std::optional> contentFormat) -> HoverClientCapabilities& { + if (!contentFormat.has_value()) { + repr_->erase("contentFormat"); + return *this; + } + lsp_runtime_error( + "HoverClientCapabilities::contentFormat: not implement yet"); return *this; } SignatureHelpClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SignatureHelpClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15546,18 +21015,18 @@ auto SignatureHelpClientCapabilities::dynamicRegistration() const auto SignatureHelpClientCapabilities::signatureInformation() const -> std::optional { - if (!repr_.contains("signatureInformation")) return std::nullopt; + if (!repr_->contains("signatureInformation")) return std::nullopt; - const auto& value = repr_["signatureInformation"]; + auto& value = (*repr_)["signatureInformation"]; return ClientSignatureInformationOptions(value); } auto SignatureHelpClientCapabilities::contextSupport() const -> std::optional { - if (!repr_.contains("contextSupport")) return std::nullopt; + if (!repr_->contains("contextSupport")) return std::nullopt; - const auto& value = repr_["contextSupport"]; + auto& value = (*repr_)["contextSupport"]; assert(value.is_boolean()); return value.get(); @@ -15566,39 +21035,54 @@ auto SignatureHelpClientCapabilities::contextSupport() const auto SignatureHelpClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> SignatureHelpClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto SignatureHelpClientCapabilities::signatureInformation( std::optional signatureInformation) -> SignatureHelpClientCapabilities& { + if (!signatureInformation.has_value()) { + repr_->erase("signatureInformation"); + return *this; + } + repr_->emplace("signatureInformation", signatureInformation.value()); return *this; } auto SignatureHelpClientCapabilities::contextSupport( std::optional contextSupport) -> SignatureHelpClientCapabilities& { + if (!contextSupport.has_value()) { + repr_->erase("contextSupport"); + return *this; + } + repr_->emplace("contextSupport", std::move(contextSupport.value())); return *this; } DeclarationClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DeclarationClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); } auto DeclarationClientCapabilities::linkSupport() const -> std::optional { - if (!repr_.contains("linkSupport")) return std::nullopt; + if (!repr_->contains("linkSupport")) return std::nullopt; - const auto& value = repr_["linkSupport"]; + auto& value = (*repr_)["linkSupport"]; assert(value.is_boolean()); return value.get(); @@ -15606,33 +21090,43 @@ auto DeclarationClientCapabilities::linkSupport() const -> std::optional { auto DeclarationClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DeclarationClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DeclarationClientCapabilities::linkSupport(std::optional linkSupport) -> DeclarationClientCapabilities& { + if (!linkSupport.has_value()) { + repr_->erase("linkSupport"); + return *this; + } + repr_->emplace("linkSupport", std::move(linkSupport.value())); return *this; } DefinitionClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DefinitionClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); } auto DefinitionClientCapabilities::linkSupport() const -> std::optional { - if (!repr_.contains("linkSupport")) return std::nullopt; + if (!repr_->contains("linkSupport")) return std::nullopt; - const auto& value = repr_["linkSupport"]; + auto& value = (*repr_)["linkSupport"]; assert(value.is_boolean()); return value.get(); @@ -15640,24 +21134,34 @@ auto DefinitionClientCapabilities::linkSupport() const -> std::optional { auto DefinitionClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DefinitionClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DefinitionClientCapabilities::linkSupport(std::optional linkSupport) -> DefinitionClientCapabilities& { + if (!linkSupport.has_value()) { + repr_->erase("linkSupport"); + return *this; + } + repr_->emplace("linkSupport", std::move(linkSupport.value())); return *this; } TypeDefinitionClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TypeDefinitionClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15665,9 +21169,9 @@ auto TypeDefinitionClientCapabilities::dynamicRegistration() const auto TypeDefinitionClientCapabilities::linkSupport() const -> std::optional { - if (!repr_.contains("linkSupport")) return std::nullopt; + if (!repr_->contains("linkSupport")) return std::nullopt; - const auto& value = repr_["linkSupport"]; + auto& value = (*repr_)["linkSupport"]; assert(value.is_boolean()); return value.get(); @@ -15676,24 +21180,34 @@ auto TypeDefinitionClientCapabilities::linkSupport() const auto TypeDefinitionClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> TypeDefinitionClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto TypeDefinitionClientCapabilities::linkSupport( std::optional linkSupport) -> TypeDefinitionClientCapabilities& { + if (!linkSupport.has_value()) { + repr_->erase("linkSupport"); + return *this; + } + repr_->emplace("linkSupport", std::move(linkSupport.value())); return *this; } ImplementationClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ImplementationClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15701,9 +21215,9 @@ auto ImplementationClientCapabilities::dynamicRegistration() const auto ImplementationClientCapabilities::linkSupport() const -> std::optional { - if (!repr_.contains("linkSupport")) return std::nullopt; + if (!repr_->contains("linkSupport")) return std::nullopt; - const auto& value = repr_["linkSupport"]; + auto& value = (*repr_)["linkSupport"]; assert(value.is_boolean()); return value.get(); @@ -15712,24 +21226,34 @@ auto ImplementationClientCapabilities::linkSupport() const auto ImplementationClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> ImplementationClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto ImplementationClientCapabilities::linkSupport( std::optional linkSupport) -> ImplementationClientCapabilities& { + if (!linkSupport.has_value()) { + repr_->erase("linkSupport"); + return *this; + } + repr_->emplace("linkSupport", std::move(linkSupport.value())); return *this; } ReferenceClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ReferenceClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15737,19 +21261,24 @@ auto ReferenceClientCapabilities::dynamicRegistration() const auto ReferenceClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> ReferenceClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } DocumentHighlightClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentHighlightClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15758,19 +21287,24 @@ auto DocumentHighlightClientCapabilities::dynamicRegistration() const auto DocumentHighlightClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentHighlightClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } DocumentSymbolClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentSymbolClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15778,18 +21312,19 @@ auto DocumentSymbolClientCapabilities::dynamicRegistration() const auto DocumentSymbolClientCapabilities::symbolKind() const -> std::optional { - if (!repr_.contains("symbolKind")) return std::nullopt; + if (!repr_->contains("symbolKind")) return std::nullopt; - const auto& value = repr_["symbolKind"]; + auto& value = (*repr_)["symbolKind"]; return ClientSymbolKindOptions(value); } auto DocumentSymbolClientCapabilities::hierarchicalDocumentSymbolSupport() const -> std::optional { - if (!repr_.contains("hierarchicalDocumentSymbolSupport")) return std::nullopt; + if (!repr_->contains("hierarchicalDocumentSymbolSupport")) + return std::nullopt; - const auto& value = repr_["hierarchicalDocumentSymbolSupport"]; + auto& value = (*repr_)["hierarchicalDocumentSymbolSupport"]; assert(value.is_boolean()); return value.get(); @@ -15797,18 +21332,18 @@ auto DocumentSymbolClientCapabilities::hierarchicalDocumentSymbolSupport() const auto DocumentSymbolClientCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return ClientSymbolTagOptions(value); } auto DocumentSymbolClientCapabilities::labelSupport() const -> std::optional { - if (!repr_.contains("labelSupport")) return std::nullopt; + if (!repr_->contains("labelSupport")) return std::nullopt; - const auto& value = repr_["labelSupport"]; + auto& value = (*repr_)["labelSupport"]; assert(value.is_boolean()); return value.get(); @@ -15817,42 +21352,68 @@ auto DocumentSymbolClientCapabilities::labelSupport() const auto DocumentSymbolClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentSymbolClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DocumentSymbolClientCapabilities::symbolKind( std::optional symbolKind) -> DocumentSymbolClientCapabilities& { + if (!symbolKind.has_value()) { + repr_->erase("symbolKind"); + return *this; + } + repr_->emplace("symbolKind", symbolKind.value()); return *this; } auto DocumentSymbolClientCapabilities::hierarchicalDocumentSymbolSupport( std::optional hierarchicalDocumentSymbolSupport) -> DocumentSymbolClientCapabilities& { + if (!hierarchicalDocumentSymbolSupport.has_value()) { + repr_->erase("hierarchicalDocumentSymbolSupport"); + return *this; + } + repr_->emplace("hierarchicalDocumentSymbolSupport", + std::move(hierarchicalDocumentSymbolSupport.value())); return *this; } auto DocumentSymbolClientCapabilities::tagSupport( std::optional tagSupport) -> DocumentSymbolClientCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto DocumentSymbolClientCapabilities::labelSupport( std::optional labelSupport) -> DocumentSymbolClientCapabilities& { + if (!labelSupport.has_value()) { + repr_->erase("labelSupport"); + return *this; + } + repr_->emplace("labelSupport", std::move(labelSupport.value())); return *this; } CodeActionClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CodeActionClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -15860,18 +21421,18 @@ auto CodeActionClientCapabilities::dynamicRegistration() const auto CodeActionClientCapabilities::codeActionLiteralSupport() const -> std::optional { - if (!repr_.contains("codeActionLiteralSupport")) return std::nullopt; + if (!repr_->contains("codeActionLiteralSupport")) return std::nullopt; - const auto& value = repr_["codeActionLiteralSupport"]; + auto& value = (*repr_)["codeActionLiteralSupport"]; return ClientCodeActionLiteralOptions(value); } auto CodeActionClientCapabilities::isPreferredSupport() const -> std::optional { - if (!repr_.contains("isPreferredSupport")) return std::nullopt; + if (!repr_->contains("isPreferredSupport")) return std::nullopt; - const auto& value = repr_["isPreferredSupport"]; + auto& value = (*repr_)["isPreferredSupport"]; assert(value.is_boolean()); return value.get(); @@ -15879,18 +21440,18 @@ auto CodeActionClientCapabilities::isPreferredSupport() const auto CodeActionClientCapabilities::disabledSupport() const -> std::optional { - if (!repr_.contains("disabledSupport")) return std::nullopt; + if (!repr_->contains("disabledSupport")) return std::nullopt; - const auto& value = repr_["disabledSupport"]; + auto& value = (*repr_)["disabledSupport"]; assert(value.is_boolean()); return value.get(); } auto CodeActionClientCapabilities::dataSupport() const -> std::optional { - if (!repr_.contains("dataSupport")) return std::nullopt; + if (!repr_->contains("dataSupport")) return std::nullopt; - const auto& value = repr_["dataSupport"]; + auto& value = (*repr_)["dataSupport"]; assert(value.is_boolean()); return value.get(); @@ -15898,18 +21459,18 @@ auto CodeActionClientCapabilities::dataSupport() const -> std::optional { auto CodeActionClientCapabilities::resolveSupport() const -> std::optional { - if (!repr_.contains("resolveSupport")) return std::nullopt; + if (!repr_->contains("resolveSupport")) return std::nullopt; - const auto& value = repr_["resolveSupport"]; + auto& value = (*repr_)["resolveSupport"]; return ClientCodeActionResolveOptions(value); } auto CodeActionClientCapabilities::honorsChangeAnnotations() const -> std::optional { - if (!repr_.contains("honorsChangeAnnotations")) return std::nullopt; + if (!repr_->contains("honorsChangeAnnotations")) return std::nullopt; - const auto& value = repr_["honorsChangeAnnotations"]; + auto& value = (*repr_)["honorsChangeAnnotations"]; assert(value.is_boolean()); return value.get(); @@ -15917,9 +21478,9 @@ auto CodeActionClientCapabilities::honorsChangeAnnotations() const auto CodeActionClientCapabilities::documentationSupport() const -> std::optional { - if (!repr_.contains("documentationSupport")) return std::nullopt; + if (!repr_->contains("documentationSupport")) return std::nullopt; - const auto& value = repr_["documentationSupport"]; + auto& value = (*repr_)["documentationSupport"]; assert(value.is_boolean()); return value.get(); @@ -15927,72 +21488,119 @@ auto CodeActionClientCapabilities::documentationSupport() const auto CodeActionClientCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return CodeActionTagOptions(value); } auto CodeActionClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> CodeActionClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto CodeActionClientCapabilities::codeActionLiteralSupport( std::optional codeActionLiteralSupport) -> CodeActionClientCapabilities& { + if (!codeActionLiteralSupport.has_value()) { + repr_->erase("codeActionLiteralSupport"); + return *this; + } + repr_->emplace("codeActionLiteralSupport", codeActionLiteralSupport.value()); return *this; } auto CodeActionClientCapabilities::isPreferredSupport( std::optional isPreferredSupport) -> CodeActionClientCapabilities& { + if (!isPreferredSupport.has_value()) { + repr_->erase("isPreferredSupport"); + return *this; + } + repr_->emplace("isPreferredSupport", std::move(isPreferredSupport.value())); return *this; } auto CodeActionClientCapabilities::disabledSupport( std::optional disabledSupport) -> CodeActionClientCapabilities& { + if (!disabledSupport.has_value()) { + repr_->erase("disabledSupport"); + return *this; + } + repr_->emplace("disabledSupport", std::move(disabledSupport.value())); return *this; } auto CodeActionClientCapabilities::dataSupport(std::optional dataSupport) -> CodeActionClientCapabilities& { + if (!dataSupport.has_value()) { + repr_->erase("dataSupport"); + return *this; + } + repr_->emplace("dataSupport", std::move(dataSupport.value())); return *this; } auto CodeActionClientCapabilities::resolveSupport( std::optional resolveSupport) -> CodeActionClientCapabilities& { + if (!resolveSupport.has_value()) { + repr_->erase("resolveSupport"); + return *this; + } + repr_->emplace("resolveSupport", resolveSupport.value()); return *this; } auto CodeActionClientCapabilities::honorsChangeAnnotations( std::optional honorsChangeAnnotations) -> CodeActionClientCapabilities& { + if (!honorsChangeAnnotations.has_value()) { + repr_->erase("honorsChangeAnnotations"); + return *this; + } + repr_->emplace("honorsChangeAnnotations", + std::move(honorsChangeAnnotations.value())); return *this; } auto CodeActionClientCapabilities::documentationSupport( std::optional documentationSupport) -> CodeActionClientCapabilities& { + if (!documentationSupport.has_value()) { + repr_->erase("documentationSupport"); + return *this; + } + repr_->emplace("documentationSupport", + std::move(documentationSupport.value())); return *this; } auto CodeActionClientCapabilities::tagSupport( std::optional tagSupport) -> CodeActionClientCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } CodeLensClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CodeLensClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16000,34 +21608,44 @@ auto CodeLensClientCapabilities::dynamicRegistration() const auto CodeLensClientCapabilities::resolveSupport() const -> std::optional { - if (!repr_.contains("resolveSupport")) return std::nullopt; + if (!repr_->contains("resolveSupport")) return std::nullopt; - const auto& value = repr_["resolveSupport"]; + auto& value = (*repr_)["resolveSupport"]; return ClientCodeLensResolveOptions(value); } auto CodeLensClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> CodeLensClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto CodeLensClientCapabilities::resolveSupport( std::optional resolveSupport) -> CodeLensClientCapabilities& { + if (!resolveSupport.has_value()) { + repr_->erase("resolveSupport"); + return *this; + } + repr_->emplace("resolveSupport", resolveSupport.value()); return *this; } DocumentLinkClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentLinkClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16035,9 +21653,9 @@ auto DocumentLinkClientCapabilities::dynamicRegistration() const auto DocumentLinkClientCapabilities::tooltipSupport() const -> std::optional { - if (!repr_.contains("tooltipSupport")) return std::nullopt; + if (!repr_->contains("tooltipSupport")) return std::nullopt; - const auto& value = repr_["tooltipSupport"]; + auto& value = (*repr_)["tooltipSupport"]; assert(value.is_boolean()); return value.get(); @@ -16046,24 +21664,34 @@ auto DocumentLinkClientCapabilities::tooltipSupport() const auto DocumentLinkClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentLinkClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DocumentLinkClientCapabilities::tooltipSupport( std::optional tooltipSupport) -> DocumentLinkClientCapabilities& { + if (!tooltipSupport.has_value()) { + repr_->erase("tooltipSupport"); + return *this; + } + repr_->emplace("tooltipSupport", std::move(tooltipSupport.value())); return *this; } DocumentColorClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentColorClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16072,19 +21700,24 @@ auto DocumentColorClientCapabilities::dynamicRegistration() const auto DocumentColorClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentColorClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } DocumentFormattingClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentFormattingClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16093,19 +21726,24 @@ auto DocumentFormattingClientCapabilities::dynamicRegistration() const auto DocumentFormattingClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentFormattingClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } DocumentRangeFormattingClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentRangeFormattingClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16113,9 +21751,9 @@ auto DocumentRangeFormattingClientCapabilities::dynamicRegistration() const auto DocumentRangeFormattingClientCapabilities::rangesSupport() const -> std::optional { - if (!repr_.contains("rangesSupport")) return std::nullopt; + if (!repr_->contains("rangesSupport")) return std::nullopt; - const auto& value = repr_["rangesSupport"]; + auto& value = (*repr_)["rangesSupport"]; assert(value.is_boolean()); return value.get(); @@ -16124,25 +21762,35 @@ auto DocumentRangeFormattingClientCapabilities::rangesSupport() const auto DocumentRangeFormattingClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentRangeFormattingClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DocumentRangeFormattingClientCapabilities::rangesSupport( std::optional rangesSupport) -> DocumentRangeFormattingClientCapabilities& { + if (!rangesSupport.has_value()) { + repr_->erase("rangesSupport"); + return *this; + } + repr_->emplace("rangesSupport", std::move(rangesSupport.value())); return *this; } DocumentOnTypeFormattingClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DocumentOnTypeFormattingClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16151,28 +21799,33 @@ auto DocumentOnTypeFormattingClientCapabilities::dynamicRegistration() const auto DocumentOnTypeFormattingClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DocumentOnTypeFormattingClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } RenameClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto RenameClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); } auto RenameClientCapabilities::prepareSupport() const -> std::optional { - if (!repr_.contains("prepareSupport")) return std::nullopt; + if (!repr_->contains("prepareSupport")) return std::nullopt; - const auto& value = repr_["prepareSupport"]; + auto& value = (*repr_)["prepareSupport"]; assert(value.is_boolean()); return value.get(); @@ -16180,18 +21833,18 @@ auto RenameClientCapabilities::prepareSupport() const -> std::optional { auto RenameClientCapabilities::prepareSupportDefaultBehavior() const -> std::optional { - if (!repr_.contains("prepareSupportDefaultBehavior")) return std::nullopt; + if (!repr_->contains("prepareSupportDefaultBehavior")) return std::nullopt; - const auto& value = repr_["prepareSupportDefaultBehavior"]; + auto& value = (*repr_)["prepareSupportDefaultBehavior"]; return PrepareSupportDefaultBehavior(value); } auto RenameClientCapabilities::honorsChangeAnnotations() const -> std::optional { - if (!repr_.contains("honorsChangeAnnotations")) return std::nullopt; + if (!repr_->contains("honorsChangeAnnotations")) return std::nullopt; - const auto& value = repr_["honorsChangeAnnotations"]; + auto& value = (*repr_)["honorsChangeAnnotations"]; assert(value.is_boolean()); return value.get(); @@ -16199,44 +21852,66 @@ auto RenameClientCapabilities::honorsChangeAnnotations() const auto RenameClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> RenameClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto RenameClientCapabilities::prepareSupport( std::optional prepareSupport) -> RenameClientCapabilities& { + if (!prepareSupport.has_value()) { + repr_->erase("prepareSupport"); + return *this; + } + repr_->emplace("prepareSupport", std::move(prepareSupport.value())); return *this; } auto RenameClientCapabilities::prepareSupportDefaultBehavior( std::optional prepareSupportDefaultBehavior) -> RenameClientCapabilities& { + if (!prepareSupportDefaultBehavior.has_value()) { + repr_->erase("prepareSupportDefaultBehavior"); + return *this; + } + repr_->emplace("prepareSupportDefaultBehavior", + static_cast(prepareSupportDefaultBehavior.value())); return *this; } auto RenameClientCapabilities::honorsChangeAnnotations( std::optional honorsChangeAnnotations) -> RenameClientCapabilities& { + if (!honorsChangeAnnotations.has_value()) { + repr_->erase("honorsChangeAnnotations"); + return *this; + } + repr_->emplace("honorsChangeAnnotations", + std::move(honorsChangeAnnotations.value())); return *this; } FoldingRangeClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto FoldingRangeClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); } auto FoldingRangeClientCapabilities::rangeLimit() const -> std::optional { - if (!repr_.contains("rangeLimit")) return std::nullopt; + if (!repr_->contains("rangeLimit")) return std::nullopt; - const auto& value = repr_["rangeLimit"]; + auto& value = (*repr_)["rangeLimit"]; assert(value.is_number_integer()); return value.get(); @@ -16244,9 +21919,9 @@ auto FoldingRangeClientCapabilities::rangeLimit() const -> std::optional { auto FoldingRangeClientCapabilities::lineFoldingOnly() const -> std::optional { - if (!repr_.contains("lineFoldingOnly")) return std::nullopt; + if (!repr_->contains("lineFoldingOnly")) return std::nullopt; - const auto& value = repr_["lineFoldingOnly"]; + auto& value = (*repr_)["lineFoldingOnly"]; assert(value.is_boolean()); return value.get(); @@ -16254,18 +21929,18 @@ auto FoldingRangeClientCapabilities::lineFoldingOnly() const auto FoldingRangeClientCapabilities::foldingRangeKind() const -> std::optional { - if (!repr_.contains("foldingRangeKind")) return std::nullopt; + if (!repr_->contains("foldingRangeKind")) return std::nullopt; - const auto& value = repr_["foldingRangeKind"]; + auto& value = (*repr_)["foldingRangeKind"]; return ClientFoldingRangeKindOptions(value); } auto FoldingRangeClientCapabilities::foldingRange() const -> std::optional { - if (!repr_.contains("foldingRange")) return std::nullopt; + if (!repr_->contains("foldingRange")) return std::nullopt; - const auto& value = repr_["foldingRange"]; + auto& value = (*repr_)["foldingRange"]; return ClientFoldingRangeOptions(value); } @@ -16273,41 +21948,66 @@ auto FoldingRangeClientCapabilities::foldingRange() const auto FoldingRangeClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> FoldingRangeClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto FoldingRangeClientCapabilities::rangeLimit(std::optional rangeLimit) -> FoldingRangeClientCapabilities& { + if (!rangeLimit.has_value()) { + repr_->erase("rangeLimit"); + return *this; + } + repr_->emplace("rangeLimit", std::move(rangeLimit.value())); return *this; } auto FoldingRangeClientCapabilities::lineFoldingOnly( std::optional lineFoldingOnly) -> FoldingRangeClientCapabilities& { + if (!lineFoldingOnly.has_value()) { + repr_->erase("lineFoldingOnly"); + return *this; + } + repr_->emplace("lineFoldingOnly", std::move(lineFoldingOnly.value())); return *this; } auto FoldingRangeClientCapabilities::foldingRangeKind( std::optional foldingRangeKind) -> FoldingRangeClientCapabilities& { + if (!foldingRangeKind.has_value()) { + repr_->erase("foldingRangeKind"); + return *this; + } + repr_->emplace("foldingRangeKind", foldingRangeKind.value()); return *this; } auto FoldingRangeClientCapabilities::foldingRange( std::optional foldingRange) -> FoldingRangeClientCapabilities& { + if (!foldingRange.has_value()) { + repr_->erase("foldingRange"); + return *this; + } + repr_->emplace("foldingRange", foldingRange.value()); return *this; } SelectionRangeClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto SelectionRangeClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16316,19 +22016,24 @@ auto SelectionRangeClientCapabilities::dynamicRegistration() const auto SelectionRangeClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> SelectionRangeClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } PublishDiagnosticsClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto PublishDiagnosticsClientCapabilities::versionSupport() const -> std::optional { - if (!repr_.contains("versionSupport")) return std::nullopt; + if (!repr_->contains("versionSupport")) return std::nullopt; - const auto& value = repr_["versionSupport"]; + auto& value = (*repr_)["versionSupport"]; assert(value.is_boolean()); return value.get(); @@ -16336,9 +22041,9 @@ auto PublishDiagnosticsClientCapabilities::versionSupport() const auto PublishDiagnosticsClientCapabilities::relatedInformation() const -> std::optional { - if (!repr_.contains("relatedInformation")) return std::nullopt; + if (!repr_->contains("relatedInformation")) return std::nullopt; - const auto& value = repr_["relatedInformation"]; + auto& value = (*repr_)["relatedInformation"]; assert(value.is_boolean()); return value.get(); @@ -16346,18 +22051,18 @@ auto PublishDiagnosticsClientCapabilities::relatedInformation() const auto PublishDiagnosticsClientCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return ClientDiagnosticsTagOptions(value); } auto PublishDiagnosticsClientCapabilities::codeDescriptionSupport() const -> std::optional { - if (!repr_.contains("codeDescriptionSupport")) return std::nullopt; + if (!repr_->contains("codeDescriptionSupport")) return std::nullopt; - const auto& value = repr_["codeDescriptionSupport"]; + auto& value = (*repr_)["codeDescriptionSupport"]; assert(value.is_boolean()); return value.get(); @@ -16365,9 +22070,9 @@ auto PublishDiagnosticsClientCapabilities::codeDescriptionSupport() const auto PublishDiagnosticsClientCapabilities::dataSupport() const -> std::optional { - if (!repr_.contains("dataSupport")) return std::nullopt; + if (!repr_->contains("dataSupport")) return std::nullopt; - const auto& value = repr_["dataSupport"]; + auto& value = (*repr_)["dataSupport"]; assert(value.is_boolean()); return value.get(); @@ -16376,42 +22081,68 @@ auto PublishDiagnosticsClientCapabilities::dataSupport() const auto PublishDiagnosticsClientCapabilities::versionSupport( std::optional versionSupport) -> PublishDiagnosticsClientCapabilities& { + if (!versionSupport.has_value()) { + repr_->erase("versionSupport"); + return *this; + } + repr_->emplace("versionSupport", std::move(versionSupport.value())); return *this; } auto PublishDiagnosticsClientCapabilities::relatedInformation( std::optional relatedInformation) -> PublishDiagnosticsClientCapabilities& { + if (!relatedInformation.has_value()) { + repr_->erase("relatedInformation"); + return *this; + } + repr_->emplace("relatedInformation", std::move(relatedInformation.value())); return *this; } auto PublishDiagnosticsClientCapabilities::tagSupport( std::optional tagSupport) -> PublishDiagnosticsClientCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto PublishDiagnosticsClientCapabilities::codeDescriptionSupport( std::optional codeDescriptionSupport) -> PublishDiagnosticsClientCapabilities& { + if (!codeDescriptionSupport.has_value()) { + repr_->erase("codeDescriptionSupport"); + return *this; + } + repr_->emplace("codeDescriptionSupport", + std::move(codeDescriptionSupport.value())); return *this; } auto PublishDiagnosticsClientCapabilities::dataSupport( std::optional dataSupport) -> PublishDiagnosticsClientCapabilities& { + if (!dataSupport.has_value()) { + repr_->erase("dataSupport"); + return *this; + } + repr_->emplace("dataSupport", std::move(dataSupport.value())); return *this; } CallHierarchyClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CallHierarchyClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16420,23 +22151,28 @@ auto CallHierarchyClientCapabilities::dynamicRegistration() const auto CallHierarchyClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> CallHierarchyClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } SemanticTokensClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("requests")) return false; - if (!repr_.contains("tokenTypes")) return false; - if (!repr_.contains("tokenModifiers")) return false; - if (!repr_.contains("formats")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("requests")) return false; + if (!repr_->contains("tokenTypes")) return false; + if (!repr_->contains("tokenModifiers")) return false; + if (!repr_->contains("formats")) return false; return true; } auto SemanticTokensClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16444,14 +22180,14 @@ auto SemanticTokensClientCapabilities::dynamicRegistration() const auto SemanticTokensClientCapabilities::requests() const -> ClientSemanticTokensRequestOptions { - const auto& value = repr_["requests"]; + auto& value = (*repr_)["requests"]; return ClientSemanticTokensRequestOptions(value); } auto SemanticTokensClientCapabilities::tokenTypes() const -> Vector { - const auto& value = repr_["tokenTypes"]; + auto& value = (*repr_)["tokenTypes"]; assert(value.is_array()); return Vector(value); @@ -16459,14 +22195,14 @@ auto SemanticTokensClientCapabilities::tokenTypes() const auto SemanticTokensClientCapabilities::tokenModifiers() const -> Vector { - const auto& value = repr_["tokenModifiers"]; + auto& value = (*repr_)["tokenModifiers"]; assert(value.is_array()); return Vector(value); } auto SemanticTokensClientCapabilities::formats() const -> Vector { - const auto& value = repr_["formats"]; + auto& value = (*repr_)["formats"]; assert(value.is_array()); return Vector(value); @@ -16474,9 +22210,9 @@ auto SemanticTokensClientCapabilities::formats() const -> Vector { auto SemanticTokensClientCapabilities::overlappingTokenSupport() const -> std::optional { - if (!repr_.contains("overlappingTokenSupport")) return std::nullopt; + if (!repr_->contains("overlappingTokenSupport")) return std::nullopt; - const auto& value = repr_["overlappingTokenSupport"]; + auto& value = (*repr_)["overlappingTokenSupport"]; assert(value.is_boolean()); return value.get(); @@ -16484,9 +22220,9 @@ auto SemanticTokensClientCapabilities::overlappingTokenSupport() const auto SemanticTokensClientCapabilities::multilineTokenSupport() const -> std::optional { - if (!repr_.contains("multilineTokenSupport")) return std::nullopt; + if (!repr_->contains("multilineTokenSupport")) return std::nullopt; - const auto& value = repr_["multilineTokenSupport"]; + auto& value = (*repr_)["multilineTokenSupport"]; assert(value.is_boolean()); return value.get(); @@ -16494,9 +22230,9 @@ auto SemanticTokensClientCapabilities::multilineTokenSupport() const auto SemanticTokensClientCapabilities::serverCancelSupport() const -> std::optional { - if (!repr_.contains("serverCancelSupport")) return std::nullopt; + if (!repr_->contains("serverCancelSupport")) return std::nullopt; - const auto& value = repr_["serverCancelSupport"]; + auto& value = (*repr_)["serverCancelSupport"]; assert(value.is_boolean()); return value.get(); @@ -16504,9 +22240,9 @@ auto SemanticTokensClientCapabilities::serverCancelSupport() const auto SemanticTokensClientCapabilities::augmentsSyntaxTokens() const -> std::optional { - if (!repr_.contains("augmentsSyntaxTokens")) return std::nullopt; + if (!repr_->contains("augmentsSyntaxTokens")) return std::nullopt; - const auto& value = repr_["augmentsSyntaxTokens"]; + auto& value = (*repr_)["augmentsSyntaxTokens"]; assert(value.is_boolean()); return value.get(); @@ -16515,64 +22251,99 @@ auto SemanticTokensClientCapabilities::augmentsSyntaxTokens() const auto SemanticTokensClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> SemanticTokensClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto SemanticTokensClientCapabilities::requests( ClientSemanticTokensRequestOptions requests) -> SemanticTokensClientCapabilities& { + repr_->emplace("requests", requests); return *this; } auto SemanticTokensClientCapabilities::tokenTypes( Vector tokenTypes) -> SemanticTokensClientCapabilities& { + lsp_runtime_error( + "SemanticTokensClientCapabilities::tokenTypes: not implement yet"); return *this; } auto SemanticTokensClientCapabilities::tokenModifiers( Vector tokenModifiers) -> SemanticTokensClientCapabilities& { + lsp_runtime_error( + "SemanticTokensClientCapabilities::tokenModifiers: not implement yet"); return *this; } auto SemanticTokensClientCapabilities::formats(Vector formats) -> SemanticTokensClientCapabilities& { + lsp_runtime_error( + "SemanticTokensClientCapabilities::formats: not implement yet"); return *this; } auto SemanticTokensClientCapabilities::overlappingTokenSupport( std::optional overlappingTokenSupport) -> SemanticTokensClientCapabilities& { + if (!overlappingTokenSupport.has_value()) { + repr_->erase("overlappingTokenSupport"); + return *this; + } + repr_->emplace("overlappingTokenSupport", + std::move(overlappingTokenSupport.value())); return *this; } auto SemanticTokensClientCapabilities::multilineTokenSupport( std::optional multilineTokenSupport) -> SemanticTokensClientCapabilities& { + if (!multilineTokenSupport.has_value()) { + repr_->erase("multilineTokenSupport"); + return *this; + } + repr_->emplace("multilineTokenSupport", + std::move(multilineTokenSupport.value())); return *this; } auto SemanticTokensClientCapabilities::serverCancelSupport( std::optional serverCancelSupport) -> SemanticTokensClientCapabilities& { + if (!serverCancelSupport.has_value()) { + repr_->erase("serverCancelSupport"); + return *this; + } + repr_->emplace("serverCancelSupport", std::move(serverCancelSupport.value())); return *this; } auto SemanticTokensClientCapabilities::augmentsSyntaxTokens( std::optional augmentsSyntaxTokens) -> SemanticTokensClientCapabilities& { + if (!augmentsSyntaxTokens.has_value()) { + repr_->erase("augmentsSyntaxTokens"); + return *this; + } + repr_->emplace("augmentsSyntaxTokens", + std::move(augmentsSyntaxTokens.value())); return *this; } LinkedEditingRangeClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto LinkedEditingRangeClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16581,19 +22352,24 @@ auto LinkedEditingRangeClientCapabilities::dynamicRegistration() const auto LinkedEditingRangeClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> LinkedEditingRangeClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } MonikerClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto MonikerClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16601,19 +22377,24 @@ auto MonikerClientCapabilities::dynamicRegistration() const auto MonikerClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> MonikerClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } TypeHierarchyClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto TypeHierarchyClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16622,19 +22403,24 @@ auto TypeHierarchyClientCapabilities::dynamicRegistration() const auto TypeHierarchyClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> TypeHierarchyClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } InlineValueClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlineValueClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16642,19 +22428,24 @@ auto InlineValueClientCapabilities::dynamicRegistration() const auto InlineValueClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> InlineValueClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } InlayHintClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlayHintClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16662,34 +22453,44 @@ auto InlayHintClientCapabilities::dynamicRegistration() const auto InlayHintClientCapabilities::resolveSupport() const -> std::optional { - if (!repr_.contains("resolveSupport")) return std::nullopt; + if (!repr_->contains("resolveSupport")) return std::nullopt; - const auto& value = repr_["resolveSupport"]; + auto& value = (*repr_)["resolveSupport"]; return ClientInlayHintResolveOptions(value); } auto InlayHintClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> InlayHintClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto InlayHintClientCapabilities::resolveSupport( std::optional resolveSupport) -> InlayHintClientCapabilities& { + if (!resolveSupport.has_value()) { + repr_->erase("resolveSupport"); + return *this; + } + repr_->emplace("resolveSupport", resolveSupport.value()); return *this; } DiagnosticClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DiagnosticClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16697,9 +22498,9 @@ auto DiagnosticClientCapabilities::dynamicRegistration() const auto DiagnosticClientCapabilities::relatedDocumentSupport() const -> std::optional { - if (!repr_.contains("relatedDocumentSupport")) return std::nullopt; + if (!repr_->contains("relatedDocumentSupport")) return std::nullopt; - const auto& value = repr_["relatedDocumentSupport"]; + auto& value = (*repr_)["relatedDocumentSupport"]; assert(value.is_boolean()); return value.get(); @@ -16707,9 +22508,9 @@ auto DiagnosticClientCapabilities::relatedDocumentSupport() const auto DiagnosticClientCapabilities::relatedInformation() const -> std::optional { - if (!repr_.contains("relatedInformation")) return std::nullopt; + if (!repr_->contains("relatedInformation")) return std::nullopt; - const auto& value = repr_["relatedInformation"]; + auto& value = (*repr_)["relatedInformation"]; assert(value.is_boolean()); return value.get(); @@ -16717,27 +22518,27 @@ auto DiagnosticClientCapabilities::relatedInformation() const auto DiagnosticClientCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return ClientDiagnosticsTagOptions(value); } auto DiagnosticClientCapabilities::codeDescriptionSupport() const -> std::optional { - if (!repr_.contains("codeDescriptionSupport")) return std::nullopt; + if (!repr_->contains("codeDescriptionSupport")) return std::nullopt; - const auto& value = repr_["codeDescriptionSupport"]; + auto& value = (*repr_)["codeDescriptionSupport"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticClientCapabilities::dataSupport() const -> std::optional { - if (!repr_.contains("dataSupport")) return std::nullopt; + if (!repr_->contains("dataSupport")) return std::nullopt; - const auto& value = repr_["dataSupport"]; + auto& value = (*repr_)["dataSupport"]; assert(value.is_boolean()); return value.get(); @@ -16745,47 +22546,79 @@ auto DiagnosticClientCapabilities::dataSupport() const -> std::optional { auto DiagnosticClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> DiagnosticClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto DiagnosticClientCapabilities::relatedDocumentSupport( std::optional relatedDocumentSupport) -> DiagnosticClientCapabilities& { + if (!relatedDocumentSupport.has_value()) { + repr_->erase("relatedDocumentSupport"); + return *this; + } + repr_->emplace("relatedDocumentSupport", + std::move(relatedDocumentSupport.value())); return *this; } auto DiagnosticClientCapabilities::relatedInformation( std::optional relatedInformation) -> DiagnosticClientCapabilities& { + if (!relatedInformation.has_value()) { + repr_->erase("relatedInformation"); + return *this; + } + repr_->emplace("relatedInformation", std::move(relatedInformation.value())); return *this; } auto DiagnosticClientCapabilities::tagSupport( std::optional tagSupport) -> DiagnosticClientCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto DiagnosticClientCapabilities::codeDescriptionSupport( std::optional codeDescriptionSupport) -> DiagnosticClientCapabilities& { + if (!codeDescriptionSupport.has_value()) { + repr_->erase("codeDescriptionSupport"); + return *this; + } + repr_->emplace("codeDescriptionSupport", + std::move(codeDescriptionSupport.value())); return *this; } auto DiagnosticClientCapabilities::dataSupport(std::optional dataSupport) -> DiagnosticClientCapabilities& { + if (!dataSupport.has_value()) { + repr_->erase("dataSupport"); + return *this; + } + repr_->emplace("dataSupport", std::move(dataSupport.value())); return *this; } InlineCompletionClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto InlineCompletionClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16794,19 +22627,24 @@ auto InlineCompletionClientCapabilities::dynamicRegistration() const auto InlineCompletionClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> InlineCompletionClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } NotebookDocumentSyncClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto NotebookDocumentSyncClientCapabilities::dynamicRegistration() const -> std::optional { - if (!repr_.contains("dynamicRegistration")) return std::nullopt; + if (!repr_->contains("dynamicRegistration")) return std::nullopt; - const auto& value = repr_["dynamicRegistration"]; + auto& value = (*repr_)["dynamicRegistration"]; assert(value.is_boolean()); return value.get(); @@ -16814,9 +22652,9 @@ auto NotebookDocumentSyncClientCapabilities::dynamicRegistration() const auto NotebookDocumentSyncClientCapabilities::executionSummarySupport() const -> std::optional { - if (!repr_.contains("executionSummarySupport")) return std::nullopt; + if (!repr_->contains("executionSummarySupport")) return std::nullopt; - const auto& value = repr_["executionSummarySupport"]; + auto& value = (*repr_)["executionSummarySupport"]; assert(value.is_boolean()); return value.get(); @@ -16825,25 +22663,36 @@ auto NotebookDocumentSyncClientCapabilities::executionSummarySupport() const auto NotebookDocumentSyncClientCapabilities::dynamicRegistration( std::optional dynamicRegistration) -> NotebookDocumentSyncClientCapabilities& { + if (!dynamicRegistration.has_value()) { + repr_->erase("dynamicRegistration"); + return *this; + } + repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); return *this; } auto NotebookDocumentSyncClientCapabilities::executionSummarySupport( std::optional executionSummarySupport) -> NotebookDocumentSyncClientCapabilities& { + if (!executionSummarySupport.has_value()) { + repr_->erase("executionSummarySupport"); + return *this; + } + repr_->emplace("executionSummarySupport", + std::move(executionSummarySupport.value())); return *this; } ShowMessageRequestClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ShowMessageRequestClientCapabilities::messageActionItem() const -> std::optional { - if (!repr_.contains("messageActionItem")) return std::nullopt; + if (!repr_->contains("messageActionItem")) return std::nullopt; - const auto& value = repr_["messageActionItem"]; + auto& value = (*repr_)["messageActionItem"]; return ClientShowMessageActionItemOptions(value); } @@ -16851,17 +22700,22 @@ auto ShowMessageRequestClientCapabilities::messageActionItem() const auto ShowMessageRequestClientCapabilities::messageActionItem( std::optional messageActionItem) -> ShowMessageRequestClientCapabilities& { + if (!messageActionItem.has_value()) { + repr_->erase("messageActionItem"); + return *this; + } + repr_->emplace("messageActionItem", messageActionItem.value()); return *this; } ShowDocumentClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("support")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("support")) return false; return true; } auto ShowDocumentClientCapabilities::support() const -> bool { - const auto& value = repr_["support"]; + auto& value = (*repr_)["support"]; assert(value.is_boolean()); return value.get(); @@ -16869,18 +22723,19 @@ auto ShowDocumentClientCapabilities::support() const -> bool { auto ShowDocumentClientCapabilities::support(bool support) -> ShowDocumentClientCapabilities& { + repr_->emplace("support", std::move(support)); return *this; } StaleRequestSupportOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("cancel")) return false; - if (!repr_.contains("retryOnContentModified")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("cancel")) return false; + if (!repr_->contains("retryOnContentModified")) return false; return true; } auto StaleRequestSupportOptions::cancel() const -> bool { - const auto& value = repr_["cancel"]; + auto& value = (*repr_)["cancel"]; assert(value.is_boolean()); return value.get(); @@ -16888,7 +22743,7 @@ auto StaleRequestSupportOptions::cancel() const -> bool { auto StaleRequestSupportOptions::retryOnContentModified() const -> Vector { - const auto& value = repr_["retryOnContentModified"]; + auto& value = (*repr_)["retryOnContentModified"]; assert(value.is_array()); return Vector(value); @@ -16896,23 +22751,26 @@ auto StaleRequestSupportOptions::retryOnContentModified() const auto StaleRequestSupportOptions::cancel(bool cancel) -> StaleRequestSupportOptions& { + repr_->emplace("cancel", std::move(cancel)); return *this; } auto StaleRequestSupportOptions::retryOnContentModified( Vector retryOnContentModified) -> StaleRequestSupportOptions& { + lsp_runtime_error( + "StaleRequestSupportOptions::retryOnContentModified: not implement yet"); return *this; } RegularExpressionsClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("engine")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("engine")) return false; return true; } auto RegularExpressionsClientCapabilities::engine() const -> RegularExpressionEngineKind { - const auto& value = repr_["engine"]; + auto& value = (*repr_)["engine"]; assert(value.is_string()); return value.get(); @@ -16920,9 +22778,9 @@ auto RegularExpressionsClientCapabilities::engine() const auto RegularExpressionsClientCapabilities::version() const -> std::optional { - if (!repr_.contains("version")) return std::nullopt; + if (!repr_->contains("version")) return std::nullopt; - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_string()); return value.get(); @@ -16931,32 +22789,39 @@ auto RegularExpressionsClientCapabilities::version() const auto RegularExpressionsClientCapabilities::engine( RegularExpressionEngineKind engine) -> RegularExpressionsClientCapabilities& { + lsp_runtime_error( + "RegularExpressionsClientCapabilities::engine: not implement yet"); return *this; } auto RegularExpressionsClientCapabilities::version( std::optional version) -> RegularExpressionsClientCapabilities& { + if (!version.has_value()) { + repr_->erase("version"); + return *this; + } + repr_->emplace("version", std::move(version.value())); return *this; } MarkdownClientCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("parser")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("parser")) return false; return true; } auto MarkdownClientCapabilities::parser() const -> std::string { - const auto& value = repr_["parser"]; + auto& value = (*repr_)["parser"]; assert(value.is_string()); return value.get(); } auto MarkdownClientCapabilities::version() const -> std::optional { - if (!repr_.contains("version")) return std::nullopt; + if (!repr_->contains("version")) return std::nullopt; - const auto& value = repr_["version"]; + auto& value = (*repr_)["version"]; assert(value.is_string()); return value.get(); @@ -16964,9 +22829,9 @@ auto MarkdownClientCapabilities::version() const -> std::optional { auto MarkdownClientCapabilities::allowedTags() const -> std::optional> { - if (!repr_.contains("allowedTags")) return std::nullopt; + if (!repr_->contains("allowedTags")) return std::nullopt; - const auto& value = repr_["allowedTags"]; + auto& value = (*repr_)["allowedTags"]; assert(value.is_array()); return Vector(value); @@ -16974,30 +22839,42 @@ auto MarkdownClientCapabilities::allowedTags() const auto MarkdownClientCapabilities::parser(std::string parser) -> MarkdownClientCapabilities& { + repr_->emplace("parser", std::move(parser)); return *this; } auto MarkdownClientCapabilities::version(std::optional version) -> MarkdownClientCapabilities& { + if (!version.has_value()) { + repr_->erase("version"); + return *this; + } + repr_->emplace("version", std::move(version.value())); return *this; } auto MarkdownClientCapabilities::allowedTags( std::optional> allowedTags) -> MarkdownClientCapabilities& { + if (!allowedTags.has_value()) { + repr_->erase("allowedTags"); + return *this; + } + lsp_runtime_error( + "MarkdownClientCapabilities::allowedTags: not implement yet"); return *this; } ChangeAnnotationsSupportOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ChangeAnnotationsSupportOptions::groupsOnLabel() const -> std::optional { - if (!repr_.contains("groupsOnLabel")) return std::nullopt; + if (!repr_->contains("groupsOnLabel")) return std::nullopt; - const auto& value = repr_["groupsOnLabel"]; + auto& value = (*repr_)["groupsOnLabel"]; assert(value.is_boolean()); return value.get(); @@ -17005,19 +22882,24 @@ auto ChangeAnnotationsSupportOptions::groupsOnLabel() const auto ChangeAnnotationsSupportOptions::groupsOnLabel( std::optional groupsOnLabel) -> ChangeAnnotationsSupportOptions& { + if (!groupsOnLabel.has_value()) { + repr_->erase("groupsOnLabel"); + return *this; + } + repr_->emplace("groupsOnLabel", std::move(groupsOnLabel.value())); return *this; } ClientSymbolKindOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientSymbolKindOptions::valueSet() const -> std::optional> { - if (!repr_.contains("valueSet")) return std::nullopt; + if (!repr_->contains("valueSet")) return std::nullopt; - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17025,17 +22907,22 @@ auto ClientSymbolKindOptions::valueSet() const auto ClientSymbolKindOptions::valueSet( std::optional> valueSet) -> ClientSymbolKindOptions& { + if (!valueSet.has_value()) { + repr_->erase("valueSet"); + return *this; + } + lsp_runtime_error("ClientSymbolKindOptions::valueSet: not implement yet"); return *this; } ClientSymbolTagOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto ClientSymbolTagOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17043,17 +22930,18 @@ auto ClientSymbolTagOptions::valueSet() const -> Vector { auto ClientSymbolTagOptions::valueSet(Vector valueSet) -> ClientSymbolTagOptions& { + lsp_runtime_error("ClientSymbolTagOptions::valueSet: not implement yet"); return *this; } ClientSymbolResolveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("properties")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("properties")) return false; return true; } auto ClientSymbolResolveOptions::properties() const -> Vector { - const auto& value = repr_["properties"]; + auto& value = (*repr_)["properties"]; assert(value.is_array()); return Vector(value); @@ -17061,19 +22949,21 @@ auto ClientSymbolResolveOptions::properties() const -> Vector { auto ClientSymbolResolveOptions::properties(Vector properties) -> ClientSymbolResolveOptions& { + lsp_runtime_error( + "ClientSymbolResolveOptions::properties: not implement yet"); return *this; } ClientCompletionItemOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientCompletionItemOptions::snippetSupport() const -> std::optional { - if (!repr_.contains("snippetSupport")) return std::nullopt; + if (!repr_->contains("snippetSupport")) return std::nullopt; - const auto& value = repr_["snippetSupport"]; + auto& value = (*repr_)["snippetSupport"]; assert(value.is_boolean()); return value.get(); @@ -17081,9 +22971,9 @@ auto ClientCompletionItemOptions::snippetSupport() const auto ClientCompletionItemOptions::commitCharactersSupport() const -> std::optional { - if (!repr_.contains("commitCharactersSupport")) return std::nullopt; + if (!repr_->contains("commitCharactersSupport")) return std::nullopt; - const auto& value = repr_["commitCharactersSupport"]; + auto& value = (*repr_)["commitCharactersSupport"]; assert(value.is_boolean()); return value.get(); @@ -17091,9 +22981,9 @@ auto ClientCompletionItemOptions::commitCharactersSupport() const auto ClientCompletionItemOptions::documentationFormat() const -> std::optional> { - if (!repr_.contains("documentationFormat")) return std::nullopt; + if (!repr_->contains("documentationFormat")) return std::nullopt; - const auto& value = repr_["documentationFormat"]; + auto& value = (*repr_)["documentationFormat"]; assert(value.is_array()); return Vector(value); @@ -17101,9 +22991,9 @@ auto ClientCompletionItemOptions::documentationFormat() const auto ClientCompletionItemOptions::deprecatedSupport() const -> std::optional { - if (!repr_.contains("deprecatedSupport")) return std::nullopt; + if (!repr_->contains("deprecatedSupport")) return std::nullopt; - const auto& value = repr_["deprecatedSupport"]; + auto& value = (*repr_)["deprecatedSupport"]; assert(value.is_boolean()); return value.get(); @@ -17111,9 +23001,9 @@ auto ClientCompletionItemOptions::deprecatedSupport() const auto ClientCompletionItemOptions::preselectSupport() const -> std::optional { - if (!repr_.contains("preselectSupport")) return std::nullopt; + if (!repr_->contains("preselectSupport")) return std::nullopt; - const auto& value = repr_["preselectSupport"]; + auto& value = (*repr_)["preselectSupport"]; assert(value.is_boolean()); return value.get(); @@ -17121,18 +23011,18 @@ auto ClientCompletionItemOptions::preselectSupport() const auto ClientCompletionItemOptions::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return CompletionItemTagOptions(value); } auto ClientCompletionItemOptions::insertReplaceSupport() const -> std::optional { - if (!repr_.contains("insertReplaceSupport")) return std::nullopt; + if (!repr_->contains("insertReplaceSupport")) return std::nullopt; - const auto& value = repr_["insertReplaceSupport"]; + auto& value = (*repr_)["insertReplaceSupport"]; assert(value.is_boolean()); return value.get(); @@ -17140,27 +23030,27 @@ auto ClientCompletionItemOptions::insertReplaceSupport() const auto ClientCompletionItemOptions::resolveSupport() const -> std::optional { - if (!repr_.contains("resolveSupport")) return std::nullopt; + if (!repr_->contains("resolveSupport")) return std::nullopt; - const auto& value = repr_["resolveSupport"]; + auto& value = (*repr_)["resolveSupport"]; return ClientCompletionItemResolveOptions(value); } auto ClientCompletionItemOptions::insertTextModeSupport() const -> std::optional { - if (!repr_.contains("insertTextModeSupport")) return std::nullopt; + if (!repr_->contains("insertTextModeSupport")) return std::nullopt; - const auto& value = repr_["insertTextModeSupport"]; + auto& value = (*repr_)["insertTextModeSupport"]; return ClientCompletionItemInsertTextModeOptions(value); } auto ClientCompletionItemOptions::labelDetailsSupport() const -> std::optional { - if (!repr_.contains("labelDetailsSupport")) return std::nullopt; + if (!repr_->contains("labelDetailsSupport")) return std::nullopt; - const auto& value = repr_["labelDetailsSupport"]; + auto& value = (*repr_)["labelDetailsSupport"]; assert(value.is_boolean()); return value.get(); @@ -17168,69 +23058,122 @@ auto ClientCompletionItemOptions::labelDetailsSupport() const auto ClientCompletionItemOptions::snippetSupport( std::optional snippetSupport) -> ClientCompletionItemOptions& { + if (!snippetSupport.has_value()) { + repr_->erase("snippetSupport"); + return *this; + } + repr_->emplace("snippetSupport", std::move(snippetSupport.value())); return *this; } auto ClientCompletionItemOptions::commitCharactersSupport( std::optional commitCharactersSupport) -> ClientCompletionItemOptions& { + if (!commitCharactersSupport.has_value()) { + repr_->erase("commitCharactersSupport"); + return *this; + } + repr_->emplace("commitCharactersSupport", + std::move(commitCharactersSupport.value())); return *this; } auto ClientCompletionItemOptions::documentationFormat( std::optional> documentationFormat) -> ClientCompletionItemOptions& { + if (!documentationFormat.has_value()) { + repr_->erase("documentationFormat"); + return *this; + } + lsp_runtime_error( + "ClientCompletionItemOptions::documentationFormat: not implement yet"); return *this; } auto ClientCompletionItemOptions::deprecatedSupport( std::optional deprecatedSupport) -> ClientCompletionItemOptions& { + if (!deprecatedSupport.has_value()) { + repr_->erase("deprecatedSupport"); + return *this; + } + repr_->emplace("deprecatedSupport", std::move(deprecatedSupport.value())); return *this; } auto ClientCompletionItemOptions::preselectSupport( std::optional preselectSupport) -> ClientCompletionItemOptions& { + if (!preselectSupport.has_value()) { + repr_->erase("preselectSupport"); + return *this; + } + repr_->emplace("preselectSupport", std::move(preselectSupport.value())); return *this; } auto ClientCompletionItemOptions::tagSupport( std::optional tagSupport) -> ClientCompletionItemOptions& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto ClientCompletionItemOptions::insertReplaceSupport( std::optional insertReplaceSupport) -> ClientCompletionItemOptions& { + if (!insertReplaceSupport.has_value()) { + repr_->erase("insertReplaceSupport"); + return *this; + } + repr_->emplace("insertReplaceSupport", + std::move(insertReplaceSupport.value())); return *this; } auto ClientCompletionItemOptions::resolveSupport( std::optional resolveSupport) -> ClientCompletionItemOptions& { + if (!resolveSupport.has_value()) { + repr_->erase("resolveSupport"); + return *this; + } + repr_->emplace("resolveSupport", resolveSupport.value()); return *this; } auto ClientCompletionItemOptions::insertTextModeSupport( std::optional insertTextModeSupport) -> ClientCompletionItemOptions& { + if (!insertTextModeSupport.has_value()) { + repr_->erase("insertTextModeSupport"); + return *this; + } + repr_->emplace("insertTextModeSupport", insertTextModeSupport.value()); return *this; } auto ClientCompletionItemOptions::labelDetailsSupport( std::optional labelDetailsSupport) -> ClientCompletionItemOptions& { + if (!labelDetailsSupport.has_value()) { + repr_->erase("labelDetailsSupport"); + return *this; + } + repr_->emplace("labelDetailsSupport", std::move(labelDetailsSupport.value())); return *this; } ClientCompletionItemOptionsKind::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientCompletionItemOptionsKind::valueSet() const -> std::optional> { - if (!repr_.contains("valueSet")) return std::nullopt; + if (!repr_->contains("valueSet")) return std::nullopt; - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17239,19 +23182,25 @@ auto ClientCompletionItemOptionsKind::valueSet() const auto ClientCompletionItemOptionsKind::valueSet( std::optional> valueSet) -> ClientCompletionItemOptionsKind& { + if (!valueSet.has_value()) { + repr_->erase("valueSet"); + return *this; + } + lsp_runtime_error( + "ClientCompletionItemOptionsKind::valueSet: not implement yet"); return *this; } CompletionListCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto CompletionListCapabilities::itemDefaults() const -> std::optional> { - if (!repr_.contains("itemDefaults")) return std::nullopt; + if (!repr_->contains("itemDefaults")) return std::nullopt; - const auto& value = repr_["itemDefaults"]; + auto& value = (*repr_)["itemDefaults"]; assert(value.is_array()); return Vector(value); @@ -17259,9 +23208,9 @@ auto CompletionListCapabilities::itemDefaults() const auto CompletionListCapabilities::applyKindSupport() const -> std::optional { - if (!repr_.contains("applyKindSupport")) return std::nullopt; + if (!repr_->contains("applyKindSupport")) return std::nullopt; - const auto& value = repr_["applyKindSupport"]; + auto& value = (*repr_)["applyKindSupport"]; assert(value.is_boolean()); return value.get(); @@ -17270,24 +23219,35 @@ auto CompletionListCapabilities::applyKindSupport() const auto CompletionListCapabilities::itemDefaults( std::optional> itemDefaults) -> CompletionListCapabilities& { + if (!itemDefaults.has_value()) { + repr_->erase("itemDefaults"); + return *this; + } + lsp_runtime_error( + "CompletionListCapabilities::itemDefaults: not implement yet"); return *this; } auto CompletionListCapabilities::applyKindSupport( std::optional applyKindSupport) -> CompletionListCapabilities& { + if (!applyKindSupport.has_value()) { + repr_->erase("applyKindSupport"); + return *this; + } + repr_->emplace("applyKindSupport", std::move(applyKindSupport.value())); return *this; } ClientSignatureInformationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientSignatureInformationOptions::documentationFormat() const -> std::optional> { - if (!repr_.contains("documentationFormat")) return std::nullopt; + if (!repr_->contains("documentationFormat")) return std::nullopt; - const auto& value = repr_["documentationFormat"]; + auto& value = (*repr_)["documentationFormat"]; assert(value.is_array()); return Vector(value); @@ -17295,18 +23255,18 @@ auto ClientSignatureInformationOptions::documentationFormat() const auto ClientSignatureInformationOptions::parameterInformation() const -> std::optional { - if (!repr_.contains("parameterInformation")) return std::nullopt; + if (!repr_->contains("parameterInformation")) return std::nullopt; - const auto& value = repr_["parameterInformation"]; + auto& value = (*repr_)["parameterInformation"]; return ClientSignatureParameterInformationOptions(value); } auto ClientSignatureInformationOptions::activeParameterSupport() const -> std::optional { - if (!repr_.contains("activeParameterSupport")) return std::nullopt; + if (!repr_->contains("activeParameterSupport")) return std::nullopt; - const auto& value = repr_["activeParameterSupport"]; + auto& value = (*repr_)["activeParameterSupport"]; assert(value.is_boolean()); return value.get(); @@ -17314,9 +23274,9 @@ auto ClientSignatureInformationOptions::activeParameterSupport() const auto ClientSignatureInformationOptions::noActiveParameterSupport() const -> std::optional { - if (!repr_.contains("noActiveParameterSupport")) return std::nullopt; + if (!repr_->contains("noActiveParameterSupport")) return std::nullopt; - const auto& value = repr_["noActiveParameterSupport"]; + auto& value = (*repr_)["noActiveParameterSupport"]; assert(value.is_boolean()); return value.get(); @@ -17325,36 +23285,60 @@ auto ClientSignatureInformationOptions::noActiveParameterSupport() const auto ClientSignatureInformationOptions::documentationFormat( std::optional> documentationFormat) -> ClientSignatureInformationOptions& { + if (!documentationFormat.has_value()) { + repr_->erase("documentationFormat"); + return *this; + } + lsp_runtime_error( + "ClientSignatureInformationOptions::documentationFormat: not implement " + "yet"); return *this; } auto ClientSignatureInformationOptions::parameterInformation( std::optional parameterInformation) -> ClientSignatureInformationOptions& { + if (!parameterInformation.has_value()) { + repr_->erase("parameterInformation"); + return *this; + } + repr_->emplace("parameterInformation", parameterInformation.value()); return *this; } auto ClientSignatureInformationOptions::activeParameterSupport( std::optional activeParameterSupport) -> ClientSignatureInformationOptions& { + if (!activeParameterSupport.has_value()) { + repr_->erase("activeParameterSupport"); + return *this; + } + repr_->emplace("activeParameterSupport", + std::move(activeParameterSupport.value())); return *this; } auto ClientSignatureInformationOptions::noActiveParameterSupport( std::optional noActiveParameterSupport) -> ClientSignatureInformationOptions& { + if (!noActiveParameterSupport.has_value()) { + repr_->erase("noActiveParameterSupport"); + return *this; + } + repr_->emplace("noActiveParameterSupport", + std::move(noActiveParameterSupport.value())); return *this; } ClientCodeActionLiteralOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("codeActionKind")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("codeActionKind")) return false; return true; } auto ClientCodeActionLiteralOptions::codeActionKind() const -> ClientCodeActionKindOptions { - const auto& value = repr_["codeActionKind"]; + auto& value = (*repr_)["codeActionKind"]; return ClientCodeActionKindOptions(value); } @@ -17362,17 +23346,18 @@ auto ClientCodeActionLiteralOptions::codeActionKind() const auto ClientCodeActionLiteralOptions::codeActionKind( ClientCodeActionKindOptions codeActionKind) -> ClientCodeActionLiteralOptions& { + repr_->emplace("codeActionKind", codeActionKind); return *this; } ClientCodeActionResolveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("properties")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("properties")) return false; return true; } auto ClientCodeActionResolveOptions::properties() const -> Vector { - const auto& value = repr_["properties"]; + auto& value = (*repr_)["properties"]; assert(value.is_array()); return Vector(value); @@ -17380,17 +23365,19 @@ auto ClientCodeActionResolveOptions::properties() const -> Vector { auto ClientCodeActionResolveOptions::properties(Vector properties) -> ClientCodeActionResolveOptions& { + lsp_runtime_error( + "ClientCodeActionResolveOptions::properties: not implement yet"); return *this; } CodeActionTagOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto CodeActionTagOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17398,17 +23385,18 @@ auto CodeActionTagOptions::valueSet() const -> Vector { auto CodeActionTagOptions::valueSet(Vector valueSet) -> CodeActionTagOptions& { + lsp_runtime_error("CodeActionTagOptions::valueSet: not implement yet"); return *this; } ClientCodeLensResolveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("properties")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("properties")) return false; return true; } auto ClientCodeLensResolveOptions::properties() const -> Vector { - const auto& value = repr_["properties"]; + auto& value = (*repr_)["properties"]; assert(value.is_array()); return Vector(value); @@ -17416,19 +23404,21 @@ auto ClientCodeLensResolveOptions::properties() const -> Vector { auto ClientCodeLensResolveOptions::properties(Vector properties) -> ClientCodeLensResolveOptions& { + lsp_runtime_error( + "ClientCodeLensResolveOptions::properties: not implement yet"); return *this; } ClientFoldingRangeKindOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientFoldingRangeKindOptions::valueSet() const -> std::optional> { - if (!repr_.contains("valueSet")) return std::nullopt; + if (!repr_->contains("valueSet")) return std::nullopt; - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17437,18 +23427,24 @@ auto ClientFoldingRangeKindOptions::valueSet() const auto ClientFoldingRangeKindOptions::valueSet( std::optional> valueSet) -> ClientFoldingRangeKindOptions& { + if (!valueSet.has_value()) { + repr_->erase("valueSet"); + return *this; + } + lsp_runtime_error( + "ClientFoldingRangeKindOptions::valueSet: not implement yet"); return *this; } ClientFoldingRangeOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientFoldingRangeOptions::collapsedText() const -> std::optional { - if (!repr_.contains("collapsedText")) return std::nullopt; + if (!repr_->contains("collapsedText")) return std::nullopt; - const auto& value = repr_["collapsedText"]; + auto& value = (*repr_)["collapsedText"]; assert(value.is_boolean()); return value.get(); @@ -17456,19 +23452,24 @@ auto ClientFoldingRangeOptions::collapsedText() const -> std::optional { auto ClientFoldingRangeOptions::collapsedText(std::optional collapsedText) -> ClientFoldingRangeOptions& { + if (!collapsedText.has_value()) { + repr_->erase("collapsedText"); + return *this; + } + repr_->emplace("collapsedText", std::move(collapsedText.value())); return *this; } DiagnosticsCapabilities::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto DiagnosticsCapabilities::relatedInformation() const -> std::optional { - if (!repr_.contains("relatedInformation")) return std::nullopt; + if (!repr_->contains("relatedInformation")) return std::nullopt; - const auto& value = repr_["relatedInformation"]; + auto& value = (*repr_)["relatedInformation"]; assert(value.is_boolean()); return value.get(); @@ -17476,27 +23477,27 @@ auto DiagnosticsCapabilities::relatedInformation() const auto DiagnosticsCapabilities::tagSupport() const -> std::optional { - if (!repr_.contains("tagSupport")) return std::nullopt; + if (!repr_->contains("tagSupport")) return std::nullopt; - const auto& value = repr_["tagSupport"]; + auto& value = (*repr_)["tagSupport"]; return ClientDiagnosticsTagOptions(value); } auto DiagnosticsCapabilities::codeDescriptionSupport() const -> std::optional { - if (!repr_.contains("codeDescriptionSupport")) return std::nullopt; + if (!repr_->contains("codeDescriptionSupport")) return std::nullopt; - const auto& value = repr_["codeDescriptionSupport"]; + auto& value = (*repr_)["codeDescriptionSupport"]; assert(value.is_boolean()); return value.get(); } auto DiagnosticsCapabilities::dataSupport() const -> std::optional { - if (!repr_.contains("dataSupport")) return std::nullopt; + if (!repr_->contains("dataSupport")) return std::nullopt; - const auto& value = repr_["dataSupport"]; + auto& value = (*repr_)["dataSupport"]; assert(value.is_boolean()); return value.get(); @@ -17504,35 +23505,56 @@ auto DiagnosticsCapabilities::dataSupport() const -> std::optional { auto DiagnosticsCapabilities::relatedInformation( std::optional relatedInformation) -> DiagnosticsCapabilities& { + if (!relatedInformation.has_value()) { + repr_->erase("relatedInformation"); + return *this; + } + repr_->emplace("relatedInformation", std::move(relatedInformation.value())); return *this; } auto DiagnosticsCapabilities::tagSupport( std::optional tagSupport) -> DiagnosticsCapabilities& { + if (!tagSupport.has_value()) { + repr_->erase("tagSupport"); + return *this; + } + repr_->emplace("tagSupport", tagSupport.value()); return *this; } auto DiagnosticsCapabilities::codeDescriptionSupport( std::optional codeDescriptionSupport) -> DiagnosticsCapabilities& { + if (!codeDescriptionSupport.has_value()) { + repr_->erase("codeDescriptionSupport"); + return *this; + } + repr_->emplace("codeDescriptionSupport", + std::move(codeDescriptionSupport.value())); return *this; } auto DiagnosticsCapabilities::dataSupport(std::optional dataSupport) -> DiagnosticsCapabilities& { + if (!dataSupport.has_value()) { + repr_->erase("dataSupport"); + return *this; + } + repr_->emplace("dataSupport", std::move(dataSupport.value())); return *this; } ClientSemanticTokensRequestOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientSemanticTokensRequestOptions::range() const -> std::optional> { - if (!repr_.contains("range")) return std::nullopt; + if (!repr_->contains("range")) return std::nullopt; - const auto& value = repr_["range"]; + auto& value = (*repr_)["range"]; std::variant result; @@ -17543,9 +23565,9 @@ auto ClientSemanticTokensRequestOptions::range() const auto ClientSemanticTokensRequestOptions::full() const -> std::optional< std::variant> { - if (!repr_.contains("full")) return std::nullopt; + if (!repr_->contains("full")) return std::nullopt; - const auto& value = repr_["full"]; + auto& value = (*repr_)["full"]; std::variant result; @@ -17558,6 +23580,30 @@ auto ClientSemanticTokensRequestOptions::full() const -> std::optional< auto ClientSemanticTokensRequestOptions::range( std::optional> range) -> ClientSemanticTokensRequestOptions& { + if (!range.has_value()) { + repr_->erase("range"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool range) { repr_->emplace("range", std::move(range)); } + + void operator()(json range) { + lsp_runtime_error( + "ClientSemanticTokensRequestOptions::range: not implement yet"); + } + } v{repr_}; + + std::visit(v, range.value()); + return *this; } @@ -17565,17 +23611,40 @@ auto ClientSemanticTokensRequestOptions::full( std::optional> full) -> ClientSemanticTokensRequestOptions& { + if (!full.has_value()) { + repr_->erase("full"); + return *this; + } + + // or type + + struct { + json* repr_; + + void operator()(std::monostate) { + lsp_runtime_error("monostate is not a valid a property value"); + } + + void operator()(bool full) { repr_->emplace("full", std::move(full)); } + + void operator()(ClientSemanticTokensRequestFullDelta full) { + repr_->emplace("full", full); + } + } v{repr_}; + + std::visit(v, full.value()); + return *this; } ClientInlayHintResolveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("properties")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("properties")) return false; return true; } auto ClientInlayHintResolveOptions::properties() const -> Vector { - const auto& value = repr_["properties"]; + auto& value = (*repr_)["properties"]; assert(value.is_array()); return Vector(value); @@ -17583,19 +23652,21 @@ auto ClientInlayHintResolveOptions::properties() const -> Vector { auto ClientInlayHintResolveOptions::properties(Vector properties) -> ClientInlayHintResolveOptions& { + lsp_runtime_error( + "ClientInlayHintResolveOptions::properties: not implement yet"); return *this; } ClientShowMessageActionItemOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientShowMessageActionItemOptions::additionalPropertiesSupport() const -> std::optional { - if (!repr_.contains("additionalPropertiesSupport")) return std::nullopt; + if (!repr_->contains("additionalPropertiesSupport")) return std::nullopt; - const auto& value = repr_["additionalPropertiesSupport"]; + auto& value = (*repr_)["additionalPropertiesSupport"]; assert(value.is_boolean()); return value.get(); @@ -17604,17 +23675,23 @@ auto ClientShowMessageActionItemOptions::additionalPropertiesSupport() const auto ClientShowMessageActionItemOptions::additionalPropertiesSupport( std::optional additionalPropertiesSupport) -> ClientShowMessageActionItemOptions& { + if (!additionalPropertiesSupport.has_value()) { + repr_->erase("additionalPropertiesSupport"); + return *this; + } + repr_->emplace("additionalPropertiesSupport", + std::move(additionalPropertiesSupport.value())); return *this; } CompletionItemTagOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto CompletionItemTagOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17622,18 +23699,19 @@ auto CompletionItemTagOptions::valueSet() const -> Vector { auto CompletionItemTagOptions::valueSet(Vector valueSet) -> CompletionItemTagOptions& { + lsp_runtime_error("CompletionItemTagOptions::valueSet: not implement yet"); return *this; } ClientCompletionItemResolveOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("properties")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("properties")) return false; return true; } auto ClientCompletionItemResolveOptions::properties() const -> Vector { - const auto& value = repr_["properties"]; + auto& value = (*repr_)["properties"]; assert(value.is_array()); return Vector(value); @@ -17641,18 +23719,20 @@ auto ClientCompletionItemResolveOptions::properties() const auto ClientCompletionItemResolveOptions::properties( Vector properties) -> ClientCompletionItemResolveOptions& { + lsp_runtime_error( + "ClientCompletionItemResolveOptions::properties: not implement yet"); return *this; } ClientCompletionItemInsertTextModeOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto ClientCompletionItemInsertTextModeOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17661,19 +23741,21 @@ auto ClientCompletionItemInsertTextModeOptions::valueSet() const auto ClientCompletionItemInsertTextModeOptions::valueSet( Vector valueSet) -> ClientCompletionItemInsertTextModeOptions& { + lsp_runtime_error( + "ClientCompletionItemInsertTextModeOptions::valueSet: not implement yet"); return *this; } ClientSignatureParameterInformationOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientSignatureParameterInformationOptions::labelOffsetSupport() const -> std::optional { - if (!repr_.contains("labelOffsetSupport")) return std::nullopt; + if (!repr_->contains("labelOffsetSupport")) return std::nullopt; - const auto& value = repr_["labelOffsetSupport"]; + auto& value = (*repr_)["labelOffsetSupport"]; assert(value.is_boolean()); return value.get(); @@ -17682,17 +23764,22 @@ auto ClientSignatureParameterInformationOptions::labelOffsetSupport() const auto ClientSignatureParameterInformationOptions::labelOffsetSupport( std::optional labelOffsetSupport) -> ClientSignatureParameterInformationOptions& { + if (!labelOffsetSupport.has_value()) { + repr_->erase("labelOffsetSupport"); + return *this; + } + repr_->emplace("labelOffsetSupport", std::move(labelOffsetSupport.value())); return *this; } ClientCodeActionKindOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto ClientCodeActionKindOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17700,17 +23787,18 @@ auto ClientCodeActionKindOptions::valueSet() const -> Vector { auto ClientCodeActionKindOptions::valueSet(Vector valueSet) -> ClientCodeActionKindOptions& { + lsp_runtime_error("ClientCodeActionKindOptions::valueSet: not implement yet"); return *this; } ClientDiagnosticsTagOptions::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; - if (!repr_.contains("valueSet")) return false; + if (!repr_->is_object() || repr_->is_null()) return false; + if (!repr_->contains("valueSet")) return false; return true; } auto ClientDiagnosticsTagOptions::valueSet() const -> Vector { - const auto& value = repr_["valueSet"]; + auto& value = (*repr_)["valueSet"]; assert(value.is_array()); return Vector(value); @@ -17718,19 +23806,20 @@ auto ClientDiagnosticsTagOptions::valueSet() const -> Vector { auto ClientDiagnosticsTagOptions::valueSet(Vector valueSet) -> ClientDiagnosticsTagOptions& { + lsp_runtime_error("ClientDiagnosticsTagOptions::valueSet: not implement yet"); return *this; } ClientSemanticTokensRequestFullDelta::operator bool() const { - if (!repr_.is_object() || repr_.is_null()) return false; + if (!repr_->is_object() || repr_->is_null()) return false; return true; } auto ClientSemanticTokensRequestFullDelta::delta() const -> std::optional { - if (!repr_.contains("delta")) return std::nullopt; + if (!repr_->contains("delta")) return std::nullopt; - const auto& value = repr_["delta"]; + auto& value = (*repr_)["delta"]; assert(value.is_boolean()); return value.get(); @@ -17738,6 +23827,11 @@ auto ClientSemanticTokensRequestFullDelta::delta() const auto ClientSemanticTokensRequestFullDelta::delta(std::optional delta) -> ClientSemanticTokensRequestFullDelta& { + if (!delta.has_value()) { + repr_->erase("delta"); + return *this; + } + repr_->emplace("delta", std::move(delta.value())); return *this; } } // namespace cxx::lsp diff --git a/src/lsp/tests/CMakeLists.txt b/src/lsp/tests/CMakeLists.txt new file mode 100644 index 00000000..29bf38e1 --- /dev/null +++ b/src/lsp/tests/CMakeLists.txt @@ -0,0 +1,12 @@ +if (NOT CXX_BUILD_TESTS) + return() +endif() + +aux_source_directory(. SOURCES) +add_executable(test_lsp ${SOURCES}) + +target_link_libraries(test_lsp + GTest::gtest_main + cxx-lsp) + +gtest_discover_tests(test_lsp) diff --git a/src/lsp/tests/test_types.cc b/src/lsp/tests/test_types.cc new file mode 100644 index 00000000..e65f0ec3 --- /dev/null +++ b/src/lsp/tests/test_types.cc @@ -0,0 +1,43 @@ +#include +#include + +#include "cxx/lsp/enums.h" +#include "cxx/lsp/fwd.h" + +TEST(SampleTest, AssertionTrue) { + using namespace cxx::lsp; + + // storage + auto store1 = json::object(); + auto store2 = json::object(); + auto store3 = json::object(); + + InitializeResult initializeResult{store1}; + ASSERT_TRUE(!initializeResult); + + auto serverInfo = ServerInfo{store2}.name("cxx").version("0.1.0"); + ASSERT_EQ(serverInfo.name(), "cxx"); + ASSERT_EQ(serverInfo.version(), "0.1.0"); + ASSERT_TRUE(serverInfo); + + auto capabilities = ServerCapabilities{store3}.textDocumentSync( + TextDocumentSyncKind::kIncremental); + + ASSERT_TRUE(capabilities); + + ASSERT_TRUE(capabilities.textDocumentSync().has_value()); + + ASSERT_TRUE(std::holds_alternative( + *capabilities.textDocumentSync())); + + ASSERT_EQ(std::get(*capabilities.textDocumentSync()), + TextDocumentSyncKind::kIncremental); + + initializeResult.serverInfo(std::move(serverInfo)); + ASSERT_TRUE(initializeResult.serverInfo()); + + initializeResult.capabilities(std::move(capabilities)); + ASSERT_TRUE(initializeResult.capabilities()); + + ASSERT_TRUE(initializeResult); +}