11#include <unordered_map>
39 std::vector<std::shared_ptr<bpp::bpp_program>>
programs;
53 std::unique_ptr<Snapshot>
snapshot = std::make_unique<Snapshot>();
60 std::shared_ptr<bpp::bpp_program>
_parse_program(
const std::string& file_path);
63 std::shared_ptr<std::vector<std::string>>
include_paths = std::make_shared<std::vector<std::string>>();
123 std::shared_ptr<bpp::bpp_program>
get_program(
const std::string& file_path,
bool jump_queue =
false);
138 std::vector<std::shared_ptr<bpp::bpp_program>>
get_programs_for_file(
const std::string& file_path,
bool jump_queue =
false);
154 std::vector<std::shared_ptr<bpp::bpp_program>>
re_parse_programs(
const std::string& file_path);
161 void open_file(
const std::string& file_path);
171 void close_file(
const std::string& file_path);
Manages a pool of bpp_program objects for efficient reuse and access.
Definition ProgramPool.h:36
bool utf16_mode
Definition ProgramPool.h:56
void set_target_bash_version(const BashVersion &version)
Definition ProgramPool.cpp:39
void remove_unsaved_file_contents(const std::string &file_path)
Definition ProgramPool.cpp:51
std::unordered_map< std::string, std::string > unsaved_changes
Definition ProgramPool.h:42
bool get_utf16_mode() const
Definition ProgramPool.cpp:35
void close_file(const std::string &file_path)
Mark a file as closed in the program pool.
Definition ProgramPool.cpp:346
std::recursive_mutex pool_mutex
Definition ProgramPool.h:44
std::shared_ptr< bpp::bpp_program > _parse_program(const std::string &file_path)
Definition ProgramPool.cpp:133
void set_unsaved_file_contents(const std::string &file_path, const std::string &contents)
Set the unsaved contents for a file to reflect in-editor changes.
Definition ProgramPool.cpp:43
bool suppress_warnings
Definition ProgramPool.h:64
void clean()
Definition ProgramPool.cpp:379
std::vector< std::shared_ptr< bpp::bpp_program > > programs
Definition ProgramPool.h:39
std::shared_ptr< bpp::bpp_program > get_program(const std::string &file_path, bool jump_queue=false)
Get or create a program for the given file path.
Definition ProgramPool.cpp:181
std::vector< std::shared_ptr< bpp::bpp_program > > re_parse_programs(const std::string &file_path)
Re-parse all programs associated with the given file path.
Definition ProgramPool.cpp:293
void open_file(const std::string &file_path)
Mark a file as open in the program pool.
Definition ProgramPool.cpp:332
std::shared_ptr< std::vector< std::string > > include_paths
Definition ProgramPool.h:63
std::string get_file_contents(const std::string &file_path)
Get the contents of a file, considering unsaved changes if present.
Definition ProgramPool.cpp:62
std::unordered_map< std::string, bool > open_files
Definition ProgramPool.h:41
BashVersion target_bash_version
Definition ProgramPool.h:43
Snapshot load_snapshot() const
Definition ProgramPool.cpp:101
void update_snapshot()
Definition ProgramPool.cpp:86
std::recursive_mutex snapshot_mutex
Definition ProgramPool.h:54
void set_utf16_mode(bool mode)
Definition ProgramPool.cpp:31
void _remove_program(size_t index)
Definition ProgramPool.cpp:107
std::vector< std::shared_ptr< bpp::bpp_program > > get_programs_for_file(const std::string &file_path, bool jump_queue=false)
Get all programs associated with the given file path. If no programs are associated with the given fi...
Definition ProgramPool.cpp:246
bool has_program(const std::string &file_path)
Check if a program for the given file path exists in the pool.
Definition ProgramPool.cpp:286
std::unique_ptr< Snapshot > snapshot
Definition ProgramPool.h:53
void add_include_path(const std::string &path)
Add an include path for use by all future programs to be added to the pool.
Definition ProgramPool.cpp:23
void _remove_oldest_program()
Definition ProgramPool.cpp:82
size_t max_programs
Definition ProgramPool.h:38
void set_suppress_warnings(bool suppress)
Definition ProgramPool.cpp:27
std::unordered_map< std::string, std::vector< size_t > > program_indices
Definition ProgramPool.h:40
Represents a Bash version to target for code generation.
Definition BashVersion.h:23
Definition ProgramPool.h:47
std::unordered_map< std::string, std::string > unsaved_changes_snapshot
Definition ProgramPool.h:51
std::unordered_map< std::string, std::vector< size_t > > program_indices_snapshot
Definition ProgramPool.h:49
std::vector< std::shared_ptr< bpp::bpp_program > > programs_snapshot
Definition ProgramPool.h:48
std::unordered_map< std::string, bool > open_files_snapshot
Definition ProgramPool.h:50