GCC Middle and Back End API Reference
|
Public Member Functions | |
edited_file (edit_context &ec, const char *filename) | |
const char * | get_filename () const |
char * | get_content () |
bool | apply_fixit (int line, int start_column, int next_column, const char *replacement_str, int replacement_len) |
int | get_effective_column (int line, int column) |
file_cache & | get_file_cache () const |
Static Public Member Functions | |
static void | delete_cb (edited_file *file) |
static int | call_print_diff (const char *, edited_file *file, void *user_data) |
Private Member Functions | |
bool | print_content (pretty_printer *pp) |
void | print_diff (pretty_printer *pp, bool show_filenames) |
int | print_diff_hunk (pretty_printer *pp, int old_start_of_hunk, int old_end_of_hunk, int new_start_of_hunk) |
edited_line * | get_line (int line) |
edited_line * | get_or_insert_line (int line) |
int | get_num_lines (bool *missing_trailing_newline) |
int | get_effective_line_count (int old_start_of_hunk, int old_end_of_hunk) |
void | print_run_of_changed_lines (pretty_printer *pp, int start_of_run, int end_of_run) |
Private Attributes | |
edit_context & | m_edit_context |
const char * | m_filename |
typed_splay_tree< int, edited_line * > | m_edited_lines |
int | m_num_lines |
The state of one named file within an edit_context: the filename, and the lines that have been edited so far.
edited_file::edited_file | ( | edit_context & | ec, |
const char * | filename ) |
edited_file's constructor.
bool edited_file::apply_fixit | ( | int | line, |
int | start_column, | ||
int | next_column, | ||
const char * | replacement_str, | ||
int | replacement_len ) |
Attempt to replace columns START_COLUMN up to but not including NEXT_COLUMN of LINE with the string REPLACEMENT_STR of length REPLACEMENT_LEN, updating the in-memory copy of the line, and the record of edits to the line.
References get_or_insert_line().
Referenced by edit_context::apply_fixit().
|
inlinestatic |
References diff::m_pp, diff::m_show_filenames, and print_diff().
Referenced by edit_context::print_diff().
|
static |
A callback for deleting edited_file *, for use as a delete_value_fn for edit_context::m_files.
char * edited_file::get_content | ( | ) |
Get the content of the file, with fix-its applied. The ptr should be freed by the caller.
References NULL, pp_formatted_text(), and print_content().
Referenced by edit_context::get_content().
int edited_file::get_effective_column | ( | int | line, |
int | column ) |
Given line LINE, map from COLUMN in the input file to its current column after edits have been applied.
References get_line().
Referenced by edit_context::get_effective_column().
|
private |
Determine the number of lines that will be present after editing for the range of lines from OLD_START_OF_HUNK to OLD_END_OF_HUNK inclusive.
References get_line().
Referenced by print_diff_hunk().
|
inline |
References edit_context::get_file_cache(), and m_edit_context.
Referenced by get_num_lines(), get_or_insert_line(), print_content(), print_diff_hunk(), and print_run_of_changed_lines().
|
inline |
References m_filename.
|
private |
Get the state of LINE within the file, or NULL if it is untouched.
References typed_splay_tree< KEY_TYPE, VALUE_TYPE >::lookup(), and m_edited_lines.
Referenced by get_effective_column(), get_effective_line_count(), get_or_insert_line(), print_content(), print_diff_hunk(), and print_run_of_changed_lines().
|
private |
Get the total number of lines in m_content, writing true to *MISSING_TRAILING_NEWLINE if the final line if missing a newline, false otherwise.
References gcc_assert, get_file_cache(), file_cache::get_source_line(), m_filename, m_num_lines, and file_cache::missing_trailing_newline_p().
Referenced by print_content(), and print_diff().
|
private |
Get the state of LINE within the file, creating a state for it if necessary. Return NULL if an error occurs.
References get_file_cache(), get_line(), typed_splay_tree< KEY_TYPE, VALUE_TYPE >::insert(), m_edited_lines, m_filename, and NULL.
Referenced by apply_fixit().
|
private |
Attempt to print the content of the file to PP, with edits applied. Return true if successful, false otherwise.
References get_file_cache(), get_line(), get_num_lines(), file_cache::get_source_line(), i, char_span::length(), m_filename, and pp_character().
Referenced by get_content().
|
private |
Print a unified diff to PP, showing any changes that have occurred to this file.
References colorize_start(), colorize_stop(), edited_line::get_line_num(), get_num_lines(), m_edited_lines, m_filename, typed_splay_tree< KEY_TYPE, VALUE_TYPE >::min(), pp_newline(), pp_show_color(), pp_string(), print_diff_hunk(), and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::successor().
Referenced by call_print_diff().
|
private |
Print one hunk within a unified diff to PP, covering the given range of lines. OLD_START_OF_HUNK and OLD_END_OF_HUNK are line numbers in the unedited version of the file. NEW_START_OF_HUNK is a line number in the edited version of the file. Return the change in the line count within the hunk.
References colorize_start(), colorize_stop(), char_span::get_buffer(), get_effective_line_count(), get_file_cache(), get_line(), file_cache::get_source_line(), char_span::length(), m_filename, pp_printf(), pp_show_color(), pp_string(), print_diff_line(), and print_run_of_changed_lines().
Referenced by print_diff().
|
private |
Subroutine of edited_file::print_diff_hunk: given a run of lines from START_OF_RUN to END_OF_RUN that all have edited_line instances, print the diff to PP.
References edited_line::actually_edited_p(), colorize_start(), colorize_stop(), gcc_assert, char_span::get_buffer(), get_file_cache(), get_line(), file_cache::get_source_line(), char_span::length(), m_filename, pp_show_color(), pp_string(), print_diff_line(), and edited_line::print_diff_lines().
Referenced by print_diff_hunk().
|
private |
Referenced by get_file_cache().
|
private |
Referenced by get_line(), get_or_insert_line(), and print_diff().
|
private |
Referenced by get_filename(), get_num_lines(), get_or_insert_line(), print_content(), print_diff(), print_diff_hunk(), and print_run_of_changed_lines().
|
private |
Referenced by get_num_lines().