Bash++
Bash++ compiler internal documentation
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]

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)
 
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
 
std::unordered_map< std::string, std::string > unsaved_changes
 
std::mutex unsaved_changes_mutex
 
std::atomic< bool > stored_changes_content_updating = false
 
std::unordered_map< std::string, std::shared_ptr< std::atomic< uint64_t > > > debounce_timestamps
 
std::mutex debounce_mutex
 
CompletionList default_completion_list
 

Static Private Attributes

static std::mutex output_mutex
 
static std::mutex log_mutex
 
static const frozen::unordered_map< frozen::string, RequestHandler, 8 > request_handlers
 Maps request types to the functions that handle them.
 
static const 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)

◆ shutdown()

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

Member Data Documentation

◆ debounce_mutex

std::mutex bpp::BashppServer::debounce_mutex
private

◆ debounce_timestamps

std::unordered_map<std::string, std::shared_ptr<std::atomic<uint64_t> > > bpp::BashppServer::debounce_timestamps
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

const frozen::unordered_map< frozen::string, bpp::BashppServer::NotificationHandler, 4 > bpp::BashppServer::notification_handlers
staticprivate
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

◆ program_pool

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

◆ request_handlers

const frozen::unordered_map< frozen::string, bpp::BashppServer::RequestHandler, 8 > bpp::BashppServer::request_handlers
staticprivate
Initial value:
= {
{frozen::string("initialize"), &BashppServer::handleInitialize},
{frozen::string("textDocument/definition"), &BashppServer::handleDefinition},
{frozen::string("textDocument/completion"), &BashppServer::handleCompletion},
{frozen::string("textDocument/hover"), &BashppServer::handleHover},
{frozen::string("textDocument/documentSymbol"), &BashppServer::handleDocumentSymbol},
{frozen::string("textDocument/rename"), &BashppServer::handleRename},
{frozen::string("textDocument/references"), &BashppServer::handleReferences},
{frozen::string("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:319
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

◆ stored_changes_content_updating

std::atomic<bool> bpp::BashppServer::stored_changes_content_updating = false
private

◆ thread_pool

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

◆ unsaved_changes

std::unordered_map<std::string, std::string> bpp::BashppServer::unsaved_changes
private

◆ unsaved_changes_mutex

std::mutex bpp::BashppServer::unsaved_changes_mutex
private

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