diff --git a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h index de08fa247bd84a..1f67b0dcad1dad 100644 --- a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h +++ b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h @@ -128,6 +128,7 @@ class URIForFile { std::string uriStr; }; +/// Add support for JSON serialization. llvm::json::Value toJSON(const URIForFile &value); bool fromJSON(const llvm::json::Value &value, URIForFile &result, llvm::json::Path path); @@ -142,6 +143,8 @@ enum class TraceLevel { Messages = 1, Verbose = 2, }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, TraceLevel &result, llvm::json::Path path); @@ -149,6 +152,8 @@ struct InitializeParams { /// The initial trace setting. If omitted trace is disabled ('off'). Optional trace; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, InitializeParams &result, llvm::json::Path path); @@ -176,6 +181,8 @@ struct TextDocumentItem { /// The content of the opened text document. std::string text; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, TextDocumentItem &result, llvm::json::Path path); @@ -187,6 +194,8 @@ struct TextDocumentIdentifier { /// The text document's URI. URIForFile uri; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const TextDocumentIdentifier &value); bool fromJSON(const llvm::json::Value &value, TextDocumentIdentifier &result, llvm::json::Path path); @@ -218,6 +227,8 @@ struct Position { std::tie(rhs.line, rhs.character); } }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, Position &result, llvm::json::Path path); llvm::json::Value toJSON(const Position &value); @@ -253,6 +264,8 @@ struct Range { return start <= range.start && range.end <= end; } }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, Range &result, llvm::json::Path path); llvm::json::Value toJSON(const Range &value); @@ -279,6 +292,8 @@ struct Location { return std::tie(lhs.uri, lhs.range) < std::tie(rhs.uri, rhs.range); } }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const Location &value); raw_ostream &operator<<(raw_ostream &os, const Location &value); @@ -293,6 +308,8 @@ struct TextDocumentPositionParams { /// The position inside the text document. Position position; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, TextDocumentPositionParams &result, llvm::json::Path path); @@ -304,12 +321,16 @@ struct ReferenceContext { /// Include the declaration of the current symbol. bool includeDeclaration = false; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, ReferenceContext &result, llvm::json::Path path); struct ReferenceParams : public TextDocumentPositionParams { ReferenceContext context; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, ReferenceParams &result, llvm::json::Path path); @@ -321,6 +342,8 @@ struct DidOpenTextDocumentParams { /// The document that was opened. TextDocumentItem textDocument; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, DidOpenTextDocumentParams &result, llvm::json::Path path); @@ -332,6 +355,8 @@ struct DidCloseTextDocumentParams { /// The document that was closed. TextDocumentIdentifier textDocument; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, DidCloseTextDocumentParams &result, llvm::json::Path path); @@ -349,6 +374,8 @@ struct TextDocumentContentChangeEvent { /// The new text of the range/document. std::string text; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, TextDocumentContentChangeEvent &result, llvm::json::Path path); @@ -359,6 +386,8 @@ struct DidChangeTextDocumentParams { /// The actual content changes. std::vector contentChanges; }; + +/// Add support for JSON serialization. bool fromJSON(const llvm::json::Value &value, DidChangeTextDocumentParams &result, llvm::json::Path path); @@ -378,6 +407,8 @@ struct MarkupContent { MarkupKind kind = MarkupKind::PlainText; std::string value; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const MarkupContent &mc); //===----------------------------------------------------------------------===// @@ -395,6 +426,8 @@ struct Hover { /// visualize a hover, e.g. by changing the background color. Optional range; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const Hover &hover); //===----------------------------------------------------------------------===// @@ -413,6 +446,8 @@ struct DiagnosticRelatedInformation { /// The message of this related diagnostic information. std::string message; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const DiagnosticRelatedInformation &info); //===----------------------------------------------------------------------===// @@ -454,6 +489,8 @@ struct Diagnostic { /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue". Optional category; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const Diagnostic &diag); //===----------------------------------------------------------------------===// @@ -468,6 +505,8 @@ struct PublishDiagnosticsParams { /// The list of reported diagnostics. std::vector diagnostics; }; + +/// Add support for JSON serialization. llvm::json::Value toJSON(const PublishDiagnosticsParams ¶ms); } // namespace lsp