hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
LspServer Class Reference

#include <server.h>

Collaboration diagram for LspServer:

Public Member Functions

 LspServer ()
 
 ~LspServer ()
 
void run ()
 

Private Member Functions

std::string readMessage ()
 
void writeMessage (const std::string &content)
 
void handleMessage (const json &msg)
 
void sendResponse (const json &id, const json &result)
 
void sendError (const json &id, int code, const std::string &message)
 
void sendNotification (const std::string &method, const json &params)
 
void handleInitialize (const json &id, const json &params)
 
void handleInitialized (const json &params)
 
void handleShutdown (const json &id)
 
void handleExit ()
 
void handleDidOpen (const json &params)
 
void handleDidChange (const json &params)
 
void handleDidClose (const json &params)
 
void handleCompletion (const json &id, const json &params)
 
void handleHover (const json &id, const json &params)
 
void handleDefinition (const json &id, const json &params)
 
void handleReferences (const json &id, const json &params)
 
void handleDocumentSymbol (const json &id, const json &params)
 
void publishDiagnostics (const std::string &uri, int version)
 

Private Attributes

DocumentStore documents
 
ProjectIndex projectIndex
 
std::shared_ptr< yoi::compilerContextcompilerCtx
 
std::string workspaceRoot
 
bool isInitialized = false
 
bool compilerInitialized = false
 
bool isShuttingDown = false
 

Detailed Description

Definition at line 17 of file server.h.

Constructor & Destructor Documentation

◆ LspServer()

◆ ~LspServer()

~LspServer ( )
default

Member Function Documentation

◆ handleCompletion()

void handleCompletion ( const json id,
const json params 
)
private

Definition at line 295 of file server.cpp.

References LspServer::documents, DocumentStore::getDocument(), CompletionParams::position, CompletionProvider::provide(), LspServer::sendResponse(), CompletionParams::textDocument, and TextDocumentIdentifier::uri.

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleDefinition()

void handleDefinition ( const json id,
const json params 
)
private

Definition at line 319 of file server.cpp.

References LspServer::documents, DocumentStore::getDocument(), DefinitionParams::position, DefinitionProvider::provide(), LspServer::sendResponse(), DefinitionParams::textDocument, and TextDocumentIdentifier::uri.

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleDidChange()

void handleDidChange ( const json params)
private

◆ handleDidClose()

void handleDidClose ( const json params)
private

Definition at line 238 of file server.cpp.

References DocumentStore::closeDocument(), LspServer::documents, LspServer::sendNotification(), DidCloseTextDocumentParams::textDocument, TextDocumentIdentifier::uri, and PublishDiagnosticsParams::uri.

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleDidOpen()

void handleDidOpen ( const json params)
private

◆ handleDocumentSymbol()

void handleDocumentSymbol ( const json id,
const json params 
)
private

Definition at line 405 of file server.cpp.

References DocumentSymbol::children, LspServer::documents, lsp::documentSymbolFor(), lsp::extendRangeToInclude(), DocumentStore::getDocument(), DocumentSymbol::range, DocumentSymbol::selectionRange, and LspServer::sendResponse().

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleExit()

void handleExit ( )
private

Definition at line 210 of file server.cpp.

References LspServer::isShuttingDown.

Referenced by LspServer::handleMessage().

Here is the caller graph for this function:

◆ handleHover()

void handleHover ( const json id,
const json params 
)
private

Definition at line 305 of file server.cpp.

References LspServer::documents, DocumentStore::getDocument(), HoverParams::position, HoverProvider::provide(), LspServer::sendResponse(), HoverParams::textDocument, and TextDocumentIdentifier::uri.

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleInitialize()

void handleInitialize ( const json id,
const json params 
)
private

Definition at line 152 of file server.cpp.

References ProjectIndex::addSearchPath(), LspServer::projectIndex, LspServer::sendResponse(), yoi::whereIsHoshiLang(), LspServer::workspaceRoot, and yoi::wstring2string().

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleInitialized()

void handleInitialized ( const json params)
private

Definition at line 193 of file server.cpp.

References LspServer::compilerCtx, LspServer::compilerInitialized, and LspServer::isInitialized.

Referenced by LspServer::handleMessage().

Here is the caller graph for this function:

◆ handleMessage()

◆ handleReferences()

void handleReferences ( const json id,
const json params 
)
private

◆ handleShutdown()

void handleShutdown ( const json id)
private

Definition at line 205 of file server.cpp.

References LspServer::isShuttingDown, and LspServer::sendResponse().

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishDiagnostics()

◆ readMessage()

std::string readMessage ( )
private

Definition at line 44 of file server.cpp.

Referenced by LspServer::run().

Here is the caller graph for this function:

◆ run()

void run ( )

Definition at line 449 of file server.cpp.

References LspServer::handleMessage(), LspServer::isShuttingDown, and LspServer::readMessage().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendError()

void sendError ( const json id,
int  code,
const std::string &  message 
)
private

Definition at line 88 of file server.cpp.

References LspServer::writeMessage().

Referenced by LspServer::handleMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendNotification()

void sendNotification ( const std::string &  method,
const json params 
)
private

Definition at line 97 of file server.cpp.

References LspServer::writeMessage().

Referenced by LspServer::handleDidClose(), and LspServer::publishDiagnostics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendResponse()

void sendResponse ( const json id,
const json result 
)
private

Definition at line 79 of file server.cpp.

References LspServer::writeMessage().

Referenced by LspServer::handleCompletion(), LspServer::handleDefinition(), LspServer::handleDocumentSymbol(), LspServer::handleHover(), LspServer::handleInitialize(), LspServer::handleReferences(), and LspServer::handleShutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeMessage()

void writeMessage ( const std::string &  content)
private

Definition at line 73 of file server.cpp.

Referenced by LspServer::sendError(), LspServer::sendNotification(), and LspServer::sendResponse().

Here is the caller graph for this function:

Member Data Documentation

◆ compilerCtx

std::shared_ptr<yoi::compilerContext> compilerCtx
private

Definition at line 57 of file server.h.

Referenced by LspServer::handleInitialized(), and LspServer::LspServer().

◆ compilerInitialized

bool compilerInitialized = false
private

Definition at line 60 of file server.h.

Referenced by LspServer::handleInitialized().

◆ documents

◆ isInitialized

bool isInitialized = false
private

Definition at line 59 of file server.h.

Referenced by LspServer::handleInitialized().

◆ isShuttingDown

bool isShuttingDown = false
private

Definition at line 61 of file server.h.

Referenced by LspServer::handleExit(), LspServer::handleShutdown(), and LspServer::run().

◆ projectIndex

ProjectIndex projectIndex
private

Definition at line 56 of file server.h.

Referenced by LspServer::handleInitialize(), and LspServer::LspServer().

◆ workspaceRoot

std::string workspaceRoot
private

Definition at line 58 of file server.h.

Referenced by LspServer::handleInitialize().


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