72 lines · c
1//===--- Protocol.h - Language Server Protocol Implementation ---*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file contains structs for LSP commands that are specific to the PDLL10// server.11//12// Each struct has a toJSON and fromJSON function, that converts between13// the struct and a JSON representation. (See JSON.h)14//15// Some structs also have operator<< serialization. This is for debugging and16// tests, and is not generally machine-readable.17//18//===----------------------------------------------------------------------===//19 20#ifndef LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_PROTOCOL_H_21#define LIB_MLIR_TOOLS_MLIRPDLLLSPSERVER_PROTOCOL_H_22 23#include "llvm/Support/LSP/Protocol.h"24 25namespace mlir {26namespace lsp {27using llvm::lsp::URIForFile;28 29//===----------------------------------------------------------------------===//30// PDLLViewOutputParams31//===----------------------------------------------------------------------===//32 33/// The type of output to view from PDLL.34enum class PDLLViewOutputKind {35 AST,36 MLIR,37 CPP,38};39 40/// Represents the parameters used when viewing the output of a PDLL file.41struct PDLLViewOutputParams {42 /// The URI of the document to view the output of.43 URIForFile uri;44 45 /// The kind of output to generate.46 PDLLViewOutputKind kind;47};48 49/// Add support for JSON serialization.50bool fromJSON(const llvm::json::Value &value, PDLLViewOutputKind &result,51 llvm::json::Path path);52bool fromJSON(const llvm::json::Value &value, PDLLViewOutputParams &result,53 llvm::json::Path path);54 55//===----------------------------------------------------------------------===//56// PDLLViewOutputResult57//===----------------------------------------------------------------------===//58 59/// Represents the result of viewing the output of a PDLL file.60struct PDLLViewOutputResult {61 /// The string representation of the output.62 std::string output;63};64 65/// Add support for JSON serialization.66llvm::json::Value toJSON(const PDLLViewOutputResult &value);67 68} // namespace lsp69} // namespace mlir70 71#endif72