MLIR  20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::lsp::MessageHandler Class Reference

A handler used to process the incoming transport messages. More...

#include "mlir/Tools/lsp-server-support/Transport.h"

Public Member Functions

 MessageHandler (JSONTransport &transport)
 
bool onNotify (StringRef method, llvm::json::Value value)
 
bool onCall (StringRef method, llvm::json::Value params, llvm::json::Value id)
 
bool onReply (llvm::json::Value id, llvm::Expected< llvm::json::Value > result)
 
template<typename Param , typename Result , typename ThisT >
void method (llvm::StringLiteral method, ThisT *thisPtr, void(ThisT::*handler)(const Param &, Callback< Result >))
 
template<typename Param , typename ThisT >
void notification (llvm::StringLiteral method, ThisT *thisPtr, void(ThisT::*handler)(const Param &))
 
template<typename T >
OutgoingNotification< T > outgoingNotification (llvm::StringLiteral method)
 Create an OutgoingNotification object used for the given method. More...
 
template<typename Param , typename Result >
OutgoingRequest< Param > outgoingRequest (llvm::StringLiteral method, OutgoingRequestCallback< Result > callback)
 Create an OutgoingRequest function that, when called, sends a request with the given method via the transport. More...
 

Static Public Member Functions

template<typename T >
static llvm::Expected< T > parse (const llvm::json::Value &raw, StringRef payloadName, StringRef payloadKind)
 

Detailed Description

A handler used to process the incoming transport messages.

Definition at line 117 of file Transport.h.

Constructor & Destructor Documentation

◆ MessageHandler()

mlir::lsp::MessageHandler::MessageHandler ( JSONTransport transport)
inline

Definition at line 119 of file Transport.h.

Member Function Documentation

◆ method()

template<typename Param , typename Result , typename ThisT >
void mlir::lsp::MessageHandler::method ( llvm::StringLiteral  method,
ThisT *  thisPtr,
void(ThisT::*)(const Param &, Callback< Result >)  handler 
)
inline

◆ notification()

template<typename Param , typename ThisT >
void mlir::lsp::MessageHandler::notification ( llvm::StringLiteral  method,
ThisT *  thisPtr,
void(ThisT::*)(const Param &)  handler 
)
inline

◆ onCall()

bool MessageHandler::onCall ( StringRef  method,
llvm::json::Value  params,
llvm::json::Value  id 
)

Definition at line 102 of file Transport.cpp.

References mlir::lsp::Logger::info(), method(), and mlir::lsp::MethodNotFound.

◆ onNotify()

bool MessageHandler::onNotify ( StringRef  method,
llvm::json::Value  value 
)

Definition at line 87 of file Transport.cpp.

References mlir::lsp::Logger::info(), and method().

◆ onReply()

bool MessageHandler::onReply ( llvm::json::Value  id,
llvm::Expected< llvm::json::Value >  result 
)

◆ outgoingNotification()

template<typename T >
OutgoingNotification<T> mlir::lsp::MessageHandler::outgoingNotification ( llvm::StringLiteral  method)
inline

Create an OutgoingNotification object used for the given method.

Definition at line 178 of file Transport.h.

References mlir::lsp::Logger::info(), method(), and mlir::lsp::JSONTransport::notify().

Referenced by mlir::lsp::runMlirLSPServer(), mlir::lsp::runPdllLSPServer(), and mlir::lsp::runTableGenLSPServer().

◆ outgoingRequest()

template<typename Param , typename Result >
OutgoingRequest<Param> mlir::lsp::MessageHandler::outgoingRequest ( llvm::StringLiteral  method,
OutgoingRequestCallback< Result >  callback 
)
inline

Create an OutgoingRequest function that, when called, sends a request with the given method via the transport.

Should the outgoing request be met with a response, the result JSON is parsed and the response callback is invoked.

Definition at line 192 of file Transport.h.

References mlir::lsp::JSONTransport::call(), mlir::debugString(), mlir::lsp::Logger::info(), and method().

◆ parse()

template<typename T >
static llvm::Expected<T> mlir::lsp::MessageHandler::parse ( const llvm::json::Value &  raw,
StringRef  payloadName,
StringRef  payloadKind 
)
inlinestatic

Definition at line 126 of file Transport.h.

References mlir::lsp::fromJSON(), and mlir::lsp::InvalidParams.


The documentation for this class was generated from the following files: