sun::support::SourceManager
class · Source (opens in a new tab)
class sun::support::SourceManagerGlobal source text manager for error reporting.
Stores source text for all compiled files so that error messages can display source line previews even after parsing is complete.
Public Functions
addAnonymousSource
public · function · Source (opens in a new tab)
std::string sun::support::SourceManager::addAnonymousSource(const std::string &content)Register source text without a file path (e.g., executeString).
Uses a synthetic path like "<string:N>".
addSource
public · function · Source (opens in a new tab)
void sun::support::SourceManager::addSource(const std::string &filePath, const std::string &content)Register source text for a file path.
Call this when reading a file for compilation.
clear
public · function · Source (opens in a new tab)
void sun::support::SourceManager::clear()Clear all stored sources.
Useful for testing.
getLine
getLine(const std::string &filePath, int lineNum) const
public · function · Source (opens in a new tab)
std::string sun::support::SourceManager::getLine(const std::string &filePath, int lineNum) constGet a specific line from a file (1-indexed).
Returns empty string if file or line not found.
getLine(const Position &pos) const
public · function · Source (opens in a new tab)
std::string sun::support::SourceManager::getLine(const Position &pos) constGet line from a Position (uses filePath if available).
getLineWithContext
public · function · Source (opens in a new tab)
std::pair< std::string, std::string > sun::support::SourceManager::getLineWithContext(const Position &pos) constGet source line and previous line for error preview.
Returns {currentLine, previousLine}.
Related: Position
getSource
public · function · Source (opens in a new tab)
std::optional< std::string > sun::support::SourceManager::getSource(const std::string &filePath) constFull text of a registered file, or nothing when the path is unknown.
hasSource
public · function · Source (opens in a new tab)
bool sun::support::SourceManager::hasSource(const std::string &filePath) constCheck if source is available for a file path.
instance
public · function · static · Source (opens in a new tab)
static SourceManager & sun::support::SourceManager::instance()Get the global singleton instance.
Related: SourceManager
Private Functions
SourceManager
SourceManager(const SourceManager &)=delete
private · function · Source (opens in a new tab)
sun::support::SourceManager::SourceManager(const SourceManager &)=deleteDisallows copying so the owned state cannot be duplicated.
Related: SourceManager
SourceManager()=default
private · function · Source (opens in a new tab)
sun::support::SourceManager::SourceManager()=defaultCreates an instance with its default state.
computeLineOffsets
private · function · Source (opens in a new tab)
void sun::support::SourceManager::computeLineOffsets(const std::string &filePath)Compute line start offsets for fast line lookup.
operator=
private · function · Source (opens in a new tab)
SourceManager & sun::support::SourceManager::operator=(const SourceManager &)=deleteDisallows assignment so ownership and object identity cannot be duplicated.
Related: SourceManager
Private Fields
anonymousCounter_
private · variable · Source (opens in a new tab)
int sun::support::SourceManager::anonymousCounter_ = 0No documentation comment.
lineOffsets_
private · variable · Source (opens in a new tab)
std::map<std::string, std::vector<size_t> > sun::support::SourceManager::lineOffsets_No documentation comment.
mutex_
private · variable · Source (opens in a new tab)
std::mutex sun::support::SourceManager::mutex_No documentation comment.
sources_
private · variable · Source (opens in a new tab)
std::map<std::string, std::string> sun::support::SourceManager::sources_No documentation comment.