Debian Codegraph @

CodeLite/CompletionHelper.hpp

raw
1 #ifndef COMPLETIONHELPER_HPP
2 #define COMPLETIONHELPER_HPP
3
4 #include "CxxTokenizer.h"
5 #include "codelite_exports.h"
6 #include "entry.h"
7 #include "istorage.h"
8
9 #include <functional>
10 #include <vector>
11 #include <wx/filename.h>
12 #include <wx/string.h>
13
14 class WXDLLIMPEXP_CL CompletionHelper
15 {
16 public:
17 enum eSplitFlags {
18 STRIP_DEFAULT = 0,
19 STRIP_NO_DEFAULT_VALUES = (1 << 0), // do not include the default value
20 STRIP_NO_NAME = (1 << 1), // do not include the function argument name
21 };
22
23 enum eTruncateStyle {
24 TRUNCATE_EXACT_POS = (1 << 0),
25 TRUNCATE_COMPLETE_WORDS = (1 << 1),
26 TRUNCATE_COMPLETE_LINES = (1 << 2),
27 };
28
29 public:
30 CompletionHelper();
31 ~CompletionHelper();
32
33 /**
34 * @brief normalize function signature by removing from its signature all
35 * default values and removing the arguments name (both is configurable via `flags`)
36 */
37 wxString normalize_function(TagEntryPtr tag, size_t flags = CompletionHelper::STRIP_NO_DEFAULT_VALUES |
38 CompletionHelper::STRIP_NO_NAME);
39 /**
40 * @brief same as above
41 */
42 wxString normalize_function(const TagEntry* tag, size_t flags = CompletionHelper::STRIP_NO_DEFAULT_VALUES |
43 CompletionHelper::STRIP_NO_NAME);
44 wxString get_expression(const wxString& file_content, bool for_calltip, wxString* last_word = nullptr) const;
45 wxString truncate_file_to_location(const wxString& file_content, size_t line, size_t column, size_t flags) const;
46 std::vector<wxString> split_function_signature(const wxString& signature, wxString* return_value,
47 size_t flags = CompletionHelper::STRIP_DEFAULT) const;
48 static bool is_cxx_keyword(const wxString& word);
49
50 /**
51 * @brief return list of keywords
52 */
53 void get_cxx_keywords(std::vector<wxString>& keywords);
54
55 /**
56 * @brief format a tag comment
57 * @param tag the tag which owns the comment
58 * @param input_comment raw comment
59 * @return formatted comment
60 */
61 wxString format_comment(TagEntryPtr tag, const wxString& input_comment) const;
62 /**
63 * @brief same as the above, but accepts raw pointer
64 */
65 wxString format_comment(TagEntry* tag, const wxString& input_comment) const;
66
67 /**
68 * @brief go backward and check if the caret line is an include statement
69 * @param file_content the current file. The caret is assumed at the end of the string
70 * @param file_name [output]
71 * @param suffix [output] does the completion entry should end with '>' or with '"'?
72 */
73 bool is_include_statement(const wxString& file_content, wxString* file_name, wxString* suffix) const;
74 /**
75 * @brief Similar to the above, but for the current line check if the current line matches an include statement
76 */
77 bool is_line_include_statement(const wxString& line, wxString* file_name, wxString* suffix) const;
78 };
79
80 #endif // COMPLETIONHELPER_HPP