Bash++
Bash++ compiler internal documentation
Functions
resolve_entity.h File Reference
#include <fstream>
#include <memory>
#include <string>
#include <cstdint>
#include "../../antlr/BashppLexer.h"
#include "../../antlr/BashppParser.h"
#include "../../bpp_include/bpp_codegen.h"
#include "explode.h"
Include dependency graph for resolve_entity.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

antlr4::tree::ParseTree * find_node_at_column (antlr4::tree::ParseTree *single_line_node, uint32_t column)
 
std::shared_ptr< bpp::bpp_entityresolve_entity_at (const std::string &file, uint32_t line, uint32_t column, std::shared_ptr< bpp::bpp_program > program, bool utf16_mode, const std::string &file_contents="")
 Resolves the entity referenced at the given line and column in the specified file.
 
std::string find_comments_for_entity (std::shared_ptr< bpp::bpp_entity > entity)
 Finds comments ostensibly associated with the given entity's definition.
 

Function Documentation

◆ find_comments_for_entity()

std::string find_comments_for_entity ( std::shared_ptr< bpp::bpp_entity entity)

Finds comments ostensibly associated with the given entity's definition.

This function searches for contiguous comment blocks that are located immediately before the entity's definition position. It returns a string containing the comments, or an empty string if no comments are found.

Parameters
entityThe entity to find comments for.
Returns
A string containing the comments associated with the entity, or an empty string if no comments are found.

◆ find_node_at_column()

antlr4::tree::ParseTree * find_node_at_column ( antlr4::tree::ParseTree *  single_line_node,
uint32_t  column 
)

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

◆ resolve_entity_at()

std::shared_ptr< bpp::bpp_entity > resolve_entity_at ( const std::string &  file,
uint32_t  line,
uint32_t  column,
std::shared_ptr< bpp::bpp_program program,
bool  utf16_mode,
const std::string &  file_contents = "" 
)

Resolves the entity referenced at the given line and column in the specified file.

This function uses the ANTLR4 parser to parse the line content and find the entity which is referenced at the specified column. It returns a shared pointer to the resolved entity, or nullptr if no entity is found.

E.g, if the segment pointed to by the position contains @MyClass myObject, we will return a pointer to the MyClass class. If the segment contains @myObject.myMethod, we will return a pointer to the myMethod method of the myObject object. If the segment contains @myObject, we will return a pointer to the myObject object. If the segment contains @include <file>, we will return a newly-constructed faux-entity that points to the resolved path of the included file.

Parameters
fileThe file to resolve the entity in.
lineThe line number to resolve the entity at (0-indexed).
columnThe column number to resolve the entity at (0-indexed).
programThe program to resolve the entity in.
utf16_modeWhether to use UTF-16 mode for character counting.
file_contentsAlternative contents of the file to use instead of reading from the filesystem.
Returns
A shared pointer to the resolved entity, or nullptr if no entity is found.