annotate gcc/edit-context.h @ 158:494b0b89df80 default tip

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