Properly print leading comments and indentation in functions

Store the entire function declaration, not just its job list.
This allows us to extract the body of the function complete with any
leading comments and indents.

Fixes #5285
This commit is contained in:
ridiculousfish
2020-01-03 14:40:28 -08:00
parent c3374edc59
commit 62302ee172
9 changed files with 71 additions and 25 deletions

View File

@@ -20,8 +20,10 @@ struct function_properties_t {
/// Parsed source containing the function.
parsed_source_ref_t parsed_source;
/// Node containing the function body, pointing into parsed_source.
tnode_t<grammar::job_list> body_node;
/// Node containing the function statement, pointing into parsed_source.
/// We store block_statement, not job_list, so that comments attached to the header are
/// preserved.
tnode_t<grammar::block_statement> func_node;
/// List of all named arguments for this function.
wcstring_list_t named_arguments;