1*38fd1498Szrj /* Determining the results of applying fix-it hints. 2*38fd1498Szrj Copyright (C) 2016-2018 Free Software Foundation, Inc. 3*38fd1498Szrj 4*38fd1498Szrj This file is part of GCC. 5*38fd1498Szrj 6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under 7*38fd1498Szrj the terms of the GNU General Public License as published by the Free 8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later 9*38fd1498Szrj version. 10*38fd1498Szrj 11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or 13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*38fd1498Szrj for more details. 15*38fd1498Szrj 16*38fd1498Szrj You should have received a copy of the GNU General Public License 17*38fd1498Szrj along with GCC; see the file COPYING3. If not see 18*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 19*38fd1498Szrj 20*38fd1498Szrj #ifndef GCC_EDIT_CONTEXT_H 21*38fd1498Szrj #define GCC_EDIT_CONTEXT_H 22*38fd1498Szrj 23*38fd1498Szrj #include "typed-splay-tree.h" 24*38fd1498Szrj 25*38fd1498Szrj class edit_context; 26*38fd1498Szrj class edited_file; 27*38fd1498Szrj 28*38fd1498Szrj /* A set of changes to the source code. 29*38fd1498Szrj 30*38fd1498Szrj The changes are "atomic" - if any changes can't be applied, 31*38fd1498Szrj none of them can be (tracked by the m_valid flag). 32*38fd1498Szrj Similarly, attempts to add the changes from a rich_location flagged 33*38fd1498Szrj as containing invalid changes mean that the whole of the edit_context 34*38fd1498Szrj is flagged as invalid. 35*38fd1498Szrj 36*38fd1498Szrj A complication here is that fix-its are expressed relative to coordinates 37*38fd1498Szrj in the files when they were parsed, before any changes have been made, and 38*38fd1498Szrj so if there's more that one fix-it to be applied, we have to adjust 39*38fd1498Szrj later fix-its to allow for the changes made by earlier ones. This 40*38fd1498Szrj is done by the various "get_effective_column" methods. */ 41*38fd1498Szrj 42*38fd1498Szrj class edit_context 43*38fd1498Szrj { 44*38fd1498Szrj public: 45*38fd1498Szrj edit_context (); 46*38fd1498Szrj valid_p()47*38fd1498Szrj bool valid_p () const { return m_valid; } 48*38fd1498Szrj 49*38fd1498Szrj void add_fixits (rich_location *richloc); 50*38fd1498Szrj 51*38fd1498Szrj char *get_content (const char *filename); 52*38fd1498Szrj 53*38fd1498Szrj int get_effective_column (const char *filename, int line, int column); 54*38fd1498Szrj 55*38fd1498Szrj char *generate_diff (bool show_filenames); 56*38fd1498Szrj void print_diff (pretty_printer *pp, bool show_filenames); 57*38fd1498Szrj 58*38fd1498Szrj private: 59*38fd1498Szrj bool apply_fixit (const fixit_hint *hint); 60*38fd1498Szrj edited_file *get_file (const char *filename); 61*38fd1498Szrj edited_file &get_or_insert_file (const char *filename); 62*38fd1498Szrj 63*38fd1498Szrj bool m_valid; 64*38fd1498Szrj typed_splay_tree<const char *, edited_file *> m_files; 65*38fd1498Szrj }; 66*38fd1498Szrj 67*38fd1498Szrj #endif /* GCC_EDIT_CONTEXT_H. */ 68