| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2008 by Eran Ifrah |
| 5 |
// file name : tags_options_data.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
#ifndef TAGS_OPTIONS_DATA_H |
| 26 |
#define TAGS_OPTIONS_DATA_H |
| 27 |
|
| 28 |
#include "cl_config.h" |
| 29 |
#include "codelite_exports.h" |
| 30 |
#include "macros.h" |
| 31 |
#include "wxStringHash.h" |
| 32 |
|
| 33 |
#include <map> |
| 34 |
#include <unordered_map> |
| 35 |
#include <wx/filename.h> |
| 36 |
#include <wx/tokenzr.h> |
| 37 |
|
| 38 |
enum CodeCompletionOpts { |
| 39 |
CC_PARSE_COMMENTS = 0x00000001, |
| 40 |
CC_DISP_COMMENTS = 0x00000002, |
| 41 |
CC_DISP_TYPE_INFO = 0x00000004, |
| 42 |
CC_DISP_FUNC_CALLTIP = 0x00000008, |
| 43 |
CC_LOAD_EXT_DB = 0x00000010, |
| 44 |
CC_AUTO_INSERT_SINGLE_CHOICE = 0x00000020, |
| 45 |
CC_COLOUR_VARS = 0x00000080, |
| 46 |
CC_DISABLE_AUTO_PARSING = 0x00000800, |
| 47 |
CC_MARK_TAGS_FILES_IN_BOLD = 0x00001000, |
| 48 |
CC_RETAG_WORKSPACE_ON_STARTUP = 0x00004000, |
| 49 |
CC_ACCURATE_SCOPE_RESOLVING = 0x00008000, |
| 50 |
CC_DEEP_SCAN_USING_NAMESPACE_RESOLVING = 0x00010000, |
| 51 |
CC_IS_CASE_SENSITIVE = 0x00020000, |
| 52 |
CC_BACKSPACE_TRIGGER = 0x00040000, |
| 53 |
}; |
| 54 |
|
| 55 |
enum CodeCompletionColourOpts { |
| 56 |
CC_COLOUR_CLASS = 0x00000001, |
| 57 |
CC_COLOUR_STRUCT = 0x00000002, |
| 58 |
CC_COLOUR_FUNCTION = 0x00000004, |
| 59 |
CC_COLOUR_ENUM = 0x00000008, |
| 60 |
CC_COLOUR_UNION = 0x00000010, |
| 61 |
CC_COLOUR_PROTOTYPE = 0x00000020, |
| 62 |
CC_COLOUR_TYPEDEF = 0x00000040, |
| 63 |
CC_COLOUR_MACRO = 0x00000080, |
| 64 |
CC_COLOUR_NAMESPACE = 0x00000100, |
| 65 |
CC_COLOUR_ENUMERATOR = 0x00000200, |
| 66 |
CC_COLOUR_VARIABLE = 0x00000400, |
| 67 |
CC_COLOUR_MEMBER = 0x00000800, |
| 68 |
CC_COLOUR_MACRO_BLOCKS = 0x00001000, |
| 69 |
CC_COLOUR_ALL = CC_COLOUR_CLASS | CC_COLOUR_STRUCT | CC_COLOUR_FUNCTION | CC_COLOUR_ENUM | CC_COLOUR_UNION | |
| 70 |
CC_COLOUR_PROTOTYPE | CC_COLOUR_TYPEDEF | CC_COLOUR_MACRO | CC_COLOUR_NAMESPACE | |
| 71 |
CC_COLOUR_ENUMERATOR | CC_COLOUR_VARIABLE | CC_COLOUR_MEMBER, |
| 72 |
CC_COLOUR_DEFAULT = CC_COLOUR_CLASS | CC_COLOUR_STRUCT | CC_COLOUR_NAMESPACE | CC_COLOUR_ENUM | CC_COLOUR_TYPEDEF |
| 73 |
}; |
| 74 |
|
| 75 |
enum CodeCompletionClangOptions { |
| 76 |
CC_CLANG_ENABLED = (1 << 0), |
| 77 |
CC_CLANG_FIRST = (1 << 1), |
| 78 |
CC_CTAGS_ENABLED = (1 << 2), |
| 79 |
CC_CLANG_INLINE_ERRORS = (1 << 3), |
| 80 |
}; |
| 81 |
|
| 82 |
class WXDLLIMPEXP_CL TagsOptionsData : public clConfigItem |
| 83 |
{ |
| 84 |
protected: |
| 85 |
size_t m_ccFlags; |
| 86 |
size_t m_ccColourFlags; |
| 87 |
wxArrayString m_tokens; |
| 88 |
wxArrayString m_types; |
| 89 |
wxString m_fileSpec; |
| 90 |
wxArrayString m_languages; |
| 91 |
int m_minWordLen; |
| 92 |
wxArrayString m_parserSearchPaths; |
| 93 |
wxArrayString m_parserExcludePaths; |
| 94 |
bool m_parserEnabled; |
| 95 |
int m_maxItemToColour; |
| 96 |
wxStringTable_t m_tokensWxMap; |
| 97 |
wxStringTable_t m_tokensWxMapReversed; |
| 98 |
wxString m_macrosFiles; |
| 99 |
size_t m_clangOptions; |
| 100 |
wxString m_clangBinary; |
| 101 |
wxString m_clangCmpOptions; |
| 102 |
wxArrayString m_clangSearchPaths; |
| 103 |
wxString m_clangMacros; |
| 104 |
wxString m_clangCachePolicy; |
| 105 |
size_t m_ccNumberOfDisplayItems; |
| 106 |
size_t m_version; |
| 107 |
|
| 108 |
public: |
| 109 |
static size_t CURRENT_VERSION; |
| 110 |
|
| 111 |
protected: |
| 112 |
virtual void FromJSON(const JSONItem& json); |
| 113 |
virtual JSONItem ToJSON() const; |
| 114 |
|
| 115 |
void DoUpdateTokensWxMap(); |
| 116 |
void DoUpdateTokensWxMapReversed(); |
| 117 |
wxString DoJoinArray(const wxArrayString& arr) const; |
| 118 |
|
| 119 |
public: |
| 120 |
static wxString CLANG_CACHE_LAZY; |
| 121 |
static wxString CLANG_CACHE_ON_FILE_LOAD; |
| 122 |
|
| 123 |
public: |
| 124 |
TagsOptionsData(); |
| 125 |
virtual ~TagsOptionsData(); |
| 126 |
|
| 127 |
void AddDefaultTokens(); |
| 128 |
void AddDefaultTypes(); |
| 129 |
|
| 130 |
void Merge(const TagsOptionsData& tod); |
| 131 |
void SetVersion(size_t version) { this->m_version = version; } |
| 132 |
|
| 133 |
// setters/getters |
| 134 |
void SetCcNumberOfDisplayItems(size_t ccNumberOfDisplayItems) |
| 135 |
{ |
| 136 |
this->m_ccNumberOfDisplayItems = ccNumberOfDisplayItems; |
| 137 |
} |
| 138 |
size_t GetCcNumberOfDisplayItems() const { return m_ccNumberOfDisplayItems; } |
| 139 |
void SetClangCachePolicy(const wxString& clangCachePolicy) { this->m_clangCachePolicy = clangCachePolicy; } |
| 140 |
const wxString& GetClangCachePolicy() const { return m_clangCachePolicy; } |
| 141 |
void SetClangMacros(const wxString& clangMacros) { this->m_clangMacros = clangMacros; } |
| 142 |
void SetClangSearchPaths(const wxString& clangSearchPaths) |
| 143 |
{ |
| 144 |
this->m_clangSearchPaths = ::wxStringTokenize(clangSearchPaths, "\r\n", wxTOKEN_STRTOK); |
| 145 |
} |
| 146 |
const wxString& GetClangMacros() const { return m_clangMacros; } |
| 147 |
wxString GetClangSearchPaths() const { return DoJoinArray(m_clangSearchPaths); } |
| 148 |
|
| 149 |
const wxArrayString& GetClangSearchPathsArray() const { return m_clangSearchPaths; } |
| 150 |
|
| 151 |
void SetClangSearchPathsArray(const wxArrayString& paths) { m_clangSearchPaths = paths; } |
| 152 |
|
| 153 |
void SetClangCmpOptions(const wxString& clangCmpOptions) { this->m_clangCmpOptions = clangCmpOptions; } |
| 154 |
const wxString& GetClangCmpOptions() const { return m_clangCmpOptions; } |
| 155 |
void SetClangOptions(size_t clangOptions) { this->m_clangOptions = clangOptions; } |
| 156 |
size_t GetClangOptions() const { return m_clangOptions; } |
| 157 |
void SetClangBinary(const wxString& clangBinary) { this->m_clangBinary = clangBinary; } |
| 158 |
const wxString& GetClangBinary() const { return m_clangBinary; } |
| 159 |
void SetFlags(size_t flags) { m_ccFlags = flags; } |
| 160 |
|
| 161 |
void SetFileSpec(const wxString& filespec) { m_fileSpec = filespec; } |
| 162 |
|
| 163 |
void SetLanguages(const wxArrayString& langs) { m_languages = langs; } |
| 164 |
|
| 165 |
void SetLanguageSelection(const wxString& lang); |
| 166 |
|
| 167 |
const wxArrayString& GetLanguages() const { return m_languages; } |
| 168 |
|
| 169 |
void SetTokens(const wxString& tokens); |
| 170 |
void SetTypes(const wxString& types) { this->m_types = ::wxStringTokenize(types, "\r\n", wxTOKEN_STRTOK); } |
| 171 |
wxString GetTokens() const { return DoJoinArray(m_tokens); } |
| 172 |
std::vector<std::pair<wxString, wxString>> GetTypes() const; |
| 173 |
|
| 174 |
std::map<std::string, std::string> GetTokensMap() const; |
| 175 |
|
| 176 |
const wxStringTable_t& GetTokensReversedWxMap() const; |
| 177 |
const wxStringTable_t& GetTokensWxMap() const; |
| 178 |
|
| 179 |
wxStringTable_t GetTypesMap() const; |
| 180 |
|
| 181 |
const size_t& GetFlags() const { return m_ccFlags; } |
| 182 |
const wxString& GetFileSpec() const { return m_fileSpec; } |
| 183 |
|
| 184 |
// Setters |
| 185 |
void SetMinWordLen(const int& minWordLen) { this->m_minWordLen = minWordLen; } |
| 186 |
// Getters |
| 187 |
const int& GetMinWordLen() const { return m_minWordLen; } |
| 188 |
|
| 189 |
// Serialization API |
| 190 |
|
| 191 |
wxString ToString() const; |
| 192 |
|
| 193 |
/** |
| 194 |
* @brief Sync the data stored in this object with the file system |
| 195 |
*/ |
| 196 |
void SyncData(); |
| 197 |
|
| 198 |
void SetCcColourFlags(const size_t& ccColourFlags) { this->m_ccColourFlags = ccColourFlags; } |
| 199 |
|
| 200 |
const size_t& GetCcColourFlags() const { return m_ccColourFlags; } |
| 201 |
void SetParserEnabled(const bool& parserEnabled) { this->m_parserEnabled = parserEnabled; } |
| 202 |
void SetParserSearchPaths(const wxArrayString& parserSearchPaths) { this->m_parserSearchPaths = parserSearchPaths; } |
| 203 |
const bool& GetParserEnabled() const { return m_parserEnabled; } |
| 204 |
const wxArrayString& GetParserSearchPaths() const { return m_parserSearchPaths; } |
| 205 |
void SetParserExcludePaths(const wxArrayString& parserExcludePaths) |
| 206 |
{ |
| 207 |
this->m_parserExcludePaths = parserExcludePaths; |
| 208 |
} |
| 209 |
const wxArrayString& GetParserExcludePaths() const { return m_parserExcludePaths; } |
| 210 |
void SetMaxItemToColour(int maxItemToColour) { this->m_maxItemToColour = maxItemToColour; } |
| 211 |
int GetMaxItemToColour() const { return m_maxItemToColour; } |
| 212 |
void SetMacrosFiles(const wxString& macrosFiles) { this->m_macrosFiles = macrosFiles; } |
| 213 |
const wxString& GetMacrosFiles() const { return m_macrosFiles; } |
| 214 |
}; |
| 215 |
|
| 216 |
#endif // TAGS_OPTIONS_DATA_H |