]>
Commit | Line | Data |
---|---|---|
2abdff38 | 1 | /* Provide suggestions to handle misspelled options, and implement the |
2 | --complete option for auto-completing options from a prefix. | |
fbd26352 | 3 | Copyright (C) 2016-2019 Free Software Foundation, Inc. |
2abdff38 | 4 | |
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #ifndef GCC_OPT_PROPOSER_H | |
22 | #define GCC_OPT_PROPOSER_H | |
23 | ||
24 | /* Option proposer is class used by driver in order to provide hints | |
25 | for wrong options provided. And it's used by --complete option that's | |
26 | intended to be invoked by BASH in order to provide better option | |
27 | completion support. */ | |
28 | ||
29 | class option_proposer | |
30 | { | |
31 | public: | |
32 | /* Default constructor. */ | |
33 | option_proposer (): m_option_suggestions (NULL) | |
34 | {} | |
35 | ||
36 | /* Default destructor. */ | |
37 | ~option_proposer (); | |
38 | ||
39 | /* Helper function for driver::handle_unrecognized_options. | |
40 | ||
41 | Given an unrecognized option BAD_OPT (without the leading dash), | |
42 | locate the closest reasonable matching option (again, without the | |
43 | leading dash), or NULL. | |
44 | ||
45 | The returned string is owned by the option_proposer instance. */ | |
46 | const char *suggest_option (const char *bad_opt); | |
47 | ||
6e8a18d1 | 48 | /* Print on stdout a list of valid options that begin with OPTION_PREFIX, |
49 | one per line, suitable for use by Bash completion. | |
50 | ||
51 | Implementation of the "-completion=" option. */ | |
52 | void suggest_completion (const char *option_prefix); | |
53 | ||
54 | /* Populate RESULTS with valid completions of options that begin | |
55 | with OPTION_PREFIX. */ | |
56 | void get_completions (const char *option_prefix, auto_string_vec &results); | |
57 | ||
2abdff38 | 58 | private: |
59 | /* Helper function for option_proposer::suggest_option. Populate | |
60 | m_option_suggestions with candidate strings for misspelled options. | |
b2903606 | 61 | The strings will be freed by the option_proposer's dtor. |
62 | PREFIX is used for bash completion suggestions, otherwise | |
63 | it's set to NULL. */ | |
64 | void build_option_suggestions (const char *prefix); | |
2abdff38 | 65 | |
6e8a18d1 | 66 | /* Find parameter completions for --param format with SEPARATOR. |
67 | Again, save the completions into results. */ | |
68 | void find_param_completions (const char separator, const char *param_prefix, | |
69 | auto_string_vec &results); | |
70 | ||
2abdff38 | 71 | private: |
72 | /* Cache with all suggestions. */ | |
73 | auto_string_vec *m_option_suggestions; | |
74 | }; | |
75 | ||
76 | #endif /* GCC_OPT_PROPOSER_H */ |