diff --git a/packages/cxx-gen-lsp/src/MetaModel.ts b/packages/cxx-gen-lsp/src/MetaModel.ts index d8bb8730..e6954d50 100644 --- a/packages/cxx-gen-lsp/src/MetaModel.ts +++ b/packages/cxx-gen-lsp/src/MetaModel.ts @@ -199,7 +199,7 @@ export function toCppType(type: Type): string { return `std::tuple<${type.items.map(toCppType).join(", ")}>`; case "or": - return `std::variant`; + return `std::variant<${type.items.map(toCppType).join(", ")}>`; case "and": return `std::tuple<${type.items.map(toCppType).join(", ")}>`; diff --git a/packages/cxx-gen-lsp/src/gen_fwd_h.ts b/packages/cxx-gen-lsp/src/gen_fwd_h.ts index d63c6b42..0a744323 100644 --- a/packages/cxx-gen-lsp/src/gen_fwd_h.ts +++ b/packages/cxx-gen-lsp/src/gen_fwd_h.ts @@ -31,8 +31,10 @@ using Pattern = std::string; class LSPObject { public: + LSPObject() = default; explicit LSPObject(json& repr): repr_(&repr) {} + [[nodiscard]] explicit operator bool() const { return repr_ != nullptr; } [[nodiscard]] operator const json&() const { return *repr_; } [[nodiscard]] auto get() const -> json& { return *repr_; } @@ -45,7 +47,7 @@ class Vector final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] explicit operator bool() const { return repr_ && 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); } @@ -71,11 +73,6 @@ auto try_emplace(std::variant& result, json& value) -> bool { return (details::TryEmplace{}(result, value) || ...); } -template <> -struct TryEmplace { - auto operator()(auto&, const json&) const -> bool { return false; } -}; - template <> struct TryEmplace { auto operator()(auto& result, json& value) const -> bool { @@ -169,7 +166,7 @@ class Vector> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] explicit operator bool() const { return repr_ && 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 { @@ -184,7 +181,7 @@ class Map final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] explicit operator bool() const { return repr_ && 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); } @@ -195,7 +192,7 @@ class Map> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] explicit operator bool() const { return repr_ && repr_->is_object(); } [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } diff --git a/packages/cxx-gen-lsp/src/gen_types_cc.ts b/packages/cxx-gen-lsp/src/gen_types_cc.ts index 1edd7812..83bbdebc 100644 --- a/packages/cxx-gen-lsp/src/gen_types_cc.ts +++ b/packages/cxx-gen-lsp/src/gen_types_cc.ts @@ -188,16 +188,17 @@ class TypeGenerator { } case "array": - this.emit(`assert(value.is_array());`); + this.emit(`if (value.is_null()) value = json::array();`); this.emit(`return ${propertyType}(value);`); return; case "map": - this.emit(`assert(value.is_object());`); + this.emit(`if (value.is_null()) value = json::object();`); this.emit(`return ${propertyType}(value);`); return; case "stringLiteral": + this.emit(`if (value.is_null()) value = "${property.type.value}";`); this.emit(`assert(value.is_string());`); this.emit(`return value.get();`); return; @@ -222,36 +223,43 @@ class TypeGenerator { throw new Error(`Unexpected null type`); case "string": + this.emit(`if (value.is_null()) value = "";`); this.emit(`assert(value.is_string());`); this.emit(`return value.get();`); return true; case "integer": + this.emit(`if (value.is_null()) value = 0;`); this.emit(`assert(value.is_number_integer());`); this.emit(`return value.get();`); return true; case "uinteger": + this.emit(`if (value.is_null()) value = 0;`); this.emit(`assert(value.is_number_integer());`); this.emit(`return value.get();`); return true; case "decimal": + this.emit(`if (value.is_null()) value = 0.0;`); this.emit(`assert(value.is_number());`); this.emit(`return value.get();`); return true; case "boolean": + this.emit(`if (value.is_null()) value = false;`); this.emit(`assert(value.is_boolean());`); this.emit(`return value.get();`); return true; case "DocumentUri": + this.emit(`if (value.is_null()) value = "";`); this.emit(`assert(value.is_string());`); this.emit(`return value.get();`); return true; case "URI": + this.emit(`if (value.is_null()) value = "";`); this.emit(`assert(value.is_string());`); this.emit(`return value.get();`); return true; @@ -347,7 +355,7 @@ class TypeGenerator { switch (property.type.kind) { case "base": - this.emit(`repr_->emplace("${property.name}", std::move(${value}));`); + this.emit(`(*repr_)["${property.name}"] = std::move(${value});`); return; case "reference": @@ -380,7 +388,7 @@ class TypeGenerator { if (enumeration.type.name !== "string") { const enumBaseType = toCppType(enumeration.type); - this.emit(`repr_->emplace("${property.name}", static_cast<${enumBaseType}>(${value}));`); + this.emit(`(*repr_)["${property.name}"] = static_cast<${enumBaseType}>(${value});`); return true; } @@ -389,7 +397,7 @@ class TypeGenerator { } if (this.structByName.has(property.type.name)) { - this.emit(`repr_->emplace("${property.name}", ${value});`); + this.emit(`(*repr_)["${property.name}"] = ${value};`); return true; } @@ -407,15 +415,9 @@ class TypeGenerator { }): 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 }); diff --git a/src/lsp/cxx/lsp/fwd.h b/src/lsp/cxx/lsp/fwd.h index ab31c7af..62b047a8 100644 --- a/src/lsp/cxx/lsp/fwd.h +++ b/src/lsp/cxx/lsp/fwd.h @@ -463,8 +463,10 @@ using Pattern = std::string; class LSPObject { public: + LSPObject() = default; explicit LSPObject(json& repr) : repr_(&repr) {} + [[nodiscard]] explicit operator bool() const { return repr_ != nullptr; } [[nodiscard]] operator const json&() const { return *repr_; } [[nodiscard]] auto get() const -> json& { return *repr_; } @@ -477,7 +479,9 @@ class Vector final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] explicit operator bool() const { + return repr_ && 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& { @@ -505,11 +509,6 @@ auto try_emplace(std::variant& result, json& value) -> bool { return (details::TryEmplace{}(result, value) || ...); } -template <> -struct TryEmplace { - auto operator()(auto&, const json&) const -> bool { return false; } -}; - template <> struct TryEmplace { auto operator()(auto& result, json& value) const -> bool { @@ -603,7 +602,9 @@ class Vector> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_array(); } + [[nodiscard]] explicit operator bool() const { + return repr_ && 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 { @@ -618,7 +619,9 @@ class Map final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] explicit operator bool() const { + return repr_ && 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& { @@ -631,7 +634,9 @@ class Map> final : public LSPObject { public: using LSPObject::LSPObject; - [[nodiscard]] explicit operator bool() const { return repr_->is_object(); } + [[nodiscard]] explicit operator bool() const { + return repr_ && repr_->is_object(); + } [[nodiscard]] auto size() const -> std::size_t { return repr_->size(); } [[nodiscard]] auto empty() const -> bool { return repr_->empty(); } @@ -645,53 +650,50 @@ class Map> final : public LSPObject { using RegularExpressionEngineKind = std::string; using NotebookDocumentFilter = - std::variant; using TextDocumentFilter = - std::variant; + std::variant; -using GlobPattern = std::variant; +using GlobPattern = std::variant; -using DocumentFilter = std::variant; +using DocumentFilter = + std::variant; -using MarkedString = - std::variant; +using MarkedString = std::variant; using TextDocumentContentChangeEvent = - std::variant; using WorkspaceDocumentDiagnosticReport = - std::variant; using ChangeAnnotationIdentifier = std::string; -using ProgressToken = std::variant; +using ProgressToken = std::variant; using DocumentSelector = Vector; using PrepareRenameResult = - std::variant; + std::variant; using DocumentDiagnosticReport = - std::variant; -using InlineValue = - std::variant; +using InlineValue = std::variant; using DeclarationLink = LocationLink; -using Declaration = std::variant>; +using Declaration = std::variant>; using DefinitionLink = LocationLink; -using Definition = std::variant>; +using Definition = std::variant>; } // namespace cxx::lsp diff --git a/src/lsp/cxx/lsp/types.cc b/src/lsp/cxx/lsp/types.cc index fae76a2b..09ae6c39 100644 --- a/src/lsp/cxx/lsp/types.cc +++ b/src/lsp/cxx/lsp/types.cc @@ -69,13 +69,13 @@ auto ImplementationParams::partialResultToken() const auto ImplementationParams::textDocument(TextDocumentIdentifier textDocument) -> ImplementationParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto ImplementationParams::position(Position position) -> ImplementationParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -110,6 +110,7 @@ Location::operator bool() const { auto Location::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -121,12 +122,12 @@ auto Location::range() const -> Range { } auto Location::uri(std::string uri) -> Location& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto Location::range(Range range) -> Location& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -137,10 +138,10 @@ ImplementationRegistrationOptions::operator bool() const { } auto ImplementationRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -153,6 +154,7 @@ auto ImplementationRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -163,22 +165,17 @@ auto ImplementationRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ImplementationRegistrationOptions::documentSelector( - std::variant - documentSelector) -> ImplementationRegistrationOptions& { - // or type - + std::variant documentSelector) + -> ImplementationRegistrationOptions& { 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 " @@ -186,7 +183,7 @@ auto ImplementationRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -202,7 +199,7 @@ auto ImplementationRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -212,7 +209,7 @@ auto ImplementationRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -263,13 +260,13 @@ auto TypeDefinitionParams::partialResultToken() const auto TypeDefinitionParams::textDocument(TextDocumentIdentifier textDocument) -> TypeDefinitionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto TypeDefinitionParams::position(Position position) -> TypeDefinitionParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -301,10 +298,10 @@ TypeDefinitionRegistrationOptions::operator bool() const { } auto TypeDefinitionRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -317,6 +314,7 @@ auto TypeDefinitionRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -327,22 +325,17 @@ auto TypeDefinitionRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TypeDefinitionRegistrationOptions::documentSelector( - std::variant - documentSelector) -> TypeDefinitionRegistrationOptions& { - // or type - + std::variant documentSelector) + -> TypeDefinitionRegistrationOptions& { 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 " @@ -350,7 +343,7 @@ auto TypeDefinitionRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -366,7 +359,7 @@ auto TypeDefinitionRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -376,7 +369,7 @@ auto TypeDefinitionRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -390,6 +383,7 @@ WorkspaceFolder::operator bool() const { auto WorkspaceFolder::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -397,17 +391,18 @@ auto WorkspaceFolder::uri() const -> std::string { auto WorkspaceFolder::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto WorkspaceFolder::uri(std::string uri) -> WorkspaceFolder& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto WorkspaceFolder::name(std::string name) -> WorkspaceFolder& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } @@ -426,7 +421,7 @@ auto DidChangeWorkspaceFoldersParams::event() const auto DidChangeWorkspaceFoldersParams::event(WorkspaceFoldersChangeEvent event) -> DidChangeWorkspaceFoldersParams& { - repr_->emplace("event", event); + (*repr_)["event"] = event; return *this; } @@ -439,7 +434,7 @@ ConfigurationParams::operator bool() const { auto ConfigurationParams::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -489,7 +484,7 @@ auto DocumentColorParams::partialResultToken() const auto DocumentColorParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentColorParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -534,12 +529,12 @@ auto ColorInformation::color() const -> Color { } auto ColorInformation::range(Range range) -> ColorInformation& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto ColorInformation::color(Color color) -> ColorInformation& { - repr_->emplace("color", color); + (*repr_)["color"] = color; return *this; } @@ -550,10 +545,10 @@ DocumentColorRegistrationOptions::operator bool() const { } auto DocumentColorRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -566,6 +561,7 @@ auto DocumentColorRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -576,22 +572,17 @@ auto DocumentColorRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto DocumentColorRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentColorRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentColorRegistrationOptions& { 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 " @@ -599,7 +590,7 @@ auto DocumentColorRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -614,7 +605,7 @@ auto DocumentColorRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -624,7 +615,7 @@ auto DocumentColorRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -682,17 +673,17 @@ auto ColorPresentationParams::partialResultToken() const auto ColorPresentationParams::textDocument(TextDocumentIdentifier textDocument) -> ColorPresentationParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto ColorPresentationParams::color(Color color) -> ColorPresentationParams& { - repr_->emplace("color", color); + (*repr_)["color"] = color; return *this; } auto ColorPresentationParams::range(Range range) -> ColorPresentationParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -728,6 +719,7 @@ ColorPresentation::operator bool() const { auto ColorPresentation::label() const -> std::string { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -746,12 +738,12 @@ auto ColorPresentation::additionalTextEdits() const auto& value = (*repr_)["additionalTextEdits"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto ColorPresentation::label(std::string label) -> ColorPresentation& { - repr_->emplace("label", std::move(label)); + (*repr_)["label"] = std::move(label); return *this; } @@ -761,7 +753,7 @@ auto ColorPresentation::textEdit(std::optional textEdit) repr_->erase("textEdit"); return *this; } - repr_->emplace("textEdit", textEdit.value()); + (*repr_)["textEdit"] = textEdit.value(); return *this; } @@ -786,6 +778,7 @@ auto WorkDoneProgressOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -796,7 +789,7 @@ auto WorkDoneProgressOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -807,10 +800,10 @@ TextDocumentRegistrationOptions::operator bool() const { } auto TextDocumentRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -818,17 +811,11 @@ auto TextDocumentRegistrationOptions::documentSelector() const } auto TextDocumentRegistrationOptions::documentSelector( - std::variant - documentSelector) -> TextDocumentRegistrationOptions& { - // or type - + std::variant documentSelector) + -> TextDocumentRegistrationOptions& { 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 " @@ -836,7 +823,7 @@ auto TextDocumentRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -884,7 +871,7 @@ auto FoldingRangeParams::partialResultToken() const auto FoldingRangeParams::textDocument(TextDocumentIdentifier textDocument) -> FoldingRangeParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -919,6 +906,7 @@ FoldingRange::operator bool() const { auto FoldingRange::startLine() const -> long { auto& value = (*repr_)["startLine"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -928,6 +916,7 @@ auto FoldingRange::startCharacter() const -> std::optional { auto& value = (*repr_)["startCharacter"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -935,6 +924,7 @@ auto FoldingRange::startCharacter() const -> std::optional { auto FoldingRange::endLine() const -> long { auto& value = (*repr_)["endLine"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -944,6 +934,7 @@ auto FoldingRange::endCharacter() const -> std::optional { auto& value = (*repr_)["endCharacter"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -961,12 +952,13 @@ auto FoldingRange::collapsedText() const -> std::optional { auto& value = (*repr_)["collapsedText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto FoldingRange::startLine(long startLine) -> FoldingRange& { - repr_->emplace("startLine", std::move(startLine)); + (*repr_)["startLine"] = std::move(startLine); return *this; } @@ -976,12 +968,12 @@ auto FoldingRange::startCharacter(std::optional startCharacter) repr_->erase("startCharacter"); return *this; } - repr_->emplace("startCharacter", std::move(startCharacter.value())); + (*repr_)["startCharacter"] = std::move(startCharacter.value()); return *this; } auto FoldingRange::endLine(long endLine) -> FoldingRange& { - repr_->emplace("endLine", std::move(endLine)); + (*repr_)["endLine"] = std::move(endLine); return *this; } @@ -991,7 +983,7 @@ auto FoldingRange::endCharacter(std::optional endCharacter) repr_->erase("endCharacter"); return *this; } - repr_->emplace("endCharacter", std::move(endCharacter.value())); + (*repr_)["endCharacter"] = std::move(endCharacter.value()); return *this; } @@ -1010,7 +1002,7 @@ auto FoldingRange::collapsedText(std::optional collapsedText) repr_->erase("collapsedText"); return *this; } - repr_->emplace("collapsedText", std::move(collapsedText.value())); + (*repr_)["collapsedText"] = std::move(collapsedText.value()); return *this; } @@ -1021,10 +1013,10 @@ FoldingRangeRegistrationOptions::operator bool() const { } auto FoldingRangeRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -1037,6 +1029,7 @@ auto FoldingRangeRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -1046,22 +1039,17 @@ auto FoldingRangeRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto FoldingRangeRegistrationOptions::documentSelector( - std::variant - documentSelector) -> FoldingRangeRegistrationOptions& { - // or type - + std::variant documentSelector) + -> FoldingRangeRegistrationOptions& { 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 " @@ -1069,7 +1057,7 @@ auto FoldingRangeRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -1084,7 +1072,7 @@ auto FoldingRangeRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -1094,7 +1082,7 @@ auto FoldingRangeRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -1144,12 +1132,12 @@ auto DeclarationParams::partialResultToken() const auto DeclarationParams::textDocument(TextDocumentIdentifier textDocument) -> DeclarationParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DeclarationParams::position(Position position) -> DeclarationParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -1185,15 +1173,16 @@ auto DeclarationRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DeclarationRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -1205,6 +1194,7 @@ auto DeclarationRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -1215,22 +1205,16 @@ auto DeclarationRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } auto DeclarationRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DeclarationRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DeclarationRegistrationOptions& { 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 " @@ -1238,7 +1222,7 @@ auto DeclarationRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -1253,7 +1237,7 @@ auto DeclarationRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -1273,7 +1257,7 @@ auto SelectionRangeParams::textDocument() const -> TextDocumentIdentifier { auto SelectionRangeParams::positions() const -> Vector { auto& value = (*repr_)["positions"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -1305,7 +1289,7 @@ auto SelectionRangeParams::partialResultToken() const auto SelectionRangeParams::textDocument(TextDocumentIdentifier textDocument) -> SelectionRangeParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -1357,7 +1341,7 @@ auto SelectionRange::parent() const -> std::optional { } auto SelectionRange::range(Range range) -> SelectionRange& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -1367,7 +1351,7 @@ auto SelectionRange::parent(std::optional parent) repr_->erase("parent"); return *this; } - repr_->emplace("parent", parent.value()); + (*repr_)["parent"] = parent.value(); return *this; } @@ -1383,15 +1367,16 @@ auto SelectionRangeRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto SelectionRangeRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -1404,6 +1389,7 @@ auto SelectionRangeRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -1415,22 +1401,16 @@ auto SelectionRangeRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } auto SelectionRangeRegistrationOptions::documentSelector( - std::variant - documentSelector) -> SelectionRangeRegistrationOptions& { - // or type - + std::variant documentSelector) + -> SelectionRangeRegistrationOptions& { 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 " @@ -1438,7 +1418,7 @@ auto SelectionRangeRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -1453,7 +1433,7 @@ auto SelectionRangeRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -1536,13 +1516,13 @@ auto CallHierarchyPrepareParams::workDoneToken() const auto CallHierarchyPrepareParams::textDocument( TextDocumentIdentifier textDocument) -> CallHierarchyPrepareParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto CallHierarchyPrepareParams::position(Position position) -> CallHierarchyPrepareParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -1570,6 +1550,7 @@ CallHierarchyItem::operator bool() const { auto CallHierarchyItem::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -1585,7 +1566,7 @@ auto CallHierarchyItem::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -1594,6 +1575,7 @@ auto CallHierarchyItem::detail() const -> std::optional { auto& value = (*repr_)["detail"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -1601,6 +1583,7 @@ auto CallHierarchyItem::detail() const -> std::optional { auto CallHierarchyItem::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -1627,12 +1610,12 @@ auto CallHierarchyItem::data() const -> std::optional { } auto CallHierarchyItem::name(std::string name) -> CallHierarchyItem& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } auto CallHierarchyItem::kind(SymbolKind kind) -> CallHierarchyItem& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -1652,23 +1635,23 @@ auto CallHierarchyItem::detail(std::optional detail) repr_->erase("detail"); return *this; } - repr_->emplace("detail", std::move(detail.value())); + (*repr_)["detail"] = std::move(detail.value()); return *this; } auto CallHierarchyItem::uri(std::string uri) -> CallHierarchyItem& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto CallHierarchyItem::range(Range range) -> CallHierarchyItem& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto CallHierarchyItem::selectionRange(Range selectionRange) -> CallHierarchyItem& { - repr_->emplace("selectionRange", selectionRange); + (*repr_)["selectionRange"] = selectionRange; return *this; } @@ -1688,10 +1671,10 @@ CallHierarchyRegistrationOptions::operator bool() const { } auto CallHierarchyRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -1704,6 +1687,7 @@ auto CallHierarchyRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -1714,22 +1698,17 @@ auto CallHierarchyRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto CallHierarchyRegistrationOptions::documentSelector( - std::variant - documentSelector) -> CallHierarchyRegistrationOptions& { - // or type - + std::variant documentSelector) + -> CallHierarchyRegistrationOptions& { 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 " @@ -1737,7 +1716,7 @@ auto CallHierarchyRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -1752,7 +1731,7 @@ auto CallHierarchyRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -1762,7 +1741,7 @@ auto CallHierarchyRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -1806,7 +1785,7 @@ auto CallHierarchyIncomingCallsParams::partialResultToken() const auto CallHierarchyIncomingCallsParams::item(CallHierarchyItem item) -> CallHierarchyIncomingCallsParams& { - repr_->emplace("item", item); + (*repr_)["item"] = item; return *this; } @@ -1851,13 +1830,13 @@ auto CallHierarchyIncomingCall::from() const -> CallHierarchyItem { auto CallHierarchyIncomingCall::fromRanges() const -> Vector { auto& value = (*repr_)["fromRanges"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto CallHierarchyIncomingCall::from(CallHierarchyItem from) -> CallHierarchyIncomingCall& { - repr_->emplace("from", from); + (*repr_)["from"] = from; return *this; } @@ -1907,7 +1886,7 @@ auto CallHierarchyOutgoingCallsParams::partialResultToken() const auto CallHierarchyOutgoingCallsParams::item(CallHierarchyItem item) -> CallHierarchyOutgoingCallsParams& { - repr_->emplace("item", item); + (*repr_)["item"] = item; return *this; } @@ -1952,13 +1931,13 @@ auto CallHierarchyOutgoingCall::to() const -> CallHierarchyItem { auto CallHierarchyOutgoingCall::fromRanges() const -> Vector { auto& value = (*repr_)["fromRanges"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto CallHierarchyOutgoingCall::to(CallHierarchyItem to) -> CallHierarchyOutgoingCall& { - repr_->emplace("to", to); + (*repr_)["to"] = to; return *this; } @@ -2008,7 +1987,7 @@ auto SemanticTokensParams::partialResultToken() const auto SemanticTokensParams::textDocument(TextDocumentIdentifier textDocument) -> SemanticTokensParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -2044,6 +2023,7 @@ auto SemanticTokens::resultId() const -> std::optional { auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -2051,7 +2031,7 @@ auto SemanticTokens::resultId() const -> std::optional { auto SemanticTokens::data() const -> Vector { auto& value = (*repr_)["data"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2061,7 +2041,7 @@ auto SemanticTokens::resultId(std::optional resultId) repr_->erase("resultId"); return *this; } - repr_->emplace("resultId", std::move(resultId.value())); + (*repr_)["resultId"] = std::move(resultId.value()); return *this; } @@ -2079,7 +2059,7 @@ SemanticTokensPartialResult::operator bool() const { auto SemanticTokensPartialResult::data() const -> Vector { auto& value = (*repr_)["data"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2097,10 +2077,10 @@ SemanticTokensRegistrationOptions::operator bool() const { } auto SemanticTokensRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -2114,25 +2094,25 @@ auto SemanticTokensRegistrationOptions::legend() const -> SemanticTokensLegend { } auto SemanticTokensRegistrationOptions::range() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("range")) return std::nullopt; auto& value = (*repr_)["range"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto SemanticTokensRegistrationOptions::full() const -> std::optional< - std::variant> { +auto SemanticTokensRegistrationOptions::full() const + -> std::optional> { if (!repr_->contains("full")) return std::nullopt; auto& value = (*repr_)["full"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -2145,6 +2125,7 @@ auto SemanticTokensRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -2155,22 +2136,17 @@ auto SemanticTokensRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto SemanticTokensRegistrationOptions::documentSelector( - std::variant - documentSelector) -> SemanticTokensRegistrationOptions& { - // or type - + std::variant documentSelector) + -> SemanticTokensRegistrationOptions& { 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 " @@ -2178,7 +2154,7 @@ auto SemanticTokensRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -2189,28 +2165,22 @@ auto SemanticTokensRegistrationOptions::documentSelector( auto SemanticTokensRegistrationOptions::legend(SemanticTokensLegend legend) -> SemanticTokensRegistrationOptions& { - repr_->emplace("legend", legend); + (*repr_)["legend"] = legend; return *this; } auto SemanticTokensRegistrationOptions::range( - std::optional> 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()(bool range) { (*repr_)["range"] = std::move(range); } void operator()(json range) { lsp_runtime_error( @@ -2224,27 +2194,19 @@ auto SemanticTokensRegistrationOptions::range( } auto SemanticTokensRegistrationOptions::full( - std::optional> - full) -> SemanticTokensRegistrationOptions& { + 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()(bool full) { (*repr_)["full"] = std::move(full); } - void operator()(SemanticTokensFullDelta full) { - repr_->emplace("full", full); - } + void operator()(SemanticTokensFullDelta full) { (*repr_)["full"] = full; } } v{repr_}; std::visit(v, full.value()); @@ -2259,7 +2221,7 @@ auto SemanticTokensRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -2269,7 +2231,7 @@ auto SemanticTokensRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -2289,6 +2251,7 @@ auto SemanticTokensDeltaParams::textDocument() const -> TextDocumentIdentifier { auto SemanticTokensDeltaParams::previousResultId() const -> std::string { auto& value = (*repr_)["previousResultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -2321,13 +2284,13 @@ auto SemanticTokensDeltaParams::partialResultToken() const auto SemanticTokensDeltaParams::textDocument( TextDocumentIdentifier textDocument) -> SemanticTokensDeltaParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto SemanticTokensDeltaParams::previousResultId(std::string previousResultId) -> SemanticTokensDeltaParams& { - repr_->emplace("previousResultId", std::move(previousResultId)); + (*repr_)["previousResultId"] = std::move(previousResultId); return *this; } @@ -2365,6 +2328,7 @@ auto SemanticTokensDelta::resultId() const -> std::optional { auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -2372,7 +2336,7 @@ auto SemanticTokensDelta::resultId() const -> std::optional { auto SemanticTokensDelta::edits() const -> Vector { auto& value = (*repr_)["edits"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2382,7 +2346,7 @@ auto SemanticTokensDelta::resultId(std::optional resultId) repr_->erase("resultId"); return *this; } - repr_->emplace("resultId", std::move(resultId.value())); + (*repr_)["resultId"] = std::move(resultId.value()); return *this; } @@ -2402,7 +2366,7 @@ auto SemanticTokensDeltaPartialResult::edits() const -> Vector { auto& value = (*repr_)["edits"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2460,13 +2424,13 @@ auto SemanticTokensRangeParams::partialResultToken() const auto SemanticTokensRangeParams::textDocument( TextDocumentIdentifier textDocument) -> SemanticTokensRangeParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto SemanticTokensRangeParams::range(Range range) -> SemanticTokensRangeParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -2502,6 +2466,7 @@ ShowDocumentParams::operator bool() const { auto ShowDocumentParams::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -2511,6 +2476,7 @@ auto ShowDocumentParams::external() const -> std::optional { auto& value = (*repr_)["external"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -2520,6 +2486,7 @@ auto ShowDocumentParams::takeFocus() const -> std::optional { auto& value = (*repr_)["takeFocus"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -2533,7 +2500,7 @@ auto ShowDocumentParams::selection() const -> std::optional { } auto ShowDocumentParams::uri(std::string uri) -> ShowDocumentParams& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -2543,7 +2510,7 @@ auto ShowDocumentParams::external(std::optional external) repr_->erase("external"); return *this; } - repr_->emplace("external", std::move(external.value())); + (*repr_)["external"] = std::move(external.value()); return *this; } @@ -2553,7 +2520,7 @@ auto ShowDocumentParams::takeFocus(std::optional takeFocus) repr_->erase("takeFocus"); return *this; } - repr_->emplace("takeFocus", std::move(takeFocus.value())); + (*repr_)["takeFocus"] = std::move(takeFocus.value()); return *this; } @@ -2563,7 +2530,7 @@ auto ShowDocumentParams::selection(std::optional selection) repr_->erase("selection"); return *this; } - repr_->emplace("selection", selection.value()); + (*repr_)["selection"] = selection.value(); return *this; } @@ -2576,12 +2543,13 @@ ShowDocumentResult::operator bool() const { auto ShowDocumentResult::success() const -> bool { auto& value = (*repr_)["success"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto ShowDocumentResult::success(bool success) -> ShowDocumentResult& { - repr_->emplace("success", std::move(success)); + (*repr_)["success"] = std::move(success); return *this; } @@ -2619,13 +2587,13 @@ auto LinkedEditingRangeParams::workDoneToken() const auto LinkedEditingRangeParams::textDocument(TextDocumentIdentifier textDocument) -> LinkedEditingRangeParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto LinkedEditingRangeParams::position(Position position) -> LinkedEditingRangeParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -2649,7 +2617,7 @@ LinkedEditingRanges::operator bool() const { auto LinkedEditingRanges::ranges() const -> Vector { auto& value = (*repr_)["ranges"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2658,6 +2626,7 @@ auto LinkedEditingRanges::wordPattern() const -> std::optional { auto& value = (*repr_)["wordPattern"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -2673,7 +2642,7 @@ auto LinkedEditingRanges::wordPattern(std::optional wordPattern) repr_->erase("wordPattern"); return *this; } - repr_->emplace("wordPattern", std::move(wordPattern.value())); + (*repr_)["wordPattern"] = std::move(wordPattern.value()); return *this; } @@ -2684,10 +2653,10 @@ LinkedEditingRangeRegistrationOptions::operator bool() const { } auto LinkedEditingRangeRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -2700,6 +2669,7 @@ auto LinkedEditingRangeRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -2710,22 +2680,17 @@ auto LinkedEditingRangeRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto LinkedEditingRangeRegistrationOptions::documentSelector( - std::variant - documentSelector) -> LinkedEditingRangeRegistrationOptions& { - // or type - + std::variant documentSelector) + -> LinkedEditingRangeRegistrationOptions& { 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 " @@ -2733,7 +2698,7 @@ auto LinkedEditingRangeRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -2749,7 +2714,7 @@ auto LinkedEditingRangeRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -2759,7 +2724,7 @@ auto LinkedEditingRangeRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -2772,7 +2737,7 @@ CreateFilesParams::operator bool() const { auto CreateFilesParams::files() const -> Vector { auto& value = (*repr_)["files"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2792,20 +2757,20 @@ auto WorkspaceEdit::changes() const auto& value = (*repr_)["changes"]; - assert(value.is_object()); + if (value.is_null()) value = json::object(); return Map>(value); } -auto WorkspaceEdit::documentChanges() const - -> std::optional>> { +auto WorkspaceEdit::documentChanges() const -> std::optional>> { if (!repr_->contains("documentChanges")) return std::nullopt; auto& value = (*repr_)["documentChanges"]; - assert(value.is_array()); - return Vector>(value); + if (value.is_null()) value = json::array(); + return Vector< + std::variant>( + value); } auto WorkspaceEdit::changeAnnotations() const @@ -2814,7 +2779,7 @@ auto WorkspaceEdit::changeAnnotations() const auto& value = (*repr_)["changeAnnotations"]; - assert(value.is_object()); + if (value.is_null()) value = json::object(); return Map(value); } @@ -2830,8 +2795,8 @@ auto WorkspaceEdit::changes( } auto WorkspaceEdit::documentChanges( - std::optional>> + std::optional>> documentChanges) -> WorkspaceEdit& { if (!documentChanges.has_value()) { repr_->erase("documentChanges"); @@ -2862,7 +2827,7 @@ auto FileOperationRegistrationOptions::filters() const -> Vector { auto& value = (*repr_)["filters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2882,7 +2847,7 @@ RenameFilesParams::operator bool() const { auto RenameFilesParams::files() const -> Vector { auto& value = (*repr_)["files"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2900,7 +2865,7 @@ DeleteFilesParams::operator bool() const { auto DeleteFilesParams::files() const -> Vector { auto& value = (*repr_)["files"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -2954,12 +2919,12 @@ auto MonikerParams::partialResultToken() const -> std::optional { auto MonikerParams::textDocument(TextDocumentIdentifier textDocument) -> MonikerParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto MonikerParams::position(Position position) -> MonikerParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -2994,6 +2959,7 @@ Moniker::operator bool() const { auto Moniker::scheme() const -> std::string { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3001,6 +2967,7 @@ auto Moniker::scheme() const -> std::string { auto Moniker::identifier() const -> std::string { auto& value = (*repr_)["identifier"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3020,12 +2987,12 @@ auto Moniker::kind() const -> std::optional { } auto Moniker::scheme(std::string scheme) -> Moniker& { - repr_->emplace("scheme", std::move(scheme)); + (*repr_)["scheme"] = std::move(scheme); return *this; } auto Moniker::identifier(std::string identifier) -> Moniker& { - repr_->emplace("identifier", std::move(identifier)); + (*repr_)["identifier"] = std::move(identifier); return *this; } @@ -3050,10 +3017,10 @@ MonikerRegistrationOptions::operator bool() const { } auto MonikerRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -3066,29 +3033,24 @@ auto MonikerRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto MonikerRegistrationOptions::documentSelector( - std::variant - documentSelector) -> MonikerRegistrationOptions& { - // or type - + std::variant documentSelector) + -> MonikerRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -3103,7 +3065,7 @@ auto MonikerRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -3142,13 +3104,13 @@ auto TypeHierarchyPrepareParams::workDoneToken() const auto TypeHierarchyPrepareParams::textDocument( TextDocumentIdentifier textDocument) -> TypeHierarchyPrepareParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto TypeHierarchyPrepareParams::position(Position position) -> TypeHierarchyPrepareParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -3176,6 +3138,7 @@ TypeHierarchyItem::operator bool() const { auto TypeHierarchyItem::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3191,7 +3154,7 @@ auto TypeHierarchyItem::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -3200,6 +3163,7 @@ auto TypeHierarchyItem::detail() const -> std::optional { auto& value = (*repr_)["detail"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3207,6 +3171,7 @@ auto TypeHierarchyItem::detail() const -> std::optional { auto TypeHierarchyItem::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3233,12 +3198,12 @@ auto TypeHierarchyItem::data() const -> std::optional { } auto TypeHierarchyItem::name(std::string name) -> TypeHierarchyItem& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } auto TypeHierarchyItem::kind(SymbolKind kind) -> TypeHierarchyItem& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -3258,23 +3223,23 @@ auto TypeHierarchyItem::detail(std::optional detail) repr_->erase("detail"); return *this; } - repr_->emplace("detail", std::move(detail.value())); + (*repr_)["detail"] = std::move(detail.value()); return *this; } auto TypeHierarchyItem::uri(std::string uri) -> TypeHierarchyItem& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto TypeHierarchyItem::range(Range range) -> TypeHierarchyItem& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto TypeHierarchyItem::selectionRange(Range selectionRange) -> TypeHierarchyItem& { - repr_->emplace("selectionRange", selectionRange); + (*repr_)["selectionRange"] = selectionRange; return *this; } @@ -3294,10 +3259,10 @@ TypeHierarchyRegistrationOptions::operator bool() const { } auto TypeHierarchyRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -3310,6 +3275,7 @@ auto TypeHierarchyRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -3320,22 +3286,17 @@ auto TypeHierarchyRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TypeHierarchyRegistrationOptions::documentSelector( - std::variant - documentSelector) -> TypeHierarchyRegistrationOptions& { - // or type - + std::variant documentSelector) + -> TypeHierarchyRegistrationOptions& { 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 " @@ -3343,7 +3304,7 @@ auto TypeHierarchyRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -3358,7 +3319,7 @@ auto TypeHierarchyRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -3368,7 +3329,7 @@ auto TypeHierarchyRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -3412,7 +3373,7 @@ auto TypeHierarchySupertypesParams::partialResultToken() const auto TypeHierarchySupertypesParams::item(TypeHierarchyItem item) -> TypeHierarchySupertypesParams& { - repr_->emplace("item", item); + (*repr_)["item"] = item; return *this; } @@ -3480,7 +3441,7 @@ auto TypeHierarchySubtypesParams::partialResultToken() const auto TypeHierarchySubtypesParams::item(TypeHierarchyItem item) -> TypeHierarchySubtypesParams& { - repr_->emplace("item", item); + (*repr_)["item"] = item; return *this; } @@ -3548,18 +3509,18 @@ auto InlineValueParams::workDoneToken() const -> std::optional { auto InlineValueParams::textDocument(TextDocumentIdentifier textDocument) -> InlineValueParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto InlineValueParams::range(Range range) -> InlineValueParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto InlineValueParams::context(InlineValueContext context) -> InlineValueParams& { - repr_->emplace("context", context); + (*repr_)["context"] = context; return *this; } @@ -3585,15 +3546,16 @@ auto InlineValueRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto InlineValueRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -3605,6 +3567,7 @@ auto InlineValueRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3615,22 +3578,16 @@ auto InlineValueRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } auto InlineValueRegistrationOptions::documentSelector( - std::variant - documentSelector) -> InlineValueRegistrationOptions& { - // or type - + std::variant documentSelector) + -> InlineValueRegistrationOptions& { 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 " @@ -3638,7 +3595,7 @@ auto InlineValueRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -3653,7 +3610,7 @@ auto InlineValueRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -3690,12 +3647,12 @@ auto InlayHintParams::workDoneToken() const -> std::optional { auto InlayHintParams::textDocument(TextDocumentIdentifier textDocument) -> InlayHintParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto InlayHintParams::range(Range range) -> InlayHintParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -3723,10 +3680,10 @@ auto InlayHint::position() const -> Position { } auto InlayHint::label() const - -> std::variant> { + -> std::variant> { auto& value = (*repr_)["label"]; - std::variant> result; + std::variant> result; details::try_emplace(result, value); @@ -3746,17 +3703,17 @@ auto InlayHint::textEdits() const -> std::optional> { auto& value = (*repr_)["textEdits"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto InlayHint::tooltip() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("tooltip")) return std::nullopt; auto& value = (*repr_)["tooltip"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -3768,6 +3725,7 @@ auto InlayHint::paddingLeft() const -> std::optional { auto& value = (*repr_)["paddingLeft"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -3777,6 +3735,7 @@ auto InlayHint::paddingRight() const -> std::optional { auto& value = (*repr_)["paddingRight"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -3791,25 +3750,16 @@ auto InlayHint::data() const -> std::optional { } auto InlayHint::position(Position position) -> InlayHint& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } auto InlayHint::label( - std::variant> label) - -> InlayHint& { - // or type - + std::variant> label) -> InlayHint& { 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::string label) { (*repr_)["label"] = std::move(label); } void operator()(Vector label) { lsp_runtime_error("InlayHint::label: not implement yet"); @@ -3826,7 +3776,7 @@ auto InlayHint::kind(std::optional kind) -> InlayHint& { repr_->erase("kind"); return *this; } - repr_->emplace("kind", static_cast(kind.value())); + (*repr_)["kind"] = static_cast(kind.value()); return *this; } @@ -3841,29 +3791,21 @@ auto InlayHint::textEdits(std::optional> textEdits) } auto InlayHint::tooltip( - std::optional> - tooltip) -> InlayHint& { + 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)); + (*repr_)["tooltip"] = std::move(tooltip); } - void operator()(MarkupContent tooltip) { - repr_->emplace("tooltip", tooltip); - } + void operator()(MarkupContent tooltip) { (*repr_)["tooltip"] = tooltip; } } v{repr_}; std::visit(v, tooltip.value()); @@ -3876,7 +3818,7 @@ auto InlayHint::paddingLeft(std::optional paddingLeft) -> InlayHint& { repr_->erase("paddingLeft"); return *this; } - repr_->emplace("paddingLeft", std::move(paddingLeft.value())); + (*repr_)["paddingLeft"] = std::move(paddingLeft.value()); return *this; } @@ -3885,7 +3827,7 @@ auto InlayHint::paddingRight(std::optional paddingRight) -> InlayHint& { repr_->erase("paddingRight"); return *this; } - repr_->emplace("paddingRight", std::move(paddingRight.value())); + (*repr_)["paddingRight"] = std::move(paddingRight.value()); return *this; } @@ -3910,6 +3852,7 @@ auto InlayHintRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -3920,15 +3863,16 @@ auto InlayHintRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto InlayHintRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -3940,6 +3884,7 @@ auto InlayHintRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -3950,7 +3895,7 @@ auto InlayHintRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -3960,29 +3905,23 @@ auto InlayHintRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } auto InlayHintRegistrationOptions::documentSelector( - std::variant - documentSelector) -> InlayHintRegistrationOptions& { - // or type - + std::variant documentSelector) + -> InlayHintRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -3997,7 +3936,7 @@ auto InlayHintRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -4019,6 +3958,7 @@ auto DocumentDiagnosticParams::identifier() const auto& value = (*repr_)["identifier"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4029,6 +3969,7 @@ auto DocumentDiagnosticParams::previousResultId() const auto& value = (*repr_)["previousResultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4061,7 +4002,7 @@ auto DocumentDiagnosticParams::partialResultToken() const auto DocumentDiagnosticParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentDiagnosticParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -4071,7 +4012,7 @@ auto DocumentDiagnosticParams::identifier(std::optional identifier) repr_->erase("identifier"); return *this; } - repr_->emplace("identifier", std::move(identifier.value())); + (*repr_)["identifier"] = std::move(identifier.value()); return *this; } @@ -4081,7 +4022,7 @@ auto DocumentDiagnosticParams::previousResultId( repr_->erase("previousResultId"); return *this; } - repr_->emplace("previousResultId", std::move(previousResultId.value())); + (*repr_)["previousResultId"] = std::move(previousResultId.value()); return *this; } @@ -4115,19 +4056,18 @@ DocumentDiagnosticReportPartialResult::operator bool() const { } auto DocumentDiagnosticReportPartialResult::relatedDocuments() const - -> Map> { + -> Map> { auto& value = (*repr_)["relatedDocuments"]; - assert(value.is_object()); - return Map>(value); + if (value.is_null()) value = json::object(); + return Map>( + value); } auto DocumentDiagnosticReportPartialResult::relatedDocuments( - Map> relatedDocuments) -> DocumentDiagnosticReportPartialResult& { lsp_runtime_error( @@ -4145,13 +4085,14 @@ DiagnosticServerCancellationData::operator bool() const { auto DiagnosticServerCancellationData::retriggerRequest() const -> bool { auto& value = (*repr_)["retriggerRequest"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DiagnosticServerCancellationData::retriggerRequest(bool retriggerRequest) -> DiagnosticServerCancellationData& { - repr_->emplace("retriggerRequest", std::move(retriggerRequest)); + (*repr_)["retriggerRequest"] = std::move(retriggerRequest); return *this; } @@ -4164,10 +4105,10 @@ DiagnosticRegistrationOptions::operator bool() const { } auto DiagnosticRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -4180,6 +4121,7 @@ auto DiagnosticRegistrationOptions::identifier() const auto& value = (*repr_)["identifier"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4187,6 +4129,7 @@ auto DiagnosticRegistrationOptions::identifier() const auto DiagnosticRegistrationOptions::interFileDependencies() const -> bool { auto& value = (*repr_)["interFileDependencies"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -4194,6 +4137,7 @@ auto DiagnosticRegistrationOptions::interFileDependencies() const -> bool { auto DiagnosticRegistrationOptions::workspaceDiagnostics() const -> bool { auto& value = (*repr_)["workspaceDiagnostics"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -4204,6 +4148,7 @@ auto DiagnosticRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -4213,29 +4158,24 @@ auto DiagnosticRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto DiagnosticRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DiagnosticRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DiagnosticRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -4250,19 +4190,19 @@ auto DiagnosticRegistrationOptions::identifier( repr_->erase("identifier"); return *this; } - repr_->emplace("identifier", std::move(identifier.value())); + (*repr_)["identifier"] = std::move(identifier.value()); return *this; } auto DiagnosticRegistrationOptions::interFileDependencies( bool interFileDependencies) -> DiagnosticRegistrationOptions& { - repr_->emplace("interFileDependencies", std::move(interFileDependencies)); + (*repr_)["interFileDependencies"] = std::move(interFileDependencies); return *this; } auto DiagnosticRegistrationOptions::workspaceDiagnostics( bool workspaceDiagnostics) -> DiagnosticRegistrationOptions& { - repr_->emplace("workspaceDiagnostics", std::move(workspaceDiagnostics)); + (*repr_)["workspaceDiagnostics"] = std::move(workspaceDiagnostics); return *this; } @@ -4272,7 +4212,7 @@ auto DiagnosticRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -4282,7 +4222,7 @@ auto DiagnosticRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -4298,6 +4238,7 @@ auto WorkspaceDiagnosticParams::identifier() const auto& value = (*repr_)["identifier"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4306,7 +4247,7 @@ auto WorkspaceDiagnosticParams::previousResultIds() const -> Vector { auto& value = (*repr_)["previousResultIds"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -4342,7 +4283,7 @@ auto WorkspaceDiagnosticParams::identifier( repr_->erase("identifier"); return *this; } - repr_->emplace("identifier", std::move(identifier.value())); + (*repr_)["identifier"] = std::move(identifier.value()); return *this; } @@ -4386,7 +4327,7 @@ auto WorkspaceDiagnosticReport::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -4407,7 +4348,7 @@ auto WorkspaceDiagnosticReportPartialResult::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -4437,13 +4378,13 @@ auto DidOpenNotebookDocumentParams::cellTextDocuments() const -> Vector { auto& value = (*repr_)["cellTextDocuments"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DidOpenNotebookDocumentParams::notebookDocument( NotebookDocument notebookDocument) -> DidOpenNotebookDocumentParams& { - repr_->emplace("notebookDocument", notebookDocument); + (*repr_)["notebookDocument"] = notebookDocument; return *this; } @@ -4462,12 +4403,12 @@ NotebookDocumentSyncRegistrationOptions::operator bool() const { } auto NotebookDocumentSyncRegistrationOptions::notebookSelector() const - -> Vector Vector> { auto& value = (*repr_)["notebookSelector"]; - assert(value.is_array()); - return Vector>(value); } @@ -4477,6 +4418,7 @@ auto NotebookDocumentSyncRegistrationOptions::save() const auto& value = (*repr_)["save"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -4487,12 +4429,13 @@ auto NotebookDocumentSyncRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto NotebookDocumentSyncRegistrationOptions::notebookSelector( - Vector> notebookSelector) -> NotebookDocumentSyncRegistrationOptions& { lsp_runtime_error( @@ -4507,7 +4450,7 @@ auto NotebookDocumentSyncRegistrationOptions::save(std::optional save) repr_->erase("save"); return *this; } - repr_->emplace("save", std::move(save.value())); + (*repr_)["save"] = std::move(save.value()); return *this; } @@ -4517,7 +4460,7 @@ auto NotebookDocumentSyncRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -4545,13 +4488,13 @@ auto DidChangeNotebookDocumentParams::change() const auto DidChangeNotebookDocumentParams::notebookDocument( VersionedNotebookDocumentIdentifier notebookDocument) -> DidChangeNotebookDocumentParams& { - repr_->emplace("notebookDocument", notebookDocument); + (*repr_)["notebookDocument"] = notebookDocument; return *this; } auto DidChangeNotebookDocumentParams::change(NotebookDocumentChangeEvent change) -> DidChangeNotebookDocumentParams& { - repr_->emplace("change", change); + (*repr_)["change"] = change; return *this; } @@ -4571,7 +4514,7 @@ auto DidSaveNotebookDocumentParams::notebookDocument() const auto DidSaveNotebookDocumentParams::notebookDocument( NotebookDocumentIdentifier notebookDocument) -> DidSaveNotebookDocumentParams& { - repr_->emplace("notebookDocument", notebookDocument); + (*repr_)["notebookDocument"] = notebookDocument; return *this; } @@ -4593,14 +4536,14 @@ auto DidCloseNotebookDocumentParams::cellTextDocuments() const -> Vector { auto& value = (*repr_)["cellTextDocuments"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DidCloseNotebookDocumentParams::notebookDocument( NotebookDocumentIdentifier notebookDocument) -> DidCloseNotebookDocumentParams& { - repr_->emplace("notebookDocument", notebookDocument); + (*repr_)["notebookDocument"] = notebookDocument; return *this; } @@ -4653,19 +4596,19 @@ auto InlineCompletionParams::workDoneToken() const auto InlineCompletionParams::context(InlineCompletionContext context) -> InlineCompletionParams& { - repr_->emplace("context", context); + (*repr_)["context"] = context; return *this; } auto InlineCompletionParams::textDocument(TextDocumentIdentifier textDocument) -> InlineCompletionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto InlineCompletionParams::position(Position position) -> InlineCompletionParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -4688,7 +4631,7 @@ InlineCompletionList::operator bool() const { auto InlineCompletionList::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -4705,10 +4648,10 @@ InlineCompletionItem::operator bool() const { } auto InlineCompletionItem::insertText() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["insertText"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -4720,6 +4663,7 @@ auto InlineCompletionItem::filterText() const -> std::optional { auto& value = (*repr_)["filterText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4741,23 +4685,17 @@ auto InlineCompletionItem::command() const -> std::optional { } auto InlineCompletionItem::insertText( - std::variant 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)); + (*repr_)["insertText"] = std::move(insertText); } void operator()(StringValue insertText) { - repr_->emplace("insertText", insertText); + (*repr_)["insertText"] = insertText; } } v{repr_}; @@ -4772,7 +4710,7 @@ auto InlineCompletionItem::filterText(std::optional filterText) repr_->erase("filterText"); return *this; } - repr_->emplace("filterText", std::move(filterText.value())); + (*repr_)["filterText"] = std::move(filterText.value()); return *this; } @@ -4782,7 +4720,7 @@ auto InlineCompletionItem::range(std::optional range) repr_->erase("range"); return *this; } - repr_->emplace("range", range.value()); + (*repr_)["range"] = range.value(); return *this; } @@ -4792,7 +4730,7 @@ auto InlineCompletionItem::command(std::optional command) repr_->erase("command"); return *this; } - repr_->emplace("command", command.value()); + (*repr_)["command"] = command.value(); return *this; } @@ -4808,15 +4746,16 @@ auto InlineCompletionRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto InlineCompletionRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -4829,6 +4768,7 @@ auto InlineCompletionRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4840,22 +4780,16 @@ auto InlineCompletionRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } auto InlineCompletionRegistrationOptions::documentSelector( - std::variant - documentSelector) -> InlineCompletionRegistrationOptions& { - // or type - + std::variant documentSelector) + -> InlineCompletionRegistrationOptions& { 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 " @@ -4863,7 +4797,7 @@ auto InlineCompletionRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -4878,7 +4812,7 @@ auto InlineCompletionRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -4891,13 +4825,14 @@ TextDocumentContentParams::operator bool() const { auto TextDocumentContentParams::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentContentParams::uri(std::string uri) -> TextDocumentContentParams& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -4910,13 +4845,14 @@ TextDocumentContentResult::operator bool() const { auto TextDocumentContentResult::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentContentResult::text(std::string text) -> TextDocumentContentResult& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -4930,7 +4866,7 @@ auto TextDocumentContentRegistrationOptions::schemes() const -> Vector { auto& value = (*repr_)["schemes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -4940,6 +4876,7 @@ auto TextDocumentContentRegistrationOptions::id() const auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -4957,7 +4894,7 @@ auto TextDocumentContentRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -4970,13 +4907,14 @@ TextDocumentContentRefreshParams::operator bool() const { auto TextDocumentContentRefreshParams::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentContentRefreshParams::uri(std::string uri) -> TextDocumentContentRefreshParams& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -4989,7 +4927,7 @@ RegistrationParams::operator bool() const { auto RegistrationParams::registrations() const -> Vector { auto& value = (*repr_)["registrations"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -5008,7 +4946,7 @@ UnregistrationParams::operator bool() const { auto UnregistrationParams::unregisterations() const -> Vector { auto& value = (*repr_)["unregisterations"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -5027,11 +4965,10 @@ InitializeParams::operator bool() const { return true; } -auto InitializeParams::processId() const - -> std::variant { +auto InitializeParams::processId() const -> std::variant { auto& value = (*repr_)["processId"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -5051,17 +4988,18 @@ auto InitializeParams::locale() const -> std::optional { auto& value = (*repr_)["locale"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } -auto InitializeParams::rootPath() const -> std::optional< - std::variant> { +auto InitializeParams::rootPath() const + -> std::optional> { if (!repr_->contains("rootPath")) return std::nullopt; auto& value = (*repr_)["rootPath"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -5069,10 +5007,10 @@ auto InitializeParams::rootPath() const -> std::optional< } auto InitializeParams::rootUri() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["rootUri"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -5114,37 +5052,30 @@ auto InitializeParams::workDoneToken() const -> std::optional { return result; } -auto InitializeParams::workspaceFolders() const -> std::optional< - std::variant, std::nullptr_t>> { +auto InitializeParams::workspaceFolders() const + -> std::optional, std::nullptr_t>> { if (!repr_->contains("workspaceFolders")) return std::nullopt; auto& value = (*repr_)["workspaceFolders"]; - std::variant, std::nullptr_t> result; + std::variant, std::nullptr_t> result; details::try_emplace(result, value); return result; } -auto InitializeParams::processId( - std::variant processId) +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)); + (*repr_)["processId"] = std::move(processId); } void operator()(std::nullptr_t processId) { - repr_->emplace("processId", std::move(processId)); + (*repr_)["processId"] = std::move(processId); } } v{repr_}; @@ -5159,7 +5090,7 @@ auto InitializeParams::clientInfo(std::optional clientInfo) repr_->erase("clientInfo"); return *this; } - repr_->emplace("clientInfo", clientInfo.value()); + (*repr_)["clientInfo"] = clientInfo.value(); return *this; } @@ -5169,33 +5100,27 @@ auto InitializeParams::locale(std::optional locale) repr_->erase("locale"); return *this; } - repr_->emplace("locale", std::move(locale.value())); + (*repr_)["locale"] = std::move(locale.value()); return *this; } auto InitializeParams::rootPath( - std::optional> - rootPath) -> InitializeParams& { + 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)); + (*repr_)["rootPath"] = std::move(rootPath); } void operator()(std::nullptr_t rootPath) { - repr_->emplace("rootPath", std::move(rootPath)); + (*repr_)["rootPath"] = std::move(rootPath); } } v{repr_}; @@ -5205,23 +5130,16 @@ auto InitializeParams::rootPath( } auto InitializeParams::rootUri( - std::variant rootUri) - -> InitializeParams& { - // or type - + std::variant rootUri) -> InitializeParams& { 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)); + (*repr_)["rootUri"] = std::move(rootUri); } void operator()(std::nullptr_t rootUri) { - repr_->emplace("rootUri", std::move(rootUri)); + (*repr_)["rootUri"] = std::move(rootUri); } } v{repr_}; @@ -5232,7 +5150,7 @@ auto InitializeParams::rootUri( auto InitializeParams::capabilities(ClientCapabilities capabilities) -> InitializeParams& { - repr_->emplace("capabilities", capabilities); + (*repr_)["capabilities"] = capabilities; return *this; } @@ -5268,30 +5186,23 @@ auto InitializeParams::workDoneToken(std::optional workDoneToken) } auto InitializeParams::workspaceFolders( - std::optional< - std::variant, std::nullptr_t>> + std::optional, 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)); + (*repr_)["workspaceFolders"] = std::move(workspaceFolders); } } v{repr_}; @@ -5322,7 +5233,7 @@ auto InitializeResult::serverInfo() const -> std::optional { auto InitializeResult::capabilities(ServerCapabilities capabilities) -> InitializeResult& { - repr_->emplace("capabilities", capabilities); + (*repr_)["capabilities"] = capabilities; return *this; } @@ -5332,7 +5243,7 @@ auto InitializeResult::serverInfo(std::optional serverInfo) repr_->erase("serverInfo"); return *this; } - repr_->emplace("serverInfo", serverInfo.value()); + (*repr_)["serverInfo"] = serverInfo.value(); return *this; } @@ -5345,12 +5256,13 @@ InitializeError::operator bool() const { auto InitializeError::retry() const -> bool { auto& value = (*repr_)["retry"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto InitializeError::retry(bool retry) -> InitializeError& { - repr_->emplace("retry", std::move(retry)); + (*repr_)["retry"] = std::move(retry); return *this; } @@ -5385,13 +5297,12 @@ DidChangeConfigurationRegistrationOptions::operator bool() const { } auto DidChangeConfigurationRegistrationOptions::section() const - -> std::optional< - std::variant>> { + -> std::optional>> { if (!repr_->contains("section")) return std::nullopt; auto& value = (*repr_)["section"]; - std::variant> result; + std::variant> result; details::try_emplace(result, value); @@ -5399,25 +5310,18 @@ auto DidChangeConfigurationRegistrationOptions::section() const } auto DidChangeConfigurationRegistrationOptions::section( - std::optional< - std::variant>> - section) -> DidChangeConfigurationRegistrationOptions& { + std::optional>> 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)); + (*repr_)["section"] = std::move(section); } void operator()(Vector section) { @@ -5448,17 +5352,18 @@ auto ShowMessageParams::type() const -> MessageType { auto ShowMessageParams::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ShowMessageParams::type(MessageType type) -> ShowMessageParams& { - repr_->emplace("type", static_cast(type)); + (*repr_)["type"] = static_cast(type); return *this; } auto ShowMessageParams::message(std::string message) -> ShowMessageParams& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -5478,6 +5383,7 @@ auto ShowMessageRequestParams::type() const -> MessageType { auto ShowMessageRequestParams::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -5488,19 +5394,19 @@ auto ShowMessageRequestParams::actions() const auto& value = (*repr_)["actions"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto ShowMessageRequestParams::type(MessageType type) -> ShowMessageRequestParams& { - repr_->emplace("type", static_cast(type)); + (*repr_)["type"] = static_cast(type); return *this; } auto ShowMessageRequestParams::message(std::string message) -> ShowMessageRequestParams& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -5524,12 +5430,13 @@ MessageActionItem::operator bool() const { auto MessageActionItem::title() const -> std::string { auto& value = (*repr_)["title"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto MessageActionItem::title(std::string title) -> MessageActionItem& { - repr_->emplace("title", std::move(title)); + (*repr_)["title"] = std::move(title); return *this; } @@ -5549,17 +5456,18 @@ auto LogMessageParams::type() const -> MessageType { auto LogMessageParams::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto LogMessageParams::type(MessageType type) -> LogMessageParams& { - repr_->emplace("type", static_cast(type)); + (*repr_)["type"] = static_cast(type); return *this; } auto LogMessageParams::message(std::string message) -> LogMessageParams& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -5577,7 +5485,7 @@ auto DidOpenTextDocumentParams::textDocument() const -> TextDocumentItem { auto DidOpenTextDocumentParams::textDocument(TextDocumentItem textDocument) -> DidOpenTextDocumentParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -5599,14 +5507,14 @@ auto DidChangeTextDocumentParams::contentChanges() const -> Vector { auto& value = (*repr_)["contentChanges"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DidChangeTextDocumentParams::textDocument( VersionedTextDocumentIdentifier textDocument) -> DidChangeTextDocumentParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -5633,10 +5541,10 @@ auto TextDocumentChangeRegistrationOptions::syncKind() const } auto TextDocumentChangeRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -5645,22 +5553,16 @@ auto TextDocumentChangeRegistrationOptions::documentSelector() const auto TextDocumentChangeRegistrationOptions::syncKind( TextDocumentSyncKind syncKind) -> TextDocumentChangeRegistrationOptions& { - repr_->emplace("syncKind", static_cast(syncKind)); + (*repr_)["syncKind"] = static_cast(syncKind); return *this; } auto TextDocumentChangeRegistrationOptions::documentSelector( - std::variant - documentSelector) -> TextDocumentChangeRegistrationOptions& { - // or type - + std::variant documentSelector) + -> TextDocumentChangeRegistrationOptions& { 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 " @@ -5668,7 +5570,7 @@ auto TextDocumentChangeRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -5692,7 +5594,7 @@ auto DidCloseTextDocumentParams::textDocument() const auto DidCloseTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> DidCloseTextDocumentParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -5713,13 +5615,14 @@ auto DidSaveTextDocumentParams::text() const -> std::optional { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto DidSaveTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> DidSaveTextDocumentParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -5729,7 +5632,7 @@ auto DidSaveTextDocumentParams::text(std::optional text) repr_->erase("text"); return *this; } - repr_->emplace("text", std::move(text.value())); + (*repr_)["text"] = std::move(text.value()); return *this; } @@ -5740,10 +5643,10 @@ TextDocumentSaveRegistrationOptions::operator bool() const { } auto TextDocumentSaveRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -5756,22 +5659,17 @@ auto TextDocumentSaveRegistrationOptions::includeText() const auto& value = (*repr_)["includeText"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto TextDocumentSaveRegistrationOptions::documentSelector( - std::variant - documentSelector) -> TextDocumentSaveRegistrationOptions& { - // or type - + std::variant documentSelector) + -> TextDocumentSaveRegistrationOptions& { 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 " @@ -5779,7 +5677,7 @@ auto TextDocumentSaveRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -5794,7 +5692,7 @@ auto TextDocumentSaveRegistrationOptions::includeText( repr_->erase("includeText"); return *this; } - repr_->emplace("includeText", std::move(includeText.value())); + (*repr_)["includeText"] = std::move(includeText.value()); return *this; } @@ -5820,13 +5718,13 @@ auto WillSaveTextDocumentParams::reason() const -> TextDocumentSaveReason { auto WillSaveTextDocumentParams::textDocument( TextDocumentIdentifier textDocument) -> WillSaveTextDocumentParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto WillSaveTextDocumentParams::reason(TextDocumentSaveReason reason) -> WillSaveTextDocumentParams& { - repr_->emplace("reason", static_cast(reason)); + (*repr_)["reason"] = static_cast(reason); return *this; } @@ -5846,17 +5744,18 @@ auto TextEdit::range() const -> Range { auto TextEdit::newText() const -> std::string { auto& value = (*repr_)["newText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextEdit::range(Range range) -> TextEdit& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto TextEdit::newText(std::string newText) -> TextEdit& { - repr_->emplace("newText", std::move(newText)); + (*repr_)["newText"] = std::move(newText); return *this; } @@ -5869,7 +5768,7 @@ DidChangeWatchedFilesParams::operator bool() const { auto DidChangeWatchedFilesParams::changes() const -> Vector { auto& value = (*repr_)["changes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -5889,7 +5788,7 @@ auto DidChangeWatchedFilesRegistrationOptions::watchers() const -> Vector { auto& value = (*repr_)["watchers"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -5911,6 +5810,7 @@ PublishDiagnosticsParams::operator bool() const { auto PublishDiagnosticsParams::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -5920,6 +5820,7 @@ auto PublishDiagnosticsParams::version() const -> std::optional { auto& value = (*repr_)["version"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -5927,13 +5828,13 @@ auto PublishDiagnosticsParams::version() const -> std::optional { auto PublishDiagnosticsParams::diagnostics() const -> Vector { auto& value = (*repr_)["diagnostics"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto PublishDiagnosticsParams::uri(std::string uri) -> PublishDiagnosticsParams& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -5943,7 +5844,7 @@ auto PublishDiagnosticsParams::version(std::optional version) repr_->erase("version"); return *this; } - repr_->emplace("version", std::move(version.value())); + (*repr_)["version"] = std::move(version.value()); return *this; } @@ -6011,18 +5912,18 @@ auto CompletionParams::context(std::optional context) repr_->erase("context"); return *this; } - repr_->emplace("context", context.value()); + (*repr_)["context"] = context.value(); return *this; } auto CompletionParams::textDocument(TextDocumentIdentifier textDocument) -> CompletionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto CompletionParams::position(Position position) -> CompletionParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -6055,6 +5956,7 @@ CompletionItem::operator bool() const { auto CompletionItem::label() const -> std::string { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -6081,7 +5983,7 @@ auto CompletionItem::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6090,17 +5992,18 @@ auto CompletionItem::detail() const -> std::optional { auto& value = (*repr_)["detail"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto CompletionItem::documentation() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("documentation")) return std::nullopt; auto& value = (*repr_)["documentation"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -6112,6 +6015,7 @@ auto CompletionItem::deprecated() const -> std::optional { auto& value = (*repr_)["deprecated"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -6121,6 +6025,7 @@ auto CompletionItem::preselect() const -> std::optional { auto& value = (*repr_)["preselect"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -6130,6 +6035,7 @@ auto CompletionItem::sortText() const -> std::optional { auto& value = (*repr_)["sortText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -6139,6 +6045,7 @@ auto CompletionItem::filterText() const -> std::optional { auto& value = (*repr_)["filterText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -6148,6 +6055,7 @@ auto CompletionItem::insertText() const -> std::optional { auto& value = (*repr_)["insertText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -6169,13 +6077,13 @@ auto CompletionItem::insertTextMode() const -> std::optional { return InsertTextMode(value); } -auto CompletionItem::textEdit() const -> std::optional< - std::variant> { +auto CompletionItem::textEdit() const + -> std::optional> { if (!repr_->contains("textEdit")) return std::nullopt; auto& value = (*repr_)["textEdit"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -6187,6 +6095,7 @@ auto CompletionItem::textEditText() const -> std::optional { auto& value = (*repr_)["textEditText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -6197,7 +6106,7 @@ auto CompletionItem::additionalTextEdits() const auto& value = (*repr_)["additionalTextEdits"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6207,7 +6116,7 @@ auto CompletionItem::commitCharacters() const auto& value = (*repr_)["commitCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6229,7 +6138,7 @@ auto CompletionItem::data() const -> std::optional { } auto CompletionItem::label(std::string label) -> CompletionItem& { - repr_->emplace("label", std::move(label)); + (*repr_)["label"] = std::move(label); return *this; } @@ -6239,7 +6148,7 @@ auto CompletionItem::labelDetails( repr_->erase("labelDetails"); return *this; } - repr_->emplace("labelDetails", labelDetails.value()); + (*repr_)["labelDetails"] = labelDetails.value(); return *this; } @@ -6249,7 +6158,7 @@ auto CompletionItem::kind(std::optional kind) repr_->erase("kind"); return *this; } - repr_->emplace("kind", static_cast(kind.value())); + (*repr_)["kind"] = static_cast(kind.value()); return *this; } @@ -6269,33 +6178,27 @@ auto CompletionItem::detail(std::optional detail) repr_->erase("detail"); return *this; } - repr_->emplace("detail", std::move(detail.value())); + (*repr_)["detail"] = std::move(detail.value()); return *this; } auto CompletionItem::documentation( - std::optional> - documentation) -> CompletionItem& { + std::optional> documentation) + -> CompletionItem& { 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)); + (*repr_)["documentation"] = std::move(documentation); } void operator()(MarkupContent documentation) { - repr_->emplace("documentation", documentation); + (*repr_)["documentation"] = documentation; } } v{repr_}; @@ -6310,7 +6213,7 @@ auto CompletionItem::deprecated(std::optional deprecated) repr_->erase("deprecated"); return *this; } - repr_->emplace("deprecated", std::move(deprecated.value())); + (*repr_)["deprecated"] = std::move(deprecated.value()); return *this; } @@ -6320,7 +6223,7 @@ auto CompletionItem::preselect(std::optional preselect) repr_->erase("preselect"); return *this; } - repr_->emplace("preselect", std::move(preselect.value())); + (*repr_)["preselect"] = std::move(preselect.value()); return *this; } @@ -6330,7 +6233,7 @@ auto CompletionItem::sortText(std::optional sortText) repr_->erase("sortText"); return *this; } - repr_->emplace("sortText", std::move(sortText.value())); + (*repr_)["sortText"] = std::move(sortText.value()); return *this; } @@ -6340,7 +6243,7 @@ auto CompletionItem::filterText(std::optional filterText) repr_->erase("filterText"); return *this; } - repr_->emplace("filterText", std::move(filterText.value())); + (*repr_)["filterText"] = std::move(filterText.value()); return *this; } @@ -6350,7 +6253,7 @@ auto CompletionItem::insertText(std::optional insertText) repr_->erase("insertText"); return *this; } - repr_->emplace("insertText", std::move(insertText.value())); + (*repr_)["insertText"] = std::move(insertText.value()); return *this; } @@ -6360,8 +6263,7 @@ auto CompletionItem::insertTextFormat( repr_->erase("insertTextFormat"); return *this; } - repr_->emplace("insertTextFormat", - static_cast(insertTextFormat.value())); + (*repr_)["insertTextFormat"] = static_cast(insertTextFormat.value()); return *this; } @@ -6371,31 +6273,25 @@ auto CompletionItem::insertTextMode( repr_->erase("insertTextMode"); return *this; } - repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); + (*repr_)["insertTextMode"] = static_cast(insertTextMode.value()); return *this; } auto CompletionItem::textEdit( - std::optional> - textEdit) -> CompletionItem& { + 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()(TextEdit textEdit) { (*repr_)["textEdit"] = textEdit; } void operator()(InsertReplaceEdit textEdit) { - repr_->emplace("textEdit", textEdit); + (*repr_)["textEdit"] = textEdit; } } v{repr_}; @@ -6410,7 +6306,7 @@ auto CompletionItem::textEditText(std::optional textEditText) repr_->erase("textEditText"); return *this; } - repr_->emplace("textEditText", std::move(textEditText.value())); + (*repr_)["textEditText"] = std::move(textEditText.value()); return *this; } @@ -6440,7 +6336,7 @@ auto CompletionItem::command(std::optional command) repr_->erase("command"); return *this; } - repr_->emplace("command", command.value()); + (*repr_)["command"] = command.value(); return *this; } @@ -6463,6 +6359,7 @@ CompletionList::operator bool() const { auto CompletionList::isIncomplete() const -> bool { auto& value = (*repr_)["isIncomplete"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -6488,12 +6385,12 @@ auto CompletionList::applyKind() const auto CompletionList::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto CompletionList::isIncomplete(bool isIncomplete) -> CompletionList& { - repr_->emplace("isIncomplete", std::move(isIncomplete)); + (*repr_)["isIncomplete"] = std::move(isIncomplete); return *this; } @@ -6503,7 +6400,7 @@ auto CompletionList::itemDefaults( repr_->erase("itemDefaults"); return *this; } - repr_->emplace("itemDefaults", itemDefaults.value()); + (*repr_)["itemDefaults"] = itemDefaults.value(); return *this; } @@ -6513,7 +6410,7 @@ auto CompletionList::applyKind( repr_->erase("applyKind"); return *this; } - repr_->emplace("applyKind", applyKind.value()); + (*repr_)["applyKind"] = applyKind.value(); return *this; } @@ -6529,10 +6426,10 @@ CompletionRegistrationOptions::operator bool() const { } auto CompletionRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -6545,7 +6442,7 @@ auto CompletionRegistrationOptions::triggerCharacters() const auto& value = (*repr_)["triggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6555,7 +6452,7 @@ auto CompletionRegistrationOptions::allCommitCharacters() const auto& value = (*repr_)["allCommitCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6565,6 +6462,7 @@ auto CompletionRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -6584,29 +6482,24 @@ auto CompletionRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto CompletionRegistrationOptions::documentSelector( - std::variant - documentSelector) -> CompletionRegistrationOptions& { - // or type - + std::variant documentSelector) + -> CompletionRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -6645,7 +6538,7 @@ auto CompletionRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -6656,7 +6549,7 @@ auto CompletionRegistrationOptions::completionItem( repr_->erase("completionItem"); return *this; } - repr_->emplace("completionItem", completionItem.value()); + (*repr_)["completionItem"] = completionItem.value(); return *this; } @@ -6666,7 +6559,7 @@ auto CompletionRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -6703,12 +6596,12 @@ auto HoverParams::workDoneToken() const -> std::optional { auto HoverParams::textDocument(TextDocumentIdentifier textDocument) -> HoverParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto HoverParams::position(Position position) -> HoverParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -6729,13 +6622,10 @@ Hover::operator bool() const { } auto Hover::contents() const - -> std::variant> { + -> std::variant> { auto& value = (*repr_)["contents"]; - std::variant> - result; + std::variant> result; details::try_emplace(result, value); @@ -6750,21 +6640,13 @@ auto Hover::range() const -> std::optional { return Range(value); } -auto Hover::contents(std::variant> - contents) -> Hover& { - // or type - +auto Hover::contents( + std::variant> contents) + -> Hover& { 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()(MarkupContent contents) { (*repr_)["contents"] = contents; } void operator()(MarkedString contents) { lsp_runtime_error("Hover::contents: not implement yet"); @@ -6785,7 +6667,7 @@ auto Hover::range(std::optional range) -> Hover& { repr_->erase("range"); return *this; } - repr_->emplace("range", range.value()); + (*repr_)["range"] = range.value(); return *this; } @@ -6796,10 +6678,10 @@ HoverRegistrationOptions::operator bool() const { } auto HoverRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -6811,29 +6693,24 @@ auto HoverRegistrationOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto HoverRegistrationOptions::documentSelector( - std::variant - documentSelector) -> HoverRegistrationOptions& { - // or type - + std::variant documentSelector) + -> HoverRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -6848,7 +6725,7 @@ auto HoverRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -6899,18 +6776,18 @@ auto SignatureHelpParams::context(std::optional context) repr_->erase("context"); return *this; } - repr_->emplace("context", context.value()); + (*repr_)["context"] = context.value(); return *this; } auto SignatureHelpParams::textDocument(TextDocumentIdentifier textDocument) -> SignatureHelpParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto SignatureHelpParams::position(Position position) -> SignatureHelpParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -6933,7 +6810,7 @@ SignatureHelp::operator bool() const { auto SignatureHelp::signatures() const -> Vector { auto& value = (*repr_)["signatures"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -6942,17 +6819,18 @@ auto SignatureHelp::activeSignature() const -> std::optional { auto& value = (*repr_)["activeSignature"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } auto SignatureHelp::activeParameter() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("activeParameter")) return std::nullopt; auto& value = (*repr_)["activeParameter"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -6971,33 +6849,27 @@ auto SignatureHelp::activeSignature(std::optional activeSignature) repr_->erase("activeSignature"); return *this; } - repr_->emplace("activeSignature", std::move(activeSignature.value())); + (*repr_)["activeSignature"] = std::move(activeSignature.value()); return *this; } auto SignatureHelp::activeParameter( - std::optional> - activeParameter) -> SignatureHelp& { + 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)); + (*repr_)["activeParameter"] = std::move(activeParameter); } void operator()(std::nullptr_t activeParameter) { - repr_->emplace("activeParameter", std::move(activeParameter)); + (*repr_)["activeParameter"] = std::move(activeParameter); } } v{repr_}; @@ -7013,10 +6885,10 @@ SignatureHelpRegistrationOptions::operator bool() const { } auto SignatureHelpRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -7029,7 +6901,7 @@ auto SignatureHelpRegistrationOptions::triggerCharacters() const auto& value = (*repr_)["triggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -7039,7 +6911,7 @@ auto SignatureHelpRegistrationOptions::retriggerCharacters() const auto& value = (*repr_)["retriggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -7049,22 +6921,17 @@ auto SignatureHelpRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto SignatureHelpRegistrationOptions::documentSelector( - std::variant - documentSelector) -> SignatureHelpRegistrationOptions& { - // or type - + std::variant documentSelector) + -> SignatureHelpRegistrationOptions& { 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 " @@ -7072,7 +6939,7 @@ auto SignatureHelpRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -7112,7 +6979,7 @@ auto SignatureHelpRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -7162,12 +7029,12 @@ auto DefinitionParams::partialResultToken() const auto DefinitionParams::textDocument(TextDocumentIdentifier textDocument) -> DefinitionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DefinitionParams::position(Position position) -> DefinitionParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -7198,10 +7065,10 @@ DefinitionRegistrationOptions::operator bool() const { } auto DefinitionRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -7214,29 +7081,24 @@ auto DefinitionRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DefinitionRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DefinitionRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DefinitionRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -7251,7 +7113,7 @@ auto DefinitionRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -7307,18 +7169,18 @@ auto ReferenceParams::partialResultToken() const } auto ReferenceParams::context(ReferenceContext context) -> ReferenceParams& { - repr_->emplace("context", context); + (*repr_)["context"] = context; return *this; } auto ReferenceParams::textDocument(TextDocumentIdentifier textDocument) -> ReferenceParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto ReferenceParams::position(Position position) -> ReferenceParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -7349,10 +7211,10 @@ ReferenceRegistrationOptions::operator bool() const { } auto ReferenceRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -7365,29 +7227,24 @@ auto ReferenceRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto ReferenceRegistrationOptions::documentSelector( - std::variant - documentSelector) -> ReferenceRegistrationOptions& { - // or type - + std::variant documentSelector) + -> ReferenceRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -7402,7 +7259,7 @@ auto ReferenceRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -7453,13 +7310,13 @@ auto DocumentHighlightParams::partialResultToken() const auto DocumentHighlightParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentHighlightParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DocumentHighlightParams::position(Position position) -> DocumentHighlightParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -7507,7 +7364,7 @@ auto DocumentHighlight::kind() const -> std::optional { } auto DocumentHighlight::range(Range range) -> DocumentHighlight& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -7517,7 +7374,7 @@ auto DocumentHighlight::kind(std::optional kind) repr_->erase("kind"); return *this; } - repr_->emplace("kind", static_cast(kind.value())); + (*repr_)["kind"] = static_cast(kind.value()); return *this; } @@ -7528,10 +7385,10 @@ DocumentHighlightRegistrationOptions::operator bool() const { } auto DocumentHighlightRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -7544,22 +7401,17 @@ auto DocumentHighlightRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DocumentHighlightRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentHighlightRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentHighlightRegistrationOptions& { 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 " @@ -7567,7 +7419,7 @@ auto DocumentHighlightRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -7583,7 +7435,7 @@ auto DocumentHighlightRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -7627,7 +7479,7 @@ auto DocumentSymbolParams::partialResultToken() const auto DocumentSymbolParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentSymbolParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -7665,6 +7517,7 @@ auto SymbolInformation::deprecated() const -> std::optional { auto& value = (*repr_)["deprecated"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -7678,6 +7531,7 @@ auto SymbolInformation::location() const -> Location { auto SymbolInformation::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -7693,7 +7547,7 @@ auto SymbolInformation::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -7702,6 +7556,7 @@ auto SymbolInformation::containerName() const -> std::optional { auto& value = (*repr_)["containerName"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -7712,22 +7567,22 @@ auto SymbolInformation::deprecated(std::optional deprecated) repr_->erase("deprecated"); return *this; } - repr_->emplace("deprecated", std::move(deprecated.value())); + (*repr_)["deprecated"] = std::move(deprecated.value()); return *this; } auto SymbolInformation::location(Location location) -> SymbolInformation& { - repr_->emplace("location", location); + (*repr_)["location"] = location; return *this; } auto SymbolInformation::name(std::string name) -> SymbolInformation& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } auto SymbolInformation::kind(SymbolKind kind) -> SymbolInformation& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -7747,7 +7602,7 @@ auto SymbolInformation::containerName(std::optional containerName) repr_->erase("containerName"); return *this; } - repr_->emplace("containerName", std::move(containerName.value())); + (*repr_)["containerName"] = std::move(containerName.value()); return *this; } @@ -7763,6 +7618,7 @@ DocumentSymbol::operator bool() const { auto DocumentSymbol::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -7772,6 +7628,7 @@ auto DocumentSymbol::detail() const -> std::optional { auto& value = (*repr_)["detail"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -7787,7 +7644,7 @@ auto DocumentSymbol::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -7796,6 +7653,7 @@ auto DocumentSymbol::deprecated() const -> std::optional { auto& value = (*repr_)["deprecated"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -7817,12 +7675,12 @@ auto DocumentSymbol::children() const -> std::optional> { auto& value = (*repr_)["children"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DocumentSymbol::name(std::string name) -> DocumentSymbol& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } @@ -7832,12 +7690,12 @@ auto DocumentSymbol::detail(std::optional detail) repr_->erase("detail"); return *this; } - repr_->emplace("detail", std::move(detail.value())); + (*repr_)["detail"] = std::move(detail.value()); return *this; } auto DocumentSymbol::kind(SymbolKind kind) -> DocumentSymbol& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -7857,17 +7715,17 @@ auto DocumentSymbol::deprecated(std::optional deprecated) repr_->erase("deprecated"); return *this; } - repr_->emplace("deprecated", std::move(deprecated.value())); + (*repr_)["deprecated"] = std::move(deprecated.value()); return *this; } auto DocumentSymbol::range(Range range) -> DocumentSymbol& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto DocumentSymbol::selectionRange(Range selectionRange) -> DocumentSymbol& { - repr_->emplace("selectionRange", selectionRange); + (*repr_)["selectionRange"] = selectionRange; return *this; } @@ -7888,10 +7746,10 @@ DocumentSymbolRegistrationOptions::operator bool() const { } auto DocumentSymbolRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -7904,6 +7762,7 @@ auto DocumentSymbolRegistrationOptions::label() const auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -7914,22 +7773,17 @@ auto DocumentSymbolRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DocumentSymbolRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentSymbolRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentSymbolRegistrationOptions& { 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 " @@ -7937,7 +7791,7 @@ auto DocumentSymbolRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -7952,7 +7806,7 @@ auto DocumentSymbolRegistrationOptions::label(std::optional label) repr_->erase("label"); return *this; } - repr_->emplace("label", std::move(label.value())); + (*repr_)["label"] = std::move(label.value()); return *this; } @@ -7963,7 +7817,7 @@ auto DocumentSymbolRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -8020,17 +7874,17 @@ auto CodeActionParams::partialResultToken() const auto CodeActionParams::textDocument(TextDocumentIdentifier textDocument) -> CodeActionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto CodeActionParams::range(Range range) -> CodeActionParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto CodeActionParams::context(CodeActionContext context) -> CodeActionParams& { - repr_->emplace("context", context); + (*repr_)["context"] = context; return *this; } @@ -8064,6 +7918,7 @@ Command::operator bool() const { auto Command::title() const -> std::string { auto& value = (*repr_)["title"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8073,6 +7928,7 @@ auto Command::tooltip() const -> std::optional { auto& value = (*repr_)["tooltip"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8080,6 +7936,7 @@ auto Command::tooltip() const -> std::optional { auto Command::command() const -> std::string { auto& value = (*repr_)["command"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8089,12 +7946,12 @@ auto Command::arguments() const -> std::optional> { auto& value = (*repr_)["arguments"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto Command::title(std::string title) -> Command& { - repr_->emplace("title", std::move(title)); + (*repr_)["title"] = std::move(title); return *this; } @@ -8103,12 +7960,12 @@ auto Command::tooltip(std::optional tooltip) -> Command& { repr_->erase("tooltip"); return *this; } - repr_->emplace("tooltip", std::move(tooltip.value())); + (*repr_)["tooltip"] = std::move(tooltip.value()); return *this; } auto Command::command(std::string command) -> Command& { - repr_->emplace("command", std::move(command)); + (*repr_)["command"] = std::move(command); return *this; } @@ -8130,6 +7987,7 @@ CodeAction::operator bool() const { auto CodeAction::title() const -> std::string { auto& value = (*repr_)["title"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8147,7 +8005,7 @@ auto CodeAction::diagnostics() const -> std::optional> { auto& value = (*repr_)["diagnostics"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -8156,6 +8014,7 @@ auto CodeAction::isPreferred() const -> std::optional { auto& value = (*repr_)["isPreferred"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -8198,12 +8057,12 @@ auto CodeAction::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto CodeAction::title(std::string title) -> CodeAction& { - repr_->emplace("title", std::move(title)); + (*repr_)["title"] = std::move(title); return *this; } @@ -8231,7 +8090,7 @@ auto CodeAction::isPreferred(std::optional isPreferred) -> CodeAction& { repr_->erase("isPreferred"); return *this; } - repr_->emplace("isPreferred", std::move(isPreferred.value())); + (*repr_)["isPreferred"] = std::move(isPreferred.value()); return *this; } @@ -8241,7 +8100,7 @@ auto CodeAction::disabled(std::optional disabled) repr_->erase("disabled"); return *this; } - repr_->emplace("disabled", disabled.value()); + (*repr_)["disabled"] = disabled.value(); return *this; } @@ -8250,7 +8109,7 @@ auto CodeAction::edit(std::optional edit) -> CodeAction& { repr_->erase("edit"); return *this; } - repr_->emplace("edit", edit.value()); + (*repr_)["edit"] = edit.value(); return *this; } @@ -8259,7 +8118,7 @@ auto CodeAction::command(std::optional command) -> CodeAction& { repr_->erase("command"); return *this; } - repr_->emplace("command", command.value()); + (*repr_)["command"] = command.value(); return *this; } @@ -8289,10 +8148,10 @@ CodeActionRegistrationOptions::operator bool() const { } auto CodeActionRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -8305,7 +8164,7 @@ auto CodeActionRegistrationOptions::codeActionKinds() const auto& value = (*repr_)["codeActionKinds"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -8315,7 +8174,7 @@ auto CodeActionRegistrationOptions::documentation() const auto& value = (*repr_)["documentation"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -8325,6 +8184,7 @@ auto CodeActionRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -8335,29 +8195,24 @@ auto CodeActionRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto CodeActionRegistrationOptions::documentSelector( - std::variant - documentSelector) -> CodeActionRegistrationOptions& { - // or type - + std::variant documentSelector) + -> CodeActionRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -8396,7 +8251,7 @@ auto CodeActionRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -8406,7 +8261,7 @@ auto CodeActionRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -8419,6 +8274,7 @@ WorkspaceSymbolParams::operator bool() const { auto WorkspaceSymbolParams::query() const -> std::string { auto& value = (*repr_)["query"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8450,7 +8306,7 @@ auto WorkspaceSymbolParams::partialResultToken() const } auto WorkspaceSymbolParams::query(std::string query) -> WorkspaceSymbolParams& { - repr_->emplace("query", std::move(query)); + (*repr_)["query"] = std::move(query); return *this; } @@ -8484,10 +8340,10 @@ WorkspaceSymbol::operator bool() const { } auto WorkspaceSymbol::location() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["location"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -8506,6 +8362,7 @@ auto WorkspaceSymbol::data() const -> std::optional { auto WorkspaceSymbol::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8521,7 +8378,7 @@ auto WorkspaceSymbol::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -8530,26 +8387,20 @@ auto WorkspaceSymbol::containerName() const -> std::optional { auto& value = (*repr_)["containerName"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } -auto WorkspaceSymbol::location( - std::variant location) +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()(Location location) { (*repr_)["location"] = location; } void operator()(LocationUriOnly location) { - repr_->emplace("location", location); + (*repr_)["location"] = location; } } v{repr_}; @@ -8568,12 +8419,12 @@ auto WorkspaceSymbol::data(std::optional data) -> WorkspaceSymbol& { } auto WorkspaceSymbol::name(std::string name) -> WorkspaceSymbol& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } auto WorkspaceSymbol::kind(SymbolKind kind) -> WorkspaceSymbol& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -8593,7 +8444,7 @@ auto WorkspaceSymbol::containerName(std::optional containerName) repr_->erase("containerName"); return *this; } - repr_->emplace("containerName", std::move(containerName.value())); + (*repr_)["containerName"] = std::move(containerName.value()); return *this; } @@ -8608,6 +8459,7 @@ auto WorkspaceSymbolRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -8618,6 +8470,7 @@ auto WorkspaceSymbolRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -8629,7 +8482,7 @@ auto WorkspaceSymbolRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -8640,7 +8493,7 @@ auto WorkspaceSymbolRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -8683,7 +8536,7 @@ auto CodeLensParams::partialResultToken() const auto CodeLensParams::textDocument(TextDocumentIdentifier textDocument) -> CodeLensParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -8737,7 +8590,7 @@ auto CodeLens::data() const -> std::optional { } auto CodeLens::range(Range range) -> CodeLens& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -8746,7 +8599,7 @@ auto CodeLens::command(std::optional command) -> CodeLens& { repr_->erase("command"); return *this; } - repr_->emplace("command", command.value()); + (*repr_)["command"] = command.value(); return *this; } @@ -8766,10 +8619,10 @@ CodeLensRegistrationOptions::operator bool() const { } auto CodeLensRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -8782,6 +8635,7 @@ auto CodeLensRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -8792,29 +8646,24 @@ auto CodeLensRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto CodeLensRegistrationOptions::documentSelector( - std::variant - documentSelector) -> CodeLensRegistrationOptions& { - // or type - + std::variant documentSelector) + -> CodeLensRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -8829,7 +8678,7 @@ auto CodeLensRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -8839,7 +8688,7 @@ auto CodeLensRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -8882,7 +8731,7 @@ auto DocumentLinkParams::partialResultToken() const auto DocumentLinkParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentLinkParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -8924,6 +8773,7 @@ auto DocumentLink::target() const -> std::optional { auto& value = (*repr_)["target"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8933,6 +8783,7 @@ auto DocumentLink::tooltip() const -> std::optional { auto& value = (*repr_)["tooltip"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -8947,7 +8798,7 @@ auto DocumentLink::data() const -> std::optional { } auto DocumentLink::range(Range range) -> DocumentLink& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -8956,7 +8807,7 @@ auto DocumentLink::target(std::optional target) -> DocumentLink& { repr_->erase("target"); return *this; } - repr_->emplace("target", std::move(target.value())); + (*repr_)["target"] = std::move(target.value()); return *this; } @@ -8966,7 +8817,7 @@ auto DocumentLink::tooltip(std::optional tooltip) repr_->erase("tooltip"); return *this; } - repr_->emplace("tooltip", std::move(tooltip.value())); + (*repr_)["tooltip"] = std::move(tooltip.value()); return *this; } @@ -8986,10 +8837,10 @@ DocumentLinkRegistrationOptions::operator bool() const { } auto DocumentLinkRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -9002,6 +8853,7 @@ auto DocumentLinkRegistrationOptions::resolveProvider() const auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -9012,22 +8864,17 @@ auto DocumentLinkRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DocumentLinkRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentLinkRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentLinkRegistrationOptions& { 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 " @@ -9035,7 +8882,7 @@ auto DocumentLinkRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -9050,7 +8897,7 @@ auto DocumentLinkRegistrationOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -9060,7 +8907,7 @@ auto DocumentLinkRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -9098,13 +8945,13 @@ auto DocumentFormattingParams::workDoneToken() const auto DocumentFormattingParams::textDocument(TextDocumentIdentifier textDocument) -> DocumentFormattingParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DocumentFormattingParams::options(FormattingOptions options) -> DocumentFormattingParams& { - repr_->emplace("options", options); + (*repr_)["options"] = options; return *this; } @@ -9126,10 +8973,10 @@ DocumentFormattingRegistrationOptions::operator bool() const { } auto DocumentFormattingRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -9142,22 +8989,17 @@ auto DocumentFormattingRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DocumentFormattingRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentFormattingRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentFormattingRegistrationOptions& { 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 " @@ -9165,7 +9007,7 @@ auto DocumentFormattingRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -9181,7 +9023,7 @@ auto DocumentFormattingRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -9227,19 +9069,19 @@ auto DocumentRangeFormattingParams::workDoneToken() const auto DocumentRangeFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentRangeFormattingParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DocumentRangeFormattingParams::range(Range range) -> DocumentRangeFormattingParams& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto DocumentRangeFormattingParams::options(FormattingOptions options) -> DocumentRangeFormattingParams& { - repr_->emplace("options", options); + (*repr_)["options"] = options; return *this; } @@ -9262,10 +9104,10 @@ DocumentRangeFormattingRegistrationOptions::operator bool() const { } auto DocumentRangeFormattingRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -9278,6 +9120,7 @@ auto DocumentRangeFormattingRegistrationOptions::rangesSupport() const auto& value = (*repr_)["rangesSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -9288,22 +9131,17 @@ auto DocumentRangeFormattingRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto DocumentRangeFormattingRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentRangeFormattingRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentRangeFormattingRegistrationOptions& { 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 " @@ -9311,7 +9149,7 @@ auto DocumentRangeFormattingRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -9327,7 +9165,7 @@ auto DocumentRangeFormattingRegistrationOptions::rangesSupport( repr_->erase("rangesSupport"); return *this; } - repr_->emplace("rangesSupport", std::move(rangesSupport.value())); + (*repr_)["rangesSupport"] = std::move(rangesSupport.value()); return *this; } @@ -9338,7 +9176,7 @@ auto DocumentRangeFormattingRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -9360,7 +9198,7 @@ auto DocumentRangesFormattingParams::textDocument() const auto DocumentRangesFormattingParams::ranges() const -> Vector { auto& value = (*repr_)["ranges"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -9385,7 +9223,7 @@ auto DocumentRangesFormattingParams::workDoneToken() const auto DocumentRangesFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentRangesFormattingParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } @@ -9398,7 +9236,7 @@ auto DocumentRangesFormattingParams::ranges(Vector ranges) auto DocumentRangesFormattingParams::options(FormattingOptions options) -> DocumentRangesFormattingParams& { - repr_->emplace("options", options); + (*repr_)["options"] = options; return *this; } @@ -9439,6 +9277,7 @@ auto DocumentOnTypeFormattingParams::position() const -> Position { auto DocumentOnTypeFormattingParams::ch() const -> std::string { auto& value = (*repr_)["ch"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9451,25 +9290,25 @@ auto DocumentOnTypeFormattingParams::options() const -> FormattingOptions { auto DocumentOnTypeFormattingParams::textDocument( TextDocumentIdentifier textDocument) -> DocumentOnTypeFormattingParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto DocumentOnTypeFormattingParams::position(Position position) -> DocumentOnTypeFormattingParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } auto DocumentOnTypeFormattingParams::ch(std::string ch) -> DocumentOnTypeFormattingParams& { - repr_->emplace("ch", std::move(ch)); + (*repr_)["ch"] = std::move(ch); return *this; } auto DocumentOnTypeFormattingParams::options(FormattingOptions options) -> DocumentOnTypeFormattingParams& { - repr_->emplace("options", options); + (*repr_)["options"] = options; return *this; } @@ -9481,10 +9320,10 @@ DocumentOnTypeFormattingRegistrationOptions::operator bool() const { } auto DocumentOnTypeFormattingRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -9495,6 +9334,7 @@ auto DocumentOnTypeFormattingRegistrationOptions::firstTriggerCharacter() const -> std::string { auto& value = (*repr_)["firstTriggerCharacter"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9505,22 +9345,16 @@ auto DocumentOnTypeFormattingRegistrationOptions::moreTriggerCharacter() const auto& value = (*repr_)["moreTriggerCharacter"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DocumentOnTypeFormattingRegistrationOptions::documentSelector( - std::variant - documentSelector) -> DocumentOnTypeFormattingRegistrationOptions& { - // or type - + std::variant documentSelector) + -> DocumentOnTypeFormattingRegistrationOptions& { 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 " @@ -9528,7 +9362,7 @@ auto DocumentOnTypeFormattingRegistrationOptions::documentSelector( } void operator()(std::nullptr_t documentSelector) { - repr_->emplace("documentSelector", std::move(documentSelector)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -9540,7 +9374,7 @@ auto DocumentOnTypeFormattingRegistrationOptions::documentSelector( auto DocumentOnTypeFormattingRegistrationOptions::firstTriggerCharacter( std::string firstTriggerCharacter) -> DocumentOnTypeFormattingRegistrationOptions& { - repr_->emplace("firstTriggerCharacter", std::move(firstTriggerCharacter)); + (*repr_)["firstTriggerCharacter"] = std::move(firstTriggerCharacter); return *this; } @@ -9580,6 +9414,7 @@ auto RenameParams::position() const -> Position { auto RenameParams::newName() const -> std::string { auto& value = (*repr_)["newName"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9598,17 +9433,17 @@ auto RenameParams::workDoneToken() const -> std::optional { auto RenameParams::textDocument(TextDocumentIdentifier textDocument) -> RenameParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto RenameParams::position(Position position) -> RenameParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } auto RenameParams::newName(std::string newName) -> RenameParams& { - repr_->emplace("newName", std::move(newName)); + (*repr_)["newName"] = std::move(newName); return *this; } @@ -9629,10 +9464,10 @@ RenameRegistrationOptions::operator bool() const { } auto RenameRegistrationOptions::documentSelector() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["documentSelector"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -9644,6 +9479,7 @@ auto RenameRegistrationOptions::prepareProvider() const -> std::optional { auto& value = (*repr_)["prepareProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -9654,29 +9490,24 @@ auto RenameRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto RenameRegistrationOptions::documentSelector( - std::variant - documentSelector) -> RenameRegistrationOptions& { - // or type - + std::variant documentSelector) + -> RenameRegistrationOptions& { 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)); + (*repr_)["documentSelector"] = std::move(documentSelector); } } v{repr_}; @@ -9691,7 +9522,7 @@ auto RenameRegistrationOptions::prepareProvider( repr_->erase("prepareProvider"); return *this; } - repr_->emplace("prepareProvider", std::move(prepareProvider.value())); + (*repr_)["prepareProvider"] = std::move(prepareProvider.value()); return *this; } @@ -9701,7 +9532,7 @@ auto RenameRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -9739,12 +9570,12 @@ auto PrepareRenameParams::workDoneToken() const auto PrepareRenameParams::textDocument(TextDocumentIdentifier textDocument) -> PrepareRenameParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto PrepareRenameParams::position(Position position) -> PrepareRenameParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -9767,6 +9598,7 @@ ExecuteCommandParams::operator bool() const { auto ExecuteCommandParams::command() const -> std::string { auto& value = (*repr_)["command"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9776,7 +9608,7 @@ auto ExecuteCommandParams::arguments() const -> std::optional> { auto& value = (*repr_)["arguments"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -9795,7 +9627,7 @@ auto ExecuteCommandParams::workDoneToken() const auto ExecuteCommandParams::command(std::string command) -> ExecuteCommandParams& { - repr_->emplace("command", std::move(command)); + (*repr_)["command"] = std::move(command); return *this; } @@ -9829,7 +9661,7 @@ auto ExecuteCommandRegistrationOptions::commands() const -> Vector { auto& value = (*repr_)["commands"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -9839,6 +9671,7 @@ auto ExecuteCommandRegistrationOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -9857,7 +9690,7 @@ auto ExecuteCommandRegistrationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -9872,6 +9705,7 @@ auto ApplyWorkspaceEditParams::label() const -> std::optional { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9897,13 +9731,13 @@ auto ApplyWorkspaceEditParams::label(std::optional label) repr_->erase("label"); return *this; } - repr_->emplace("label", std::move(label.value())); + (*repr_)["label"] = std::move(label.value()); return *this; } auto ApplyWorkspaceEditParams::edit(WorkspaceEdit edit) -> ApplyWorkspaceEditParams& { - repr_->emplace("edit", edit); + (*repr_)["edit"] = edit; return *this; } @@ -9914,7 +9748,7 @@ auto ApplyWorkspaceEditParams::metadata( repr_->erase("metadata"); return *this; } - repr_->emplace("metadata", metadata.value()); + (*repr_)["metadata"] = metadata.value(); return *this; } @@ -9927,6 +9761,7 @@ ApplyWorkspaceEditResult::operator bool() const { auto ApplyWorkspaceEditResult::applied() const -> bool { auto& value = (*repr_)["applied"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -9937,6 +9772,7 @@ auto ApplyWorkspaceEditResult::failureReason() const auto& value = (*repr_)["failureReason"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -9946,13 +9782,14 @@ auto ApplyWorkspaceEditResult::failedChange() const -> std::optional { auto& value = (*repr_)["failedChange"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } auto ApplyWorkspaceEditResult::applied(bool applied) -> ApplyWorkspaceEditResult& { - repr_->emplace("applied", std::move(applied)); + (*repr_)["applied"] = std::move(applied); return *this; } @@ -9962,7 +9799,7 @@ auto ApplyWorkspaceEditResult::failureReason( repr_->erase("failureReason"); return *this; } - repr_->emplace("failureReason", std::move(failureReason.value())); + (*repr_)["failureReason"] = std::move(failureReason.value()); return *this; } @@ -9972,7 +9809,7 @@ auto ApplyWorkspaceEditResult::failedChange(std::optional failedChange) repr_->erase("failedChange"); return *this; } - repr_->emplace("failedChange", std::move(failedChange.value())); + (*repr_)["failedChange"] = std::move(failedChange.value()); return *this; } @@ -9987,6 +9824,7 @@ WorkDoneProgressBegin::operator bool() const { auto WorkDoneProgressBegin::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "begin"; assert(value.is_string()); return value.get(); } @@ -9994,6 +9832,7 @@ auto WorkDoneProgressBegin::kind() const -> std::string { auto WorkDoneProgressBegin::title() const -> std::string { auto& value = (*repr_)["title"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10003,6 +9842,7 @@ auto WorkDoneProgressBegin::cancellable() const -> std::optional { auto& value = (*repr_)["cancellable"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10012,6 +9852,7 @@ auto WorkDoneProgressBegin::message() const -> std::optional { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10021,6 +9862,7 @@ auto WorkDoneProgressBegin::percentage() const -> std::optional { auto& value = (*repr_)["percentage"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -10031,7 +9873,7 @@ auto WorkDoneProgressBegin::kind(std::string kind) -> WorkDoneProgressBegin& { } auto WorkDoneProgressBegin::title(std::string title) -> WorkDoneProgressBegin& { - repr_->emplace("title", std::move(title)); + (*repr_)["title"] = std::move(title); return *this; } @@ -10041,7 +9883,7 @@ auto WorkDoneProgressBegin::cancellable(std::optional cancellable) repr_->erase("cancellable"); return *this; } - repr_->emplace("cancellable", std::move(cancellable.value())); + (*repr_)["cancellable"] = std::move(cancellable.value()); return *this; } @@ -10051,7 +9893,7 @@ auto WorkDoneProgressBegin::message(std::optional message) repr_->erase("message"); return *this; } - repr_->emplace("message", std::move(message.value())); + (*repr_)["message"] = std::move(message.value()); return *this; } @@ -10061,7 +9903,7 @@ auto WorkDoneProgressBegin::percentage(std::optional percentage) repr_->erase("percentage"); return *this; } - repr_->emplace("percentage", std::move(percentage.value())); + (*repr_)["percentage"] = std::move(percentage.value()); return *this; } @@ -10075,6 +9917,7 @@ WorkDoneProgressReport::operator bool() const { auto WorkDoneProgressReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "report"; assert(value.is_string()); return value.get(); } @@ -10084,6 +9927,7 @@ auto WorkDoneProgressReport::cancellable() const -> std::optional { auto& value = (*repr_)["cancellable"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10093,6 +9937,7 @@ auto WorkDoneProgressReport::message() const -> std::optional { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10102,6 +9947,7 @@ auto WorkDoneProgressReport::percentage() const -> std::optional { auto& value = (*repr_)["percentage"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -10117,7 +9963,7 @@ auto WorkDoneProgressReport::cancellable(std::optional cancellable) repr_->erase("cancellable"); return *this; } - repr_->emplace("cancellable", std::move(cancellable.value())); + (*repr_)["cancellable"] = std::move(cancellable.value()); return *this; } @@ -10127,7 +9973,7 @@ auto WorkDoneProgressReport::message(std::optional message) repr_->erase("message"); return *this; } - repr_->emplace("message", std::move(message.value())); + (*repr_)["message"] = std::move(message.value()); return *this; } @@ -10137,7 +9983,7 @@ auto WorkDoneProgressReport::percentage(std::optional percentage) repr_->erase("percentage"); return *this; } - repr_->emplace("percentage", std::move(percentage.value())); + (*repr_)["percentage"] = std::move(percentage.value()); return *this; } @@ -10151,6 +9997,7 @@ WorkDoneProgressEnd::operator bool() const { auto WorkDoneProgressEnd::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "end"; assert(value.is_string()); return value.get(); } @@ -10160,6 +10007,7 @@ auto WorkDoneProgressEnd::message() const -> std::optional { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10175,7 +10023,7 @@ auto WorkDoneProgressEnd::message(std::optional message) repr_->erase("message"); return *this; } - repr_->emplace("message", std::move(message.value())); + (*repr_)["message"] = std::move(message.value()); return *this; } @@ -10205,6 +10053,7 @@ LogTraceParams::operator bool() const { auto LogTraceParams::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10214,12 +10063,13 @@ auto LogTraceParams::verbose() const -> std::optional { auto& value = (*repr_)["verbose"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto LogTraceParams::message(std::string message) -> LogTraceParams& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -10229,7 +10079,7 @@ auto LogTraceParams::verbose(std::optional verbose) repr_->erase("verbose"); return *this; } - repr_->emplace("verbose", std::move(verbose.value())); + (*repr_)["verbose"] = std::move(verbose.value()); return *this; } @@ -10239,31 +10089,23 @@ CancelParams::operator bool() const { return true; } -auto CancelParams::id() const - -> std::variant { +auto CancelParams::id() const -> std::variant { auto& value = (*repr_)["id"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto CancelParams::id(std::variant id) - -> CancelParams& { - // or type - +auto CancelParams::id(std::variant id) -> CancelParams& { 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()(int id) { (*repr_)["id"] = std::move(id); } - void operator()(std::string id) { repr_->emplace("id", std::move(id)); } + void operator()(std::string id) { (*repr_)["id"] = std::move(id); } } v{repr_}; std::visit(v, id); @@ -10327,13 +10169,13 @@ auto TextDocumentPositionParams::position() const -> Position { auto TextDocumentPositionParams::textDocument( TextDocumentIdentifier textDocument) -> TextDocumentPositionParams& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto TextDocumentPositionParams::position(Position position) -> TextDocumentPositionParams& { - repr_->emplace("position", position); + (*repr_)["position"] = position; return *this; } @@ -10413,6 +10255,7 @@ auto LocationLink::originSelectionRange() const -> std::optional { auto LocationLink::targetUri() const -> std::string { auto& value = (*repr_)["targetUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10435,23 +10278,23 @@ auto LocationLink::originSelectionRange( repr_->erase("originSelectionRange"); return *this; } - repr_->emplace("originSelectionRange", originSelectionRange.value()); + (*repr_)["originSelectionRange"] = originSelectionRange.value(); return *this; } auto LocationLink::targetUri(std::string targetUri) -> LocationLink& { - repr_->emplace("targetUri", std::move(targetUri)); + (*repr_)["targetUri"] = std::move(targetUri); return *this; } auto LocationLink::targetRange(Range targetRange) -> LocationLink& { - repr_->emplace("targetRange", targetRange); + (*repr_)["targetRange"] = targetRange; return *this; } auto LocationLink::targetSelectionRange(Range targetSelectionRange) -> LocationLink& { - repr_->emplace("targetSelectionRange", targetSelectionRange); + (*repr_)["targetSelectionRange"] = targetSelectionRange; return *this; } @@ -10475,12 +10318,12 @@ auto Range::end() const -> Position { } auto Range::start(Position start) -> Range& { - repr_->emplace("start", start); + (*repr_)["start"] = start; return *this; } auto Range::end(Position end) -> Range& { - repr_->emplace("end", end); + (*repr_)["end"] = end; return *this; } @@ -10494,6 +10337,7 @@ auto ImplementationOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10504,7 +10348,7 @@ auto ImplementationOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10518,6 +10362,7 @@ auto StaticRegistrationOptions::id() const -> std::optional { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10528,7 +10373,7 @@ auto StaticRegistrationOptions::id(std::optional id) repr_->erase("id"); return *this; } - repr_->emplace("id", std::move(id.value())); + (*repr_)["id"] = std::move(id.value()); return *this; } @@ -10542,6 +10387,7 @@ auto TypeDefinitionOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10552,7 +10398,7 @@ auto TypeDefinitionOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10566,14 +10412,14 @@ WorkspaceFoldersChangeEvent::operator bool() const { auto WorkspaceFoldersChangeEvent::added() const -> Vector { auto& value = (*repr_)["added"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto WorkspaceFoldersChangeEvent::removed() const -> Vector { auto& value = (*repr_)["removed"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -10599,6 +10445,7 @@ auto ConfigurationItem::scopeUri() const -> std::optional { auto& value = (*repr_)["scopeUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10608,6 +10455,7 @@ auto ConfigurationItem::section() const -> std::optional { auto& value = (*repr_)["section"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -10618,7 +10466,7 @@ auto ConfigurationItem::scopeUri(std::optional scopeUri) repr_->erase("scopeUri"); return *this; } - repr_->emplace("scopeUri", std::move(scopeUri.value())); + (*repr_)["scopeUri"] = std::move(scopeUri.value()); return *this; } @@ -10628,7 +10476,7 @@ auto ConfigurationItem::section(std::optional section) repr_->erase("section"); return *this; } - repr_->emplace("section", std::move(section.value())); + (*repr_)["section"] = std::move(section.value()); return *this; } @@ -10641,12 +10489,13 @@ TextDocumentIdentifier::operator bool() const { auto TextDocumentIdentifier::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentIdentifier::uri(std::string uri) -> TextDocumentIdentifier& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -10662,6 +10511,7 @@ Color::operator bool() const { auto Color::red() const -> double { auto& value = (*repr_)["red"]; + if (value.is_null()) value = 0.0; assert(value.is_number()); return value.get(); } @@ -10669,6 +10519,7 @@ auto Color::red() const -> double { auto Color::green() const -> double { auto& value = (*repr_)["green"]; + if (value.is_null()) value = 0.0; assert(value.is_number()); return value.get(); } @@ -10676,6 +10527,7 @@ auto Color::green() const -> double { auto Color::blue() const -> double { auto& value = (*repr_)["blue"]; + if (value.is_null()) value = 0.0; assert(value.is_number()); return value.get(); } @@ -10683,27 +10535,28 @@ auto Color::blue() const -> double { auto Color::alpha() const -> double { auto& value = (*repr_)["alpha"]; + if (value.is_null()) value = 0.0; assert(value.is_number()); return value.get(); } auto Color::red(double red) -> Color& { - repr_->emplace("red", std::move(red)); + (*repr_)["red"] = std::move(red); return *this; } auto Color::green(double green) -> Color& { - repr_->emplace("green", std::move(green)); + (*repr_)["green"] = std::move(green); return *this; } auto Color::blue(double blue) -> Color& { - repr_->emplace("blue", std::move(blue)); + (*repr_)["blue"] = std::move(blue); return *this; } auto Color::alpha(double alpha) -> Color& { - repr_->emplace("alpha", std::move(alpha)); + (*repr_)["alpha"] = std::move(alpha); return *this; } @@ -10717,6 +10570,7 @@ auto DocumentColorOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10727,7 +10581,7 @@ auto DocumentColorOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10741,6 +10595,7 @@ auto FoldingRangeOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10751,7 +10606,7 @@ auto FoldingRangeOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10765,6 +10620,7 @@ auto DeclarationOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10775,7 +10631,7 @@ auto DeclarationOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10789,6 +10645,7 @@ Position::operator bool() const { auto Position::line() const -> long { auto& value = (*repr_)["line"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -10796,17 +10653,18 @@ auto Position::line() const -> long { auto Position::character() const -> long { auto& value = (*repr_)["character"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } auto Position::line(long line) -> Position& { - repr_->emplace("line", std::move(line)); + (*repr_)["line"] = std::move(line); return *this; } auto Position::character(long character) -> Position& { - repr_->emplace("character", std::move(character)); + (*repr_)["character"] = std::move(character); return *this; } @@ -10820,6 +10678,7 @@ auto SelectionRangeOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10830,7 +10689,7 @@ auto SelectionRangeOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10844,6 +10703,7 @@ auto CallHierarchyOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -10854,7 +10714,7 @@ auto CallHierarchyOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10871,25 +10731,25 @@ auto SemanticTokensOptions::legend() const -> SemanticTokensLegend { } auto SemanticTokensOptions::range() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("range")) return std::nullopt; auto& value = (*repr_)["range"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto SemanticTokensOptions::full() const -> std::optional< - std::variant> { +auto SemanticTokensOptions::full() const + -> std::optional> { if (!repr_->contains("full")) return std::nullopt; auto& value = (*repr_)["full"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -10901,34 +10761,28 @@ auto SemanticTokensOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto SemanticTokensOptions::legend(SemanticTokensLegend legend) -> SemanticTokensOptions& { - repr_->emplace("legend", legend); + (*repr_)["legend"] = legend; return *this; } -auto SemanticTokensOptions::range( - std::optional> range) +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()(bool range) { (*repr_)["range"] = std::move(range); } void operator()(json range) { lsp_runtime_error("SemanticTokensOptions::range: not implement yet"); @@ -10941,27 +10795,19 @@ auto SemanticTokensOptions::range( } auto SemanticTokensOptions::full( - std::optional> - full) -> SemanticTokensOptions& { + 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()(bool full) { (*repr_)["full"] = std::move(full); } - void operator()(SemanticTokensFullDelta full) { - repr_->emplace("full", full); - } + void operator()(SemanticTokensFullDelta full) { (*repr_)["full"] = full; } } v{repr_}; std::visit(v, full.value()); @@ -10975,7 +10821,7 @@ auto SemanticTokensOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -10989,6 +10835,7 @@ SemanticTokensEdit::operator bool() const { auto SemanticTokensEdit::start() const -> long { auto& value = (*repr_)["start"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -10996,6 +10843,7 @@ auto SemanticTokensEdit::start() const -> long { auto SemanticTokensEdit::deleteCount() const -> long { auto& value = (*repr_)["deleteCount"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -11005,17 +10853,17 @@ auto SemanticTokensEdit::data() const -> std::optional> { auto& value = (*repr_)["data"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto SemanticTokensEdit::start(long start) -> SemanticTokensEdit& { - repr_->emplace("start", std::move(start)); + (*repr_)["start"] = std::move(start); return *this; } auto SemanticTokensEdit::deleteCount(long deleteCount) -> SemanticTokensEdit& { - repr_->emplace("deleteCount", std::move(deleteCount)); + (*repr_)["deleteCount"] = std::move(deleteCount); return *this; } @@ -11040,6 +10888,7 @@ auto LinkedEditingRangeOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11050,7 +10899,7 @@ auto LinkedEditingRangeOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -11063,12 +10912,13 @@ FileCreate::operator bool() const { auto FileCreate::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto FileCreate::uri(std::string uri) -> FileCreate& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -11087,25 +10937,23 @@ auto TextDocumentEdit::textDocument() const } auto TextDocumentEdit::edits() const - -> Vector> { + -> Vector> { auto& value = (*repr_)["edits"]; - assert(value.is_array()); - return Vector>(value); + if (value.is_null()) value = json::array(); + return Vector>( + value); } auto TextDocumentEdit::textDocument( OptionalVersionedTextDocumentIdentifier textDocument) -> TextDocumentEdit& { - repr_->emplace("textDocument", textDocument); + (*repr_)["textDocument"] = textDocument; return *this; } auto TextDocumentEdit::edits( - Vector> - edits) -> TextDocumentEdit& { + Vector> edits) + -> TextDocumentEdit& { lsp_runtime_error("TextDocumentEdit::edits: not implement yet"); return *this; } @@ -11121,6 +10969,7 @@ CreateFile::operator bool() const { auto CreateFile::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "create"; assert(value.is_string()); return value.get(); } @@ -11128,6 +10977,7 @@ auto CreateFile::kind() const -> std::string { auto CreateFile::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11146,6 +10996,7 @@ auto CreateFile::annotationId() const auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11156,7 +11007,7 @@ auto CreateFile::kind(std::string kind) -> CreateFile& { } auto CreateFile::uri(std::string uri) -> CreateFile& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -11166,7 +11017,7 @@ auto CreateFile::options(std::optional options) repr_->erase("options"); return *this; } - repr_->emplace("options", options.value()); + (*repr_)["options"] = options.value(); return *this; } @@ -11192,6 +11043,7 @@ RenameFile::operator bool() const { auto RenameFile::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "rename"; assert(value.is_string()); return value.get(); } @@ -11199,6 +11051,7 @@ auto RenameFile::kind() const -> std::string { auto RenameFile::oldUri() const -> std::string { auto& value = (*repr_)["oldUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11206,6 +11059,7 @@ auto RenameFile::oldUri() const -> std::string { auto RenameFile::newUri() const -> std::string { auto& value = (*repr_)["newUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11224,6 +11078,7 @@ auto RenameFile::annotationId() const auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11234,12 +11089,12 @@ auto RenameFile::kind(std::string kind) -> RenameFile& { } auto RenameFile::oldUri(std::string oldUri) -> RenameFile& { - repr_->emplace("oldUri", std::move(oldUri)); + (*repr_)["oldUri"] = std::move(oldUri); return *this; } auto RenameFile::newUri(std::string newUri) -> RenameFile& { - repr_->emplace("newUri", std::move(newUri)); + (*repr_)["newUri"] = std::move(newUri); return *this; } @@ -11249,7 +11104,7 @@ auto RenameFile::options(std::optional options) repr_->erase("options"); return *this; } - repr_->emplace("options", options.value()); + (*repr_)["options"] = options.value(); return *this; } @@ -11274,6 +11129,7 @@ DeleteFile::operator bool() const { auto DeleteFile::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "delete"; assert(value.is_string()); return value.get(); } @@ -11281,6 +11137,7 @@ auto DeleteFile::kind() const -> std::string { auto DeleteFile::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11299,6 +11156,7 @@ auto DeleteFile::annotationId() const auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11309,7 +11167,7 @@ auto DeleteFile::kind(std::string kind) -> DeleteFile& { } auto DeleteFile::uri(std::string uri) -> DeleteFile& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -11319,7 +11177,7 @@ auto DeleteFile::options(std::optional options) repr_->erase("options"); return *this; } - repr_->emplace("options", options.value()); + (*repr_)["options"] = options.value(); return *this; } @@ -11342,6 +11200,7 @@ ChangeAnnotation::operator bool() const { auto ChangeAnnotation::label() const -> std::string { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11351,6 +11210,7 @@ auto ChangeAnnotation::needsConfirmation() const -> std::optional { auto& value = (*repr_)["needsConfirmation"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11360,12 +11220,13 @@ auto ChangeAnnotation::description() const -> std::optional { auto& value = (*repr_)["description"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ChangeAnnotation::label(std::string label) -> ChangeAnnotation& { - repr_->emplace("label", std::move(label)); + (*repr_)["label"] = std::move(label); return *this; } @@ -11375,7 +11236,7 @@ auto ChangeAnnotation::needsConfirmation(std::optional needsConfirmation) repr_->erase("needsConfirmation"); return *this; } - repr_->emplace("needsConfirmation", std::move(needsConfirmation.value())); + (*repr_)["needsConfirmation"] = std::move(needsConfirmation.value()); return *this; } @@ -11385,7 +11246,7 @@ auto ChangeAnnotation::description(std::optional description) repr_->erase("description"); return *this; } - repr_->emplace("description", std::move(description.value())); + (*repr_)["description"] = std::move(description.value()); return *this; } @@ -11400,6 +11261,7 @@ auto FileOperationFilter::scheme() const -> std::optional { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11416,13 +11278,13 @@ auto FileOperationFilter::scheme(std::optional scheme) repr_->erase("scheme"); return *this; } - repr_->emplace("scheme", std::move(scheme.value())); + (*repr_)["scheme"] = std::move(scheme.value()); return *this; } auto FileOperationFilter::pattern(FileOperationPattern pattern) -> FileOperationFilter& { - repr_->emplace("pattern", pattern); + (*repr_)["pattern"] = pattern; return *this; } @@ -11436,6 +11298,7 @@ FileRename::operator bool() const { auto FileRename::oldUri() const -> std::string { auto& value = (*repr_)["oldUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11443,17 +11306,18 @@ auto FileRename::oldUri() const -> std::string { auto FileRename::newUri() const -> std::string { auto& value = (*repr_)["newUri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto FileRename::oldUri(std::string oldUri) -> FileRename& { - repr_->emplace("oldUri", std::move(oldUri)); + (*repr_)["oldUri"] = std::move(oldUri); return *this; } auto FileRename::newUri(std::string newUri) -> FileRename& { - repr_->emplace("newUri", std::move(newUri)); + (*repr_)["newUri"] = std::move(newUri); return *this; } @@ -11466,12 +11330,13 @@ FileDelete::operator bool() const { auto FileDelete::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto FileDelete::uri(std::string uri) -> FileDelete& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -11485,6 +11350,7 @@ auto MonikerOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11495,7 +11361,7 @@ auto MonikerOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -11509,6 +11375,7 @@ auto TypeHierarchyOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11519,7 +11386,7 @@ auto TypeHierarchyOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -11533,6 +11400,7 @@ InlineValueContext::operator bool() const { auto InlineValueContext::frameId() const -> int { auto& value = (*repr_)["frameId"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -11544,13 +11412,13 @@ auto InlineValueContext::stoppedLocation() const -> Range { } auto InlineValueContext::frameId(int frameId) -> InlineValueContext& { - repr_->emplace("frameId", std::move(frameId)); + (*repr_)["frameId"] = std::move(frameId); return *this; } auto InlineValueContext::stoppedLocation(Range stoppedLocation) -> InlineValueContext& { - repr_->emplace("stoppedLocation", stoppedLocation); + (*repr_)["stoppedLocation"] = stoppedLocation; return *this; } @@ -11570,17 +11438,18 @@ auto InlineValueText::range() const -> Range { auto InlineValueText::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto InlineValueText::range(Range range) -> InlineValueText& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto InlineValueText::text(std::string text) -> InlineValueText& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -11603,6 +11472,7 @@ auto InlineValueVariableLookup::variableName() const auto& value = (*repr_)["variableName"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11610,13 +11480,14 @@ auto InlineValueVariableLookup::variableName() const auto InlineValueVariableLookup::caseSensitiveLookup() const -> bool { auto& value = (*repr_)["caseSensitiveLookup"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto InlineValueVariableLookup::range(Range range) -> InlineValueVariableLookup& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -11626,13 +11497,13 @@ auto InlineValueVariableLookup::variableName( repr_->erase("variableName"); return *this; } - repr_->emplace("variableName", std::move(variableName.value())); + (*repr_)["variableName"] = std::move(variableName.value()); return *this; } auto InlineValueVariableLookup::caseSensitiveLookup(bool caseSensitiveLookup) -> InlineValueVariableLookup& { - repr_->emplace("caseSensitiveLookup", std::move(caseSensitiveLookup)); + (*repr_)["caseSensitiveLookup"] = std::move(caseSensitiveLookup); return *this; } @@ -11654,13 +11525,14 @@ auto InlineValueEvaluatableExpression::expression() const auto& value = (*repr_)["expression"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto InlineValueEvaluatableExpression::range(Range range) -> InlineValueEvaluatableExpression& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -11671,7 +11543,7 @@ auto InlineValueEvaluatableExpression::expression( repr_->erase("expression"); return *this; } - repr_->emplace("expression", std::move(expression.value())); + (*repr_)["expression"] = std::move(expression.value()); return *this; } @@ -11685,6 +11557,7 @@ auto InlineValueOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11695,7 +11568,7 @@ auto InlineValueOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -11708,17 +11581,18 @@ InlayHintLabelPart::operator bool() const { auto InlayHintLabelPart::value() const -> std::string { auto& value = (*repr_)["value"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto InlayHintLabelPart::tooltip() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("tooltip")) return std::nullopt; auto& value = (*repr_)["tooltip"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -11742,34 +11616,26 @@ auto InlayHintLabelPart::command() const -> std::optional { } auto InlayHintLabelPart::value(std::string value) -> InlayHintLabelPart& { - repr_->emplace("value", std::move(value)); + (*repr_)["value"] = std::move(value); return *this; } auto InlayHintLabelPart::tooltip( - std::optional> - tooltip) -> InlayHintLabelPart& { + 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)); + (*repr_)["tooltip"] = std::move(tooltip); } - void operator()(MarkupContent tooltip) { - repr_->emplace("tooltip", tooltip); - } + void operator()(MarkupContent tooltip) { (*repr_)["tooltip"] = tooltip; } } v{repr_}; std::visit(v, tooltip.value()); @@ -11783,7 +11649,7 @@ auto InlayHintLabelPart::location(std::optional location) repr_->erase("location"); return *this; } - repr_->emplace("location", location.value()); + (*repr_)["location"] = location.value(); return *this; } @@ -11793,7 +11659,7 @@ auto InlayHintLabelPart::command(std::optional command) repr_->erase("command"); return *this; } - repr_->emplace("command", command.value()); + (*repr_)["command"] = command.value(); return *this; } @@ -11813,6 +11679,7 @@ auto MarkupContent::kind() const -> MarkupKind { auto MarkupContent::value() const -> std::string { auto& value = (*repr_)["value"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11823,7 +11690,7 @@ auto MarkupContent::kind(MarkupKind kind) -> MarkupContent& { } auto MarkupContent::value(std::string value) -> MarkupContent& { - repr_->emplace("value", std::move(value)); + (*repr_)["value"] = std::move(value); return *this; } @@ -11837,6 +11704,7 @@ auto InlayHintOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11846,6 +11714,7 @@ auto InlayHintOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -11856,7 +11725,7 @@ auto InlayHintOptions::resolveProvider(std::optional resolveProvider) repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -11866,7 +11735,7 @@ auto InlayHintOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -11879,22 +11748,23 @@ RelatedFullDocumentDiagnosticReport::operator bool() const { } auto RelatedFullDocumentDiagnosticReport::relatedDocuments() const - -> std::optional>> { + -> std::optional< + Map>> { if (!repr_->contains("relatedDocuments")) return std::nullopt; auto& value = (*repr_)["relatedDocuments"]; - assert(value.is_object()); - return Map>(value); + if (value.is_null()) value = json::object(); + return Map>( + value); } auto RelatedFullDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "full"; assert(value.is_string()); return value.get(); } @@ -11905,6 +11775,7 @@ auto RelatedFullDocumentDiagnosticReport::resultId() const auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -11912,14 +11783,14 @@ auto RelatedFullDocumentDiagnosticReport::resultId() const auto RelatedFullDocumentDiagnosticReport::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto RelatedFullDocumentDiagnosticReport::relatedDocuments( - std::optional>> + std::optional< + Map>> relatedDocuments) -> RelatedFullDocumentDiagnosticReport& { if (!relatedDocuments.has_value()) { repr_->erase("relatedDocuments"); @@ -11945,7 +11816,7 @@ auto RelatedFullDocumentDiagnosticReport::resultId( repr_->erase("resultId"); return *this; } - repr_->emplace("resultId", std::move(resultId.value())); + (*repr_)["resultId"] = std::move(resultId.value()); return *this; } @@ -11965,22 +11836,23 @@ RelatedUnchangedDocumentDiagnosticReport::operator bool() const { } auto RelatedUnchangedDocumentDiagnosticReport::relatedDocuments() const - -> std::optional>> { + -> std::optional< + Map>> { if (!repr_->contains("relatedDocuments")) return std::nullopt; auto& value = (*repr_)["relatedDocuments"]; - assert(value.is_object()); - return Map>(value); + if (value.is_null()) value = json::object(); + return Map>( + value); } auto RelatedUnchangedDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "unchanged"; assert(value.is_string()); return value.get(); } @@ -11988,14 +11860,15 @@ auto RelatedUnchangedDocumentDiagnosticReport::kind() const -> std::string { auto RelatedUnchangedDocumentDiagnosticReport::resultId() const -> std::string { auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto RelatedUnchangedDocumentDiagnosticReport::relatedDocuments( - std::optional>> + std::optional< + Map>> relatedDocuments) -> RelatedUnchangedDocumentDiagnosticReport& { if (!relatedDocuments.has_value()) { repr_->erase("relatedDocuments"); @@ -12016,7 +11889,7 @@ auto RelatedUnchangedDocumentDiagnosticReport::kind(std::string kind) auto RelatedUnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> RelatedUnchangedDocumentDiagnosticReport& { - repr_->emplace("resultId", std::move(resultId)); + (*repr_)["resultId"] = std::move(resultId); return *this; } @@ -12031,6 +11904,7 @@ FullDocumentDiagnosticReport::operator bool() const { auto FullDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "full"; assert(value.is_string()); return value.get(); } @@ -12041,6 +11915,7 @@ auto FullDocumentDiagnosticReport::resultId() const auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12048,7 +11923,7 @@ auto FullDocumentDiagnosticReport::resultId() const auto FullDocumentDiagnosticReport::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -12064,7 +11939,7 @@ auto FullDocumentDiagnosticReport::resultId(std::optional resultId) repr_->erase("resultId"); return *this; } - repr_->emplace("resultId", std::move(resultId.value())); + (*repr_)["resultId"] = std::move(resultId.value()); return *this; } @@ -12085,6 +11960,7 @@ UnchangedDocumentDiagnosticReport::operator bool() const { auto UnchangedDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "unchanged"; assert(value.is_string()); return value.get(); } @@ -12092,6 +11968,7 @@ auto UnchangedDocumentDiagnosticReport::kind() const -> std::string { auto UnchangedDocumentDiagnosticReport::resultId() const -> std::string { auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12105,7 +11982,7 @@ auto UnchangedDocumentDiagnosticReport::kind(std::string kind) auto UnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> UnchangedDocumentDiagnosticReport& { - repr_->emplace("resultId", std::move(resultId)); + (*repr_)["resultId"] = std::move(resultId); return *this; } @@ -12121,6 +11998,7 @@ auto DiagnosticOptions::identifier() const -> std::optional { auto& value = (*repr_)["identifier"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12128,6 +12006,7 @@ auto DiagnosticOptions::identifier() const -> std::optional { auto DiagnosticOptions::interFileDependencies() const -> bool { auto& value = (*repr_)["interFileDependencies"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -12135,6 +12014,7 @@ auto DiagnosticOptions::interFileDependencies() const -> bool { auto DiagnosticOptions::workspaceDiagnostics() const -> bool { auto& value = (*repr_)["workspaceDiagnostics"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -12144,6 +12024,7 @@ auto DiagnosticOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -12154,19 +12035,19 @@ auto DiagnosticOptions::identifier(std::optional identifier) repr_->erase("identifier"); return *this; } - repr_->emplace("identifier", std::move(identifier.value())); + (*repr_)["identifier"] = std::move(identifier.value()); return *this; } auto DiagnosticOptions::interFileDependencies(bool interFileDependencies) -> DiagnosticOptions& { - repr_->emplace("interFileDependencies", std::move(interFileDependencies)); + (*repr_)["interFileDependencies"] = std::move(interFileDependencies); return *this; } auto DiagnosticOptions::workspaceDiagnostics(bool workspaceDiagnostics) -> DiagnosticOptions& { - repr_->emplace("workspaceDiagnostics", std::move(workspaceDiagnostics)); + (*repr_)["workspaceDiagnostics"] = std::move(workspaceDiagnostics); return *this; } @@ -12176,7 +12057,7 @@ auto DiagnosticOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -12190,6 +12071,7 @@ PreviousResultId::operator bool() const { auto PreviousResultId::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12197,17 +12079,18 @@ auto PreviousResultId::uri() const -> std::string { auto PreviousResultId::value() const -> std::string { auto& value = (*repr_)["value"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto PreviousResultId::uri(std::string uri) -> PreviousResultId& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto PreviousResultId::value(std::string value) -> PreviousResultId& { - repr_->emplace("value", std::move(value)); + (*repr_)["value"] = std::move(value); return *this; } @@ -12223,6 +12106,7 @@ NotebookDocument::operator bool() const { auto NotebookDocument::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12230,6 +12114,7 @@ auto NotebookDocument::uri() const -> std::string { auto NotebookDocument::notebookType() const -> std::string { auto& value = (*repr_)["notebookType"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12237,6 +12122,7 @@ auto NotebookDocument::notebookType() const -> std::string { auto NotebookDocument::version() const -> int { auto& value = (*repr_)["version"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -12253,23 +12139,23 @@ auto NotebookDocument::metadata() const -> std::optional { auto NotebookDocument::cells() const -> Vector { auto& value = (*repr_)["cells"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookDocument::uri(std::string uri) -> NotebookDocument& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto NotebookDocument::notebookType(std::string notebookType) -> NotebookDocument& { - repr_->emplace("notebookType", std::move(notebookType)); + (*repr_)["notebookType"] = std::move(notebookType); return *this; } auto NotebookDocument::version(int version) -> NotebookDocument& { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); return *this; } @@ -12300,6 +12186,7 @@ TextDocumentItem::operator bool() const { auto TextDocumentItem::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12313,6 +12200,7 @@ auto TextDocumentItem::languageId() const -> LanguageKind { auto TextDocumentItem::version() const -> int { auto& value = (*repr_)["version"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -12320,12 +12208,13 @@ auto TextDocumentItem::version() const -> int { auto TextDocumentItem::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentItem::uri(std::string uri) -> TextDocumentItem& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -12336,12 +12225,12 @@ auto TextDocumentItem::languageId(LanguageKind languageId) } auto TextDocumentItem::version(int version) -> TextDocumentItem& { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); return *this; } auto TextDocumentItem::text(std::string text) -> TextDocumentItem& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -12352,12 +12241,12 @@ NotebookDocumentSyncOptions::operator bool() const { } auto NotebookDocumentSyncOptions::notebookSelector() const - -> Vector Vector> { auto& value = (*repr_)["notebookSelector"]; - assert(value.is_array()); - return Vector>(value); } @@ -12366,12 +12255,13 @@ auto NotebookDocumentSyncOptions::save() const -> std::optional { auto& value = (*repr_)["save"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto NotebookDocumentSyncOptions::notebookSelector( - Vector> notebookSelector) -> NotebookDocumentSyncOptions& { lsp_runtime_error( @@ -12385,7 +12275,7 @@ auto NotebookDocumentSyncOptions::save(std::optional save) repr_->erase("save"); return *this; } - repr_->emplace("save", std::move(save.value())); + (*repr_)["save"] = std::move(save.value()); return *this; } @@ -12399,6 +12289,7 @@ VersionedNotebookDocumentIdentifier::operator bool() const { auto VersionedNotebookDocumentIdentifier::version() const -> int { auto& value = (*repr_)["version"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -12406,19 +12297,20 @@ auto VersionedNotebookDocumentIdentifier::version() const -> int { auto VersionedNotebookDocumentIdentifier::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto VersionedNotebookDocumentIdentifier::version(int version) -> VersionedNotebookDocumentIdentifier& { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); return *this; } auto VersionedNotebookDocumentIdentifier::uri(std::string uri) -> VersionedNotebookDocumentIdentifier& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -12462,7 +12354,7 @@ auto NotebookDocumentChangeEvent::cells( repr_->erase("cells"); return *this; } - repr_->emplace("cells", cells.value()); + (*repr_)["cells"] = cells.value(); return *this; } @@ -12475,13 +12367,14 @@ NotebookDocumentIdentifier::operator bool() const { auto NotebookDocumentIdentifier::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto NotebookDocumentIdentifier::uri(std::string uri) -> NotebookDocumentIdentifier& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -12509,7 +12402,7 @@ auto InlineCompletionContext::selectedCompletionInfo() const auto InlineCompletionContext::triggerKind( InlineCompletionTriggerKind triggerKind) -> InlineCompletionContext& { - repr_->emplace("triggerKind", static_cast(triggerKind)); + (*repr_)["triggerKind"] = static_cast(triggerKind); return *this; } @@ -12520,7 +12413,7 @@ auto InlineCompletionContext::selectedCompletionInfo( repr_->erase("selectedCompletionInfo"); return *this; } - repr_->emplace("selectedCompletionInfo", selectedCompletionInfo.value()); + (*repr_)["selectedCompletionInfo"] = selectedCompletionInfo.value(); return *this; } @@ -12535,6 +12428,7 @@ StringValue::operator bool() const { auto StringValue::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "snippet"; assert(value.is_string()); return value.get(); } @@ -12542,6 +12436,7 @@ auto StringValue::kind() const -> std::string { auto StringValue::value() const -> std::string { auto& value = (*repr_)["value"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12552,7 +12447,7 @@ auto StringValue::kind(std::string kind) -> StringValue& { } auto StringValue::value(std::string value) -> StringValue& { - repr_->emplace("value", std::move(value)); + (*repr_)["value"] = std::move(value); return *this; } @@ -12566,6 +12461,7 @@ auto InlineCompletionOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -12576,7 +12472,7 @@ auto InlineCompletionOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -12589,7 +12485,7 @@ TextDocumentContentOptions::operator bool() const { auto TextDocumentContentOptions::schemes() const -> Vector { auto& value = (*repr_)["schemes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -12609,6 +12505,7 @@ Registration::operator bool() const { auto Registration::id() const -> std::string { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12616,6 +12513,7 @@ auto Registration::id() const -> std::string { auto Registration::method() const -> std::string { auto& value = (*repr_)["method"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12630,12 +12528,12 @@ auto Registration::registerOptions() const -> std::optional { } auto Registration::id(std::string id) -> Registration& { - repr_->emplace("id", std::move(id)); + (*repr_)["id"] = std::move(id); return *this; } auto Registration::method(std::string method) -> Registration& { - repr_->emplace("method", std::move(method)); + (*repr_)["method"] = std::move(method); return *this; } @@ -12659,6 +12557,7 @@ Unregistration::operator bool() const { auto Unregistration::id() const -> std::string { auto& value = (*repr_)["id"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -12666,17 +12565,18 @@ auto Unregistration::id() const -> std::string { auto Unregistration::method() const -> std::string { auto& value = (*repr_)["method"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto Unregistration::id(std::string id) -> Unregistration& { - repr_->emplace("id", std::move(id)); + (*repr_)["id"] = std::move(id); return *this; } auto Unregistration::method(std::string method) -> Unregistration& { - repr_->emplace("method", std::move(method)); + (*repr_)["method"] = std::move(method); return *this; } @@ -12688,11 +12588,10 @@ _InitializeParams::operator bool() const { return true; } -auto _InitializeParams::processId() const - -> std::variant { +auto _InitializeParams::processId() const -> std::variant { auto& value = (*repr_)["processId"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -12712,17 +12611,18 @@ auto _InitializeParams::locale() const -> std::optional { auto& value = (*repr_)["locale"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } -auto _InitializeParams::rootPath() const -> std::optional< - std::variant> { +auto _InitializeParams::rootPath() const + -> std::optional> { if (!repr_->contains("rootPath")) return std::nullopt; auto& value = (*repr_)["rootPath"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -12730,10 +12630,10 @@ auto _InitializeParams::rootPath() const -> std::optional< } auto _InitializeParams::rootUri() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["rootUri"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -12775,24 +12675,17 @@ auto _InitializeParams::workDoneToken() const -> std::optional { return result; } -auto _InitializeParams::processId( - std::variant processId) +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)); + (*repr_)["processId"] = std::move(processId); } void operator()(std::nullptr_t processId) { - repr_->emplace("processId", std::move(processId)); + (*repr_)["processId"] = std::move(processId); } } v{repr_}; @@ -12807,7 +12700,7 @@ auto _InitializeParams::clientInfo(std::optional clientInfo) repr_->erase("clientInfo"); return *this; } - repr_->emplace("clientInfo", clientInfo.value()); + (*repr_)["clientInfo"] = clientInfo.value(); return *this; } @@ -12817,33 +12710,27 @@ auto _InitializeParams::locale(std::optional locale) repr_->erase("locale"); return *this; } - repr_->emplace("locale", std::move(locale.value())); + (*repr_)["locale"] = std::move(locale.value()); return *this; } auto _InitializeParams::rootPath( - std::optional> - rootPath) -> _InitializeParams& { + 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)); + (*repr_)["rootPath"] = std::move(rootPath); } void operator()(std::nullptr_t rootPath) { - repr_->emplace("rootPath", std::move(rootPath)); + (*repr_)["rootPath"] = std::move(rootPath); } } v{repr_}; @@ -12853,23 +12740,16 @@ auto _InitializeParams::rootPath( } auto _InitializeParams::rootUri( - std::variant rootUri) - -> _InitializeParams& { - // or type - + std::variant rootUri) -> _InitializeParams& { 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)); + (*repr_)["rootUri"] = std::move(rootUri); } void operator()(std::nullptr_t rootUri) { - repr_->emplace("rootUri", std::move(rootUri)); + (*repr_)["rootUri"] = std::move(rootUri); } } v{repr_}; @@ -12880,7 +12760,7 @@ auto _InitializeParams::rootUri( auto _InitializeParams::capabilities(ClientCapabilities capabilities) -> _InitializeParams& { - repr_->emplace("capabilities", capabilities); + (*repr_)["capabilities"] = capabilities; return *this; } @@ -12921,13 +12801,12 @@ WorkspaceFoldersInitializeParams::operator bool() const { } auto WorkspaceFoldersInitializeParams::workspaceFolders() const - -> std::optional< - std::variant, std::nullptr_t>> { + -> std::optional, std::nullptr_t>> { if (!repr_->contains("workspaceFolders")) return std::nullopt; auto& value = (*repr_)["workspaceFolders"]; - std::variant, std::nullptr_t> result; + std::variant, std::nullptr_t> result; details::try_emplace(result, value); @@ -12935,23 +12814,16 @@ auto WorkspaceFoldersInitializeParams::workspaceFolders() const } auto WorkspaceFoldersInitializeParams::workspaceFolders( - std::optional< - std::variant, std::nullptr_t>> + std::optional, 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 " @@ -12959,7 +12831,7 @@ auto WorkspaceFoldersInitializeParams::workspaceFolders( } void operator()(std::nullptr_t workspaceFolders) { - repr_->emplace("workspaceFolders", std::move(workspaceFolders)); + (*repr_)["workspaceFolders"] = std::move(workspaceFolders); } } v{repr_}; @@ -12982,15 +12854,13 @@ auto ServerCapabilities::positionEncoding() const lsp_runtime_error("ServerCapabilities::positionEncoding: not implement yet"); } -auto ServerCapabilities::textDocumentSync() const - -> std::optional> { +auto ServerCapabilities::textDocumentSync() const -> std::optional< + std::variant> { if (!repr_->contains("textDocumentSync")) return std::nullopt; auto& value = (*repr_)["textDocumentSync"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); @@ -12998,13 +12868,13 @@ auto ServerCapabilities::textDocumentSync() const } auto ServerCapabilities::notebookDocumentSync() const - -> std::optional std::optional> { if (!repr_->contains("notebookDocumentSync")) return std::nullopt; auto& value = (*repr_)["notebookDocumentSync"]; - std::variant result; @@ -13023,12 +12893,12 @@ auto ServerCapabilities::completionProvider() const } auto ServerCapabilities::hoverProvider() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("hoverProvider")) return std::nullopt; auto& value = (*repr_)["hoverProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13044,16 +12914,13 @@ auto ServerCapabilities::signatureHelpProvider() const return SignatureHelpOptions(value); } -auto ServerCapabilities::declarationProvider() const - -> std::optional> { +auto ServerCapabilities::declarationProvider() const -> std::optional< + std::variant> { if (!repr_->contains("declarationProvider")) return std::nullopt; auto& value = (*repr_)["declarationProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); @@ -13061,12 +12928,12 @@ auto ServerCapabilities::declarationProvider() const } auto ServerCapabilities::definitionProvider() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("definitionProvider")) return std::nullopt; auto& value = (*repr_)["definitionProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13074,14 +12941,13 @@ auto ServerCapabilities::definitionProvider() const } auto ServerCapabilities::typeDefinitionProvider() const - -> std::optional std::optional> { if (!repr_->contains("typeDefinitionProvider")) return std::nullopt; auto& value = (*repr_)["typeDefinitionProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13090,14 +12956,13 @@ auto ServerCapabilities::typeDefinitionProvider() const } auto ServerCapabilities::implementationProvider() const - -> std::optional std::optional> { if (!repr_->contains("implementationProvider")) return std::nullopt; auto& value = (*repr_)["implementationProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13106,38 +12971,38 @@ auto ServerCapabilities::implementationProvider() const } auto ServerCapabilities::referencesProvider() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("referencesProvider")) return std::nullopt; auto& value = (*repr_)["referencesProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::documentHighlightProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::documentHighlightProvider() const + -> std::optional> { if (!repr_->contains("documentHighlightProvider")) return std::nullopt; auto& value = (*repr_)["documentHighlightProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::documentSymbolProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::documentSymbolProvider() const + -> std::optional> { if (!repr_->contains("documentSymbolProvider")) return std::nullopt; auto& value = (*repr_)["documentSymbolProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13145,12 +13010,12 @@ auto ServerCapabilities::documentSymbolProvider() const -> std::optional< } auto ServerCapabilities::codeActionProvider() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("codeActionProvider")) return std::nullopt; auto& value = (*repr_)["codeActionProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13176,14 +13041,13 @@ auto ServerCapabilities::documentLinkProvider() const } auto ServerCapabilities::colorProvider() const - -> std::optional std::optional> { if (!repr_->contains("colorProvider")) return std::nullopt; auto& value = (*repr_)["colorProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13191,26 +13055,26 @@ auto ServerCapabilities::colorProvider() const return result; } -auto ServerCapabilities::workspaceSymbolProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::workspaceSymbolProvider() const + -> std::optional> { if (!repr_->contains("workspaceSymbolProvider")) return std::nullopt; auto& value = (*repr_)["workspaceSymbolProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::documentFormattingProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::documentFormattingProvider() const + -> std::optional> { if (!repr_->contains("documentFormattingProvider")) return std::nullopt; auto& value = (*repr_)["documentFormattingProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13218,13 +13082,12 @@ auto ServerCapabilities::documentFormattingProvider() const -> std::optional< } auto ServerCapabilities::documentRangeFormattingProvider() const - -> std::optional< - std::variant> { + -> std::optional> { if (!repr_->contains("documentRangeFormattingProvider")) return std::nullopt; auto& value = (*repr_)["documentRangeFormattingProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13241,27 +13104,25 @@ auto ServerCapabilities::documentOnTypeFormattingProvider() const } auto ServerCapabilities::renameProvider() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("renameProvider")) return std::nullopt; auto& value = (*repr_)["renameProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::foldingRangeProvider() const - -> std::optional> { +auto ServerCapabilities::foldingRangeProvider() const -> std::optional< + std::variant> { if (!repr_->contains("foldingRangeProvider")) return std::nullopt; auto& value = (*repr_)["foldingRangeProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13270,14 +13131,13 @@ auto ServerCapabilities::foldingRangeProvider() const } auto ServerCapabilities::selectionRangeProvider() const - -> std::optional std::optional> { if (!repr_->contains("selectionRangeProvider")) return std::nullopt; auto& value = (*repr_)["selectionRangeProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13295,14 +13155,13 @@ auto ServerCapabilities::executeCommandProvider() const } auto ServerCapabilities::callHierarchyProvider() const - -> std::optional std::optional> { if (!repr_->contains("callHierarchyProvider")) return std::nullopt; auto& value = (*repr_)["callHierarchyProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13310,14 +13169,14 @@ auto ServerCapabilities::callHierarchyProvider() const return result; } -auto ServerCapabilities::linkedEditingRangeProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::linkedEditingRangeProvider() const + -> std::optional> { if (!repr_->contains("linkedEditingRangeProvider")) return std::nullopt; auto& value = (*repr_)["linkedEditingRangeProvider"]; - std::variant result; @@ -13326,31 +13185,26 @@ auto ServerCapabilities::linkedEditingRangeProvider() const -> std::optional< return result; } -auto ServerCapabilities::semanticTokensProvider() const - -> std::optional> { +auto ServerCapabilities::semanticTokensProvider() const -> std::optional< + std::variant> { if (!repr_->contains("semanticTokensProvider")) return std::nullopt; auto& value = (*repr_)["semanticTokensProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::monikerProvider() const - -> std::optional> { +auto ServerCapabilities::monikerProvider() const -> std::optional< + std::variant> { if (!repr_->contains("monikerProvider")) return std::nullopt; auto& value = (*repr_)["monikerProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); @@ -13358,14 +13212,13 @@ auto ServerCapabilities::monikerProvider() const } auto ServerCapabilities::typeHierarchyProvider() const - -> std::optional std::optional> { if (!repr_->contains("typeHierarchyProvider")) return std::nullopt; auto& value = (*repr_)["typeHierarchyProvider"]; - std::variant + std::variant result; details::try_emplace(result, value); @@ -13373,60 +13226,52 @@ auto ServerCapabilities::typeHierarchyProvider() const return result; } -auto ServerCapabilities::inlineValueProvider() const - -> std::optional> { +auto ServerCapabilities::inlineValueProvider() const -> std::optional< + std::variant> { if (!repr_->contains("inlineValueProvider")) return std::nullopt; auto& value = (*repr_)["inlineValueProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::inlayHintProvider() const - -> std::optional> { +auto ServerCapabilities::inlayHintProvider() const -> std::optional< + std::variant> { if (!repr_->contains("inlayHintProvider")) return std::nullopt; auto& value = (*repr_)["inlayHintProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::diagnosticProvider() const - -> std::optional> { +auto ServerCapabilities::diagnosticProvider() const -> std::optional< + std::variant> { if (!repr_->contains("diagnosticProvider")) return std::nullopt; auto& value = (*repr_)["diagnosticProvider"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); return result; } -auto ServerCapabilities::inlineCompletionProvider() const -> std::optional< - std::variant> { +auto ServerCapabilities::inlineCompletionProvider() const + -> std::optional> { if (!repr_->contains("inlineCompletionProvider")) return std::nullopt; auto& value = (*repr_)["inlineCompletionProvider"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -13462,29 +13307,22 @@ auto ServerCapabilities::positionEncoding( } auto ServerCapabilities::textDocumentSync( - std::optional> + 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); + (*repr_)["textDocumentSync"] = textDocumentSync; } void operator()(TextDocumentSyncKind textDocumentSync) { - repr_->emplace("textDocumentSync", static_cast(textDocumentSync)); + (*repr_)["textDocumentSync"] = static_cast(textDocumentSync); } } v{repr_}; @@ -13494,7 +13332,7 @@ auto ServerCapabilities::textDocumentSync( } auto ServerCapabilities::notebookDocumentSync( - std::optional> notebookDocumentSync) -> ServerCapabilities& { if (!notebookDocumentSync.has_value()) { @@ -13502,22 +13340,16 @@ auto ServerCapabilities::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); + (*repr_)["notebookDocumentSync"] = notebookDocumentSync; } void operator()( NotebookDocumentSyncRegistrationOptions notebookDocumentSync) { - repr_->emplace("notebookDocumentSync", notebookDocumentSync); + (*repr_)["notebookDocumentSync"] = notebookDocumentSync; } } v{repr_}; @@ -13533,33 +13365,27 @@ auto ServerCapabilities::completionProvider( repr_->erase("completionProvider"); return *this; } - repr_->emplace("completionProvider", completionProvider.value()); + (*repr_)["completionProvider"] = completionProvider.value(); return *this; } auto ServerCapabilities::hoverProvider( - std::optional> - hoverProvider) -> ServerCapabilities& { + 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)); + (*repr_)["hoverProvider"] = std::move(hoverProvider); } void operator()(HoverOptions hoverProvider) { - repr_->emplace("hoverProvider", hoverProvider); + (*repr_)["hoverProvider"] = hoverProvider; } } v{repr_}; @@ -13575,38 +13401,32 @@ auto ServerCapabilities::signatureHelpProvider( repr_->erase("signatureHelpProvider"); return *this; } - repr_->emplace("signatureHelpProvider", signatureHelpProvider.value()); + (*repr_)["signatureHelpProvider"] = signatureHelpProvider.value(); return *this; } auto ServerCapabilities::declarationProvider( - std::optional> + std::optional< + std::variant> 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)); + (*repr_)["declarationProvider"] = std::move(declarationProvider); } void operator()(DeclarationOptions declarationProvider) { - repr_->emplace("declarationProvider", declarationProvider); + (*repr_)["declarationProvider"] = declarationProvider; } void operator()(DeclarationRegistrationOptions declarationProvider) { - repr_->emplace("declarationProvider", declarationProvider); + (*repr_)["declarationProvider"] = declarationProvider; } } v{repr_}; @@ -13616,28 +13436,22 @@ auto ServerCapabilities::declarationProvider( } auto ServerCapabilities::definitionProvider( - std::optional> - definitionProvider) -> ServerCapabilities& { + 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)); + (*repr_)["definitionProvider"] = std::move(definitionProvider); } void operator()(DefinitionOptions definitionProvider) { - repr_->emplace("definitionProvider", definitionProvider); + (*repr_)["definitionProvider"] = definitionProvider; } } v{repr_}; @@ -13647,7 +13461,7 @@ auto ServerCapabilities::definitionProvider( } auto ServerCapabilities::typeDefinitionProvider( - std::optional> typeDefinitionProvider) -> ServerCapabilities& { if (!typeDefinitionProvider.has_value()) { @@ -13655,26 +13469,19 @@ auto ServerCapabilities::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)); + (*repr_)["typeDefinitionProvider"] = std::move(typeDefinitionProvider); } void operator()(TypeDefinitionOptions typeDefinitionProvider) { - repr_->emplace("typeDefinitionProvider", typeDefinitionProvider); + (*repr_)["typeDefinitionProvider"] = typeDefinitionProvider; } void operator()(TypeDefinitionRegistrationOptions typeDefinitionProvider) { - repr_->emplace("typeDefinitionProvider", typeDefinitionProvider); + (*repr_)["typeDefinitionProvider"] = typeDefinitionProvider; } } v{repr_}; @@ -13684,7 +13491,7 @@ auto ServerCapabilities::typeDefinitionProvider( } auto ServerCapabilities::implementationProvider( - std::optional> implementationProvider) -> ServerCapabilities& { if (!implementationProvider.has_value()) { @@ -13692,26 +13499,19 @@ auto ServerCapabilities::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)); + (*repr_)["implementationProvider"] = std::move(implementationProvider); } void operator()(ImplementationOptions implementationProvider) { - repr_->emplace("implementationProvider", implementationProvider); + (*repr_)["implementationProvider"] = implementationProvider; } void operator()(ImplementationRegistrationOptions implementationProvider) { - repr_->emplace("implementationProvider", implementationProvider); + (*repr_)["implementationProvider"] = implementationProvider; } } v{repr_}; @@ -13721,28 +13521,22 @@ auto ServerCapabilities::implementationProvider( } auto ServerCapabilities::referencesProvider( - std::optional> - referencesProvider) -> ServerCapabilities& { + 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)); + (*repr_)["referencesProvider"] = std::move(referencesProvider); } void operator()(ReferenceOptions referencesProvider) { - repr_->emplace("referencesProvider", referencesProvider); + (*repr_)["referencesProvider"] = referencesProvider; } } v{repr_}; @@ -13752,29 +13546,23 @@ auto ServerCapabilities::referencesProvider( } auto ServerCapabilities::documentHighlightProvider( - std::optional> + 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)); + (*repr_)["documentHighlightProvider"] = + std::move(documentHighlightProvider); } void operator()(DocumentHighlightOptions documentHighlightProvider) { - repr_->emplace("documentHighlightProvider", documentHighlightProvider); + (*repr_)["documentHighlightProvider"] = documentHighlightProvider; } } v{repr_}; @@ -13784,29 +13572,22 @@ auto ServerCapabilities::documentHighlightProvider( } auto ServerCapabilities::documentSymbolProvider( - std::optional> + 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)); + (*repr_)["documentSymbolProvider"] = std::move(documentSymbolProvider); } void operator()(DocumentSymbolOptions documentSymbolProvider) { - repr_->emplace("documentSymbolProvider", documentSymbolProvider); + (*repr_)["documentSymbolProvider"] = documentSymbolProvider; } } v{repr_}; @@ -13816,28 +13597,22 @@ auto ServerCapabilities::documentSymbolProvider( } auto ServerCapabilities::codeActionProvider( - std::optional> - codeActionProvider) -> ServerCapabilities& { + 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)); + (*repr_)["codeActionProvider"] = std::move(codeActionProvider); } void operator()(CodeActionOptions codeActionProvider) { - repr_->emplace("codeActionProvider", codeActionProvider); + (*repr_)["codeActionProvider"] = codeActionProvider; } } v{repr_}; @@ -13852,7 +13627,7 @@ auto ServerCapabilities::codeLensProvider( repr_->erase("codeLensProvider"); return *this; } - repr_->emplace("codeLensProvider", codeLensProvider.value()); + (*repr_)["codeLensProvider"] = codeLensProvider.value(); return *this; } @@ -13863,12 +13638,12 @@ auto ServerCapabilities::documentLinkProvider( repr_->erase("documentLinkProvider"); return *this; } - repr_->emplace("documentLinkProvider", documentLinkProvider.value()); + (*repr_)["documentLinkProvider"] = documentLinkProvider.value(); return *this; } auto ServerCapabilities::colorProvider( - std::optional> colorProvider) -> ServerCapabilities& { if (!colorProvider.has_value()) { @@ -13876,25 +13651,19 @@ auto ServerCapabilities::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)); + (*repr_)["colorProvider"] = std::move(colorProvider); } void operator()(DocumentColorOptions colorProvider) { - repr_->emplace("colorProvider", colorProvider); + (*repr_)["colorProvider"] = colorProvider; } void operator()(DocumentColorRegistrationOptions colorProvider) { - repr_->emplace("colorProvider", colorProvider); + (*repr_)["colorProvider"] = colorProvider; } } v{repr_}; @@ -13904,29 +13673,22 @@ auto ServerCapabilities::colorProvider( } auto ServerCapabilities::workspaceSymbolProvider( - std::optional> + 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)); + (*repr_)["workspaceSymbolProvider"] = std::move(workspaceSymbolProvider); } void operator()(WorkspaceSymbolOptions workspaceSymbolProvider) { - repr_->emplace("workspaceSymbolProvider", workspaceSymbolProvider); + (*repr_)["workspaceSymbolProvider"] = workspaceSymbolProvider; } } v{repr_}; @@ -13936,29 +13698,23 @@ auto ServerCapabilities::workspaceSymbolProvider( } auto ServerCapabilities::documentFormattingProvider( - std::optional> + 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)); + (*repr_)["documentFormattingProvider"] = + std::move(documentFormattingProvider); } void operator()(DocumentFormattingOptions documentFormattingProvider) { - repr_->emplace("documentFormattingProvider", documentFormattingProvider); + (*repr_)["documentFormattingProvider"] = documentFormattingProvider; } } v{repr_}; @@ -13968,32 +13724,25 @@ auto ServerCapabilities::documentFormattingProvider( } auto ServerCapabilities::documentRangeFormattingProvider( - std::optional< - std::variant> + std::optional> 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)); + (*repr_)["documentRangeFormattingProvider"] = + std::move(documentRangeFormattingProvider); } void operator()( DocumentRangeFormattingOptions documentRangeFormattingProvider) { - repr_->emplace("documentRangeFormattingProvider", - documentRangeFormattingProvider); + (*repr_)["documentRangeFormattingProvider"] = + documentRangeFormattingProvider; } } v{repr_}; @@ -14009,34 +13758,28 @@ auto ServerCapabilities::documentOnTypeFormattingProvider( repr_->erase("documentOnTypeFormattingProvider"); return *this; } - repr_->emplace("documentOnTypeFormattingProvider", - documentOnTypeFormattingProvider.value()); + (*repr_)["documentOnTypeFormattingProvider"] = + documentOnTypeFormattingProvider.value(); return *this; } auto ServerCapabilities::renameProvider( - std::optional> - renameProvider) -> ServerCapabilities& { + 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)); + (*repr_)["renameProvider"] = std::move(renameProvider); } void operator()(RenameOptions renameProvider) { - repr_->emplace("renameProvider", renameProvider); + (*repr_)["renameProvider"] = renameProvider; } } v{repr_}; @@ -14046,7 +13789,7 @@ auto ServerCapabilities::renameProvider( } auto ServerCapabilities::foldingRangeProvider( - std::optional> foldingRangeProvider) -> ServerCapabilities& { if (!foldingRangeProvider.has_value()) { @@ -14054,25 +13797,19 @@ auto ServerCapabilities::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)); + (*repr_)["foldingRangeProvider"] = std::move(foldingRangeProvider); } void operator()(FoldingRangeOptions foldingRangeProvider) { - repr_->emplace("foldingRangeProvider", foldingRangeProvider); + (*repr_)["foldingRangeProvider"] = foldingRangeProvider; } void operator()(FoldingRangeRegistrationOptions foldingRangeProvider) { - repr_->emplace("foldingRangeProvider", foldingRangeProvider); + (*repr_)["foldingRangeProvider"] = foldingRangeProvider; } } v{repr_}; @@ -14082,7 +13819,7 @@ auto ServerCapabilities::foldingRangeProvider( } auto ServerCapabilities::selectionRangeProvider( - std::optional> selectionRangeProvider) -> ServerCapabilities& { if (!selectionRangeProvider.has_value()) { @@ -14090,26 +13827,19 @@ auto ServerCapabilities::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)); + (*repr_)["selectionRangeProvider"] = std::move(selectionRangeProvider); } void operator()(SelectionRangeOptions selectionRangeProvider) { - repr_->emplace("selectionRangeProvider", selectionRangeProvider); + (*repr_)["selectionRangeProvider"] = selectionRangeProvider; } void operator()(SelectionRangeRegistrationOptions selectionRangeProvider) { - repr_->emplace("selectionRangeProvider", selectionRangeProvider); + (*repr_)["selectionRangeProvider"] = selectionRangeProvider; } } v{repr_}; @@ -14125,12 +13855,12 @@ auto ServerCapabilities::executeCommandProvider( repr_->erase("executeCommandProvider"); return *this; } - repr_->emplace("executeCommandProvider", executeCommandProvider.value()); + (*repr_)["executeCommandProvider"] = executeCommandProvider.value(); return *this; } auto ServerCapabilities::callHierarchyProvider( - std::optional> callHierarchyProvider) -> ServerCapabilities& { if (!callHierarchyProvider.has_value()) { @@ -14138,25 +13868,19 @@ auto ServerCapabilities::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)); + (*repr_)["callHierarchyProvider"] = std::move(callHierarchyProvider); } void operator()(CallHierarchyOptions callHierarchyProvider) { - repr_->emplace("callHierarchyProvider", callHierarchyProvider); + (*repr_)["callHierarchyProvider"] = callHierarchyProvider; } void operator()(CallHierarchyRegistrationOptions callHierarchyProvider) { - repr_->emplace("callHierarchyProvider", callHierarchyProvider); + (*repr_)["callHierarchyProvider"] = callHierarchyProvider; } } v{repr_}; @@ -14166,7 +13890,7 @@ auto ServerCapabilities::callHierarchyProvider( } auto ServerCapabilities::linkedEditingRangeProvider( - std::optional> linkedEditingRangeProvider) -> ServerCapabilities& { if (!linkedEditingRangeProvider.has_value()) { @@ -14174,27 +13898,21 @@ auto ServerCapabilities::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)); + (*repr_)["linkedEditingRangeProvider"] = + std::move(linkedEditingRangeProvider); } void operator()(LinkedEditingRangeOptions linkedEditingRangeProvider) { - repr_->emplace("linkedEditingRangeProvider", linkedEditingRangeProvider); + (*repr_)["linkedEditingRangeProvider"] = linkedEditingRangeProvider; } void operator()( LinkedEditingRangeRegistrationOptions linkedEditingRangeProvider) { - repr_->emplace("linkedEditingRangeProvider", linkedEditingRangeProvider); + (*repr_)["linkedEditingRangeProvider"] = linkedEditingRangeProvider; } } v{repr_}; @@ -14204,29 +13922,23 @@ auto ServerCapabilities::linkedEditingRangeProvider( } auto ServerCapabilities::semanticTokensProvider( - std::optional> + std::optional< + std::variant> 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); + (*repr_)["semanticTokensProvider"] = semanticTokensProvider; } void operator()(SemanticTokensRegistrationOptions semanticTokensProvider) { - repr_->emplace("semanticTokensProvider", semanticTokensProvider); + (*repr_)["semanticTokensProvider"] = semanticTokensProvider; } } v{repr_}; @@ -14236,33 +13948,27 @@ auto ServerCapabilities::semanticTokensProvider( } auto ServerCapabilities::monikerProvider( - std::optional> + std::optional< + std::variant> 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)); + (*repr_)["monikerProvider"] = std::move(monikerProvider); } void operator()(MonikerOptions monikerProvider) { - repr_->emplace("monikerProvider", monikerProvider); + (*repr_)["monikerProvider"] = monikerProvider; } void operator()(MonikerRegistrationOptions monikerProvider) { - repr_->emplace("monikerProvider", monikerProvider); + (*repr_)["monikerProvider"] = monikerProvider; } } v{repr_}; @@ -14272,7 +13978,7 @@ auto ServerCapabilities::monikerProvider( } auto ServerCapabilities::typeHierarchyProvider( - std::optional> typeHierarchyProvider) -> ServerCapabilities& { if (!typeHierarchyProvider.has_value()) { @@ -14280,25 +13986,19 @@ auto ServerCapabilities::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)); + (*repr_)["typeHierarchyProvider"] = std::move(typeHierarchyProvider); } void operator()(TypeHierarchyOptions typeHierarchyProvider) { - repr_->emplace("typeHierarchyProvider", typeHierarchyProvider); + (*repr_)["typeHierarchyProvider"] = typeHierarchyProvider; } void operator()(TypeHierarchyRegistrationOptions typeHierarchyProvider) { - repr_->emplace("typeHierarchyProvider", typeHierarchyProvider); + (*repr_)["typeHierarchyProvider"] = typeHierarchyProvider; } } v{repr_}; @@ -14308,33 +14008,27 @@ auto ServerCapabilities::typeHierarchyProvider( } auto ServerCapabilities::inlineValueProvider( - std::optional> + std::optional< + std::variant> 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)); + (*repr_)["inlineValueProvider"] = std::move(inlineValueProvider); } void operator()(InlineValueOptions inlineValueProvider) { - repr_->emplace("inlineValueProvider", inlineValueProvider); + (*repr_)["inlineValueProvider"] = inlineValueProvider; } void operator()(InlineValueRegistrationOptions inlineValueProvider) { - repr_->emplace("inlineValueProvider", inlineValueProvider); + (*repr_)["inlineValueProvider"] = inlineValueProvider; } } v{repr_}; @@ -14344,33 +14038,27 @@ auto ServerCapabilities::inlineValueProvider( } auto ServerCapabilities::inlayHintProvider( - std::optional> + std::optional< + std::variant> 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)); + (*repr_)["inlayHintProvider"] = std::move(inlayHintProvider); } void operator()(InlayHintOptions inlayHintProvider) { - repr_->emplace("inlayHintProvider", inlayHintProvider); + (*repr_)["inlayHintProvider"] = inlayHintProvider; } void operator()(InlayHintRegistrationOptions inlayHintProvider) { - repr_->emplace("inlayHintProvider", inlayHintProvider); + (*repr_)["inlayHintProvider"] = inlayHintProvider; } } v{repr_}; @@ -14380,29 +14068,23 @@ auto ServerCapabilities::inlayHintProvider( } auto ServerCapabilities::diagnosticProvider( - std::optional> + std::optional< + std::variant> 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); + (*repr_)["diagnosticProvider"] = diagnosticProvider; } void operator()(DiagnosticRegistrationOptions diagnosticProvider) { - repr_->emplace("diagnosticProvider", diagnosticProvider); + (*repr_)["diagnosticProvider"] = diagnosticProvider; } } v{repr_}; @@ -14412,29 +14094,23 @@ auto ServerCapabilities::diagnosticProvider( } auto ServerCapabilities::inlineCompletionProvider( - std::optional> + 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)); + (*repr_)["inlineCompletionProvider"] = + std::move(inlineCompletionProvider); } void operator()(InlineCompletionOptions inlineCompletionProvider) { - repr_->emplace("inlineCompletionProvider", inlineCompletionProvider); + (*repr_)["inlineCompletionProvider"] = inlineCompletionProvider; } } v{repr_}; @@ -14449,7 +14125,7 @@ auto ServerCapabilities::workspace(std::optional workspace) repr_->erase("workspace"); return *this; } - repr_->emplace("workspace", workspace.value()); + (*repr_)["workspace"] = workspace.value(); return *this; } @@ -14472,6 +14148,7 @@ ServerInfo::operator bool() const { auto ServerInfo::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14481,12 +14158,13 @@ auto ServerInfo::version() const -> std::optional { auto& value = (*repr_)["version"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ServerInfo::name(std::string name) -> ServerInfo& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } @@ -14495,7 +14173,7 @@ auto ServerInfo::version(std::optional version) -> ServerInfo& { repr_->erase("version"); return *this; } - repr_->emplace("version", std::move(version.value())); + (*repr_)["version"] = std::move(version.value()); return *this; } @@ -14509,6 +14187,7 @@ VersionedTextDocumentIdentifier::operator bool() const { auto VersionedTextDocumentIdentifier::version() const -> int { auto& value = (*repr_)["version"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -14516,19 +14195,20 @@ auto VersionedTextDocumentIdentifier::version() const -> int { auto VersionedTextDocumentIdentifier::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto VersionedTextDocumentIdentifier::version(int version) -> VersionedTextDocumentIdentifier& { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); return *this; } auto VersionedTextDocumentIdentifier::uri(std::string uri) -> VersionedTextDocumentIdentifier& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -14542,6 +14222,7 @@ auto SaveOptions::includeText() const -> std::optional { auto& value = (*repr_)["includeText"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -14551,7 +14232,7 @@ auto SaveOptions::includeText(std::optional includeText) -> SaveOptions& { repr_->erase("includeText"); return *this; } - repr_->emplace("includeText", std::move(includeText.value())); + (*repr_)["includeText"] = std::move(includeText.value()); return *this; } @@ -14565,6 +14246,7 @@ FileEvent::operator bool() const { auto FileEvent::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14576,12 +14258,12 @@ auto FileEvent::type() const -> FileChangeType { } auto FileEvent::uri(std::string uri) -> FileEvent& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto FileEvent::type(FileChangeType type) -> FileEvent& { - repr_->emplace("type", static_cast(type)); + (*repr_)["type"] = static_cast(type); return *this; } @@ -14621,7 +14303,7 @@ auto FileSystemWatcher::kind(std::optional kind) repr_->erase("kind"); return *this; } - repr_->emplace("kind", static_cast(kind.value())); + (*repr_)["kind"] = static_cast(kind.value()); return *this; } @@ -14646,13 +14328,12 @@ auto Diagnostic::severity() const -> std::optional { return DiagnosticSeverity(value); } -auto Diagnostic::code() const - -> std::optional> { +auto Diagnostic::code() const -> std::optional> { if (!repr_->contains("code")) return std::nullopt; auto& value = (*repr_)["code"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -14672,6 +14353,7 @@ auto Diagnostic::source() const -> std::optional { auto& value = (*repr_)["source"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14679,6 +14361,7 @@ auto Diagnostic::source() const -> std::optional { auto Diagnostic::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14688,7 +14371,7 @@ auto Diagnostic::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -14698,7 +14381,7 @@ auto Diagnostic::relatedInformation() const auto& value = (*repr_)["relatedInformation"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -14712,7 +14395,7 @@ auto Diagnostic::data() const -> std::optional { } auto Diagnostic::range(Range range) -> Diagnostic& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -14722,32 +14405,23 @@ auto Diagnostic::severity(std::optional severity) repr_->erase("severity"); return *this; } - repr_->emplace("severity", static_cast(severity.value())); + (*repr_)["severity"] = static_cast(severity.value()); return *this; } -auto Diagnostic::code( - std::optional> code) +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()(int code) { (*repr_)["code"] = std::move(code); } - void operator()(std::string code) { - repr_->emplace("code", std::move(code)); - } + void operator()(std::string code) { (*repr_)["code"] = std::move(code); } } v{repr_}; std::visit(v, code.value()); @@ -14761,7 +14435,7 @@ auto Diagnostic::codeDescription(std::optional codeDescription) repr_->erase("codeDescription"); return *this; } - repr_->emplace("codeDescription", codeDescription.value()); + (*repr_)["codeDescription"] = codeDescription.value(); return *this; } @@ -14770,12 +14444,12 @@ auto Diagnostic::source(std::optional source) -> Diagnostic& { repr_->erase("source"); return *this; } - repr_->emplace("source", std::move(source.value())); + (*repr_)["source"] = std::move(source.value()); return *this; } auto Diagnostic::message(std::string message) -> Diagnostic& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -14826,13 +14500,14 @@ auto CompletionContext::triggerCharacter() const -> std::optional { auto& value = (*repr_)["triggerCharacter"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto CompletionContext::triggerKind(CompletionTriggerKind triggerKind) -> CompletionContext& { - repr_->emplace("triggerKind", static_cast(triggerKind)); + (*repr_)["triggerKind"] = static_cast(triggerKind); return *this; } @@ -14842,7 +14517,7 @@ auto CompletionContext::triggerCharacter( repr_->erase("triggerCharacter"); return *this; } - repr_->emplace("triggerCharacter", std::move(triggerCharacter.value())); + (*repr_)["triggerCharacter"] = std::move(triggerCharacter.value()); return *this; } @@ -14856,6 +14531,7 @@ auto CompletionItemLabelDetails::detail() const -> std::optional { auto& value = (*repr_)["detail"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14866,6 +14542,7 @@ auto CompletionItemLabelDetails::description() const auto& value = (*repr_)["description"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14876,7 +14553,7 @@ auto CompletionItemLabelDetails::detail(std::optional detail) repr_->erase("detail"); return *this; } - repr_->emplace("detail", std::move(detail.value())); + (*repr_)["detail"] = std::move(detail.value()); return *this; } @@ -14886,7 +14563,7 @@ auto CompletionItemLabelDetails::description( repr_->erase("description"); return *this; } - repr_->emplace("description", std::move(description.value())); + (*repr_)["description"] = std::move(description.value()); return *this; } @@ -14901,6 +14578,7 @@ InsertReplaceEdit::operator bool() const { auto InsertReplaceEdit::newText() const -> std::string { auto& value = (*repr_)["newText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -14918,17 +14596,17 @@ auto InsertReplaceEdit::replace() const -> Range { } auto InsertReplaceEdit::newText(std::string newText) -> InsertReplaceEdit& { - repr_->emplace("newText", std::move(newText)); + (*repr_)["newText"] = std::move(newText); return *this; } auto InsertReplaceEdit::insert(Range insert) -> InsertReplaceEdit& { - repr_->emplace("insert", insert); + (*repr_)["insert"] = insert; return *this; } auto InsertReplaceEdit::replace(Range replace) -> InsertReplaceEdit& { - repr_->emplace("replace", replace); + (*repr_)["replace"] = replace; return *this; } @@ -14943,17 +14621,17 @@ auto CompletionItemDefaults::commitCharacters() const auto& value = (*repr_)["commitCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } -auto CompletionItemDefaults::editRange() const -> std::optional< - std::variant> { +auto CompletionItemDefaults::editRange() const + -> std::optional> { if (!repr_->contains("editRange")) return std::nullopt; auto& value = (*repr_)["editRange"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -15000,27 +14678,20 @@ auto CompletionItemDefaults::commitCharacters( } auto CompletionItemDefaults::editRange( - std::optional< - std::variant> - editRange) -> CompletionItemDefaults& { + std::optional> 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()(Range editRange) { (*repr_)["editRange"] = editRange; } void operator()(EditRangeWithInsertReplace editRange) { - repr_->emplace("editRange", editRange); + (*repr_)["editRange"] = editRange; } } v{repr_}; @@ -15036,8 +14707,7 @@ auto CompletionItemDefaults::insertTextFormat( repr_->erase("insertTextFormat"); return *this; } - repr_->emplace("insertTextFormat", - static_cast(insertTextFormat.value())); + (*repr_)["insertTextFormat"] = static_cast(insertTextFormat.value()); return *this; } @@ -15047,7 +14717,7 @@ auto CompletionItemDefaults::insertTextMode( repr_->erase("insertTextMode"); return *this; } - repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); + (*repr_)["insertTextMode"] = static_cast(insertTextMode.value()); return *this; } @@ -15089,8 +14759,7 @@ auto CompletionItemApplyKinds::commitCharacters( repr_->erase("commitCharacters"); return *this; } - repr_->emplace("commitCharacters", - static_cast(commitCharacters.value())); + (*repr_)["commitCharacters"] = static_cast(commitCharacters.value()); return *this; } @@ -15100,7 +14769,7 @@ auto CompletionItemApplyKinds::data(std::optional data) repr_->erase("data"); return *this; } - repr_->emplace("data", static_cast(data.value())); + (*repr_)["data"] = static_cast(data.value()); return *this; } @@ -15115,7 +14784,7 @@ auto CompletionOptions::triggerCharacters() const auto& value = (*repr_)["triggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15125,7 +14794,7 @@ auto CompletionOptions::allCommitCharacters() const auto& value = (*repr_)["allCommitCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15134,6 +14803,7 @@ auto CompletionOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15152,6 +14822,7 @@ auto CompletionOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15185,7 +14856,7 @@ auto CompletionOptions::resolveProvider(std::optional resolveProvider) repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -15196,7 +14867,7 @@ auto CompletionOptions::completionItem( repr_->erase("completionItem"); return *this; } - repr_->emplace("completionItem", completionItem.value()); + (*repr_)["completionItem"] = completionItem.value(); return *this; } @@ -15206,7 +14877,7 @@ auto CompletionOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15220,6 +14891,7 @@ auto HoverOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15230,7 +14902,7 @@ auto HoverOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15253,6 +14925,7 @@ auto SignatureHelpContext::triggerCharacter() const auto& value = (*repr_)["triggerCharacter"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -15260,6 +14933,7 @@ auto SignatureHelpContext::triggerCharacter() const auto SignatureHelpContext::isRetrigger() const -> bool { auto& value = (*repr_)["isRetrigger"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15275,7 +14949,7 @@ auto SignatureHelpContext::activeSignatureHelp() const auto SignatureHelpContext::triggerKind(SignatureHelpTriggerKind triggerKind) -> SignatureHelpContext& { - repr_->emplace("triggerKind", static_cast(triggerKind)); + (*repr_)["triggerKind"] = static_cast(triggerKind); return *this; } @@ -15285,13 +14959,13 @@ auto SignatureHelpContext::triggerCharacter( repr_->erase("triggerCharacter"); return *this; } - repr_->emplace("triggerCharacter", std::move(triggerCharacter.value())); + (*repr_)["triggerCharacter"] = std::move(triggerCharacter.value()); return *this; } auto SignatureHelpContext::isRetrigger(bool isRetrigger) -> SignatureHelpContext& { - repr_->emplace("isRetrigger", std::move(isRetrigger)); + (*repr_)["isRetrigger"] = std::move(isRetrigger); return *this; } @@ -15301,7 +14975,7 @@ auto SignatureHelpContext::activeSignatureHelp( repr_->erase("activeSignatureHelp"); return *this; } - repr_->emplace("activeSignatureHelp", activeSignatureHelp.value()); + (*repr_)["activeSignatureHelp"] = activeSignatureHelp.value(); return *this; } @@ -15314,17 +14988,18 @@ SignatureInformation::operator bool() const { auto SignatureInformation::label() const -> std::string { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto SignatureInformation::documentation() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("documentation")) return std::nullopt; auto& value = (*repr_)["documentation"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -15337,17 +15012,17 @@ auto SignatureInformation::parameters() const auto& value = (*repr_)["parameters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto SignatureInformation::activeParameter() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("activeParameter")) return std::nullopt; auto& value = (*repr_)["activeParameter"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -15355,33 +15030,27 @@ auto SignatureInformation::activeParameter() const } auto SignatureInformation::label(std::string label) -> SignatureInformation& { - repr_->emplace("label", std::move(label)); + (*repr_)["label"] = std::move(label); return *this; } auto SignatureInformation::documentation( - std::optional> - documentation) -> SignatureInformation& { + 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)); + (*repr_)["documentation"] = std::move(documentation); } void operator()(MarkupContent documentation) { - repr_->emplace("documentation", documentation); + (*repr_)["documentation"] = documentation; } } v{repr_}; @@ -15402,28 +15071,22 @@ auto SignatureInformation::parameters( } auto SignatureInformation::activeParameter( - std::optional> - activeParameter) -> SignatureInformation& { + 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)); + (*repr_)["activeParameter"] = std::move(activeParameter); } void operator()(std::nullptr_t activeParameter) { - repr_->emplace("activeParameter", std::move(activeParameter)); + (*repr_)["activeParameter"] = std::move(activeParameter); } } v{repr_}; @@ -15443,7 +15106,7 @@ auto SignatureHelpOptions::triggerCharacters() const auto& value = (*repr_)["triggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15453,7 +15116,7 @@ auto SignatureHelpOptions::retriggerCharacters() const auto& value = (*repr_)["retriggerCharacters"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15462,6 +15125,7 @@ auto SignatureHelpOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15496,7 +15160,7 @@ auto SignatureHelpOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15510,6 +15174,7 @@ auto DefinitionOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15520,7 +15185,7 @@ auto DefinitionOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15533,13 +15198,14 @@ ReferenceContext::operator bool() const { auto ReferenceContext::includeDeclaration() const -> bool { auto& value = (*repr_)["includeDeclaration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto ReferenceContext::includeDeclaration(bool includeDeclaration) -> ReferenceContext& { - repr_->emplace("includeDeclaration", std::move(includeDeclaration)); + (*repr_)["includeDeclaration"] = std::move(includeDeclaration); return *this; } @@ -15553,6 +15219,7 @@ auto ReferenceOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15563,7 +15230,7 @@ auto ReferenceOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15577,6 +15244,7 @@ auto DocumentHighlightOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15587,7 +15255,7 @@ auto DocumentHighlightOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15601,6 +15269,7 @@ BaseSymbolInformation::operator bool() const { auto BaseSymbolInformation::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -15616,7 +15285,7 @@ auto BaseSymbolInformation::tags() const -> std::optional> { auto& value = (*repr_)["tags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15626,17 +15295,18 @@ auto BaseSymbolInformation::containerName() const auto& value = (*repr_)["containerName"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto BaseSymbolInformation::name(std::string name) -> BaseSymbolInformation& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } auto BaseSymbolInformation::kind(SymbolKind kind) -> BaseSymbolInformation& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } @@ -15656,7 +15326,7 @@ auto BaseSymbolInformation::containerName( repr_->erase("containerName"); return *this; } - repr_->emplace("containerName", std::move(containerName.value())); + (*repr_)["containerName"] = std::move(containerName.value()); return *this; } @@ -15670,6 +15340,7 @@ auto DocumentSymbolOptions::label() const -> std::optional { auto& value = (*repr_)["label"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -15679,6 +15350,7 @@ auto DocumentSymbolOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15689,7 +15361,7 @@ auto DocumentSymbolOptions::label(std::optional label) repr_->erase("label"); return *this; } - repr_->emplace("label", std::move(label.value())); + (*repr_)["label"] = std::move(label.value()); return *this; } @@ -15699,7 +15371,7 @@ auto DocumentSymbolOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15712,7 +15384,7 @@ CodeActionContext::operator bool() const { auto CodeActionContext::diagnostics() const -> Vector { auto& value = (*repr_)["diagnostics"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15721,7 +15393,7 @@ auto CodeActionContext::only() const -> std::optional> { auto& value = (*repr_)["only"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15756,7 +15428,7 @@ auto CodeActionContext::triggerKind( repr_->erase("triggerKind"); return *this; } - repr_->emplace("triggerKind", static_cast(triggerKind.value())); + (*repr_)["triggerKind"] = static_cast(triggerKind.value()); return *this; } @@ -15769,12 +15441,13 @@ CodeActionDisabled::operator bool() const { auto CodeActionDisabled::reason() const -> std::string { auto& value = (*repr_)["reason"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto CodeActionDisabled::reason(std::string reason) -> CodeActionDisabled& { - repr_->emplace("reason", std::move(reason)); + (*repr_)["reason"] = std::move(reason); return *this; } @@ -15789,7 +15462,7 @@ auto CodeActionOptions::codeActionKinds() const auto& value = (*repr_)["codeActionKinds"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15799,7 +15472,7 @@ auto CodeActionOptions::documentation() const auto& value = (*repr_)["documentation"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -15808,6 +15481,7 @@ auto CodeActionOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15817,6 +15491,7 @@ auto CodeActionOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15849,7 +15524,7 @@ auto CodeActionOptions::resolveProvider(std::optional resolveProvider) repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -15859,7 +15534,7 @@ auto CodeActionOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15872,12 +15547,13 @@ LocationUriOnly::operator bool() const { auto LocationUriOnly::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto LocationUriOnly::uri(std::string uri) -> LocationUriOnly& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -15891,6 +15567,7 @@ auto WorkspaceSymbolOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15900,6 +15577,7 @@ auto WorkspaceSymbolOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15910,7 +15588,7 @@ auto WorkspaceSymbolOptions::resolveProvider( repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -15920,7 +15598,7 @@ auto WorkspaceSymbolOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15934,6 +15612,7 @@ auto CodeLensOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15943,6 +15622,7 @@ auto CodeLensOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15953,7 +15633,7 @@ auto CodeLensOptions::resolveProvider(std::optional resolveProvider) repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -15963,7 +15643,7 @@ auto CodeLensOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -15977,6 +15657,7 @@ auto DocumentLinkOptions::resolveProvider() const -> std::optional { auto& value = (*repr_)["resolveProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15986,6 +15667,7 @@ auto DocumentLinkOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -15996,7 +15678,7 @@ auto DocumentLinkOptions::resolveProvider(std::optional resolveProvider) repr_->erase("resolveProvider"); return *this; } - repr_->emplace("resolveProvider", std::move(resolveProvider.value())); + (*repr_)["resolveProvider"] = std::move(resolveProvider.value()); return *this; } @@ -16006,7 +15688,7 @@ auto DocumentLinkOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -16020,6 +15702,7 @@ FormattingOptions::operator bool() const { auto FormattingOptions::tabSize() const -> long { auto& value = (*repr_)["tabSize"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -16027,6 +15710,7 @@ auto FormattingOptions::tabSize() const -> long { auto FormattingOptions::insertSpaces() const -> bool { auto& value = (*repr_)["insertSpaces"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16036,6 +15720,7 @@ auto FormattingOptions::trimTrailingWhitespace() const -> std::optional { auto& value = (*repr_)["trimTrailingWhitespace"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16045,6 +15730,7 @@ auto FormattingOptions::insertFinalNewline() const -> std::optional { auto& value = (*repr_)["insertFinalNewline"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16054,17 +15740,18 @@ auto FormattingOptions::trimFinalNewlines() const -> std::optional { auto& value = (*repr_)["trimFinalNewlines"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto FormattingOptions::tabSize(long tabSize) -> FormattingOptions& { - repr_->emplace("tabSize", std::move(tabSize)); + (*repr_)["tabSize"] = std::move(tabSize); return *this; } auto FormattingOptions::insertSpaces(bool insertSpaces) -> FormattingOptions& { - repr_->emplace("insertSpaces", std::move(insertSpaces)); + (*repr_)["insertSpaces"] = std::move(insertSpaces); return *this; } @@ -16074,8 +15761,8 @@ auto FormattingOptions::trimTrailingWhitespace( repr_->erase("trimTrailingWhitespace"); return *this; } - repr_->emplace("trimTrailingWhitespace", - std::move(trimTrailingWhitespace.value())); + (*repr_)["trimTrailingWhitespace"] = + std::move(trimTrailingWhitespace.value()); return *this; } @@ -16085,7 +15772,7 @@ auto FormattingOptions::insertFinalNewline( repr_->erase("insertFinalNewline"); return *this; } - repr_->emplace("insertFinalNewline", std::move(insertFinalNewline.value())); + (*repr_)["insertFinalNewline"] = std::move(insertFinalNewline.value()); return *this; } @@ -16095,7 +15782,7 @@ auto FormattingOptions::trimFinalNewlines(std::optional trimFinalNewlines) repr_->erase("trimFinalNewlines"); return *this; } - repr_->emplace("trimFinalNewlines", std::move(trimFinalNewlines.value())); + (*repr_)["trimFinalNewlines"] = std::move(trimFinalNewlines.value()); return *this; } @@ -16110,6 +15797,7 @@ auto DocumentFormattingOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16120,7 +15808,7 @@ auto DocumentFormattingOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -16135,6 +15823,7 @@ auto DocumentRangeFormattingOptions::rangesSupport() const auto& value = (*repr_)["rangesSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16145,6 +15834,7 @@ auto DocumentRangeFormattingOptions::workDoneProgress() const auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16155,7 +15845,7 @@ auto DocumentRangeFormattingOptions::rangesSupport( repr_->erase("rangesSupport"); return *this; } - repr_->emplace("rangesSupport", std::move(rangesSupport.value())); + (*repr_)["rangesSupport"] = std::move(rangesSupport.value()); return *this; } @@ -16165,7 +15855,7 @@ auto DocumentRangeFormattingOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -16179,6 +15869,7 @@ auto DocumentOnTypeFormattingOptions::firstTriggerCharacter() const -> std::string { auto& value = (*repr_)["firstTriggerCharacter"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16189,13 +15880,13 @@ auto DocumentOnTypeFormattingOptions::moreTriggerCharacter() const auto& value = (*repr_)["moreTriggerCharacter"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto DocumentOnTypeFormattingOptions::firstTriggerCharacter( std::string firstTriggerCharacter) -> DocumentOnTypeFormattingOptions& { - repr_->emplace("firstTriggerCharacter", std::move(firstTriggerCharacter)); + (*repr_)["firstTriggerCharacter"] = std::move(firstTriggerCharacter); return *this; } @@ -16222,6 +15913,7 @@ auto RenameOptions::prepareProvider() const -> std::optional { auto& value = (*repr_)["prepareProvider"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16231,6 +15923,7 @@ auto RenameOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16241,7 +15934,7 @@ auto RenameOptions::prepareProvider(std::optional prepareProvider) repr_->erase("prepareProvider"); return *this; } - repr_->emplace("prepareProvider", std::move(prepareProvider.value())); + (*repr_)["prepareProvider"] = std::move(prepareProvider.value()); return *this; } @@ -16251,7 +15944,7 @@ auto RenameOptions::workDoneProgress(std::optional workDoneProgress) repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -16271,18 +15964,19 @@ auto PrepareRenamePlaceholder::range() const -> Range { auto PrepareRenamePlaceholder::placeholder() const -> std::string { auto& value = (*repr_)["placeholder"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto PrepareRenamePlaceholder::range(Range range) -> PrepareRenamePlaceholder& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto PrepareRenamePlaceholder::placeholder(std::string placeholder) -> PrepareRenamePlaceholder& { - repr_->emplace("placeholder", std::move(placeholder)); + (*repr_)["placeholder"] = std::move(placeholder); return *this; } @@ -16295,13 +15989,14 @@ PrepareRenameDefaultBehavior::operator bool() const { auto PrepareRenameDefaultBehavior::defaultBehavior() const -> bool { auto& value = (*repr_)["defaultBehavior"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto PrepareRenameDefaultBehavior::defaultBehavior(bool defaultBehavior) -> PrepareRenameDefaultBehavior& { - repr_->emplace("defaultBehavior", std::move(defaultBehavior)); + (*repr_)["defaultBehavior"] = std::move(defaultBehavior); return *this; } @@ -16314,7 +16009,7 @@ ExecuteCommandOptions::operator bool() const { auto ExecuteCommandOptions::commands() const -> Vector { auto& value = (*repr_)["commands"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -16323,6 +16018,7 @@ auto ExecuteCommandOptions::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16339,7 +16035,7 @@ auto ExecuteCommandOptions::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -16353,6 +16049,7 @@ auto WorkspaceEditMetadata::isRefactoring() const -> std::optional { auto& value = (*repr_)["isRefactoring"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16363,7 +16060,7 @@ auto WorkspaceEditMetadata::isRefactoring(std::optional isRefactoring) repr_->erase("isRefactoring"); return *this; } - repr_->emplace("isRefactoring", std::move(isRefactoring.value())); + (*repr_)["isRefactoring"] = std::move(isRefactoring.value()); return *this; } @@ -16377,14 +16074,14 @@ SemanticTokensLegend::operator bool() const { auto SemanticTokensLegend::tokenTypes() const -> Vector { auto& value = (*repr_)["tokenTypes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto SemanticTokensLegend::tokenModifiers() const -> Vector { auto& value = (*repr_)["tokenModifiers"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -16410,6 +16107,7 @@ auto SemanticTokensFullDelta::delta() const -> std::optional { auto& value = (*repr_)["delta"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16420,7 +16118,7 @@ auto SemanticTokensFullDelta::delta(std::optional delta) repr_->erase("delta"); return *this; } - repr_->emplace("delta", std::move(delta.value())); + (*repr_)["delta"] = std::move(delta.value()); return *this; } @@ -16432,10 +16130,10 @@ OptionalVersionedTextDocumentIdentifier::operator bool() const { } auto OptionalVersionedTextDocumentIdentifier::version() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["version"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -16445,28 +16143,21 @@ auto OptionalVersionedTextDocumentIdentifier::version() const auto OptionalVersionedTextDocumentIdentifier::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto OptionalVersionedTextDocumentIdentifier::version( - std::variant 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()(int version) { (*repr_)["version"] = std::move(version); } void operator()(std::nullptr_t version) { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); } } v{repr_}; @@ -16477,7 +16168,7 @@ auto OptionalVersionedTextDocumentIdentifier::version( auto OptionalVersionedTextDocumentIdentifier::uri(std::string uri) -> OptionalVersionedTextDocumentIdentifier& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } @@ -16492,6 +16183,7 @@ AnnotatedTextEdit::operator bool() const { auto AnnotatedTextEdit::annotationId() const -> ChangeAnnotationIdentifier { auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16505,6 +16197,7 @@ auto AnnotatedTextEdit::range() const -> Range { auto AnnotatedTextEdit::newText() const -> std::string { auto& value = (*repr_)["newText"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16516,12 +16209,12 @@ auto AnnotatedTextEdit::annotationId(ChangeAnnotationIdentifier annotationId) } auto AnnotatedTextEdit::range(Range range) -> AnnotatedTextEdit& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto AnnotatedTextEdit::newText(std::string newText) -> AnnotatedTextEdit& { - repr_->emplace("newText", std::move(newText)); + (*repr_)["newText"] = std::move(newText); return *this; } @@ -16550,17 +16243,18 @@ auto SnippetTextEdit::annotationId() const auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto SnippetTextEdit::range(Range range) -> SnippetTextEdit& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto SnippetTextEdit::snippet(StringValue snippet) -> SnippetTextEdit& { - repr_->emplace("snippet", snippet); + (*repr_)["snippet"] = snippet; return *this; } @@ -16584,6 +16278,7 @@ ResourceOperation::operator bool() const { auto ResourceOperation::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16594,12 +16289,13 @@ auto ResourceOperation::annotationId() const auto& value = (*repr_)["annotationId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ResourceOperation::kind(std::string kind) -> ResourceOperation& { - repr_->emplace("kind", std::move(kind)); + (*repr_)["kind"] = std::move(kind); return *this; } @@ -16624,6 +16320,7 @@ auto CreateFileOptions::overwrite() const -> std::optional { auto& value = (*repr_)["overwrite"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16633,6 +16330,7 @@ auto CreateFileOptions::ignoreIfExists() const -> std::optional { auto& value = (*repr_)["ignoreIfExists"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16643,7 +16341,7 @@ auto CreateFileOptions::overwrite(std::optional overwrite) repr_->erase("overwrite"); return *this; } - repr_->emplace("overwrite", std::move(overwrite.value())); + (*repr_)["overwrite"] = std::move(overwrite.value()); return *this; } @@ -16653,7 +16351,7 @@ auto CreateFileOptions::ignoreIfExists(std::optional ignoreIfExists) repr_->erase("ignoreIfExists"); return *this; } - repr_->emplace("ignoreIfExists", std::move(ignoreIfExists.value())); + (*repr_)["ignoreIfExists"] = std::move(ignoreIfExists.value()); return *this; } @@ -16667,6 +16365,7 @@ auto RenameFileOptions::overwrite() const -> std::optional { auto& value = (*repr_)["overwrite"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16676,6 +16375,7 @@ auto RenameFileOptions::ignoreIfExists() const -> std::optional { auto& value = (*repr_)["ignoreIfExists"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16686,7 +16386,7 @@ auto RenameFileOptions::overwrite(std::optional overwrite) repr_->erase("overwrite"); return *this; } - repr_->emplace("overwrite", std::move(overwrite.value())); + (*repr_)["overwrite"] = std::move(overwrite.value()); return *this; } @@ -16696,7 +16396,7 @@ auto RenameFileOptions::ignoreIfExists(std::optional ignoreIfExists) repr_->erase("ignoreIfExists"); return *this; } - repr_->emplace("ignoreIfExists", std::move(ignoreIfExists.value())); + (*repr_)["ignoreIfExists"] = std::move(ignoreIfExists.value()); return *this; } @@ -16710,6 +16410,7 @@ auto DeleteFileOptions::recursive() const -> std::optional { auto& value = (*repr_)["recursive"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16719,6 +16420,7 @@ auto DeleteFileOptions::ignoreIfNotExists() const -> std::optional { auto& value = (*repr_)["ignoreIfNotExists"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -16729,7 +16431,7 @@ auto DeleteFileOptions::recursive(std::optional recursive) repr_->erase("recursive"); return *this; } - repr_->emplace("recursive", std::move(recursive.value())); + (*repr_)["recursive"] = std::move(recursive.value()); return *this; } @@ -16739,7 +16441,7 @@ auto DeleteFileOptions::ignoreIfNotExists(std::optional ignoreIfNotExists) repr_->erase("ignoreIfNotExists"); return *this; } - repr_->emplace("ignoreIfNotExists", std::move(ignoreIfNotExists.value())); + (*repr_)["ignoreIfNotExists"] = std::move(ignoreIfNotExists.value()); return *this; } @@ -16752,6 +16454,7 @@ FileOperationPattern::operator bool() const { auto FileOperationPattern::glob() const -> std::string { auto& value = (*repr_)["glob"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16775,7 +16478,7 @@ auto FileOperationPattern::options() const } auto FileOperationPattern::glob(std::string glob) -> FileOperationPattern& { - repr_->emplace("glob", std::move(glob)); + (*repr_)["glob"] = std::move(glob); return *this; } @@ -16796,7 +16499,7 @@ auto FileOperationPattern::options( repr_->erase("options"); return *this; } - repr_->emplace("options", options.value()); + (*repr_)["options"] = options.value(); return *this; } @@ -16813,15 +16516,16 @@ WorkspaceFullDocumentDiagnosticReport::operator bool() const { auto WorkspaceFullDocumentDiagnosticReport::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto WorkspaceFullDocumentDiagnosticReport::version() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["version"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -16831,6 +16535,7 @@ auto WorkspaceFullDocumentDiagnosticReport::version() const auto WorkspaceFullDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "full"; assert(value.is_string()); return value.get(); } @@ -16841,6 +16546,7 @@ auto WorkspaceFullDocumentDiagnosticReport::resultId() const auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -16849,34 +16555,26 @@ auto WorkspaceFullDocumentDiagnosticReport::items() const -> Vector { auto& value = (*repr_)["items"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto WorkspaceFullDocumentDiagnosticReport::uri(std::string uri) -> WorkspaceFullDocumentDiagnosticReport& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto WorkspaceFullDocumentDiagnosticReport::version( - std::variant 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()(int version) { (*repr_)["version"] = std::move(version); } void operator()(std::nullptr_t version) { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); } } v{repr_}; @@ -16899,7 +16597,7 @@ auto WorkspaceFullDocumentDiagnosticReport::resultId( repr_->erase("resultId"); return *this; } - repr_->emplace("resultId", std::move(resultId.value())); + (*repr_)["resultId"] = std::move(resultId.value()); return *this; } @@ -16923,15 +16621,16 @@ WorkspaceUnchangedDocumentDiagnosticReport::operator bool() const { auto WorkspaceUnchangedDocumentDiagnosticReport::uri() const -> std::string { auto& value = (*repr_)["uri"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto WorkspaceUnchangedDocumentDiagnosticReport::version() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["version"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -16941,6 +16640,7 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::version() const auto WorkspaceUnchangedDocumentDiagnosticReport::kind() const -> std::string { auto& value = (*repr_)["kind"]; + if (value.is_null()) value = "unchanged"; assert(value.is_string()); return value.get(); } @@ -16949,34 +16649,27 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::resultId() const -> std::string { auto& value = (*repr_)["resultId"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto WorkspaceUnchangedDocumentDiagnosticReport::uri(std::string uri) -> WorkspaceUnchangedDocumentDiagnosticReport& { - repr_->emplace("uri", std::move(uri)); + (*repr_)["uri"] = std::move(uri); return *this; } auto WorkspaceUnchangedDocumentDiagnosticReport::version( - std::variant 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()(int version) { (*repr_)["version"] = std::move(version); } void operator()(std::nullptr_t version) { - repr_->emplace("version", std::move(version)); + (*repr_)["version"] = std::move(version); } } v{repr_}; @@ -16994,7 +16687,7 @@ auto WorkspaceUnchangedDocumentDiagnosticReport::kind(std::string kind) auto WorkspaceUnchangedDocumentDiagnosticReport::resultId(std::string resultId) -> WorkspaceUnchangedDocumentDiagnosticReport& { - repr_->emplace("resultId", std::move(resultId)); + (*repr_)["resultId"] = std::move(resultId); return *this; } @@ -17014,6 +16707,7 @@ auto NotebookCell::kind() const -> NotebookCellKind { auto NotebookCell::document() const -> std::string { auto& value = (*repr_)["document"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -17036,12 +16730,12 @@ auto NotebookCell::executionSummary() const -> std::optional { } auto NotebookCell::kind(NotebookCellKind kind) -> NotebookCell& { - repr_->emplace("kind", static_cast(kind)); + (*repr_)["kind"] = static_cast(kind); return *this; } auto NotebookCell::document(std::string document) -> NotebookCell& { - repr_->emplace("document", std::move(document)); + (*repr_)["document"] = std::move(document); return *this; } @@ -17061,7 +16755,7 @@ auto NotebookCell::executionSummary( repr_->erase("executionSummary"); return *this; } - repr_->emplace("executionSummary", executionSummary.value()); + (*repr_)["executionSummary"] = executionSummary.value(); return *this; } @@ -17072,10 +16766,10 @@ NotebookDocumentFilterWithNotebook::operator bool() const { } auto NotebookDocumentFilterWithNotebook::notebook() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["notebook"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -17088,24 +16782,18 @@ auto NotebookDocumentFilterWithNotebook::cells() const auto& value = (*repr_)["cells"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookDocumentFilterWithNotebook::notebook( - std::variant 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)); + (*repr_)["notebook"] = std::move(notebook); } void operator()(NotebookDocumentFilter notebook) { @@ -17137,13 +16825,13 @@ NotebookDocumentFilterWithCells::operator bool() const { return true; } -auto NotebookDocumentFilterWithCells::notebook() const -> std::optional< - std::variant> { +auto NotebookDocumentFilterWithCells::notebook() const + -> std::optional> { if (!repr_->contains("notebook")) return std::nullopt; auto& value = (*repr_)["notebook"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -17154,30 +16842,23 @@ auto NotebookDocumentFilterWithCells::cells() const -> Vector { auto& value = (*repr_)["cells"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookDocumentFilterWithCells::notebook( - std::optional< - std::variant> - notebook) -> NotebookDocumentFilterWithCells& { + std::optional> 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)); + (*repr_)["notebook"] = std::move(notebook); } void operator()(NotebookDocumentFilter notebook) { @@ -17218,7 +16899,7 @@ auto NotebookDocumentCellChanges::data() const auto& value = (*repr_)["data"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -17228,7 +16909,7 @@ auto NotebookDocumentCellChanges::textContent() const auto& value = (*repr_)["textContent"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -17239,7 +16920,7 @@ auto NotebookDocumentCellChanges::structure( repr_->erase("structure"); return *this; } - repr_->emplace("structure", structure.value()); + (*repr_)["structure"] = structure.value(); return *this; } @@ -17281,17 +16962,18 @@ auto SelectedCompletionInfo::range() const -> Range { auto SelectedCompletionInfo::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto SelectedCompletionInfo::range(Range range) -> SelectedCompletionInfo& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } auto SelectedCompletionInfo::text(std::string text) -> SelectedCompletionInfo& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -17304,6 +16986,7 @@ ClientInfo::operator bool() const { auto ClientInfo::name() const -> std::string { auto& value = (*repr_)["name"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -17313,12 +16996,13 @@ auto ClientInfo::version() const -> std::optional { auto& value = (*repr_)["version"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto ClientInfo::name(std::string name) -> ClientInfo& { - repr_->emplace("name", std::move(name)); + (*repr_)["name"] = std::move(name); return *this; } @@ -17327,7 +17011,7 @@ auto ClientInfo::version(std::optional version) -> ClientInfo& { repr_->erase("version"); return *this; } - repr_->emplace("version", std::move(version.value())); + (*repr_)["version"] = std::move(version.value()); return *this; } @@ -17397,7 +17081,7 @@ auto ClientCapabilities::workspace( repr_->erase("workspace"); return *this; } - repr_->emplace("workspace", workspace.value()); + (*repr_)["workspace"] = workspace.value(); return *this; } @@ -17408,7 +17092,7 @@ auto ClientCapabilities::textDocument( repr_->erase("textDocument"); return *this; } - repr_->emplace("textDocument", textDocument.value()); + (*repr_)["textDocument"] = textDocument.value(); return *this; } @@ -17419,7 +17103,7 @@ auto ClientCapabilities::notebookDocument( repr_->erase("notebookDocument"); return *this; } - repr_->emplace("notebookDocument", notebookDocument.value()); + (*repr_)["notebookDocument"] = notebookDocument.value(); return *this; } @@ -17429,7 +17113,7 @@ auto ClientCapabilities::window(std::optional window) repr_->erase("window"); return *this; } - repr_->emplace("window", window.value()); + (*repr_)["window"] = window.value(); return *this; } @@ -17439,7 +17123,7 @@ auto ClientCapabilities::general( repr_->erase("general"); return *this; } - repr_->emplace("general", general.value()); + (*repr_)["general"] = general.value(); return *this; } @@ -17463,6 +17147,7 @@ auto TextDocumentSyncOptions::openClose() const -> std::optional { auto& value = (*repr_)["openClose"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -17481,6 +17166,7 @@ auto TextDocumentSyncOptions::willSave() const -> std::optional { auto& value = (*repr_)["willSave"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -17490,17 +17176,18 @@ auto TextDocumentSyncOptions::willSaveWaitUntil() const -> std::optional { auto& value = (*repr_)["willSaveWaitUntil"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto TextDocumentSyncOptions::save() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("save")) return std::nullopt; auto& value = (*repr_)["save"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -17513,7 +17200,7 @@ auto TextDocumentSyncOptions::openClose(std::optional openClose) repr_->erase("openClose"); return *this; } - repr_->emplace("openClose", std::move(openClose.value())); + (*repr_)["openClose"] = std::move(openClose.value()); return *this; } @@ -17523,7 +17210,7 @@ auto TextDocumentSyncOptions::change(std::optional change) repr_->erase("change"); return *this; } - repr_->emplace("change", static_cast(change.value())); + (*repr_)["change"] = static_cast(change.value()); return *this; } @@ -17533,7 +17220,7 @@ auto TextDocumentSyncOptions::willSave(std::optional willSave) repr_->erase("willSave"); return *this; } - repr_->emplace("willSave", std::move(willSave.value())); + (*repr_)["willSave"] = std::move(willSave.value()); return *this; } @@ -17543,30 +17230,24 @@ auto TextDocumentSyncOptions::willSaveWaitUntil( repr_->erase("willSaveWaitUntil"); return *this; } - repr_->emplace("willSaveWaitUntil", std::move(willSaveWaitUntil.value())); + (*repr_)["willSaveWaitUntil"] = std::move(willSaveWaitUntil.value()); return *this; } auto TextDocumentSyncOptions::save( - std::optional> 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()(bool save) { (*repr_)["save"] = std::move(save); } - void operator()(SaveOptions save) { repr_->emplace("save", save); } + void operator()(SaveOptions save) { (*repr_)["save"] = save; } } v{repr_}; std::visit(v, save.value()); @@ -17598,13 +17279,13 @@ auto WorkspaceOptions::fileOperations() const } auto WorkspaceOptions::textDocumentContent() const - -> std::optional std::optional> { if (!repr_->contains("textDocumentContent")) return std::nullopt; auto& value = (*repr_)["textDocumentContent"]; - std::variant result; @@ -17620,7 +17301,7 @@ auto WorkspaceOptions::workspaceFolders( repr_->erase("workspaceFolders"); return *this; } - repr_->emplace("workspaceFolders", workspaceFolders.value()); + (*repr_)["workspaceFolders"] = workspaceFolders.value(); return *this; } @@ -17630,12 +17311,12 @@ auto WorkspaceOptions::fileOperations( repr_->erase("fileOperations"); return *this; } - repr_->emplace("fileOperations", fileOperations.value()); + (*repr_)["fileOperations"] = fileOperations.value(); return *this; } auto WorkspaceOptions::textDocumentContent( - std::optional> textDocumentContent) -> WorkspaceOptions& { if (!textDocumentContent.has_value()) { @@ -17643,22 +17324,16 @@ auto WorkspaceOptions::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); + (*repr_)["textDocumentContent"] = textDocumentContent; } void operator()( TextDocumentContentRegistrationOptions textDocumentContent) { - repr_->emplace("textDocumentContent", textDocumentContent); + (*repr_)["textDocumentContent"] = textDocumentContent; } } v{repr_}; @@ -17686,6 +17361,7 @@ auto TextDocumentContentChangePartial::rangeLength() const auto& value = (*repr_)["rangeLength"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -17693,13 +17369,14 @@ auto TextDocumentContentChangePartial::rangeLength() const auto TextDocumentContentChangePartial::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentContentChangePartial::range(Range range) -> TextDocumentContentChangePartial& { - repr_->emplace("range", range); + (*repr_)["range"] = range; return *this; } @@ -17709,13 +17386,13 @@ auto TextDocumentContentChangePartial::rangeLength( repr_->erase("rangeLength"); return *this; } - repr_->emplace("rangeLength", std::move(rangeLength.value())); + (*repr_)["rangeLength"] = std::move(rangeLength.value()); return *this; } auto TextDocumentContentChangePartial::text(std::string text) -> TextDocumentContentChangePartial& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -17728,13 +17405,14 @@ TextDocumentContentChangeWholeDocument::operator bool() const { auto TextDocumentContentChangeWholeDocument::text() const -> std::string { auto& value = (*repr_)["text"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto TextDocumentContentChangeWholeDocument::text(std::string text) -> TextDocumentContentChangeWholeDocument& { - repr_->emplace("text", std::move(text)); + (*repr_)["text"] = std::move(text); return *this; } @@ -17747,12 +17425,13 @@ CodeDescription::operator bool() const { auto CodeDescription::href() const -> std::string { auto& value = (*repr_)["href"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto CodeDescription::href(std::string href) -> CodeDescription& { - repr_->emplace("href", std::move(href)); + (*repr_)["href"] = std::move(href); return *this; } @@ -17772,19 +17451,20 @@ auto DiagnosticRelatedInformation::location() const -> Location { auto DiagnosticRelatedInformation::message() const -> std::string { auto& value = (*repr_)["message"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto DiagnosticRelatedInformation::location(Location location) -> DiagnosticRelatedInformation& { - repr_->emplace("location", location); + (*repr_)["location"] = location; return *this; } auto DiagnosticRelatedInformation::message(std::string message) -> DiagnosticRelatedInformation& { - repr_->emplace("message", std::move(message)); + (*repr_)["message"] = std::move(message); return *this; } @@ -17809,13 +17489,13 @@ auto EditRangeWithInsertReplace::replace() const -> Range { auto EditRangeWithInsertReplace::insert(Range insert) -> EditRangeWithInsertReplace& { - repr_->emplace("insert", insert); + (*repr_)["insert"] = insert; return *this; } auto EditRangeWithInsertReplace::replace(Range replace) -> EditRangeWithInsertReplace& { - repr_->emplace("replace", replace); + (*repr_)["replace"] = replace; return *this; } @@ -17830,6 +17510,7 @@ auto ServerCompletionItemOptions::labelDetailsSupport() const auto& value = (*repr_)["labelDetailsSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -17840,7 +17521,7 @@ auto ServerCompletionItemOptions::labelDetailsSupport( repr_->erase("labelDetailsSupport"); return *this; } - repr_->emplace("labelDetailsSupport", std::move(labelDetailsSupport.value())); + (*repr_)["labelDetailsSupport"] = std::move(labelDetailsSupport.value()); return *this; } @@ -17854,6 +17535,7 @@ MarkedStringWithLanguage::operator bool() const { auto MarkedStringWithLanguage::language() const -> std::string { auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -17861,19 +17543,20 @@ auto MarkedStringWithLanguage::language() const -> std::string { auto MarkedStringWithLanguage::value() const -> std::string { auto& value = (*repr_)["value"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto MarkedStringWithLanguage::language(std::string language) -> MarkedStringWithLanguage& { - repr_->emplace("language", std::move(language)); + (*repr_)["language"] = std::move(language); return *this; } auto MarkedStringWithLanguage::value(std::string value) -> MarkedStringWithLanguage& { - repr_->emplace("value", std::move(value)); + (*repr_)["value"] = std::move(value); return *this; } @@ -17884,10 +17567,10 @@ ParameterInformation::operator bool() const { } auto ParameterInformation::label() const - -> std::variant> { + -> std::variant> { auto& value = (*repr_)["label"]; - std::variant> result; + std::variant> result; details::try_emplace(result, value); @@ -17895,12 +17578,12 @@ auto ParameterInformation::label() const } auto ParameterInformation::documentation() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("documentation")) return std::nullopt; auto& value = (*repr_)["documentation"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -17908,20 +17591,12 @@ auto ParameterInformation::documentation() const } auto ParameterInformation::label( - std::variant> 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::string label) { (*repr_)["label"] = std::move(label); } void operator()(std::tuple label) { lsp_runtime_error("ParameterInformation::label: not implement yet"); @@ -17934,28 +17609,22 @@ auto ParameterInformation::label( } auto ParameterInformation::documentation( - std::optional> - documentation) -> ParameterInformation& { + 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)); + (*repr_)["documentation"] = std::move(documentation); } void operator()(MarkupContent documentation) { - repr_->emplace("documentation", documentation); + (*repr_)["documentation"] = documentation; } } v{repr_}; @@ -17991,7 +17660,7 @@ auto CodeActionKindDocumentation::kind(CodeActionKind kind) auto CodeActionKindDocumentation::command(Command command) -> CodeActionKindDocumentation& { - repr_->emplace("command", command); + (*repr_)["command"] = command; return *this; } @@ -18002,10 +17671,10 @@ NotebookCellTextDocumentFilter::operator bool() const { } auto NotebookCellTextDocumentFilter::notebook() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["notebook"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -18018,24 +17687,19 @@ auto NotebookCellTextDocumentFilter::language() const auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto NotebookCellTextDocumentFilter::notebook( - std::variant 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)); + (*repr_)["notebook"] = std::move(notebook); } void operator()(NotebookDocumentFilter notebook) { @@ -18055,7 +17719,7 @@ auto NotebookCellTextDocumentFilter::language( repr_->erase("language"); return *this; } - repr_->emplace("language", std::move(language.value())); + (*repr_)["language"] = std::move(language.value()); return *this; } @@ -18069,6 +17733,7 @@ auto FileOperationPatternOptions::ignoreCase() const -> std::optional { auto& value = (*repr_)["ignoreCase"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -18079,7 +17744,7 @@ auto FileOperationPatternOptions::ignoreCase(std::optional ignoreCase) repr_->erase("ignoreCase"); return *this; } - repr_->emplace("ignoreCase", std::move(ignoreCase.value())); + (*repr_)["ignoreCase"] = std::move(ignoreCase.value()); return *this; } @@ -18092,6 +17757,7 @@ ExecutionSummary::operator bool() const { auto ExecutionSummary::executionOrder() const -> long { auto& value = (*repr_)["executionOrder"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -18101,13 +17767,14 @@ auto ExecutionSummary::success() const -> std::optional { auto& value = (*repr_)["success"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto ExecutionSummary::executionOrder(long executionOrder) -> ExecutionSummary& { - repr_->emplace("executionOrder", std::move(executionOrder)); + (*repr_)["executionOrder"] = std::move(executionOrder); return *this; } @@ -18117,7 +17784,7 @@ auto ExecutionSummary::success(std::optional success) repr_->erase("success"); return *this; } - repr_->emplace("success", std::move(success.value())); + (*repr_)["success"] = std::move(success.value()); return *this; } @@ -18130,13 +17797,14 @@ NotebookCellLanguage::operator bool() const { auto NotebookCellLanguage::language() const -> std::string { auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto NotebookCellLanguage::language(std::string language) -> NotebookCellLanguage& { - repr_->emplace("language", std::move(language)); + (*repr_)["language"] = std::move(language); return *this; } @@ -18159,7 +17827,7 @@ auto NotebookDocumentCellChangeStructure::didOpen() const auto& value = (*repr_)["didOpen"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -18169,13 +17837,13 @@ auto NotebookDocumentCellChangeStructure::didClose() const auto& value = (*repr_)["didClose"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookDocumentCellChangeStructure::array(NotebookCellArrayChange array) -> NotebookDocumentCellChangeStructure& { - repr_->emplace("array", array); + (*repr_)["array"] = array; return *this; } @@ -18221,14 +17889,14 @@ auto NotebookDocumentCellContentChanges::changes() const -> Vector { auto& value = (*repr_)["changes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookDocumentCellContentChanges::document( VersionedTextDocumentIdentifier document) -> NotebookDocumentCellContentChanges& { - repr_->emplace("document", document); + (*repr_)["document"] = document; return *this; } @@ -18250,6 +17918,7 @@ auto WorkspaceClientCapabilities::applyEdit() const -> std::optional { auto& value = (*repr_)["applyEdit"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -18305,6 +17974,7 @@ auto WorkspaceClientCapabilities::workspaceFolders() const auto& value = (*repr_)["workspaceFolders"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -18314,6 +17984,7 @@ auto WorkspaceClientCapabilities::configuration() const -> std::optional { auto& value = (*repr_)["configuration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -18396,7 +18067,7 @@ auto WorkspaceClientCapabilities::applyEdit(std::optional applyEdit) repr_->erase("applyEdit"); return *this; } - repr_->emplace("applyEdit", std::move(applyEdit.value())); + (*repr_)["applyEdit"] = std::move(applyEdit.value()); return *this; } @@ -18407,7 +18078,7 @@ auto WorkspaceClientCapabilities::workspaceEdit( repr_->erase("workspaceEdit"); return *this; } - repr_->emplace("workspaceEdit", workspaceEdit.value()); + (*repr_)["workspaceEdit"] = workspaceEdit.value(); return *this; } @@ -18418,7 +18089,7 @@ auto WorkspaceClientCapabilities::didChangeConfiguration( repr_->erase("didChangeConfiguration"); return *this; } - repr_->emplace("didChangeConfiguration", didChangeConfiguration.value()); + (*repr_)["didChangeConfiguration"] = didChangeConfiguration.value(); return *this; } @@ -18429,7 +18100,7 @@ auto WorkspaceClientCapabilities::didChangeWatchedFiles( repr_->erase("didChangeWatchedFiles"); return *this; } - repr_->emplace("didChangeWatchedFiles", didChangeWatchedFiles.value()); + (*repr_)["didChangeWatchedFiles"] = didChangeWatchedFiles.value(); return *this; } @@ -18440,7 +18111,7 @@ auto WorkspaceClientCapabilities::symbol( repr_->erase("symbol"); return *this; } - repr_->emplace("symbol", symbol.value()); + (*repr_)["symbol"] = symbol.value(); return *this; } @@ -18451,7 +18122,7 @@ auto WorkspaceClientCapabilities::executeCommand( repr_->erase("executeCommand"); return *this; } - repr_->emplace("executeCommand", executeCommand.value()); + (*repr_)["executeCommand"] = executeCommand.value(); return *this; } @@ -18461,7 +18132,7 @@ auto WorkspaceClientCapabilities::workspaceFolders( repr_->erase("workspaceFolders"); return *this; } - repr_->emplace("workspaceFolders", std::move(workspaceFolders.value())); + (*repr_)["workspaceFolders"] = std::move(workspaceFolders.value()); return *this; } @@ -18471,7 +18142,7 @@ auto WorkspaceClientCapabilities::configuration( repr_->erase("configuration"); return *this; } - repr_->emplace("configuration", std::move(configuration.value())); + (*repr_)["configuration"] = std::move(configuration.value()); return *this; } @@ -18482,7 +18153,7 @@ auto WorkspaceClientCapabilities::semanticTokens( repr_->erase("semanticTokens"); return *this; } - repr_->emplace("semanticTokens", semanticTokens.value()); + (*repr_)["semanticTokens"] = semanticTokens.value(); return *this; } @@ -18493,7 +18164,7 @@ auto WorkspaceClientCapabilities::codeLens( repr_->erase("codeLens"); return *this; } - repr_->emplace("codeLens", codeLens.value()); + (*repr_)["codeLens"] = codeLens.value(); return *this; } @@ -18504,7 +18175,7 @@ auto WorkspaceClientCapabilities::fileOperations( repr_->erase("fileOperations"); return *this; } - repr_->emplace("fileOperations", fileOperations.value()); + (*repr_)["fileOperations"] = fileOperations.value(); return *this; } @@ -18515,7 +18186,7 @@ auto WorkspaceClientCapabilities::inlineValue( repr_->erase("inlineValue"); return *this; } - repr_->emplace("inlineValue", inlineValue.value()); + (*repr_)["inlineValue"] = inlineValue.value(); return *this; } @@ -18526,7 +18197,7 @@ auto WorkspaceClientCapabilities::inlayHint( repr_->erase("inlayHint"); return *this; } - repr_->emplace("inlayHint", inlayHint.value()); + (*repr_)["inlayHint"] = inlayHint.value(); return *this; } @@ -18537,7 +18208,7 @@ auto WorkspaceClientCapabilities::diagnostics( repr_->erase("diagnostics"); return *this; } - repr_->emplace("diagnostics", diagnostics.value()); + (*repr_)["diagnostics"] = diagnostics.value(); return *this; } @@ -18548,7 +18219,7 @@ auto WorkspaceClientCapabilities::foldingRange( repr_->erase("foldingRange"); return *this; } - repr_->emplace("foldingRange", foldingRange.value()); + (*repr_)["foldingRange"] = foldingRange.value(); return *this; } @@ -18559,7 +18230,7 @@ auto WorkspaceClientCapabilities::textDocumentContent( repr_->erase("textDocumentContent"); return *this; } - repr_->emplace("textDocumentContent", textDocumentContent.value()); + (*repr_)["textDocumentContent"] = textDocumentContent.value(); return *this; } @@ -18863,7 +18534,7 @@ auto TextDocumentClientCapabilities::synchronization( repr_->erase("synchronization"); return *this; } - repr_->emplace("synchronization", synchronization.value()); + (*repr_)["synchronization"] = synchronization.value(); return *this; } @@ -18874,7 +18545,7 @@ auto TextDocumentClientCapabilities::filters( repr_->erase("filters"); return *this; } - repr_->emplace("filters", filters.value()); + (*repr_)["filters"] = filters.value(); return *this; } @@ -18885,7 +18556,7 @@ auto TextDocumentClientCapabilities::completion( repr_->erase("completion"); return *this; } - repr_->emplace("completion", completion.value()); + (*repr_)["completion"] = completion.value(); return *this; } @@ -18896,7 +18567,7 @@ auto TextDocumentClientCapabilities::hover( repr_->erase("hover"); return *this; } - repr_->emplace("hover", hover.value()); + (*repr_)["hover"] = hover.value(); return *this; } @@ -18907,7 +18578,7 @@ auto TextDocumentClientCapabilities::signatureHelp( repr_->erase("signatureHelp"); return *this; } - repr_->emplace("signatureHelp", signatureHelp.value()); + (*repr_)["signatureHelp"] = signatureHelp.value(); return *this; } @@ -18918,7 +18589,7 @@ auto TextDocumentClientCapabilities::declaration( repr_->erase("declaration"); return *this; } - repr_->emplace("declaration", declaration.value()); + (*repr_)["declaration"] = declaration.value(); return *this; } @@ -18929,7 +18600,7 @@ auto TextDocumentClientCapabilities::definition( repr_->erase("definition"); return *this; } - repr_->emplace("definition", definition.value()); + (*repr_)["definition"] = definition.value(); return *this; } @@ -18940,7 +18611,7 @@ auto TextDocumentClientCapabilities::typeDefinition( repr_->erase("typeDefinition"); return *this; } - repr_->emplace("typeDefinition", typeDefinition.value()); + (*repr_)["typeDefinition"] = typeDefinition.value(); return *this; } @@ -18951,7 +18622,7 @@ auto TextDocumentClientCapabilities::implementation( repr_->erase("implementation"); return *this; } - repr_->emplace("implementation", implementation.value()); + (*repr_)["implementation"] = implementation.value(); return *this; } @@ -18962,7 +18633,7 @@ auto TextDocumentClientCapabilities::references( repr_->erase("references"); return *this; } - repr_->emplace("references", references.value()); + (*repr_)["references"] = references.value(); return *this; } @@ -18973,7 +18644,7 @@ auto TextDocumentClientCapabilities::documentHighlight( repr_->erase("documentHighlight"); return *this; } - repr_->emplace("documentHighlight", documentHighlight.value()); + (*repr_)["documentHighlight"] = documentHighlight.value(); return *this; } @@ -18984,7 +18655,7 @@ auto TextDocumentClientCapabilities::documentSymbol( repr_->erase("documentSymbol"); return *this; } - repr_->emplace("documentSymbol", documentSymbol.value()); + (*repr_)["documentSymbol"] = documentSymbol.value(); return *this; } @@ -18995,7 +18666,7 @@ auto TextDocumentClientCapabilities::codeAction( repr_->erase("codeAction"); return *this; } - repr_->emplace("codeAction", codeAction.value()); + (*repr_)["codeAction"] = codeAction.value(); return *this; } @@ -19006,7 +18677,7 @@ auto TextDocumentClientCapabilities::codeLens( repr_->erase("codeLens"); return *this; } - repr_->emplace("codeLens", codeLens.value()); + (*repr_)["codeLens"] = codeLens.value(); return *this; } @@ -19017,7 +18688,7 @@ auto TextDocumentClientCapabilities::documentLink( repr_->erase("documentLink"); return *this; } - repr_->emplace("documentLink", documentLink.value()); + (*repr_)["documentLink"] = documentLink.value(); return *this; } @@ -19028,7 +18699,7 @@ auto TextDocumentClientCapabilities::colorProvider( repr_->erase("colorProvider"); return *this; } - repr_->emplace("colorProvider", colorProvider.value()); + (*repr_)["colorProvider"] = colorProvider.value(); return *this; } @@ -19039,7 +18710,7 @@ auto TextDocumentClientCapabilities::formatting( repr_->erase("formatting"); return *this; } - repr_->emplace("formatting", formatting.value()); + (*repr_)["formatting"] = formatting.value(); return *this; } @@ -19050,7 +18721,7 @@ auto TextDocumentClientCapabilities::rangeFormatting( repr_->erase("rangeFormatting"); return *this; } - repr_->emplace("rangeFormatting", rangeFormatting.value()); + (*repr_)["rangeFormatting"] = rangeFormatting.value(); return *this; } @@ -19061,7 +18732,7 @@ auto TextDocumentClientCapabilities::onTypeFormatting( repr_->erase("onTypeFormatting"); return *this; } - repr_->emplace("onTypeFormatting", onTypeFormatting.value()); + (*repr_)["onTypeFormatting"] = onTypeFormatting.value(); return *this; } @@ -19072,7 +18743,7 @@ auto TextDocumentClientCapabilities::rename( repr_->erase("rename"); return *this; } - repr_->emplace("rename", rename.value()); + (*repr_)["rename"] = rename.value(); return *this; } @@ -19083,7 +18754,7 @@ auto TextDocumentClientCapabilities::foldingRange( repr_->erase("foldingRange"); return *this; } - repr_->emplace("foldingRange", foldingRange.value()); + (*repr_)["foldingRange"] = foldingRange.value(); return *this; } @@ -19094,7 +18765,7 @@ auto TextDocumentClientCapabilities::selectionRange( repr_->erase("selectionRange"); return *this; } - repr_->emplace("selectionRange", selectionRange.value()); + (*repr_)["selectionRange"] = selectionRange.value(); return *this; } @@ -19105,7 +18776,7 @@ auto TextDocumentClientCapabilities::publishDiagnostics( repr_->erase("publishDiagnostics"); return *this; } - repr_->emplace("publishDiagnostics", publishDiagnostics.value()); + (*repr_)["publishDiagnostics"] = publishDiagnostics.value(); return *this; } @@ -19116,7 +18787,7 @@ auto TextDocumentClientCapabilities::callHierarchy( repr_->erase("callHierarchy"); return *this; } - repr_->emplace("callHierarchy", callHierarchy.value()); + (*repr_)["callHierarchy"] = callHierarchy.value(); return *this; } @@ -19127,7 +18798,7 @@ auto TextDocumentClientCapabilities::semanticTokens( repr_->erase("semanticTokens"); return *this; } - repr_->emplace("semanticTokens", semanticTokens.value()); + (*repr_)["semanticTokens"] = semanticTokens.value(); return *this; } @@ -19138,7 +18809,7 @@ auto TextDocumentClientCapabilities::linkedEditingRange( repr_->erase("linkedEditingRange"); return *this; } - repr_->emplace("linkedEditingRange", linkedEditingRange.value()); + (*repr_)["linkedEditingRange"] = linkedEditingRange.value(); return *this; } @@ -19149,7 +18820,7 @@ auto TextDocumentClientCapabilities::moniker( repr_->erase("moniker"); return *this; } - repr_->emplace("moniker", moniker.value()); + (*repr_)["moniker"] = moniker.value(); return *this; } @@ -19160,7 +18831,7 @@ auto TextDocumentClientCapabilities::typeHierarchy( repr_->erase("typeHierarchy"); return *this; } - repr_->emplace("typeHierarchy", typeHierarchy.value()); + (*repr_)["typeHierarchy"] = typeHierarchy.value(); return *this; } @@ -19171,7 +18842,7 @@ auto TextDocumentClientCapabilities::inlineValue( repr_->erase("inlineValue"); return *this; } - repr_->emplace("inlineValue", inlineValue.value()); + (*repr_)["inlineValue"] = inlineValue.value(); return *this; } @@ -19182,7 +18853,7 @@ auto TextDocumentClientCapabilities::inlayHint( repr_->erase("inlayHint"); return *this; } - repr_->emplace("inlayHint", inlayHint.value()); + (*repr_)["inlayHint"] = inlayHint.value(); return *this; } @@ -19193,7 +18864,7 @@ auto TextDocumentClientCapabilities::diagnostic( repr_->erase("diagnostic"); return *this; } - repr_->emplace("diagnostic", diagnostic.value()); + (*repr_)["diagnostic"] = diagnostic.value(); return *this; } @@ -19204,7 +18875,7 @@ auto TextDocumentClientCapabilities::inlineCompletion( repr_->erase("inlineCompletion"); return *this; } - repr_->emplace("inlineCompletion", inlineCompletion.value()); + (*repr_)["inlineCompletion"] = inlineCompletion.value(); return *this; } @@ -19224,7 +18895,7 @@ auto NotebookDocumentClientCapabilities::synchronization() const auto NotebookDocumentClientCapabilities::synchronization( NotebookDocumentSyncClientCapabilities synchronization) -> NotebookDocumentClientCapabilities& { - repr_->emplace("synchronization", synchronization); + (*repr_)["synchronization"] = synchronization; return *this; } @@ -19238,6 +18909,7 @@ auto WindowClientCapabilities::workDoneProgress() const -> std::optional { auto& value = (*repr_)["workDoneProgress"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -19266,7 +18938,7 @@ auto WindowClientCapabilities::workDoneProgress( repr_->erase("workDoneProgress"); return *this; } - repr_->emplace("workDoneProgress", std::move(workDoneProgress.value())); + (*repr_)["workDoneProgress"] = std::move(workDoneProgress.value()); return *this; } @@ -19277,7 +18949,7 @@ auto WindowClientCapabilities::showMessage( repr_->erase("showMessage"); return *this; } - repr_->emplace("showMessage", showMessage.value()); + (*repr_)["showMessage"] = showMessage.value(); return *this; } @@ -19288,7 +18960,7 @@ auto WindowClientCapabilities::showDocument( repr_->erase("showDocument"); return *this; } - repr_->emplace("showDocument", showDocument.value()); + (*repr_)["showDocument"] = showDocument.value(); return *this; } @@ -19330,7 +19002,7 @@ auto GeneralClientCapabilities::positionEncodings() const auto& value = (*repr_)["positionEncodings"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -19341,7 +19013,7 @@ auto GeneralClientCapabilities::staleRequestSupport( repr_->erase("staleRequestSupport"); return *this; } - repr_->emplace("staleRequestSupport", staleRequestSupport.value()); + (*repr_)["staleRequestSupport"] = staleRequestSupport.value(); return *this; } @@ -19352,7 +19024,7 @@ auto GeneralClientCapabilities::regularExpressions( repr_->erase("regularExpressions"); return *this; } - repr_->emplace("regularExpressions", regularExpressions.value()); + (*repr_)["regularExpressions"] = regularExpressions.value(); return *this; } @@ -19363,7 +19035,7 @@ auto GeneralClientCapabilities::markdown( repr_->erase("markdown"); return *this; } - repr_->emplace("markdown", markdown.value()); + (*repr_)["markdown"] = markdown.value(); return *this; } @@ -19390,17 +19062,18 @@ auto WorkspaceFoldersServerCapabilities::supported() const auto& value = (*repr_)["supported"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto WorkspaceFoldersServerCapabilities::changeNotifications() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("changeNotifications")) return std::nullopt; auto& value = (*repr_)["changeNotifications"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -19413,33 +19086,27 @@ auto WorkspaceFoldersServerCapabilities::supported( repr_->erase("supported"); return *this; } - repr_->emplace("supported", std::move(supported.value())); + (*repr_)["supported"] = std::move(supported.value()); return *this; } auto WorkspaceFoldersServerCapabilities::changeNotifications( - std::optional> - changeNotifications) -> WorkspaceFoldersServerCapabilities& { + 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)); + (*repr_)["changeNotifications"] = std::move(changeNotifications); } void operator()(bool changeNotifications) { - repr_->emplace("changeNotifications", std::move(changeNotifications)); + (*repr_)["changeNotifications"] = std::move(changeNotifications); } } v{repr_}; @@ -19514,7 +19181,7 @@ auto FileOperationOptions::didCreate( repr_->erase("didCreate"); return *this; } - repr_->emplace("didCreate", didCreate.value()); + (*repr_)["didCreate"] = didCreate.value(); return *this; } @@ -19525,7 +19192,7 @@ auto FileOperationOptions::willCreate( repr_->erase("willCreate"); return *this; } - repr_->emplace("willCreate", willCreate.value()); + (*repr_)["willCreate"] = willCreate.value(); return *this; } @@ -19536,7 +19203,7 @@ auto FileOperationOptions::didRename( repr_->erase("didRename"); return *this; } - repr_->emplace("didRename", didRename.value()); + (*repr_)["didRename"] = didRename.value(); return *this; } @@ -19547,7 +19214,7 @@ auto FileOperationOptions::willRename( repr_->erase("willRename"); return *this; } - repr_->emplace("willRename", willRename.value()); + (*repr_)["willRename"] = willRename.value(); return *this; } @@ -19558,7 +19225,7 @@ auto FileOperationOptions::didDelete( repr_->erase("didDelete"); return *this; } - repr_->emplace("didDelete", didDelete.value()); + (*repr_)["didDelete"] = didDelete.value(); return *this; } @@ -19569,7 +19236,7 @@ auto FileOperationOptions::willDelete( repr_->erase("willDelete"); return *this; } - repr_->emplace("willDelete", willDelete.value()); + (*repr_)["willDelete"] = willDelete.value(); return *this; } @@ -19581,10 +19248,10 @@ RelativePattern::operator bool() const { } auto RelativePattern::baseUri() const - -> std::variant { + -> std::variant { auto& value = (*repr_)["baseUri"]; - std::variant result; + std::variant result; details::try_emplace(result, value); @@ -19594,28 +19261,20 @@ auto RelativePattern::baseUri() const auto RelativePattern::pattern() const -> Pattern { auto& value = (*repr_)["pattern"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } auto RelativePattern::baseUri( - std::variant baseUri) - -> RelativePattern& { - // or type - + std::variant baseUri) -> RelativePattern& { 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()(WorkspaceFolder baseUri) { (*repr_)["baseUri"] = baseUri; } void operator()(std::string baseUri) { - repr_->emplace("baseUri", std::move(baseUri)); + (*repr_)["baseUri"] = std::move(baseUri); } } v{repr_}; @@ -19638,6 +19297,7 @@ TextDocumentFilterLanguage::operator bool() const { auto TextDocumentFilterLanguage::language() const -> std::string { auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19647,6 +19307,7 @@ auto TextDocumentFilterLanguage::scheme() const -> std::optional { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19665,7 +19326,7 @@ auto TextDocumentFilterLanguage::pattern() const -> std::optional { auto TextDocumentFilterLanguage::language(std::string language) -> TextDocumentFilterLanguage& { - repr_->emplace("language", std::move(language)); + (*repr_)["language"] = std::move(language); return *this; } @@ -19675,7 +19336,7 @@ auto TextDocumentFilterLanguage::scheme(std::optional scheme) repr_->erase("scheme"); return *this; } - repr_->emplace("scheme", std::move(scheme.value())); + (*repr_)["scheme"] = std::move(scheme.value()); return *this; } @@ -19700,6 +19361,7 @@ auto TextDocumentFilterScheme::language() const -> std::optional { auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19707,6 +19369,7 @@ auto TextDocumentFilterScheme::language() const -> std::optional { auto TextDocumentFilterScheme::scheme() const -> std::string { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19729,13 +19392,13 @@ auto TextDocumentFilterScheme::language(std::optional language) repr_->erase("language"); return *this; } - repr_->emplace("language", std::move(language.value())); + (*repr_)["language"] = std::move(language.value()); return *this; } auto TextDocumentFilterScheme::scheme(std::string scheme) -> TextDocumentFilterScheme& { - repr_->emplace("scheme", std::move(scheme)); + (*repr_)["scheme"] = std::move(scheme); return *this; } @@ -19760,6 +19423,7 @@ auto TextDocumentFilterPattern::language() const -> std::optional { auto& value = (*repr_)["language"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19769,6 +19433,7 @@ auto TextDocumentFilterPattern::scheme() const -> std::optional { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19789,7 +19454,7 @@ auto TextDocumentFilterPattern::language(std::optional language) repr_->erase("language"); return *this; } - repr_->emplace("language", std::move(language.value())); + (*repr_)["language"] = std::move(language.value()); return *this; } @@ -19799,7 +19464,7 @@ auto TextDocumentFilterPattern::scheme(std::optional scheme) repr_->erase("scheme"); return *this; } - repr_->emplace("scheme", std::move(scheme.value())); + (*repr_)["scheme"] = std::move(scheme.value()); return *this; } @@ -19818,6 +19483,7 @@ NotebookDocumentFilterNotebookType::operator bool() const { auto NotebookDocumentFilterNotebookType::notebookType() const -> std::string { auto& value = (*repr_)["notebookType"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19828,6 +19494,7 @@ auto NotebookDocumentFilterNotebookType::scheme() const auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19847,7 +19514,7 @@ auto NotebookDocumentFilterNotebookType::pattern() const auto NotebookDocumentFilterNotebookType::notebookType(std::string notebookType) -> NotebookDocumentFilterNotebookType& { - repr_->emplace("notebookType", std::move(notebookType)); + (*repr_)["notebookType"] = std::move(notebookType); return *this; } @@ -19857,7 +19524,7 @@ auto NotebookDocumentFilterNotebookType::scheme( repr_->erase("scheme"); return *this; } - repr_->emplace("scheme", std::move(scheme.value())); + (*repr_)["scheme"] = std::move(scheme.value()); return *this; } @@ -19884,6 +19551,7 @@ auto NotebookDocumentFilterScheme::notebookType() const auto& value = (*repr_)["notebookType"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19891,6 +19559,7 @@ auto NotebookDocumentFilterScheme::notebookType() const auto NotebookDocumentFilterScheme::scheme() const -> std::string { auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19914,13 +19583,13 @@ auto NotebookDocumentFilterScheme::notebookType( repr_->erase("notebookType"); return *this; } - repr_->emplace("notebookType", std::move(notebookType.value())); + (*repr_)["notebookType"] = std::move(notebookType.value()); return *this; } auto NotebookDocumentFilterScheme::scheme(std::string scheme) -> NotebookDocumentFilterScheme& { - repr_->emplace("scheme", std::move(scheme)); + (*repr_)["scheme"] = std::move(scheme); return *this; } @@ -19946,6 +19615,7 @@ auto NotebookDocumentFilterPattern::notebookType() const auto& value = (*repr_)["notebookType"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19956,6 +19626,7 @@ auto NotebookDocumentFilterPattern::scheme() const auto& value = (*repr_)["scheme"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -19976,7 +19647,7 @@ auto NotebookDocumentFilterPattern::notebookType( repr_->erase("notebookType"); return *this; } - repr_->emplace("notebookType", std::move(notebookType.value())); + (*repr_)["notebookType"] = std::move(notebookType.value()); return *this; } @@ -19986,7 +19657,7 @@ auto NotebookDocumentFilterPattern::scheme(std::optional scheme) repr_->erase("scheme"); return *this; } - repr_->emplace("scheme", std::move(scheme.value())); + (*repr_)["scheme"] = std::move(scheme.value()); return *this; } @@ -20007,6 +19678,7 @@ NotebookCellArrayChange::operator bool() const { auto NotebookCellArrayChange::start() const -> long { auto& value = (*repr_)["start"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -20014,6 +19686,7 @@ auto NotebookCellArrayChange::start() const -> long { auto NotebookCellArrayChange::deleteCount() const -> long { auto& value = (*repr_)["deleteCount"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -20024,18 +19697,18 @@ auto NotebookCellArrayChange::cells() const auto& value = (*repr_)["cells"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto NotebookCellArrayChange::start(long start) -> NotebookCellArrayChange& { - repr_->emplace("start", std::move(start)); + (*repr_)["start"] = std::move(start); return *this; } auto NotebookCellArrayChange::deleteCount(long deleteCount) -> NotebookCellArrayChange& { - repr_->emplace("deleteCount", std::move(deleteCount)); + (*repr_)["deleteCount"] = std::move(deleteCount); return *this; } @@ -20060,6 +19733,7 @@ auto WorkspaceEditClientCapabilities::documentChanges() const auto& value = (*repr_)["documentChanges"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20070,7 +19744,7 @@ auto WorkspaceEditClientCapabilities::resourceOperations() const auto& value = (*repr_)["resourceOperations"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -20090,6 +19764,7 @@ auto WorkspaceEditClientCapabilities::normalizesLineEndings() const auto& value = (*repr_)["normalizesLineEndings"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20109,6 +19784,7 @@ auto WorkspaceEditClientCapabilities::metadataSupport() const auto& value = (*repr_)["metadataSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20119,6 +19795,7 @@ auto WorkspaceEditClientCapabilities::snippetEditSupport() const auto& value = (*repr_)["snippetEditSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20129,7 +19806,7 @@ auto WorkspaceEditClientCapabilities::documentChanges( repr_->erase("documentChanges"); return *this; } - repr_->emplace("documentChanges", std::move(documentChanges.value())); + (*repr_)["documentChanges"] = std::move(documentChanges.value()); return *this; } @@ -20164,8 +19841,7 @@ auto WorkspaceEditClientCapabilities::normalizesLineEndings( repr_->erase("normalizesLineEndings"); return *this; } - repr_->emplace("normalizesLineEndings", - std::move(normalizesLineEndings.value())); + (*repr_)["normalizesLineEndings"] = std::move(normalizesLineEndings.value()); return *this; } @@ -20176,7 +19852,7 @@ auto WorkspaceEditClientCapabilities::changeAnnotationSupport( repr_->erase("changeAnnotationSupport"); return *this; } - repr_->emplace("changeAnnotationSupport", changeAnnotationSupport.value()); + (*repr_)["changeAnnotationSupport"] = changeAnnotationSupport.value(); return *this; } @@ -20186,7 +19862,7 @@ auto WorkspaceEditClientCapabilities::metadataSupport( repr_->erase("metadataSupport"); return *this; } - repr_->emplace("metadataSupport", std::move(metadataSupport.value())); + (*repr_)["metadataSupport"] = std::move(metadataSupport.value()); return *this; } @@ -20197,7 +19873,7 @@ auto WorkspaceEditClientCapabilities::snippetEditSupport( repr_->erase("snippetEditSupport"); return *this; } - repr_->emplace("snippetEditSupport", std::move(snippetEditSupport.value())); + (*repr_)["snippetEditSupport"] = std::move(snippetEditSupport.value()); return *this; } @@ -20212,6 +19888,7 @@ auto DidChangeConfigurationClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20223,7 +19900,7 @@ auto DidChangeConfigurationClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20238,6 +19915,7 @@ auto DidChangeWatchedFilesClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20248,6 +19926,7 @@ auto DidChangeWatchedFilesClientCapabilities::relativePatternSupport() const auto& value = (*repr_)["relativePatternSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20259,7 +19938,7 @@ auto DidChangeWatchedFilesClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20270,8 +19949,8 @@ auto DidChangeWatchedFilesClientCapabilities::relativePatternSupport( repr_->erase("relativePatternSupport"); return *this; } - repr_->emplace("relativePatternSupport", - std::move(relativePatternSupport.value())); + (*repr_)["relativePatternSupport"] = + std::move(relativePatternSupport.value()); return *this; } @@ -20286,6 +19965,7 @@ auto WorkspaceSymbolClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20324,7 +20004,7 @@ auto WorkspaceSymbolClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20335,7 +20015,7 @@ auto WorkspaceSymbolClientCapabilities::symbolKind( repr_->erase("symbolKind"); return *this; } - repr_->emplace("symbolKind", symbolKind.value()); + (*repr_)["symbolKind"] = symbolKind.value(); return *this; } @@ -20346,7 +20026,7 @@ auto WorkspaceSymbolClientCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -20357,7 +20037,7 @@ auto WorkspaceSymbolClientCapabilities::resolveSupport( repr_->erase("resolveSupport"); return *this; } - repr_->emplace("resolveSupport", resolveSupport.value()); + (*repr_)["resolveSupport"] = resolveSupport.value(); return *this; } @@ -20372,6 +20052,7 @@ auto ExecuteCommandClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20383,7 +20064,7 @@ auto ExecuteCommandClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20398,6 +20079,7 @@ auto SemanticTokensWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20409,7 +20091,7 @@ auto SemanticTokensWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20424,6 +20106,7 @@ auto CodeLensWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20435,7 +20118,7 @@ auto CodeLensWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20450,6 +20133,7 @@ auto FileOperationClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20459,6 +20143,7 @@ auto FileOperationClientCapabilities::didCreate() const -> std::optional { auto& value = (*repr_)["didCreate"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20469,6 +20154,7 @@ auto FileOperationClientCapabilities::willCreate() const auto& value = (*repr_)["willCreate"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20478,6 +20164,7 @@ auto FileOperationClientCapabilities::didRename() const -> std::optional { auto& value = (*repr_)["didRename"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20488,6 +20175,7 @@ auto FileOperationClientCapabilities::willRename() const auto& value = (*repr_)["willRename"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20497,6 +20185,7 @@ auto FileOperationClientCapabilities::didDelete() const -> std::optional { auto& value = (*repr_)["didDelete"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20507,6 +20196,7 @@ auto FileOperationClientCapabilities::willDelete() const auto& value = (*repr_)["willDelete"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20518,7 +20208,7 @@ auto FileOperationClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20528,7 +20218,7 @@ auto FileOperationClientCapabilities::didCreate(std::optional didCreate) repr_->erase("didCreate"); return *this; } - repr_->emplace("didCreate", std::move(didCreate.value())); + (*repr_)["didCreate"] = std::move(didCreate.value()); return *this; } @@ -20538,7 +20228,7 @@ auto FileOperationClientCapabilities::willCreate(std::optional willCreate) repr_->erase("willCreate"); return *this; } - repr_->emplace("willCreate", std::move(willCreate.value())); + (*repr_)["willCreate"] = std::move(willCreate.value()); return *this; } @@ -20548,7 +20238,7 @@ auto FileOperationClientCapabilities::didRename(std::optional didRename) repr_->erase("didRename"); return *this; } - repr_->emplace("didRename", std::move(didRename.value())); + (*repr_)["didRename"] = std::move(didRename.value()); return *this; } @@ -20558,7 +20248,7 @@ auto FileOperationClientCapabilities::willRename(std::optional willRename) repr_->erase("willRename"); return *this; } - repr_->emplace("willRename", std::move(willRename.value())); + (*repr_)["willRename"] = std::move(willRename.value()); return *this; } @@ -20568,7 +20258,7 @@ auto FileOperationClientCapabilities::didDelete(std::optional didDelete) repr_->erase("didDelete"); return *this; } - repr_->emplace("didDelete", std::move(didDelete.value())); + (*repr_)["didDelete"] = std::move(didDelete.value()); return *this; } @@ -20578,7 +20268,7 @@ auto FileOperationClientCapabilities::willDelete(std::optional willDelete) repr_->erase("willDelete"); return *this; } - repr_->emplace("willDelete", std::move(willDelete.value())); + (*repr_)["willDelete"] = std::move(willDelete.value()); return *this; } @@ -20593,6 +20283,7 @@ auto InlineValueWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20604,7 +20295,7 @@ auto InlineValueWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20619,6 +20310,7 @@ auto InlayHintWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20630,7 +20322,7 @@ auto InlayHintWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20645,6 +20337,7 @@ auto DiagnosticWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20656,7 +20349,7 @@ auto DiagnosticWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20671,6 +20364,7 @@ auto FoldingRangeWorkspaceClientCapabilities::refreshSupport() const auto& value = (*repr_)["refreshSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20682,7 +20376,7 @@ auto FoldingRangeWorkspaceClientCapabilities::refreshSupport( repr_->erase("refreshSupport"); return *this; } - repr_->emplace("refreshSupport", std::move(refreshSupport.value())); + (*repr_)["refreshSupport"] = std::move(refreshSupport.value()); return *this; } @@ -20697,6 +20391,7 @@ auto TextDocumentContentClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20708,7 +20403,7 @@ auto TextDocumentContentClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20723,6 +20418,7 @@ auto TextDocumentSyncClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20733,6 +20429,7 @@ auto TextDocumentSyncClientCapabilities::willSave() const auto& value = (*repr_)["willSave"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20743,6 +20440,7 @@ auto TextDocumentSyncClientCapabilities::willSaveWaitUntil() const auto& value = (*repr_)["willSaveWaitUntil"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20753,6 +20451,7 @@ auto TextDocumentSyncClientCapabilities::didSave() const auto& value = (*repr_)["didSave"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20764,7 +20463,7 @@ auto TextDocumentSyncClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20774,7 +20473,7 @@ auto TextDocumentSyncClientCapabilities::willSave(std::optional willSave) repr_->erase("willSave"); return *this; } - repr_->emplace("willSave", std::move(willSave.value())); + (*repr_)["willSave"] = std::move(willSave.value()); return *this; } @@ -20785,7 +20484,7 @@ auto TextDocumentSyncClientCapabilities::willSaveWaitUntil( repr_->erase("willSaveWaitUntil"); return *this; } - repr_->emplace("willSaveWaitUntil", std::move(willSaveWaitUntil.value())); + (*repr_)["willSaveWaitUntil"] = std::move(willSaveWaitUntil.value()); return *this; } @@ -20795,7 +20494,7 @@ auto TextDocumentSyncClientCapabilities::didSave(std::optional didSave) repr_->erase("didSave"); return *this; } - repr_->emplace("didSave", std::move(didSave.value())); + (*repr_)["didSave"] = std::move(didSave.value()); return *this; } @@ -20810,6 +20509,7 @@ auto TextDocumentFilterClientCapabilities::relativePatternSupport() const auto& value = (*repr_)["relativePatternSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20821,8 +20521,8 @@ auto TextDocumentFilterClientCapabilities::relativePatternSupport( repr_->erase("relativePatternSupport"); return *this; } - repr_->emplace("relativePatternSupport", - std::move(relativePatternSupport.value())); + (*repr_)["relativePatternSupport"] = + std::move(relativePatternSupport.value()); return *this; } @@ -20837,6 +20537,7 @@ auto CompletionClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20874,6 +20575,7 @@ auto CompletionClientCapabilities::contextSupport() const auto& value = (*repr_)["contextSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20893,7 +20595,7 @@ auto CompletionClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -20904,7 +20606,7 @@ auto CompletionClientCapabilities::completionItem( repr_->erase("completionItem"); return *this; } - repr_->emplace("completionItem", completionItem.value()); + (*repr_)["completionItem"] = completionItem.value(); return *this; } @@ -20915,7 +20617,7 @@ auto CompletionClientCapabilities::completionItemKind( repr_->erase("completionItemKind"); return *this; } - repr_->emplace("completionItemKind", completionItemKind.value()); + (*repr_)["completionItemKind"] = completionItemKind.value(); return *this; } @@ -20926,7 +20628,7 @@ auto CompletionClientCapabilities::insertTextMode( repr_->erase("insertTextMode"); return *this; } - repr_->emplace("insertTextMode", static_cast(insertTextMode.value())); + (*repr_)["insertTextMode"] = static_cast(insertTextMode.value()); return *this; } @@ -20936,7 +20638,7 @@ auto CompletionClientCapabilities::contextSupport( repr_->erase("contextSupport"); return *this; } - repr_->emplace("contextSupport", std::move(contextSupport.value())); + (*repr_)["contextSupport"] = std::move(contextSupport.value()); return *this; } @@ -20947,7 +20649,7 @@ auto CompletionClientCapabilities::completionList( repr_->erase("completionList"); return *this; } - repr_->emplace("completionList", completionList.value()); + (*repr_)["completionList"] = completionList.value(); return *this; } @@ -20962,6 +20664,7 @@ auto HoverClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -20972,7 +20675,7 @@ auto HoverClientCapabilities::contentFormat() const auto& value = (*repr_)["contentFormat"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -20982,7 +20685,7 @@ auto HoverClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21009,6 +20712,7 @@ auto SignatureHelpClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21028,6 +20732,7 @@ auto SignatureHelpClientCapabilities::contextSupport() const auto& value = (*repr_)["contextSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21039,7 +20744,7 @@ auto SignatureHelpClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21050,7 +20755,7 @@ auto SignatureHelpClientCapabilities::signatureInformation( repr_->erase("signatureInformation"); return *this; } - repr_->emplace("signatureInformation", signatureInformation.value()); + (*repr_)["signatureInformation"] = signatureInformation.value(); return *this; } @@ -21060,7 +20765,7 @@ auto SignatureHelpClientCapabilities::contextSupport( repr_->erase("contextSupport"); return *this; } - repr_->emplace("contextSupport", std::move(contextSupport.value())); + (*repr_)["contextSupport"] = std::move(contextSupport.value()); return *this; } @@ -21075,6 +20780,7 @@ auto DeclarationClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21084,6 +20790,7 @@ auto DeclarationClientCapabilities::linkSupport() const -> std::optional { auto& value = (*repr_)["linkSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21094,7 +20801,7 @@ auto DeclarationClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21104,7 +20811,7 @@ auto DeclarationClientCapabilities::linkSupport(std::optional linkSupport) repr_->erase("linkSupport"); return *this; } - repr_->emplace("linkSupport", std::move(linkSupport.value())); + (*repr_)["linkSupport"] = std::move(linkSupport.value()); return *this; } @@ -21119,6 +20826,7 @@ auto DefinitionClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21128,6 +20836,7 @@ auto DefinitionClientCapabilities::linkSupport() const -> std::optional { auto& value = (*repr_)["linkSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21138,7 +20847,7 @@ auto DefinitionClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21148,7 +20857,7 @@ auto DefinitionClientCapabilities::linkSupport(std::optional linkSupport) repr_->erase("linkSupport"); return *this; } - repr_->emplace("linkSupport", std::move(linkSupport.value())); + (*repr_)["linkSupport"] = std::move(linkSupport.value()); return *this; } @@ -21163,6 +20872,7 @@ auto TypeDefinitionClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21173,6 +20883,7 @@ auto TypeDefinitionClientCapabilities::linkSupport() const auto& value = (*repr_)["linkSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21184,7 +20895,7 @@ auto TypeDefinitionClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21194,7 +20905,7 @@ auto TypeDefinitionClientCapabilities::linkSupport( repr_->erase("linkSupport"); return *this; } - repr_->emplace("linkSupport", std::move(linkSupport.value())); + (*repr_)["linkSupport"] = std::move(linkSupport.value()); return *this; } @@ -21209,6 +20920,7 @@ auto ImplementationClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21219,6 +20931,7 @@ auto ImplementationClientCapabilities::linkSupport() const auto& value = (*repr_)["linkSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21230,7 +20943,7 @@ auto ImplementationClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21240,7 +20953,7 @@ auto ImplementationClientCapabilities::linkSupport( repr_->erase("linkSupport"); return *this; } - repr_->emplace("linkSupport", std::move(linkSupport.value())); + (*repr_)["linkSupport"] = std::move(linkSupport.value()); return *this; } @@ -21255,6 +20968,7 @@ auto ReferenceClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21265,7 +20979,7 @@ auto ReferenceClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21280,6 +20994,7 @@ auto DocumentHighlightClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21291,7 +21006,7 @@ auto DocumentHighlightClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21306,6 +21021,7 @@ auto DocumentSymbolClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21326,6 +21042,7 @@ auto DocumentSymbolClientCapabilities::hierarchicalDocumentSymbolSupport() const auto& value = (*repr_)["hierarchicalDocumentSymbolSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21345,6 +21062,7 @@ auto DocumentSymbolClientCapabilities::labelSupport() const auto& value = (*repr_)["labelSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21356,7 +21074,7 @@ auto DocumentSymbolClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21367,7 +21085,7 @@ auto DocumentSymbolClientCapabilities::symbolKind( repr_->erase("symbolKind"); return *this; } - repr_->emplace("symbolKind", symbolKind.value()); + (*repr_)["symbolKind"] = symbolKind.value(); return *this; } @@ -21378,8 +21096,8 @@ auto DocumentSymbolClientCapabilities::hierarchicalDocumentSymbolSupport( repr_->erase("hierarchicalDocumentSymbolSupport"); return *this; } - repr_->emplace("hierarchicalDocumentSymbolSupport", - std::move(hierarchicalDocumentSymbolSupport.value())); + (*repr_)["hierarchicalDocumentSymbolSupport"] = + std::move(hierarchicalDocumentSymbolSupport.value()); return *this; } @@ -21390,7 +21108,7 @@ auto DocumentSymbolClientCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -21400,7 +21118,7 @@ auto DocumentSymbolClientCapabilities::labelSupport( repr_->erase("labelSupport"); return *this; } - repr_->emplace("labelSupport", std::move(labelSupport.value())); + (*repr_)["labelSupport"] = std::move(labelSupport.value()); return *this; } @@ -21415,6 +21133,7 @@ auto CodeActionClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21434,6 +21153,7 @@ auto CodeActionClientCapabilities::isPreferredSupport() const auto& value = (*repr_)["isPreferredSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21444,6 +21164,7 @@ auto CodeActionClientCapabilities::disabledSupport() const auto& value = (*repr_)["disabledSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21453,6 +21174,7 @@ auto CodeActionClientCapabilities::dataSupport() const -> std::optional { auto& value = (*repr_)["dataSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21472,6 +21194,7 @@ auto CodeActionClientCapabilities::honorsChangeAnnotations() const auto& value = (*repr_)["honorsChangeAnnotations"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21482,6 +21205,7 @@ auto CodeActionClientCapabilities::documentationSupport() const auto& value = (*repr_)["documentationSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21501,7 +21225,7 @@ auto CodeActionClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21512,7 +21236,7 @@ auto CodeActionClientCapabilities::codeActionLiteralSupport( repr_->erase("codeActionLiteralSupport"); return *this; } - repr_->emplace("codeActionLiteralSupport", codeActionLiteralSupport.value()); + (*repr_)["codeActionLiteralSupport"] = codeActionLiteralSupport.value(); return *this; } @@ -21522,7 +21246,7 @@ auto CodeActionClientCapabilities::isPreferredSupport( repr_->erase("isPreferredSupport"); return *this; } - repr_->emplace("isPreferredSupport", std::move(isPreferredSupport.value())); + (*repr_)["isPreferredSupport"] = std::move(isPreferredSupport.value()); return *this; } @@ -21532,7 +21256,7 @@ auto CodeActionClientCapabilities::disabledSupport( repr_->erase("disabledSupport"); return *this; } - repr_->emplace("disabledSupport", std::move(disabledSupport.value())); + (*repr_)["disabledSupport"] = std::move(disabledSupport.value()); return *this; } @@ -21542,7 +21266,7 @@ auto CodeActionClientCapabilities::dataSupport(std::optional dataSupport) repr_->erase("dataSupport"); return *this; } - repr_->emplace("dataSupport", std::move(dataSupport.value())); + (*repr_)["dataSupport"] = std::move(dataSupport.value()); return *this; } @@ -21553,7 +21277,7 @@ auto CodeActionClientCapabilities::resolveSupport( repr_->erase("resolveSupport"); return *this; } - repr_->emplace("resolveSupport", resolveSupport.value()); + (*repr_)["resolveSupport"] = resolveSupport.value(); return *this; } @@ -21564,8 +21288,8 @@ auto CodeActionClientCapabilities::honorsChangeAnnotations( repr_->erase("honorsChangeAnnotations"); return *this; } - repr_->emplace("honorsChangeAnnotations", - std::move(honorsChangeAnnotations.value())); + (*repr_)["honorsChangeAnnotations"] = + std::move(honorsChangeAnnotations.value()); return *this; } @@ -21575,8 +21299,7 @@ auto CodeActionClientCapabilities::documentationSupport( repr_->erase("documentationSupport"); return *this; } - repr_->emplace("documentationSupport", - std::move(documentationSupport.value())); + (*repr_)["documentationSupport"] = std::move(documentationSupport.value()); return *this; } @@ -21587,7 +21310,7 @@ auto CodeActionClientCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -21602,6 +21325,7 @@ auto CodeLensClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21621,7 +21345,7 @@ auto CodeLensClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21632,7 +21356,7 @@ auto CodeLensClientCapabilities::resolveSupport( repr_->erase("resolveSupport"); return *this; } - repr_->emplace("resolveSupport", resolveSupport.value()); + (*repr_)["resolveSupport"] = resolveSupport.value(); return *this; } @@ -21647,6 +21371,7 @@ auto DocumentLinkClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21657,6 +21382,7 @@ auto DocumentLinkClientCapabilities::tooltipSupport() const auto& value = (*repr_)["tooltipSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21668,7 +21394,7 @@ auto DocumentLinkClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21678,7 +21404,7 @@ auto DocumentLinkClientCapabilities::tooltipSupport( repr_->erase("tooltipSupport"); return *this; } - repr_->emplace("tooltipSupport", std::move(tooltipSupport.value())); + (*repr_)["tooltipSupport"] = std::move(tooltipSupport.value()); return *this; } @@ -21693,6 +21419,7 @@ auto DocumentColorClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21704,7 +21431,7 @@ auto DocumentColorClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21719,6 +21446,7 @@ auto DocumentFormattingClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21730,7 +21458,7 @@ auto DocumentFormattingClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21745,6 +21473,7 @@ auto DocumentRangeFormattingClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21755,6 +21484,7 @@ auto DocumentRangeFormattingClientCapabilities::rangesSupport() const auto& value = (*repr_)["rangesSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21766,7 +21496,7 @@ auto DocumentRangeFormattingClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21777,7 +21507,7 @@ auto DocumentRangeFormattingClientCapabilities::rangesSupport( repr_->erase("rangesSupport"); return *this; } - repr_->emplace("rangesSupport", std::move(rangesSupport.value())); + (*repr_)["rangesSupport"] = std::move(rangesSupport.value()); return *this; } @@ -21792,6 +21522,7 @@ auto DocumentOnTypeFormattingClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21803,7 +21534,7 @@ auto DocumentOnTypeFormattingClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21818,6 +21549,7 @@ auto RenameClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21827,6 +21559,7 @@ auto RenameClientCapabilities::prepareSupport() const -> std::optional { auto& value = (*repr_)["prepareSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21846,6 +21579,7 @@ auto RenameClientCapabilities::honorsChangeAnnotations() const auto& value = (*repr_)["honorsChangeAnnotations"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21856,7 +21590,7 @@ auto RenameClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21866,7 +21600,7 @@ auto RenameClientCapabilities::prepareSupport( repr_->erase("prepareSupport"); return *this; } - repr_->emplace("prepareSupport", std::move(prepareSupport.value())); + (*repr_)["prepareSupport"] = std::move(prepareSupport.value()); return *this; } @@ -21877,8 +21611,8 @@ auto RenameClientCapabilities::prepareSupportDefaultBehavior( repr_->erase("prepareSupportDefaultBehavior"); return *this; } - repr_->emplace("prepareSupportDefaultBehavior", - static_cast(prepareSupportDefaultBehavior.value())); + (*repr_)["prepareSupportDefaultBehavior"] = + static_cast(prepareSupportDefaultBehavior.value()); return *this; } @@ -21888,8 +21622,8 @@ auto RenameClientCapabilities::honorsChangeAnnotations( repr_->erase("honorsChangeAnnotations"); return *this; } - repr_->emplace("honorsChangeAnnotations", - std::move(honorsChangeAnnotations.value())); + (*repr_)["honorsChangeAnnotations"] = + std::move(honorsChangeAnnotations.value()); return *this; } @@ -21904,6 +21638,7 @@ auto FoldingRangeClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21913,6 +21648,7 @@ auto FoldingRangeClientCapabilities::rangeLimit() const -> std::optional { auto& value = (*repr_)["rangeLimit"]; + if (value.is_null()) value = 0; assert(value.is_number_integer()); return value.get(); } @@ -21923,6 +21659,7 @@ auto FoldingRangeClientCapabilities::lineFoldingOnly() const auto& value = (*repr_)["lineFoldingOnly"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -21952,7 +21689,7 @@ auto FoldingRangeClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -21962,7 +21699,7 @@ auto FoldingRangeClientCapabilities::rangeLimit(std::optional rangeLimit) repr_->erase("rangeLimit"); return *this; } - repr_->emplace("rangeLimit", std::move(rangeLimit.value())); + (*repr_)["rangeLimit"] = std::move(rangeLimit.value()); return *this; } @@ -21972,7 +21709,7 @@ auto FoldingRangeClientCapabilities::lineFoldingOnly( repr_->erase("lineFoldingOnly"); return *this; } - repr_->emplace("lineFoldingOnly", std::move(lineFoldingOnly.value())); + (*repr_)["lineFoldingOnly"] = std::move(lineFoldingOnly.value()); return *this; } @@ -21983,7 +21720,7 @@ auto FoldingRangeClientCapabilities::foldingRangeKind( repr_->erase("foldingRangeKind"); return *this; } - repr_->emplace("foldingRangeKind", foldingRangeKind.value()); + (*repr_)["foldingRangeKind"] = foldingRangeKind.value(); return *this; } @@ -21994,7 +21731,7 @@ auto FoldingRangeClientCapabilities::foldingRange( repr_->erase("foldingRange"); return *this; } - repr_->emplace("foldingRange", foldingRange.value()); + (*repr_)["foldingRange"] = foldingRange.value(); return *this; } @@ -22009,6 +21746,7 @@ auto SelectionRangeClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22020,7 +21758,7 @@ auto SelectionRangeClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22035,6 +21773,7 @@ auto PublishDiagnosticsClientCapabilities::versionSupport() const auto& value = (*repr_)["versionSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22045,6 +21784,7 @@ auto PublishDiagnosticsClientCapabilities::relatedInformation() const auto& value = (*repr_)["relatedInformation"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22064,6 +21804,7 @@ auto PublishDiagnosticsClientCapabilities::codeDescriptionSupport() const auto& value = (*repr_)["codeDescriptionSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22074,6 +21815,7 @@ auto PublishDiagnosticsClientCapabilities::dataSupport() const auto& value = (*repr_)["dataSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22085,7 +21827,7 @@ auto PublishDiagnosticsClientCapabilities::versionSupport( repr_->erase("versionSupport"); return *this; } - repr_->emplace("versionSupport", std::move(versionSupport.value())); + (*repr_)["versionSupport"] = std::move(versionSupport.value()); return *this; } @@ -22096,7 +21838,7 @@ auto PublishDiagnosticsClientCapabilities::relatedInformation( repr_->erase("relatedInformation"); return *this; } - repr_->emplace("relatedInformation", std::move(relatedInformation.value())); + (*repr_)["relatedInformation"] = std::move(relatedInformation.value()); return *this; } @@ -22107,7 +21849,7 @@ auto PublishDiagnosticsClientCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -22118,8 +21860,8 @@ auto PublishDiagnosticsClientCapabilities::codeDescriptionSupport( repr_->erase("codeDescriptionSupport"); return *this; } - repr_->emplace("codeDescriptionSupport", - std::move(codeDescriptionSupport.value())); + (*repr_)["codeDescriptionSupport"] = + std::move(codeDescriptionSupport.value()); return *this; } @@ -22129,7 +21871,7 @@ auto PublishDiagnosticsClientCapabilities::dataSupport( repr_->erase("dataSupport"); return *this; } - repr_->emplace("dataSupport", std::move(dataSupport.value())); + (*repr_)["dataSupport"] = std::move(dataSupport.value()); return *this; } @@ -22144,6 +21886,7 @@ auto CallHierarchyClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22155,7 +21898,7 @@ auto CallHierarchyClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22174,6 +21917,7 @@ auto SemanticTokensClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22189,7 +21933,7 @@ auto SemanticTokensClientCapabilities::tokenTypes() const -> Vector { auto& value = (*repr_)["tokenTypes"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22197,14 +21941,14 @@ auto SemanticTokensClientCapabilities::tokenModifiers() const -> Vector { auto& value = (*repr_)["tokenModifiers"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto SemanticTokensClientCapabilities::formats() const -> Vector { auto& value = (*repr_)["formats"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22214,6 +21958,7 @@ auto SemanticTokensClientCapabilities::overlappingTokenSupport() const auto& value = (*repr_)["overlappingTokenSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22224,6 +21969,7 @@ auto SemanticTokensClientCapabilities::multilineTokenSupport() const auto& value = (*repr_)["multilineTokenSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22234,6 +21980,7 @@ auto SemanticTokensClientCapabilities::serverCancelSupport() const auto& value = (*repr_)["serverCancelSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22244,6 +21991,7 @@ auto SemanticTokensClientCapabilities::augmentsSyntaxTokens() const auto& value = (*repr_)["augmentsSyntaxTokens"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22255,14 +22003,14 @@ auto SemanticTokensClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } auto SemanticTokensClientCapabilities::requests( ClientSemanticTokensRequestOptions requests) -> SemanticTokensClientCapabilities& { - repr_->emplace("requests", requests); + (*repr_)["requests"] = requests; return *this; } @@ -22294,8 +22042,8 @@ auto SemanticTokensClientCapabilities::overlappingTokenSupport( repr_->erase("overlappingTokenSupport"); return *this; } - repr_->emplace("overlappingTokenSupport", - std::move(overlappingTokenSupport.value())); + (*repr_)["overlappingTokenSupport"] = + std::move(overlappingTokenSupport.value()); return *this; } @@ -22306,8 +22054,7 @@ auto SemanticTokensClientCapabilities::multilineTokenSupport( repr_->erase("multilineTokenSupport"); return *this; } - repr_->emplace("multilineTokenSupport", - std::move(multilineTokenSupport.value())); + (*repr_)["multilineTokenSupport"] = std::move(multilineTokenSupport.value()); return *this; } @@ -22318,7 +22065,7 @@ auto SemanticTokensClientCapabilities::serverCancelSupport( repr_->erase("serverCancelSupport"); return *this; } - repr_->emplace("serverCancelSupport", std::move(serverCancelSupport.value())); + (*repr_)["serverCancelSupport"] = std::move(serverCancelSupport.value()); return *this; } @@ -22329,8 +22076,7 @@ auto SemanticTokensClientCapabilities::augmentsSyntaxTokens( repr_->erase("augmentsSyntaxTokens"); return *this; } - repr_->emplace("augmentsSyntaxTokens", - std::move(augmentsSyntaxTokens.value())); + (*repr_)["augmentsSyntaxTokens"] = std::move(augmentsSyntaxTokens.value()); return *this; } @@ -22345,6 +22091,7 @@ auto LinkedEditingRangeClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22356,7 +22103,7 @@ auto LinkedEditingRangeClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22371,6 +22118,7 @@ auto MonikerClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22381,7 +22129,7 @@ auto MonikerClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22396,6 +22144,7 @@ auto TypeHierarchyClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22407,7 +22156,7 @@ auto TypeHierarchyClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22422,6 +22171,7 @@ auto InlineValueClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22432,7 +22182,7 @@ auto InlineValueClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22447,6 +22197,7 @@ auto InlayHintClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22466,7 +22217,7 @@ auto InlayHintClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22477,7 +22228,7 @@ auto InlayHintClientCapabilities::resolveSupport( repr_->erase("resolveSupport"); return *this; } - repr_->emplace("resolveSupport", resolveSupport.value()); + (*repr_)["resolveSupport"] = resolveSupport.value(); return *this; } @@ -22492,6 +22243,7 @@ auto DiagnosticClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22502,6 +22254,7 @@ auto DiagnosticClientCapabilities::relatedDocumentSupport() const auto& value = (*repr_)["relatedDocumentSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22512,6 +22265,7 @@ auto DiagnosticClientCapabilities::relatedInformation() const auto& value = (*repr_)["relatedInformation"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22531,6 +22285,7 @@ auto DiagnosticClientCapabilities::codeDescriptionSupport() const auto& value = (*repr_)["codeDescriptionSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22540,6 +22295,7 @@ auto DiagnosticClientCapabilities::dataSupport() const -> std::optional { auto& value = (*repr_)["dataSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22550,7 +22306,7 @@ auto DiagnosticClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22561,8 +22317,8 @@ auto DiagnosticClientCapabilities::relatedDocumentSupport( repr_->erase("relatedDocumentSupport"); return *this; } - repr_->emplace("relatedDocumentSupport", - std::move(relatedDocumentSupport.value())); + (*repr_)["relatedDocumentSupport"] = + std::move(relatedDocumentSupport.value()); return *this; } @@ -22572,7 +22328,7 @@ auto DiagnosticClientCapabilities::relatedInformation( repr_->erase("relatedInformation"); return *this; } - repr_->emplace("relatedInformation", std::move(relatedInformation.value())); + (*repr_)["relatedInformation"] = std::move(relatedInformation.value()); return *this; } @@ -22583,7 +22339,7 @@ auto DiagnosticClientCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -22594,8 +22350,8 @@ auto DiagnosticClientCapabilities::codeDescriptionSupport( repr_->erase("codeDescriptionSupport"); return *this; } - repr_->emplace("codeDescriptionSupport", - std::move(codeDescriptionSupport.value())); + (*repr_)["codeDescriptionSupport"] = + std::move(codeDescriptionSupport.value()); return *this; } @@ -22605,7 +22361,7 @@ auto DiagnosticClientCapabilities::dataSupport(std::optional dataSupport) repr_->erase("dataSupport"); return *this; } - repr_->emplace("dataSupport", std::move(dataSupport.value())); + (*repr_)["dataSupport"] = std::move(dataSupport.value()); return *this; } @@ -22620,6 +22376,7 @@ auto InlineCompletionClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22631,7 +22388,7 @@ auto InlineCompletionClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22646,6 +22403,7 @@ auto NotebookDocumentSyncClientCapabilities::dynamicRegistration() const auto& value = (*repr_)["dynamicRegistration"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22656,6 +22414,7 @@ auto NotebookDocumentSyncClientCapabilities::executionSummarySupport() const auto& value = (*repr_)["executionSummarySupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22667,7 +22426,7 @@ auto NotebookDocumentSyncClientCapabilities::dynamicRegistration( repr_->erase("dynamicRegistration"); return *this; } - repr_->emplace("dynamicRegistration", std::move(dynamicRegistration.value())); + (*repr_)["dynamicRegistration"] = std::move(dynamicRegistration.value()); return *this; } @@ -22678,8 +22437,8 @@ auto NotebookDocumentSyncClientCapabilities::executionSummarySupport( repr_->erase("executionSummarySupport"); return *this; } - repr_->emplace("executionSummarySupport", - std::move(executionSummarySupport.value())); + (*repr_)["executionSummarySupport"] = + std::move(executionSummarySupport.value()); return *this; } @@ -22704,7 +22463,7 @@ auto ShowMessageRequestClientCapabilities::messageActionItem( repr_->erase("messageActionItem"); return *this; } - repr_->emplace("messageActionItem", messageActionItem.value()); + (*repr_)["messageActionItem"] = messageActionItem.value(); return *this; } @@ -22717,13 +22476,14 @@ ShowDocumentClientCapabilities::operator bool() const { auto ShowDocumentClientCapabilities::support() const -> bool { auto& value = (*repr_)["support"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } auto ShowDocumentClientCapabilities::support(bool support) -> ShowDocumentClientCapabilities& { - repr_->emplace("support", std::move(support)); + (*repr_)["support"] = std::move(support); return *this; } @@ -22737,6 +22497,7 @@ StaleRequestSupportOptions::operator bool() const { auto StaleRequestSupportOptions::cancel() const -> bool { auto& value = (*repr_)["cancel"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22745,13 +22506,13 @@ auto StaleRequestSupportOptions::retryOnContentModified() const -> Vector { auto& value = (*repr_)["retryOnContentModified"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto StaleRequestSupportOptions::cancel(bool cancel) -> StaleRequestSupportOptions& { - repr_->emplace("cancel", std::move(cancel)); + (*repr_)["cancel"] = std::move(cancel); return *this; } @@ -22772,6 +22533,7 @@ auto RegularExpressionsClientCapabilities::engine() const -> RegularExpressionEngineKind { auto& value = (*repr_)["engine"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -22782,6 +22544,7 @@ auto RegularExpressionsClientCapabilities::version() const auto& value = (*repr_)["version"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -22801,7 +22564,7 @@ auto RegularExpressionsClientCapabilities::version( repr_->erase("version"); return *this; } - repr_->emplace("version", std::move(version.value())); + (*repr_)["version"] = std::move(version.value()); return *this; } @@ -22814,6 +22577,7 @@ MarkdownClientCapabilities::operator bool() const { auto MarkdownClientCapabilities::parser() const -> std::string { auto& value = (*repr_)["parser"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -22823,6 +22587,7 @@ auto MarkdownClientCapabilities::version() const -> std::optional { auto& value = (*repr_)["version"]; + if (value.is_null()) value = ""; assert(value.is_string()); return value.get(); } @@ -22833,13 +22598,13 @@ auto MarkdownClientCapabilities::allowedTags() const auto& value = (*repr_)["allowedTags"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } auto MarkdownClientCapabilities::parser(std::string parser) -> MarkdownClientCapabilities& { - repr_->emplace("parser", std::move(parser)); + (*repr_)["parser"] = std::move(parser); return *this; } @@ -22849,7 +22614,7 @@ auto MarkdownClientCapabilities::version(std::optional version) repr_->erase("version"); return *this; } - repr_->emplace("version", std::move(version.value())); + (*repr_)["version"] = std::move(version.value()); return *this; } @@ -22876,6 +22641,7 @@ auto ChangeAnnotationsSupportOptions::groupsOnLabel() const auto& value = (*repr_)["groupsOnLabel"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22886,7 +22652,7 @@ auto ChangeAnnotationsSupportOptions::groupsOnLabel( repr_->erase("groupsOnLabel"); return *this; } - repr_->emplace("groupsOnLabel", std::move(groupsOnLabel.value())); + (*repr_)["groupsOnLabel"] = std::move(groupsOnLabel.value()); return *this; } @@ -22901,7 +22667,7 @@ auto ClientSymbolKindOptions::valueSet() const auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22924,7 +22690,7 @@ ClientSymbolTagOptions::operator bool() const { auto ClientSymbolTagOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22943,7 +22709,7 @@ ClientSymbolResolveOptions::operator bool() const { auto ClientSymbolResolveOptions::properties() const -> Vector { auto& value = (*repr_)["properties"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22965,6 +22731,7 @@ auto ClientCompletionItemOptions::snippetSupport() const auto& value = (*repr_)["snippetSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22975,6 +22742,7 @@ auto ClientCompletionItemOptions::commitCharactersSupport() const auto& value = (*repr_)["commitCharactersSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -22985,7 +22753,7 @@ auto ClientCompletionItemOptions::documentationFormat() const auto& value = (*repr_)["documentationFormat"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -22995,6 +22763,7 @@ auto ClientCompletionItemOptions::deprecatedSupport() const auto& value = (*repr_)["deprecatedSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23005,6 +22774,7 @@ auto ClientCompletionItemOptions::preselectSupport() const auto& value = (*repr_)["preselectSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23024,6 +22794,7 @@ auto ClientCompletionItemOptions::insertReplaceSupport() const auto& value = (*repr_)["insertReplaceSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23052,6 +22823,7 @@ auto ClientCompletionItemOptions::labelDetailsSupport() const auto& value = (*repr_)["labelDetailsSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23062,7 +22834,7 @@ auto ClientCompletionItemOptions::snippetSupport( repr_->erase("snippetSupport"); return *this; } - repr_->emplace("snippetSupport", std::move(snippetSupport.value())); + (*repr_)["snippetSupport"] = std::move(snippetSupport.value()); return *this; } @@ -23073,8 +22845,8 @@ auto ClientCompletionItemOptions::commitCharactersSupport( repr_->erase("commitCharactersSupport"); return *this; } - repr_->emplace("commitCharactersSupport", - std::move(commitCharactersSupport.value())); + (*repr_)["commitCharactersSupport"] = + std::move(commitCharactersSupport.value()); return *this; } @@ -23096,7 +22868,7 @@ auto ClientCompletionItemOptions::deprecatedSupport( repr_->erase("deprecatedSupport"); return *this; } - repr_->emplace("deprecatedSupport", std::move(deprecatedSupport.value())); + (*repr_)["deprecatedSupport"] = std::move(deprecatedSupport.value()); return *this; } @@ -23106,7 +22878,7 @@ auto ClientCompletionItemOptions::preselectSupport( repr_->erase("preselectSupport"); return *this; } - repr_->emplace("preselectSupport", std::move(preselectSupport.value())); + (*repr_)["preselectSupport"] = std::move(preselectSupport.value()); return *this; } @@ -23117,7 +22889,7 @@ auto ClientCompletionItemOptions::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -23127,8 +22899,7 @@ auto ClientCompletionItemOptions::insertReplaceSupport( repr_->erase("insertReplaceSupport"); return *this; } - repr_->emplace("insertReplaceSupport", - std::move(insertReplaceSupport.value())); + (*repr_)["insertReplaceSupport"] = std::move(insertReplaceSupport.value()); return *this; } @@ -23139,7 +22910,7 @@ auto ClientCompletionItemOptions::resolveSupport( repr_->erase("resolveSupport"); return *this; } - repr_->emplace("resolveSupport", resolveSupport.value()); + (*repr_)["resolveSupport"] = resolveSupport.value(); return *this; } @@ -23150,7 +22921,7 @@ auto ClientCompletionItemOptions::insertTextModeSupport( repr_->erase("insertTextModeSupport"); return *this; } - repr_->emplace("insertTextModeSupport", insertTextModeSupport.value()); + (*repr_)["insertTextModeSupport"] = insertTextModeSupport.value(); return *this; } @@ -23160,7 +22931,7 @@ auto ClientCompletionItemOptions::labelDetailsSupport( repr_->erase("labelDetailsSupport"); return *this; } - repr_->emplace("labelDetailsSupport", std::move(labelDetailsSupport.value())); + (*repr_)["labelDetailsSupport"] = std::move(labelDetailsSupport.value()); return *this; } @@ -23175,7 +22946,7 @@ auto ClientCompletionItemOptionsKind::valueSet() const auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23202,7 +22973,7 @@ auto CompletionListCapabilities::itemDefaults() const auto& value = (*repr_)["itemDefaults"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23212,6 +22983,7 @@ auto CompletionListCapabilities::applyKindSupport() const auto& value = (*repr_)["applyKindSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23234,7 +23006,7 @@ auto CompletionListCapabilities::applyKindSupport( repr_->erase("applyKindSupport"); return *this; } - repr_->emplace("applyKindSupport", std::move(applyKindSupport.value())); + (*repr_)["applyKindSupport"] = std::move(applyKindSupport.value()); return *this; } @@ -23249,7 +23021,7 @@ auto ClientSignatureInformationOptions::documentationFormat() const auto& value = (*repr_)["documentationFormat"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23268,6 +23040,7 @@ auto ClientSignatureInformationOptions::activeParameterSupport() const auto& value = (*repr_)["activeParameterSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23278,6 +23051,7 @@ auto ClientSignatureInformationOptions::noActiveParameterSupport() const auto& value = (*repr_)["noActiveParameterSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23302,7 +23076,7 @@ auto ClientSignatureInformationOptions::parameterInformation( repr_->erase("parameterInformation"); return *this; } - repr_->emplace("parameterInformation", parameterInformation.value()); + (*repr_)["parameterInformation"] = parameterInformation.value(); return *this; } @@ -23313,8 +23087,8 @@ auto ClientSignatureInformationOptions::activeParameterSupport( repr_->erase("activeParameterSupport"); return *this; } - repr_->emplace("activeParameterSupport", - std::move(activeParameterSupport.value())); + (*repr_)["activeParameterSupport"] = + std::move(activeParameterSupport.value()); return *this; } @@ -23325,8 +23099,8 @@ auto ClientSignatureInformationOptions::noActiveParameterSupport( repr_->erase("noActiveParameterSupport"); return *this; } - repr_->emplace("noActiveParameterSupport", - std::move(noActiveParameterSupport.value())); + (*repr_)["noActiveParameterSupport"] = + std::move(noActiveParameterSupport.value()); return *this; } @@ -23346,7 +23120,7 @@ auto ClientCodeActionLiteralOptions::codeActionKind() const auto ClientCodeActionLiteralOptions::codeActionKind( ClientCodeActionKindOptions codeActionKind) -> ClientCodeActionLiteralOptions& { - repr_->emplace("codeActionKind", codeActionKind); + (*repr_)["codeActionKind"] = codeActionKind; return *this; } @@ -23359,7 +23133,7 @@ ClientCodeActionResolveOptions::operator bool() const { auto ClientCodeActionResolveOptions::properties() const -> Vector { auto& value = (*repr_)["properties"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23379,7 +23153,7 @@ CodeActionTagOptions::operator bool() const { auto CodeActionTagOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23398,7 +23172,7 @@ ClientCodeLensResolveOptions::operator bool() const { auto ClientCodeLensResolveOptions::properties() const -> Vector { auto& value = (*repr_)["properties"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23420,7 +23194,7 @@ auto ClientFoldingRangeKindOptions::valueSet() const auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23446,6 +23220,7 @@ auto ClientFoldingRangeOptions::collapsedText() const -> std::optional { auto& value = (*repr_)["collapsedText"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23456,7 +23231,7 @@ auto ClientFoldingRangeOptions::collapsedText(std::optional collapsedText) repr_->erase("collapsedText"); return *this; } - repr_->emplace("collapsedText", std::move(collapsedText.value())); + (*repr_)["collapsedText"] = std::move(collapsedText.value()); return *this; } @@ -23471,6 +23246,7 @@ auto DiagnosticsCapabilities::relatedInformation() const auto& value = (*repr_)["relatedInformation"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23490,6 +23266,7 @@ auto DiagnosticsCapabilities::codeDescriptionSupport() const auto& value = (*repr_)["codeDescriptionSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23499,6 +23276,7 @@ auto DiagnosticsCapabilities::dataSupport() const -> std::optional { auto& value = (*repr_)["dataSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23509,7 +23287,7 @@ auto DiagnosticsCapabilities::relatedInformation( repr_->erase("relatedInformation"); return *this; } - repr_->emplace("relatedInformation", std::move(relatedInformation.value())); + (*repr_)["relatedInformation"] = std::move(relatedInformation.value()); return *this; } @@ -23520,7 +23298,7 @@ auto DiagnosticsCapabilities::tagSupport( repr_->erase("tagSupport"); return *this; } - repr_->emplace("tagSupport", tagSupport.value()); + (*repr_)["tagSupport"] = tagSupport.value(); return *this; } @@ -23530,8 +23308,8 @@ auto DiagnosticsCapabilities::codeDescriptionSupport( repr_->erase("codeDescriptionSupport"); return *this; } - repr_->emplace("codeDescriptionSupport", - std::move(codeDescriptionSupport.value())); + (*repr_)["codeDescriptionSupport"] = + std::move(codeDescriptionSupport.value()); return *this; } @@ -23541,7 +23319,7 @@ auto DiagnosticsCapabilities::dataSupport(std::optional dataSupport) repr_->erase("dataSupport"); return *this; } - repr_->emplace("dataSupport", std::move(dataSupport.value())); + (*repr_)["dataSupport"] = std::move(dataSupport.value()); return *this; } @@ -23551,26 +23329,25 @@ ClientSemanticTokensRequestOptions::operator bool() const { } auto ClientSemanticTokensRequestOptions::range() const - -> std::optional> { + -> std::optional> { if (!repr_->contains("range")) return std::nullopt; auto& value = (*repr_)["range"]; - std::variant result; + std::variant result; details::try_emplace(result, value); return result; } -auto ClientSemanticTokensRequestOptions::full() const -> std::optional< - std::variant> { +auto ClientSemanticTokensRequestOptions::full() const + -> std::optional> { if (!repr_->contains("full")) return std::nullopt; auto& value = (*repr_)["full"]; - std::variant - result; + std::variant result; details::try_emplace(result, value); @@ -23578,23 +23355,17 @@ auto ClientSemanticTokensRequestOptions::full() const -> std::optional< } auto ClientSemanticTokensRequestOptions::range( - std::optional> 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()(bool range) { (*repr_)["range"] = std::move(range); } void operator()(json range) { lsp_runtime_error( @@ -23608,27 +23379,20 @@ auto ClientSemanticTokensRequestOptions::range( } auto ClientSemanticTokensRequestOptions::full( - std::optional> + 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()(bool full) { (*repr_)["full"] = std::move(full); } void operator()(ClientSemanticTokensRequestFullDelta full) { - repr_->emplace("full", full); + (*repr_)["full"] = full; } } v{repr_}; @@ -23646,7 +23410,7 @@ ClientInlayHintResolveOptions::operator bool() const { auto ClientInlayHintResolveOptions::properties() const -> Vector { auto& value = (*repr_)["properties"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23668,6 +23432,7 @@ auto ClientShowMessageActionItemOptions::additionalPropertiesSupport() const auto& value = (*repr_)["additionalPropertiesSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23679,8 +23444,8 @@ auto ClientShowMessageActionItemOptions::additionalPropertiesSupport( repr_->erase("additionalPropertiesSupport"); return *this; } - repr_->emplace("additionalPropertiesSupport", - std::move(additionalPropertiesSupport.value())); + (*repr_)["additionalPropertiesSupport"] = + std::move(additionalPropertiesSupport.value()); return *this; } @@ -23693,7 +23458,7 @@ CompletionItemTagOptions::operator bool() const { auto CompletionItemTagOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23713,7 +23478,7 @@ auto ClientCompletionItemResolveOptions::properties() const -> Vector { auto& value = (*repr_)["properties"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23734,7 +23499,7 @@ auto ClientCompletionItemInsertTextModeOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23757,6 +23522,7 @@ auto ClientSignatureParameterInformationOptions::labelOffsetSupport() const auto& value = (*repr_)["labelOffsetSupport"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23768,7 +23534,7 @@ auto ClientSignatureParameterInformationOptions::labelOffsetSupport( repr_->erase("labelOffsetSupport"); return *this; } - repr_->emplace("labelOffsetSupport", std::move(labelOffsetSupport.value())); + (*repr_)["labelOffsetSupport"] = std::move(labelOffsetSupport.value()); return *this; } @@ -23781,7 +23547,7 @@ ClientCodeActionKindOptions::operator bool() const { auto ClientCodeActionKindOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23800,7 +23566,7 @@ ClientDiagnosticsTagOptions::operator bool() const { auto ClientDiagnosticsTagOptions::valueSet() const -> Vector { auto& value = (*repr_)["valueSet"]; - assert(value.is_array()); + if (value.is_null()) value = json::array(); return Vector(value); } @@ -23821,6 +23587,7 @@ auto ClientSemanticTokensRequestFullDelta::delta() const auto& value = (*repr_)["delta"]; + if (value.is_null()) value = false; assert(value.is_boolean()); return value.get(); } @@ -23831,7 +23598,7 @@ auto ClientSemanticTokensRequestFullDelta::delta(std::optional delta) repr_->erase("delta"); return *this; } - repr_->emplace("delta", std::move(delta.value())); + (*repr_)["delta"] = std::move(delta.value()); return *this; } } // namespace cxx::lsp diff --git a/src/lsp/cxx/lsp/types.h b/src/lsp/cxx/lsp/types.h index 2f6e781e..87144c52 100644 --- a/src/lsp/cxx/lsp/types.h +++ b/src/lsp/cxx/lsp/types.h @@ -72,15 +72,15 @@ class ImplementationRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> ImplementationRegistrationOptions&; + std::variant documentSelector) + -> ImplementationRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> ImplementationRegistrationOptions&; @@ -121,15 +121,15 @@ class TypeDefinitionRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> TypeDefinitionRegistrationOptions&; + std::variant documentSelector) + -> TypeDefinitionRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> TypeDefinitionRegistrationOptions&; @@ -219,15 +219,15 @@ class DocumentColorRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentColorRegistrationOptions&; + std::variant documentSelector) + -> DocumentColorRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> DocumentColorRegistrationOptions&; @@ -305,11 +305,11 @@ class TextDocumentRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; auto documentSelector( - std::variant - documentSelector) -> TextDocumentRegistrationOptions&; + std::variant documentSelector) + -> TextDocumentRegistrationOptions&; }; class FoldingRangeParams final : public LSPObject { @@ -371,15 +371,15 @@ class FoldingRangeRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> FoldingRangeRegistrationOptions&; + std::variant documentSelector) + -> FoldingRangeRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> FoldingRangeRegistrationOptions&; @@ -421,7 +421,7 @@ class DeclarationRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto id() const -> std::optional; @@ -429,8 +429,8 @@ class DeclarationRegistrationOptions final : public LSPObject { -> DeclarationRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> DeclarationRegistrationOptions&; + std::variant documentSelector) + -> DeclarationRegistrationOptions&; auto id(std::optional id) -> DeclarationRegistrationOptions&; }; @@ -485,7 +485,7 @@ class SelectionRangeRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto id() const -> std::optional; @@ -493,8 +493,8 @@ class SelectionRangeRegistrationOptions final : public LSPObject { -> SelectionRangeRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> SelectionRangeRegistrationOptions&; + std::variant documentSelector) + -> SelectionRangeRegistrationOptions&; auto id(std::optional id) -> SelectionRangeRegistrationOptions&; }; @@ -588,15 +588,15 @@ class CallHierarchyRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> CallHierarchyRegistrationOptions&; + std::variant documentSelector) + -> CallHierarchyRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> CallHierarchyRegistrationOptions&; @@ -731,33 +731,31 @@ class SemanticTokensRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto legend() const -> SemanticTokensLegend; - [[nodiscard]] auto range() const - -> std::optional>; + [[nodiscard]] auto range() const -> std::optional>; - [[nodiscard]] auto full() const -> std::optional< - std::variant>; + [[nodiscard]] auto full() const + -> std::optional>; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> SemanticTokensRegistrationOptions&; + std::variant documentSelector) + -> SemanticTokensRegistrationOptions&; auto legend(SemanticTokensLegend legend) -> SemanticTokensRegistrationOptions&; - auto range(std::optional> range) + auto range(std::optional> range) -> SemanticTokensRegistrationOptions&; - auto full( - std::optional> - full) -> SemanticTokensRegistrationOptions&; + auto full(std::optional> full) + -> SemanticTokensRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> SemanticTokensRegistrationOptions&; @@ -923,15 +921,15 @@ class LinkedEditingRangeRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> LinkedEditingRangeRegistrationOptions&; + std::variant documentSelector) + -> LinkedEditingRangeRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> LinkedEditingRangeRegistrationOptions&; @@ -960,9 +958,8 @@ class WorkspaceEdit final : public LSPObject { [[nodiscard]] auto changes() const -> std::optional>>; - [[nodiscard]] auto - documentChanges() const -> std::optional>>; + [[nodiscard]] auto documentChanges() const -> std::optional>>; [[nodiscard]] auto changeAnnotations() const -> std::optional>; @@ -971,8 +968,8 @@ class WorkspaceEdit final : public LSPObject { -> WorkspaceEdit&; auto documentChanges( - std::optional>> + std::optional>> documentChanges) -> WorkspaceEdit&; auto changeAnnotations( @@ -1069,13 +1066,13 @@ class MonikerRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> MonikerRegistrationOptions&; + std::variant documentSelector) + -> MonikerRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> MonikerRegistrationOptions&; @@ -1148,15 +1145,15 @@ class TypeHierarchyRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> TypeHierarchyRegistrationOptions&; + std::variant documentSelector) + -> TypeHierarchyRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> TypeHierarchyRegistrationOptions&; @@ -1239,7 +1236,7 @@ class InlineValueRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto id() const -> std::optional; @@ -1247,8 +1244,8 @@ class InlineValueRegistrationOptions final : public LSPObject { -> InlineValueRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> InlineValueRegistrationOptions&; + std::variant documentSelector) + -> InlineValueRegistrationOptions&; auto id(std::optional id) -> InlineValueRegistrationOptions&; }; @@ -1282,14 +1279,14 @@ class InlayHint final : public LSPObject { [[nodiscard]] auto position() const -> Position; [[nodiscard]] auto label() const - -> std::variant>; + -> std::variant>; [[nodiscard]] auto kind() const -> std::optional; [[nodiscard]] auto textEdits() const -> std::optional>; - [[nodiscard]] auto tooltip() const -> std::optional< - std::variant>; + [[nodiscard]] auto tooltip() const + -> std::optional>; [[nodiscard]] auto paddingLeft() const -> std::optional; @@ -1299,17 +1296,15 @@ class InlayHint final : public LSPObject { auto position(Position position) -> InlayHint&; - auto label( - std::variant> - label) -> InlayHint&; + auto label(std::variant> label) + -> InlayHint&; auto kind(std::optional kind) -> InlayHint&; auto textEdits(std::optional> textEdits) -> InlayHint&; - auto tooltip( - std::optional> - tooltip) -> InlayHint&; + auto tooltip(std::optional> tooltip) + -> InlayHint&; auto paddingLeft(std::optional paddingLeft) -> InlayHint&; @@ -1329,7 +1324,7 @@ class InlayHintRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto id() const -> std::optional; @@ -1340,8 +1335,8 @@ class InlayHintRegistrationOptions final : public LSPObject { -> InlayHintRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> InlayHintRegistrationOptions&; + std::variant documentSelector) + -> InlayHintRegistrationOptions&; auto id(std::optional id) -> InlayHintRegistrationOptions&; }; @@ -1385,14 +1380,12 @@ class DocumentDiagnosticReportPartialResult final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto relatedDocuments() const - -> Map>; + -> Map>; auto relatedDocuments( - Map> + Map> relatedDocuments) -> DocumentDiagnosticReportPartialResult&; }; @@ -1415,7 +1408,7 @@ class DiagnosticRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto identifier() const -> std::optional; @@ -1428,8 +1421,8 @@ class DiagnosticRegistrationOptions final : public LSPObject { [[nodiscard]] auto id() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DiagnosticRegistrationOptions&; + std::variant documentSelector) + -> DiagnosticRegistrationOptions&; auto identifier(std::optional identifier) -> DiagnosticRegistrationOptions&; @@ -1521,17 +1514,17 @@ class NotebookDocumentSyncRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto notebookSelector() const - -> Vector Vector>; [[nodiscard]] auto save() const -> std::optional; [[nodiscard]] auto id() const -> std::optional; - auto notebookSelector( - Vector> - notebookSelector) -> NotebookDocumentSyncRegistrationOptions&; + auto notebookSelector(Vector> + notebookSelector) + -> NotebookDocumentSyncRegistrationOptions&; auto save(std::optional save) -> NotebookDocumentSyncRegistrationOptions&; @@ -1631,7 +1624,7 @@ class InlineCompletionItem final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto insertText() const - -> std::variant; + -> std::variant; [[nodiscard]] auto filterText() const -> std::optional; @@ -1639,8 +1632,7 @@ class InlineCompletionItem final : public LSPObject { [[nodiscard]] auto command() const -> std::optional; - auto insertText( - std::variant insertText) + auto insertText(std::variant insertText) -> InlineCompletionItem&; auto filterText(std::optional filterText) @@ -1660,7 +1652,7 @@ class InlineCompletionRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto id() const -> std::optional; @@ -1668,8 +1660,8 @@ class InlineCompletionRegistrationOptions final : public LSPObject { -> InlineCompletionRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> InlineCompletionRegistrationOptions&; + std::variant documentSelector) + -> InlineCompletionRegistrationOptions&; auto id(std::optional id) -> InlineCompletionRegistrationOptions&; @@ -1754,18 +1746,17 @@ class InitializeParams final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto processId() const - -> std::variant; + [[nodiscard]] auto processId() const -> std::variant; [[nodiscard]] auto clientInfo() const -> std::optional; [[nodiscard]] auto locale() const -> std::optional; - [[nodiscard]] auto rootPath() const -> std::optional< - std::variant>; + [[nodiscard]] auto rootPath() const + -> std::optional>; [[nodiscard]] auto rootUri() const - -> std::variant; + -> std::variant; [[nodiscard]] auto capabilities() const -> ClientCapabilities; @@ -1775,10 +1766,10 @@ class InitializeParams final : public LSPObject { [[nodiscard]] auto workDoneToken() const -> std::optional; - [[nodiscard]] auto workspaceFolders() const -> std::optional< - std::variant, std::nullptr_t>>; + [[nodiscard]] auto workspaceFolders() const + -> std::optional, std::nullptr_t>>; - auto processId(std::variant processId) + auto processId(std::variant processId) -> InitializeParams&; auto clientInfo(std::optional clientInfo) -> InitializeParams&; @@ -1786,11 +1777,10 @@ class InitializeParams final : public LSPObject { auto locale(std::optional locale) -> InitializeParams&; auto rootPath( - std::optional> - rootPath) -> InitializeParams&; + std::optional> rootPath) + -> InitializeParams&; - auto rootUri( - std::variant rootUri) + auto rootUri(std::variant rootUri) -> InitializeParams&; auto capabilities(ClientCapabilities capabilities) -> InitializeParams&; @@ -1804,8 +1794,7 @@ class InitializeParams final : public LSPObject { -> InitializeParams&; auto workspaceFolders( - std::optional< - std::variant, std::nullptr_t>> + std::optional, std::nullptr_t>> workspaceFolders) -> InitializeParams&; }; @@ -1859,12 +1848,12 @@ class DidChangeConfigurationRegistrationOptions final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto section() const -> std::optional< - std::variant>>; + [[nodiscard]] auto section() const + -> std::optional>>; - auto section(std::optional< - std::variant>> - section) -> DidChangeConfigurationRegistrationOptions&; + auto section( + std::optional>> section) + -> DidChangeConfigurationRegistrationOptions&; }; class ShowMessageParams final : public LSPObject { @@ -1968,14 +1957,14 @@ class TextDocumentChangeRegistrationOptions final : public LSPObject { [[nodiscard]] auto syncKind() const -> TextDocumentSyncKind; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; auto syncKind(TextDocumentSyncKind syncKind) -> TextDocumentChangeRegistrationOptions&; auto documentSelector( - std::variant - documentSelector) -> TextDocumentChangeRegistrationOptions&; + std::variant documentSelector) + -> TextDocumentChangeRegistrationOptions&; }; class DidCloseTextDocumentParams final : public LSPObject { @@ -2013,13 +2002,13 @@ class TextDocumentSaveRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto includeText() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> TextDocumentSaveRegistrationOptions&; + std::variant documentSelector) + -> TextDocumentSaveRegistrationOptions&; auto includeText(std::optional includeText) -> TextDocumentSaveRegistrationOptions&; @@ -2144,8 +2133,8 @@ class CompletionItem final : public LSPObject { [[nodiscard]] auto detail() const -> std::optional; - [[nodiscard]] auto documentation() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentation() const + -> std::optional>; [[nodiscard]] auto deprecated() const -> std::optional; @@ -2162,8 +2151,8 @@ class CompletionItem final : public LSPObject { [[nodiscard]] auto insertTextMode() const -> std::optional; - [[nodiscard]] auto textEdit() const -> std::optional< - std::variant>; + [[nodiscard]] auto textEdit() const + -> std::optional>; [[nodiscard]] auto textEditText() const -> std::optional; @@ -2189,8 +2178,8 @@ class CompletionItem final : public LSPObject { auto detail(std::optional detail) -> CompletionItem&; auto documentation( - std::optional> - documentation) -> CompletionItem&; + std::optional> documentation) + -> CompletionItem&; auto deprecated(std::optional deprecated) -> CompletionItem&; @@ -2209,8 +2198,8 @@ class CompletionItem final : public LSPObject { -> CompletionItem&; auto textEdit( - std::optional> - textEdit) -> CompletionItem&; + std::optional> textEdit) + -> CompletionItem&; auto textEditText(std::optional textEditText) -> CompletionItem&; @@ -2259,7 +2248,7 @@ class CompletionRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto triggerCharacters() const -> std::optional>; @@ -2275,8 +2264,8 @@ class CompletionRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> CompletionRegistrationOptions&; + std::variant documentSelector) + -> CompletionRegistrationOptions&; auto triggerCharacters(std::optional> triggerCharacters) -> CompletionRegistrationOptions&; @@ -2322,14 +2311,13 @@ class Hover final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto contents() const - -> std::variant>; + -> std::variant>; [[nodiscard]] auto range() const -> std::optional; - auto contents(std::variant> - contents) -> Hover&; + auto contents( + std::variant> contents) + -> Hover&; auto range(std::optional range) -> Hover&; }; @@ -2341,13 +2329,13 @@ class HoverRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> HoverRegistrationOptions&; + std::variant documentSelector) + -> HoverRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> HoverRegistrationOptions&; @@ -2390,15 +2378,15 @@ class SignatureHelp final : public LSPObject { [[nodiscard]] auto activeSignature() const -> std::optional; [[nodiscard]] auto activeParameter() const - -> std::optional>; + -> std::optional>; auto signatures(Vector signatures) -> SignatureHelp&; auto activeSignature(std::optional activeSignature) -> SignatureHelp&; auto activeParameter( - std::optional> - activeParameter) -> SignatureHelp&; + std::optional> activeParameter) + -> SignatureHelp&; }; class SignatureHelpRegistrationOptions final : public LSPObject { @@ -2408,7 +2396,7 @@ class SignatureHelpRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto triggerCharacters() const -> std::optional>; @@ -2419,8 +2407,8 @@ class SignatureHelpRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> SignatureHelpRegistrationOptions&; + std::variant documentSelector) + -> SignatureHelpRegistrationOptions&; auto triggerCharacters(std::optional> triggerCharacters) -> SignatureHelpRegistrationOptions&; @@ -2465,13 +2453,13 @@ class DefinitionRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DefinitionRegistrationOptions&; + std::variant documentSelector) + -> DefinitionRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> DefinitionRegistrationOptions&; @@ -2513,13 +2501,13 @@ class ReferenceRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> ReferenceRegistrationOptions&; + std::variant documentSelector) + -> ReferenceRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> ReferenceRegistrationOptions&; @@ -2573,13 +2561,13 @@ class DocumentHighlightRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentHighlightRegistrationOptions&; + std::variant documentSelector) + -> DocumentHighlightRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> DocumentHighlightRegistrationOptions&; @@ -2686,15 +2674,15 @@ class DocumentSymbolRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto label() const -> std::optional; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentSymbolRegistrationOptions&; + std::variant documentSelector) + -> DocumentSymbolRegistrationOptions&; auto label(std::optional label) -> DocumentSymbolRegistrationOptions&; @@ -2806,7 +2794,7 @@ class CodeActionRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto codeActionKinds() const -> std::optional>; @@ -2819,8 +2807,8 @@ class CodeActionRegistrationOptions final : public LSPObject { [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> CodeActionRegistrationOptions&; + std::variant documentSelector) + -> CodeActionRegistrationOptions&; auto codeActionKinds(std::optional> codeActionKinds) -> CodeActionRegistrationOptions&; @@ -2864,7 +2852,7 @@ class WorkspaceSymbol final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto location() const - -> std::variant; + -> std::variant; [[nodiscard]] auto data() const -> std::optional; @@ -2876,8 +2864,7 @@ class WorkspaceSymbol final : public LSPObject { [[nodiscard]] auto containerName() const -> std::optional; - auto location( - std::variant location) + auto location(std::variant location) -> WorkspaceSymbol&; auto data(std::optional data) -> WorkspaceSymbol&; @@ -2956,15 +2943,15 @@ class CodeLensRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto resolveProvider() const -> std::optional; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> CodeLensRegistrationOptions&; + std::variant documentSelector) + -> CodeLensRegistrationOptions&; auto resolveProvider(std::optional resolveProvider) -> CodeLensRegistrationOptions&; @@ -3024,15 +3011,15 @@ class DocumentLinkRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto resolveProvider() const -> std::optional; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentLinkRegistrationOptions&; + std::variant documentSelector) + -> DocumentLinkRegistrationOptions&; auto resolveProvider(std::optional resolveProvider) -> DocumentLinkRegistrationOptions&; @@ -3069,13 +3056,13 @@ class DocumentFormattingRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentFormattingRegistrationOptions&; + std::variant documentSelector) + -> DocumentFormattingRegistrationOptions&; auto workDoneProgress(std::optional workDoneProgress) -> DocumentFormattingRegistrationOptions&; @@ -3113,15 +3100,15 @@ class DocumentRangeFormattingRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto rangesSupport() const -> std::optional; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> DocumentRangeFormattingRegistrationOptions&; + std::variant documentSelector) + -> DocumentRangeFormattingRegistrationOptions&; auto rangesSupport(std::optional rangesSupport) -> DocumentRangeFormattingRegistrationOptions&; @@ -3186,7 +3173,7 @@ class DocumentOnTypeFormattingRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto firstTriggerCharacter() const -> std::string; @@ -3194,8 +3181,8 @@ class DocumentOnTypeFormattingRegistrationOptions final : public LSPObject { -> std::optional>; auto documentSelector( - std::variant - documentSelector) -> DocumentOnTypeFormattingRegistrationOptions&; + std::variant documentSelector) + -> DocumentOnTypeFormattingRegistrationOptions&; auto firstTriggerCharacter(std::string firstTriggerCharacter) -> DocumentOnTypeFormattingRegistrationOptions&; @@ -3236,15 +3223,15 @@ class RenameRegistrationOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto documentSelector() const - -> std::variant; + -> std::variant; [[nodiscard]] auto prepareProvider() const -> std::optional; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto documentSelector( - std::variant - documentSelector) -> RenameRegistrationOptions&; + std::variant documentSelector) + -> RenameRegistrationOptions&; auto prepareProvider(std::optional prepareProvider) -> RenameRegistrationOptions&; @@ -3450,10 +3437,9 @@ class CancelParams final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto id() const - -> std::variant; + [[nodiscard]] auto id() const -> std::variant; - auto id(std::variant id) -> CancelParams&; + auto id(std::variant id) -> CancelParams&; }; class ProgressParams final : public LSPObject { @@ -3732,22 +3718,20 @@ class SemanticTokensOptions final : public LSPObject { [[nodiscard]] auto legend() const -> SemanticTokensLegend; - [[nodiscard]] auto range() const - -> std::optional>; + [[nodiscard]] auto range() const -> std::optional>; - [[nodiscard]] auto full() const -> std::optional< - std::variant>; + [[nodiscard]] auto full() const + -> std::optional>; [[nodiscard]] auto workDoneProgress() const -> std::optional; auto legend(SemanticTokensLegend legend) -> SemanticTokensOptions&; - auto range(std::optional> range) + auto range(std::optional> range) -> SemanticTokensOptions&; - auto full( - std::optional> - full) -> SemanticTokensOptions&; + auto full(std::optional> full) + -> SemanticTokensOptions&; auto workDoneProgress(std::optional workDoneProgress) -> SemanticTokensOptions&; @@ -3805,15 +3789,14 @@ class TextDocumentEdit final : public LSPObject { -> OptionalVersionedTextDocumentIdentifier; [[nodiscard]] auto edits() const - -> Vector>; + -> Vector>; auto textDocument(OptionalVersionedTextDocumentIdentifier textDocument) -> TextDocumentEdit&; - auto edits(Vector> - edits) -> TextDocumentEdit&; + auto edits( + Vector> edits) + -> TextDocumentEdit&; }; class CreateFile final : public LSPObject { @@ -4067,8 +4050,8 @@ class InlayHintLabelPart final : public LSPObject { [[nodiscard]] auto value() const -> std::string; - [[nodiscard]] auto tooltip() const -> std::optional< - std::variant>; + [[nodiscard]] auto tooltip() const + -> std::optional>; [[nodiscard]] auto location() const -> std::optional; @@ -4076,9 +4059,8 @@ class InlayHintLabelPart final : public LSPObject { auto value(std::string value) -> InlayHintLabelPart&; - auto tooltip( - std::optional> - tooltip) -> InlayHintLabelPart&; + auto tooltip(std::optional> tooltip) + -> InlayHintLabelPart&; auto location(std::optional location) -> InlayHintLabelPart&; @@ -4123,9 +4105,9 @@ class RelatedFullDocumentDiagnosticReport final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto relatedDocuments() const -> std::optional>>; + [[nodiscard]] auto relatedDocuments() const -> std::optional< + Map>>; [[nodiscard]] auto kind() const -> std::string; @@ -4135,9 +4117,8 @@ class RelatedFullDocumentDiagnosticReport final : public LSPObject { auto relatedDocuments( std::optional< - Map>> + Map>> relatedDocuments) -> RelatedFullDocumentDiagnosticReport&; auto kind(std::string kind) -> RelatedFullDocumentDiagnosticReport&; @@ -4154,9 +4135,9 @@ class RelatedUnchangedDocumentDiagnosticReport final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto relatedDocuments() const -> std::optional>>; + [[nodiscard]] auto relatedDocuments() const -> std::optional< + Map>>; [[nodiscard]] auto kind() const -> std::string; @@ -4164,9 +4145,8 @@ class RelatedUnchangedDocumentDiagnosticReport final : public LSPObject { auto relatedDocuments( std::optional< - Map>> + Map>> relatedDocuments) -> RelatedUnchangedDocumentDiagnosticReport&; auto kind(std::string kind) -> RelatedUnchangedDocumentDiagnosticReport&; @@ -4306,15 +4286,14 @@ class NotebookDocumentSyncOptions final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto notebookSelector() const - -> Vector Vector>; [[nodiscard]] auto save() const -> std::optional; - auto notebookSelector( - Vector> - notebookSelector) -> NotebookDocumentSyncOptions&; + auto notebookSelector(Vector> + notebookSelector) -> NotebookDocumentSyncOptions&; auto save(std::optional save) -> NotebookDocumentSyncOptions&; }; @@ -4460,18 +4439,17 @@ class _InitializeParams final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto processId() const - -> std::variant; + [[nodiscard]] auto processId() const -> std::variant; [[nodiscard]] auto clientInfo() const -> std::optional; [[nodiscard]] auto locale() const -> std::optional; - [[nodiscard]] auto rootPath() const -> std::optional< - std::variant>; + [[nodiscard]] auto rootPath() const + -> std::optional>; [[nodiscard]] auto rootUri() const - -> std::variant; + -> std::variant; [[nodiscard]] auto capabilities() const -> ClientCapabilities; @@ -4481,7 +4459,7 @@ class _InitializeParams final : public LSPObject { [[nodiscard]] auto workDoneToken() const -> std::optional; - auto processId(std::variant processId) + auto processId(std::variant processId) -> _InitializeParams&; auto clientInfo(std::optional clientInfo) -> _InitializeParams&; @@ -4489,11 +4467,10 @@ class _InitializeParams final : public LSPObject { auto locale(std::optional locale) -> _InitializeParams&; auto rootPath( - std::optional> - rootPath) -> _InitializeParams&; + std::optional> rootPath) + -> _InitializeParams&; - auto rootUri( - std::variant rootUri) + auto rootUri(std::variant rootUri) -> _InitializeParams&; auto capabilities(ClientCapabilities capabilities) -> _InitializeParams&; @@ -4513,12 +4490,11 @@ class WorkspaceFoldersInitializeParams final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto workspaceFolders() const -> std::optional< - std::variant, std::nullptr_t>>; + [[nodiscard]] auto workspaceFolders() const + -> std::optional, std::nullptr_t>>; auto workspaceFolders( - std::optional< - std::variant, std::nullptr_t>> + std::optional, std::nullptr_t>> workspaceFolders) -> WorkspaceFoldersInitializeParams&; }; @@ -4531,49 +4507,47 @@ class ServerCapabilities final : public LSPObject { [[nodiscard]] auto positionEncoding() const -> std::optional; - [[nodiscard]] auto textDocumentSync() const - -> std::optional>; + [[nodiscard]] auto textDocumentSync() const -> std::optional< + std::variant>; [[nodiscard]] auto notebookDocumentSync() const - -> std::optional std::optional>; [[nodiscard]] auto completionProvider() const -> std::optional; [[nodiscard]] auto hoverProvider() const - -> std::optional>; + -> std::optional>; [[nodiscard]] auto signatureHelpProvider() const -> std::optional; - [[nodiscard]] auto declarationProvider() const - -> std::optional>; + [[nodiscard]] auto declarationProvider() const -> std::optional< + std::variant>; [[nodiscard]] auto definitionProvider() const - -> std::optional>; + -> std::optional>; [[nodiscard]] auto typeDefinitionProvider() const - -> std::optional std::optional>; [[nodiscard]] auto implementationProvider() const - -> std::optional std::optional>; [[nodiscard]] auto referencesProvider() const - -> std::optional>; + -> std::optional>; - [[nodiscard]] auto documentHighlightProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentHighlightProvider() const + -> std::optional>; - [[nodiscard]] auto documentSymbolProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentSymbolProvider() const + -> std::optional>; [[nodiscard]] auto codeActionProvider() const - -> std::optional>; + -> std::optional>; [[nodiscard]] auto codeLensProvider() const -> std::optional; @@ -4581,69 +4555,63 @@ class ServerCapabilities final : public LSPObject { -> std::optional; [[nodiscard]] auto colorProvider() const - -> std::optional std::optional>; - [[nodiscard]] auto workspaceSymbolProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto workspaceSymbolProvider() const + -> std::optional>; - [[nodiscard]] auto documentFormattingProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentFormattingProvider() const + -> std::optional>; - [[nodiscard]] auto documentRangeFormattingProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentRangeFormattingProvider() const + -> std::optional>; [[nodiscard]] auto documentOnTypeFormattingProvider() const -> std::optional; [[nodiscard]] auto renameProvider() const - -> std::optional>; + -> std::optional>; - [[nodiscard]] auto foldingRangeProvider() const - -> std::optional>; + [[nodiscard]] auto foldingRangeProvider() const -> std::optional< + std::variant>; [[nodiscard]] auto selectionRangeProvider() const - -> std::optional std::optional>; [[nodiscard]] auto executeCommandProvider() const -> std::optional; [[nodiscard]] auto callHierarchyProvider() const - -> std::optional std::optional>; - [[nodiscard]] auto linkedEditingRangeProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto linkedEditingRangeProvider() const + -> std::optional>; - [[nodiscard]] auto semanticTokensProvider() const - -> std::optional>; + [[nodiscard]] auto semanticTokensProvider() const -> std::optional< + std::variant>; - [[nodiscard]] auto monikerProvider() const - -> std::optional>; + [[nodiscard]] auto monikerProvider() const -> std::optional< + std::variant>; [[nodiscard]] auto typeHierarchyProvider() const - -> std::optional std::optional>; - [[nodiscard]] auto inlineValueProvider() const - -> std::optional>; + [[nodiscard]] auto inlineValueProvider() const -> std::optional< + std::variant>; - [[nodiscard]] auto inlayHintProvider() const - -> std::optional>; + [[nodiscard]] auto inlayHintProvider() const -> std::optional< + std::variant>; - [[nodiscard]] auto diagnosticProvider() const - -> std::optional>; + [[nodiscard]] auto diagnosticProvider() const -> std::optional< + std::variant>; - [[nodiscard]] auto inlineCompletionProvider() const -> std::optional< - std::variant>; + [[nodiscard]] auto inlineCompletionProvider() const + -> std::optional>; [[nodiscard]] auto workspace() const -> std::optional; @@ -4653,12 +4621,11 @@ class ServerCapabilities final : public LSPObject { -> ServerCapabilities&; auto textDocumentSync( - std::optional> + std::optional> textDocumentSync) -> ServerCapabilities&; auto notebookDocumentSync( - std::optional> notebookDocumentSync) -> ServerCapabilities&; @@ -4666,48 +4633,47 @@ class ServerCapabilities final : public LSPObject { -> ServerCapabilities&; auto hoverProvider( - std::optional> - hoverProvider) -> ServerCapabilities&; + std::optional> hoverProvider) + -> ServerCapabilities&; auto signatureHelpProvider( std::optional signatureHelpProvider) -> ServerCapabilities&; auto declarationProvider( - std::optional> declarationProvider) -> ServerCapabilities&; auto definitionProvider( - std::optional> - definitionProvider) -> ServerCapabilities&; + std::optional> definitionProvider) + -> ServerCapabilities&; auto typeDefinitionProvider( - std::optional> typeDefinitionProvider) -> ServerCapabilities&; auto implementationProvider( - std::optional> implementationProvider) -> ServerCapabilities&; auto referencesProvider( - std::optional> - referencesProvider) -> ServerCapabilities&; + std::optional> referencesProvider) + -> ServerCapabilities&; auto documentHighlightProvider( - std::optional< - std::variant> + std::optional> documentHighlightProvider) -> ServerCapabilities&; auto documentSymbolProvider( - std::optional> + std::optional> documentSymbolProvider) -> ServerCapabilities&; auto codeActionProvider( - std::optional> - codeActionProvider) -> ServerCapabilities&; + std::optional> codeActionProvider) + -> ServerCapabilities&; auto codeLensProvider(std::optional codeLensProvider) -> ServerCapabilities&; @@ -4717,22 +4683,20 @@ class ServerCapabilities final : public LSPObject { -> ServerCapabilities&; auto colorProvider( - std::optional> colorProvider) -> ServerCapabilities&; auto workspaceSymbolProvider( - std::optional> + std::optional> workspaceSymbolProvider) -> ServerCapabilities&; auto documentFormattingProvider( - std::optional< - std::variant> + std::optional> documentFormattingProvider) -> ServerCapabilities&; auto documentRangeFormattingProvider( - std::optional< - std::variant> + std::optional> documentRangeFormattingProvider) -> ServerCapabilities&; auto documentOnTypeFormattingProvider( @@ -4740,16 +4704,16 @@ class ServerCapabilities final : public LSPObject { documentOnTypeFormattingProvider) -> ServerCapabilities&; auto renameProvider( - std::optional> - renameProvider) -> ServerCapabilities&; + std::optional> renameProvider) + -> ServerCapabilities&; auto foldingRangeProvider( - std::optional> foldingRangeProvider) -> ServerCapabilities&; auto selectionRangeProvider( - std::optional> selectionRangeProvider) -> ServerCapabilities&; @@ -4758,48 +4722,47 @@ class ServerCapabilities final : public LSPObject { -> ServerCapabilities&; auto callHierarchyProvider( - std::optional> callHierarchyProvider) -> ServerCapabilities&; auto linkedEditingRangeProvider( - std::optional< - std::variant> + std::optional> linkedEditingRangeProvider) -> ServerCapabilities&; auto semanticTokensProvider( - std::optional> semanticTokensProvider) -> ServerCapabilities&; auto monikerProvider( - std::optional> + std::optional< + std::variant> monikerProvider) -> ServerCapabilities&; auto typeHierarchyProvider( - std::optional> typeHierarchyProvider) -> ServerCapabilities&; auto inlineValueProvider( - std::optional> inlineValueProvider) -> ServerCapabilities&; auto inlayHintProvider( - std::optional> + std::optional< + std::variant> inlayHintProvider) -> ServerCapabilities&; auto diagnosticProvider( - std::optional> + std::optional< + std::variant> diagnosticProvider) -> ServerCapabilities&; auto inlineCompletionProvider( - std::optional> + std::optional> inlineCompletionProvider) -> ServerCapabilities&; auto workspace(std::optional workspace) @@ -4890,7 +4853,7 @@ class Diagnostic final : public LSPObject { [[nodiscard]] auto severity() const -> std::optional; [[nodiscard]] auto code() const - -> std::optional>; + -> std::optional>; [[nodiscard]] auto codeDescription() const -> std::optional; @@ -4909,8 +4872,7 @@ class Diagnostic final : public LSPObject { auto severity(std::optional severity) -> Diagnostic&; - auto code(std::optional> code) - -> Diagnostic&; + auto code(std::optional> code) -> Diagnostic&; auto codeDescription(std::optional codeDescription) -> Diagnostic&; @@ -4988,8 +4950,8 @@ class CompletionItemDefaults final : public LSPObject { [[nodiscard]] auto commitCharacters() const -> std::optional>; - [[nodiscard]] auto editRange() const -> std::optional< - std::variant>; + [[nodiscard]] auto editRange() const + -> std::optional>; [[nodiscard]] auto insertTextFormat() const -> std::optional; @@ -5002,9 +4964,8 @@ class CompletionItemDefaults final : public LSPObject { -> CompletionItemDefaults&; auto editRange( - std::optional< - std::variant> - editRange) -> CompletionItemDefaults&; + std::optional> editRange) + -> CompletionItemDefaults&; auto insertTextFormat(std::optional insertTextFormat) -> CompletionItemDefaults&; @@ -5113,27 +5074,27 @@ class SignatureInformation final : public LSPObject { [[nodiscard]] auto label() const -> std::string; - [[nodiscard]] auto documentation() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentation() const + -> std::optional>; [[nodiscard]] auto parameters() const -> std::optional>; [[nodiscard]] auto activeParameter() const - -> std::optional>; + -> std::optional>; auto label(std::string label) -> SignatureInformation&; auto documentation( - std::optional> - documentation) -> SignatureInformation&; + std::optional> documentation) + -> SignatureInformation&; auto parameters(std::optional> parameters) -> SignatureInformation&; auto activeParameter( - std::optional> - activeParameter) -> SignatureInformation&; + std::optional> activeParameter) + -> SignatureInformation&; }; class SignatureHelpOptions final : public LSPObject { @@ -5551,12 +5512,11 @@ class OptionalVersionedTextDocumentIdentifier final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto version() const - -> std::variant; + [[nodiscard]] auto version() const -> std::variant; [[nodiscard]] auto uri() const -> std::string; - auto version(std::variant version) + auto version(std::variant version) -> OptionalVersionedTextDocumentIdentifier&; auto uri(std::string uri) -> OptionalVersionedTextDocumentIdentifier&; @@ -5696,8 +5656,7 @@ class WorkspaceFullDocumentDiagnosticReport final : public LSPObject { [[nodiscard]] auto uri() const -> std::string; - [[nodiscard]] auto version() const - -> std::variant; + [[nodiscard]] auto version() const -> std::variant; [[nodiscard]] auto kind() const -> std::string; @@ -5707,7 +5666,7 @@ class WorkspaceFullDocumentDiagnosticReport final : public LSPObject { auto uri(std::string uri) -> WorkspaceFullDocumentDiagnosticReport&; - auto version(std::variant version) + auto version(std::variant version) -> WorkspaceFullDocumentDiagnosticReport&; auto kind(std::string kind) -> WorkspaceFullDocumentDiagnosticReport&; @@ -5727,8 +5686,7 @@ class WorkspaceUnchangedDocumentDiagnosticReport final : public LSPObject { [[nodiscard]] auto uri() const -> std::string; - [[nodiscard]] auto version() const - -> std::variant; + [[nodiscard]] auto version() const -> std::variant; [[nodiscard]] auto kind() const -> std::string; @@ -5736,7 +5694,7 @@ class WorkspaceUnchangedDocumentDiagnosticReport final : public LSPObject { auto uri(std::string uri) -> WorkspaceUnchangedDocumentDiagnosticReport&; - auto version(std::variant version) + auto version(std::variant version) -> WorkspaceUnchangedDocumentDiagnosticReport&; auto kind(std::string kind) -> WorkspaceUnchangedDocumentDiagnosticReport&; @@ -5777,14 +5735,13 @@ class NotebookDocumentFilterWithNotebook final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto notebook() const - -> std::variant; + -> std::variant; [[nodiscard]] auto cells() const -> std::optional>; - auto notebook( - std::variant - notebook) -> NotebookDocumentFilterWithNotebook&; + auto notebook(std::variant notebook) + -> NotebookDocumentFilterWithNotebook&; auto cells(std::optional> cells) -> NotebookDocumentFilterWithNotebook&; @@ -5796,15 +5753,14 @@ class NotebookDocumentFilterWithCells final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto notebook() const -> std::optional< - std::variant>; + [[nodiscard]] auto notebook() const + -> std::optional>; [[nodiscard]] auto cells() const -> Vector; auto notebook( - std::optional< - std::variant> - notebook) -> NotebookDocumentFilterWithCells&; + std::optional> notebook) + -> NotebookDocumentFilterWithCells&; auto cells(Vector cells) -> NotebookDocumentFilterWithCells&; @@ -5921,7 +5877,7 @@ class TextDocumentSyncOptions final : public LSPObject { [[nodiscard]] auto willSaveWaitUntil() const -> std::optional; [[nodiscard]] auto save() const - -> std::optional>; + -> std::optional>; auto openClose(std::optional openClose) -> TextDocumentSyncOptions&; @@ -5933,7 +5889,7 @@ class TextDocumentSyncOptions final : public LSPObject { auto willSaveWaitUntil(std::optional willSaveWaitUntil) -> TextDocumentSyncOptions&; - auto save(std::optional> save) + auto save(std::optional> save) -> TextDocumentSyncOptions&; }; @@ -5950,7 +5906,7 @@ class WorkspaceOptions final : public LSPObject { -> std::optional; [[nodiscard]] auto textDocumentContent() const - -> std::optional std::optional>; auto workspaceFolders( @@ -5961,7 +5917,7 @@ class WorkspaceOptions final : public LSPObject { -> WorkspaceOptions&; auto textDocumentContent( - std::optional> textDocumentContent) -> WorkspaceOptions&; }; @@ -6072,18 +6028,17 @@ class ParameterInformation final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto label() const - -> std::variant>; + -> std::variant>; - [[nodiscard]] auto documentation() const -> std::optional< - std::variant>; + [[nodiscard]] auto documentation() const + -> std::optional>; - auto label( - std::variant> label) + auto label(std::variant> label) -> ParameterInformation&; auto documentation( - std::optional> - documentation) -> ParameterInformation&; + std::optional> documentation) + -> ParameterInformation&; }; class CodeActionKindDocumentation final : public LSPObject { @@ -6108,13 +6063,12 @@ class NotebookCellTextDocumentFilter final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto notebook() const - -> std::variant; + -> std::variant; [[nodiscard]] auto language() const -> std::optional; - auto notebook( - std::variant - notebook) -> NotebookCellTextDocumentFilter&; + auto notebook(std::variant notebook) + -> NotebookCellTextDocumentFilter&; auto language(std::optional language) -> NotebookCellTextDocumentFilter&; @@ -6602,14 +6556,14 @@ class WorkspaceFoldersServerCapabilities final : public LSPObject { [[nodiscard]] auto supported() const -> std::optional; [[nodiscard]] auto changeNotifications() const - -> std::optional>; + -> std::optional>; auto supported(std::optional supported) -> WorkspaceFoldersServerCapabilities&; auto changeNotifications( - std::optional> - changeNotifications) -> WorkspaceFoldersServerCapabilities&; + std::optional> changeNotifications) + -> WorkspaceFoldersServerCapabilities&; }; class FileOperationOptions final : public LSPObject { @@ -6662,12 +6616,11 @@ class RelativePattern final : public LSPObject { explicit operator bool() const; [[nodiscard]] auto baseUri() const - -> std::variant; + -> std::variant; [[nodiscard]] auto pattern() const -> Pattern; - auto baseUri( - std::variant baseUri) + auto baseUri(std::variant baseUri) -> RelativePattern&; auto pattern(Pattern pattern) -> RelativePattern&; @@ -8118,18 +8071,17 @@ class ClientSemanticTokensRequestOptions final : public LSPObject { explicit operator bool() const; - [[nodiscard]] auto range() const - -> std::optional>; + [[nodiscard]] auto range() const -> std::optional>; [[nodiscard]] auto full() const -> std::optional< - std::variant>; + std::variant>; - auto range(std::optional> range) + auto range(std::optional> range) -> ClientSemanticTokensRequestOptions&; - auto full(std::optional> - full) -> ClientSemanticTokensRequestOptions&; + auto full( + std::optional> + full) -> ClientSemanticTokensRequestOptions&; }; class ClientInlayHintResolveOptions final : public LSPObject { diff --git a/src/lsp/tests/test_types.cc b/src/lsp/tests/test_types.cc index e65f0ec3..cf7b4532 100644 --- a/src/lsp/tests/test_types.cc +++ b/src/lsp/tests/test_types.cc @@ -4,9 +4,9 @@ #include "cxx/lsp/enums.h" #include "cxx/lsp/fwd.h" -TEST(SampleTest, AssertionTrue) { - using namespace cxx::lsp; +using namespace cxx::lsp; +TEST(LSP, Initialization) { // storage auto store1 = json::object(); auto store2 = json::object(); @@ -41,3 +41,52 @@ TEST(SampleTest, AssertionTrue) { ASSERT_TRUE(initializeResult); } + +TEST(LSP, ArrayProperty) { + json storage = json::object(); + + ConfigurationParams configurationParams{storage}; + + ASSERT_FALSE(configurationParams); + + auto items = configurationParams.items(); + + ASSERT_TRUE(items.empty()); + + ASSERT_TRUE(configurationParams); +} + +TEST(LSP, MapProperty) { + json storage = json::object(); + + DocumentDiagnosticReportPartialResult documentDiagnosticReportPartialResult{ + storage}; + + ASSERT_FALSE(documentDiagnosticReportPartialResult); + + auto relatedDocuments = + documentDiagnosticReportPartialResult.relatedDocuments(); + + ASSERT_TRUE(relatedDocuments.empty()); + + ASSERT_TRUE(documentDiagnosticReportPartialResult); +} + +TEST(LSP, StringProperty) { + json storage = json::object(); + + Location location{storage}; + + ASSERT_FALSE(location); + + ASSERT_EQ(location.uri(), ""); + + location.uri("file:///path/to/file"); + ASSERT_EQ(location.uri(), "file:///path/to/file"); + + auto range = location.range(); + ASSERT_EQ(range.start().line(), 0); + ASSERT_EQ(range.start().character(), 0); + + ASSERT_TRUE(location); +} \ No newline at end of file