Bash++
Bash++ compiler internal documentation
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
bpp::BashppServer Class Reference

The main server class for handling LSP requests and notifications. More...

#include <BashppServer.h>

Collaboration diagram for bpp::BashppServer:
Collaboration graph
[legend]

Classes

struct  DebounceState
 
class  DebounceStateMap
 

Public Member Functions

 BashppServer ()
 
 ~BashppServer ()
 
void mainLoop ()
 
void setInputStream (std::shared_ptr< std::istream > stream)
 
void setOutputStream (std::shared_ptr< std::ostream > stream)
 
void setSocketPath (const std::string &path)
 
void setLogFile (const std::string &path)
 
void setTargetBashVersion (const BashVersion &version)
 
GenericResponseMessage shutdown (const GenericRequestMessage &request)
 
void cleanup ()
 
void processMessage (const std::string &message)
 
GenericResponseMessage handleInitialize (const GenericRequestMessage &request)
 
GenericResponseMessage handleDefinition (const GenericRequestMessage &request)
 
GenericResponseMessage handleHover (const GenericRequestMessage &request)
 
GenericResponseMessage handleDocumentSymbol (const GenericRequestMessage &request)
 
GenericResponseMessage handleRename (const GenericRequestMessage &request)
 
GenericResponseMessage handleReferences (const GenericRequestMessage &request)
 
GenericResponseMessage handleCompletion (const GenericRequestMessage &request)
 
CompletionList handleATCompletion (const CompletionParams &params)
 
CompletionList handleDOTCompletion (const CompletionParams &params)
 
void handleDidOpen (const GenericNotificationMessage &request)
 
void handleDidChange (const GenericNotificationMessage &request)
 
void handleDidChangeWatchedFiles (const GenericNotificationMessage &request)
 
void handleDidClose (const GenericNotificationMessage &request)
 
void sendResponse (const GenericResponseMessage &response)
 
void sendNotification (const GenericNotificationMessage &notification)
 
void publishDiagnostics (std::shared_ptr< bpp::bpp_program > program)
 
void add_include_path (const std::string &path)
 
void set_suppress_warnings (bool suppress)
 
template<typename... Args>
void log (Args &&... args)
 

Private Types

using RequestHandler = GenericResponseMessage(BashppServer::*)(const GenericRequestMessage &)
 
using NotificationHandler = void(BashppServer::*)(const GenericNotificationMessage &)
 

Private Member Functions

void _sendMessage (const std::string &message)
 
void processRequest (const GenericRequestMessage &request)
 
void processNotification (const GenericNotificationMessage &notification)
 

Static Private Member Functions

static const GenericResponseMessage invalidRequestHandler (const GenericRequestMessage &request)
 
static void invalidNotificationHandler (const GenericNotificationMessage &request)
 

Private Attributes

pid_t pid = getpid()
 
std::shared_ptr< std::istream > input_stream
 
std::shared_ptr< std::ostream > output_stream
 
std::optional< std::string > socket_path
 
ThreadPool thread_pool = ThreadPool(std::thread::hardware_concurrency())
 
ProgramPool program_pool = ProgramPool(10)
 
std::ofstream log_file
 
DebounceStateMap debounce_states = DebounceStateMap(&program_pool)
 
std::atomic< bool > processing_didChange {false}
 
CompletionList default_completion_list
 

Static Private Attributes

static std::mutex output_mutex
 
static std::mutex log_mutex
 
static constexpr frozen::unordered_map< frozen::string, RequestHandler, 8 > request_handlers
 Maps request types to the functions that handle them.
 
static constexpr frozen::unordered_map< frozen::string, NotificationHandler, 4 > notification_handlers
 Maps notification types to the functions that handle them.
 

Detailed Description

The main server class for handling LSP requests and notifications.

This class manages the server's lifecycle, handles incoming messages, processes requests and notifications, logs, and maintains the state of the server.

Member Typedef Documentation

◆ NotificationHandler

using bpp::BashppServer::NotificationHandler = void (BashppServer::*)(const GenericNotificationMessage&)
private

◆ RequestHandler

using bpp::BashppServer::RequestHandler = GenericResponseMessage (BashppServer::*)(const GenericRequestMessage&)
private

Constructor & Destructor Documentation

◆ BashppServer()

bpp::BashppServer::BashppServer ( )

◆ ~BashppServer()

bpp::BashppServer::~BashppServer ( )

Member Function Documentation

◆ _sendMessage()

void bpp::BashppServer::_sendMessage ( const std::string &  message)
private

◆ add_include_path()

void bpp::BashppServer::add_include_path ( const std::string &  path)

◆ cleanup()

void bpp::BashppServer::cleanup ( )

◆ handleATCompletion()

CompletionList bpp::BashppServer::handleATCompletion ( const CompletionParams &  params)

◆ handleCompletion()

GenericResponseMessage bpp::BashppServer::handleCompletion ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDefinition()

GenericResponseMessage bpp::BashppServer::handleDefinition ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDidChange()

void bpp::BashppServer::handleDidChange ( const GenericNotificationMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDidChangeWatchedFiles()

void bpp::BashppServer::handleDidChangeWatchedFiles ( const GenericNotificationMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDidClose()

void bpp::BashppServer::handleDidClose ( const GenericNotificationMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDidOpen()

void bpp::BashppServer::handleDidOpen ( const GenericNotificationMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDocumentSymbol()

GenericResponseMessage bpp::BashppServer::handleDocumentSymbol ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleDOTCompletion()

CompletionList bpp::BashppServer::handleDOTCompletion ( const CompletionParams &  params)

◆ handleHover()

GenericResponseMessage bpp::BashppServer::handleHover ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleInitialize()

GenericResponseMessage bpp::BashppServer::handleInitialize ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleReferences()

GenericResponseMessage bpp::BashppServer::handleReferences ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ handleRename()

GenericResponseMessage bpp::BashppServer::handleRename ( const GenericRequestMessage &  request)

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ invalidNotificationHandler()

void bpp::BashppServer::invalidNotificationHandler ( const GenericNotificationMessage &  request)
staticprivate

◆ invalidRequestHandler()

const GenericResponseMessage bpp::BashppServer::invalidRequestHandler ( const GenericRequestMessage &  request)
staticprivate

◆ log()

template<typename... Args>
void bpp::BashppServer::log ( Args &&...  args)
inline

◆ mainLoop()

void bpp::BashppServer::mainLoop ( )

◆ processMessage()

void bpp::BashppServer::processMessage ( const std::string &  message)

◆ processNotification()

void bpp::BashppServer::processNotification ( const GenericNotificationMessage &  notification)
private

◆ processRequest()

void bpp::BashppServer::processRequest ( const GenericRequestMessage &  request)
private

◆ publishDiagnostics()

void bpp::BashppServer::publishDiagnostics ( std::shared_ptr< bpp::bpp_program program)

◆ sendNotification()

void bpp::BashppServer::sendNotification ( const GenericNotificationMessage &  notification)

◆ sendResponse()

void bpp::BashppServer::sendResponse ( const GenericResponseMessage &  response)

◆ set_suppress_warnings()

void bpp::BashppServer::set_suppress_warnings ( bool  suppress)

◆ setInputStream()

void bpp::BashppServer::setInputStream ( std::shared_ptr< std::istream >  stream)

◆ setLogFile()

void bpp::BashppServer::setLogFile ( const std::string &  path)

◆ setOutputStream()

void bpp::BashppServer::setOutputStream ( std::shared_ptr< std::ostream >  stream)

◆ setSocketPath()

void bpp::BashppServer::setSocketPath ( const std::string &  path)

◆ setTargetBashVersion()

void bpp::BashppServer::setTargetBashVersion ( const BashVersion version)

◆ shutdown()

GenericResponseMessage bpp::BashppServer::shutdown ( const GenericRequestMessage &  request)

Member Data Documentation

◆ debounce_states

DebounceStateMap bpp::BashppServer::debounce_states = DebounceStateMap(&program_pool)
private

◆ default_completion_list

CompletionList bpp::BashppServer::default_completion_list
private

◆ input_stream

std::shared_ptr<std::istream> bpp::BashppServer::input_stream
private

◆ log_file

std::ofstream bpp::BashppServer::log_file
private

◆ log_mutex

std::mutex bpp::BashppServer::log_mutex
staticprivate

◆ notification_handlers

constexpr frozen::unordered_map<frozen::string, NotificationHandler, 4> bpp::BashppServer::notification_handlers
staticconstexprprivate
Initial value:
= {
{"textDocument/didOpen", &BashppServer::handleDidOpen},
{"textDocument/didChange", &BashppServer::handleDidChange},
{"workspace/didChangeWatchedFiles", &BashppServer::handleDidChangeWatchedFiles},
{"textDocument/didClose", &BashppServer::handleDidClose}
}
void handleDidClose(const GenericNotificationMessage &request)
Definition handledDidClose.cpp:9
void handleDidChange(const GenericNotificationMessage &request)
Definition handleDidChange.cpp:9
void handleDidOpen(const GenericNotificationMessage &request)
Definition handleDidOpen.cpp:9
void handleDidChangeWatchedFiles(const GenericNotificationMessage &request)
Definition handleDidChangeWatchedFiles.cpp:9

Maps notification types to the functions that handle them.

◆ output_mutex

std::mutex bpp::BashppServer::output_mutex
staticprivate

Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes

◆ output_stream

std::shared_ptr<std::ostream> bpp::BashppServer::output_stream
private

◆ pid

pid_t bpp::BashppServer::pid = getpid()
private

◆ processing_didChange

std::atomic<bool> bpp::BashppServer::processing_didChange {false}
private

◆ program_pool

ProgramPool bpp::BashppServer::program_pool = ProgramPool(10)
private

◆ request_handlers

constexpr frozen::unordered_map<frozen::string, RequestHandler, 8> bpp::BashppServer::request_handlers
staticconstexprprivate
Initial value:
= {
{"textDocument/definition", &BashppServer::handleDefinition},
{"textDocument/completion", &BashppServer::handleCompletion},
{"textDocument/hover", &BashppServer::handleHover},
{"textDocument/documentSymbol", &BashppServer::handleDocumentSymbol},
{"textDocument/rename", &BashppServer::handleRename},
{"textDocument/references", &BashppServer::handleReferences},
{"shutdown", &BashppServer::shutdown}
}
GenericResponseMessage handleHover(const GenericRequestMessage &request)
Definition handleHover.cpp:10
GenericResponseMessage handleRename(const GenericRequestMessage &request)
Definition handleRename.cpp:10
GenericResponseMessage handleDocumentSymbol(const GenericRequestMessage &request)
Definition handleDocumentSymbol.cpp:9
GenericResponseMessage shutdown(const GenericRequestMessage &request)
Definition BashppServer.cpp:305
GenericResponseMessage handleReferences(const GenericRequestMessage &request)
Definition handleReference.cpp:11
GenericResponseMessage handleInitialize(const GenericRequestMessage &request)
Definition handleInitialize.cpp:11
GenericResponseMessage handleDefinition(const GenericRequestMessage &request)
Definition handleDefinition.cpp:10
GenericResponseMessage handleCompletion(const GenericRequestMessage &request)
Definition handleCompletion.cpp:10

Maps request types to the functions that handle them.

◆ socket_path

std::optional<std::string> bpp::BashppServer::socket_path
private

◆ thread_pool

ThreadPool bpp::BashppServer::thread_pool = ThreadPool(std::thread::hardware_concurrency())
private

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