Function Call¶
- class energyplus_refactor_helper.function_call.FunctionCall(call: int, func_name: str, line_start: int, file_start_index: int, line_start_index: int, first_line_text: str)¶
This class represents a single function call in the EnergyPlus source code. The parsing algorithms here rely on specific EnergyPlus source code style/structure assumptions, and are surely not applicable to generic codebases. In the future, a more formal C++ parser may be added.
To construct a function call, you provide the first line of code containing the function call, as well position details, then continue adding lines of text holding the function call, and then finalize the function call when the end is reached. The function call can then be parsed into arguments using methods here.
- Parameters:
call – This represents an integer call type, which is essentially the index of the function in the derived
energyplus_refactor_helper.action.RefactorBase.function_calls()method.func_name – This is the function name for this function call as defined in the
energyplus_refactor_helper.action.RefactorBase.function_calls()method.line_start – This is the 1-based line number where this function call starts in the file.
file_start_index – This is the character index in the raw file text where the function call starts.
line_start_index – This is the character index in the first line of the function call where the call starts
first_line_text – This is the raw first line text where the function call starts.
- add_to_multiline_text(line_content: str) None¶
After construction of a function call, add continuing lines to the function call by calling this method.
- Parameters:
line_content – Add continuation lines of a multi-line function call using this method.
- Returns:
None
- as_cleaned_multiline() list[str]¶
After a function call has been finalized, this function provides the function call formatted as a sanitized multiline list of strings.
- Returns:
A list of strings represented sanitized lines of the function call.
- finalize(end_character_index: int, appears_successful: bool) None¶
Once a function call reaches the end, call this method to “finalize” the structure. This function accepts a flag to indicate if the function call parsing appeared successful. This is useful when a function call extends too many lines, implying a parsing problem.
- Parameters:
end_character_index – The character index of the final line of the function call where the call ends
appears_successful – A true/false flag for whether the parse “appears” successful.
- Returns:
None
- parse_arguments() list[str]¶
After a function call has been finalized, this method can be used to parse the arguments of the call into a list of strings. This parsing takes advantage of some assumptions about the way EnergyPlus enforces code style and structure. (Such as no C++ style comments allowed, etc.)
- Returns:
A list of string arguments to the function call.
- rewrite() str¶
Rewrite the function call as a string, functionally equivalent to the original form, but modified with line breaks and such missing.