| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2008 by Eran Ifrah |
| 5 |
// file name : tags_options_data.cpp |
| 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 |
#include "tags_options_data.h" |
| 26 |
|
| 27 |
#include "cl_config.h" |
| 28 |
#include "ctags_manager.h" |
| 29 |
#include "istorage.h" |
| 30 |
#include "precompiled_header.h" |
| 31 |
|
| 32 |
#include <set> |
| 33 |
#include <wx/ffile.h> |
| 34 |
#include <wx/tokenzr.h> |
| 35 |
|
| 36 |
wxString TagsOptionsData::CLANG_CACHE_LAZY = "Lazy"; |
| 37 |
wxString TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD = "On File Load"; |
| 38 |
|
| 39 |
size_t TagsOptionsData::CURRENT_VERSION = 7100; |
| 40 |
|
| 41 |
static bool _IsValidCppIndetifier(const wxString& id) |
| 42 |
{ |
| 43 |
if(id.IsEmpty()) { |
| 44 |
return false; |
| 45 |
} |
| 46 |
// first char can be only _A-Za-z |
| 47 |
wxString first(id.Mid(0, 1)); |
| 48 |
if(first.find_first_not_of("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") != wxString::npos) { |
| 49 |
return false; |
| 50 |
} |
| 51 |
// make sure that rest of the id contains only a-zA-Z0-9_ |
| 52 |
if(id.find_first_not_of("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") != wxString::npos) { |
| 53 |
return false; |
| 54 |
} |
| 55 |
return true; |
| 56 |
} |
| 57 |
|
| 58 |
static bool _IsCppKeyword(const wxString& word) |
| 59 |
{ |
| 60 |
static wxStringSet_t words; |
| 61 |
if(words.empty()) { |
| 62 |
TagsManager::GetCXXKeywords(words); |
| 63 |
} |
| 64 |
return words.count(word); |
| 65 |
} |
| 66 |
|
| 67 |
//--------------------------------------------------------- |
| 68 |
|
| 69 |
TagsOptionsData::TagsOptionsData() |
| 70 |
: clConfigItem("code-completion") |
| 71 |
, m_ccFlags(CC_DISP_TYPE_INFO | CC_DISP_FUNC_CALLTIP) |
| 72 |
, m_ccColourFlags(CC_COLOUR_DEFAULT) |
| 73 |
, m_fileSpec("*.cpp;*.cc;*.cxx;*.h;*.hpp;*.c;*.c++;*.tcc;*.hxx;*.h++") |
| 74 |
, m_minWordLen(3) |
| 75 |
, m_parserEnabled(true) |
| 76 |
, m_maxItemToColour(1000) |
| 77 |
#ifdef __WXMSW__ |
| 78 |
, m_macrosFiles("_mingw.h bits/c++config.h") |
| 79 |
#elif defined(__WXMAC__) |
| 80 |
, m_macrosFiles("sys/cdefs.h bits/c++config.h AvailabilityMacros.h") |
| 81 |
#else |
| 82 |
, m_macrosFiles("sys/cdefs.h bits/c++config.h") |
| 83 |
#endif |
| 84 |
, m_clangOptions(0) |
| 85 |
, m_clangBinary("") |
| 86 |
, m_clangCachePolicy(TagsOptionsData::CLANG_CACHE_ON_FILE_LOAD) |
| 87 |
, m_ccNumberOfDisplayItems(150) |
| 88 |
, m_version(0) |
| 89 |
{ |
| 90 |
// Initialize defaults |
| 91 |
m_languages.Add("C++"); |
| 92 |
AddDefaultTokens(); |
| 93 |
AddDefaultTypes(); |
| 94 |
|
| 95 |
SyncData(); |
| 96 |
} |
| 97 |
|
| 98 |
TagsOptionsData::~TagsOptionsData() {} |
| 99 |
|
| 100 |
void TagsOptionsData::AddDefaultTokens() |
| 101 |
{ |
| 102 |
m_tokens.Add("ATTRIBUTE_PRINTF_1"); |
| 103 |
m_tokens.Add("ATTRIBUTE_PRINTF_2"); |
| 104 |
m_tokens.Add("BEGIN_DECLARE_EVENT_TYPES()=enum {"); |
| 105 |
m_tokens.Add("BOOST_FOREACH(%0, %1)=%0;"); |
| 106 |
m_tokens.Add("DECLARE_EVENT_TYPE"); |
| 107 |
m_tokens.Add("DECLARE_EVENT_TYPE(%0,%1)=int %0;"); |
| 108 |
m_tokens.Add("DECLARE_EXPORTED_EVENT_TYPE"); |
| 109 |
m_tokens.Add("DECLARE_INSTANCE_TYPE"); |
| 110 |
m_tokens.Add("DLLIMPORT"); |
| 111 |
m_tokens.Add("END_DECLARE_EVENT_TYPES()=};"); |
| 112 |
m_tokens.Add("EXPORT"); |
| 113 |
m_tokens.Add("LLDB_API"); |
| 114 |
m_tokens.Add("PYTHON_API"); |
| 115 |
m_tokens.Add("QT_BEGIN_HEADER"); |
| 116 |
m_tokens.Add("QT_BEGIN_NAMESPACE"); |
| 117 |
m_tokens.Add("QT_END_HEADER"); |
| 118 |
m_tokens.Add("QT_END_NAMESPACE"); |
| 119 |
m_tokens.Add("Q_GADGET"); |
| 120 |
m_tokens.Add("Q_INLINE_TEMPLATE"); |
| 121 |
m_tokens.Add("Q_OBJECT"); |
| 122 |
m_tokens.Add("Q_OUTOFLINE_TEMPLATE"); |
| 123 |
m_tokens.Add("Q_PACKED"); |
| 124 |
m_tokens.Add("Q_REQUIRED_RESULT"); |
| 125 |
m_tokens.Add("SCI_SCOPE(%0)=%0"); |
| 126 |
m_tokens.Add("UNALIGNED"); |
| 127 |
m_tokens.Add("WINAPI"); |
| 128 |
m_tokens.Add("WINBASEAPI"); |
| 129 |
m_tokens.Add("WXDLLEXPORT"); |
| 130 |
m_tokens.Add("WXDLLIMPEXP_ADV"); |
| 131 |
m_tokens.Add("WXDLLIMPEXP_AUI"); |
| 132 |
m_tokens.Add("WXDLLIMPEXP_BASE"); |
| 133 |
m_tokens.Add("WXDLLIMPEXP_CL"); |
| 134 |
m_tokens.Add("WXDLLIMPEXP_CORE"); |
| 135 |
m_tokens.Add("WXDLLIMPEXP_FWD_ADV"); |
| 136 |
m_tokens.Add("WXDLLIMPEXP_FWD_AUI"); |
| 137 |
m_tokens.Add("WXDLLIMPEXP_FWD_BASE"); |
| 138 |
m_tokens.Add("WXDLLIMPEXP_FWD_CORE"); |
| 139 |
m_tokens.Add("WXDLLIMPEXP_FWD_PROPGRID"); |
| 140 |
m_tokens.Add("WXDLLIMPEXP_FWD_XML"); |
| 141 |
m_tokens.Add("WXDLLIMPEXP_LE_SDK"); |
| 142 |
m_tokens.Add("WXDLLIMPEXP_SCI"); |
| 143 |
m_tokens.Add("WXDLLIMPEXP_SQLITE3"); |
| 144 |
m_tokens.Add("WXDLLIMPEXP_XML"); |
| 145 |
m_tokens.Add("WXDLLIMPEXP_XRC"); |
| 146 |
m_tokens.Add("WXDLLIMPORT"); |
| 147 |
m_tokens.Add("WXMAKINGDLL"); |
| 148 |
m_tokens.Add("WXUNUSED(%0)=%0"); |
| 149 |
m_tokens.Add("WXUSINGDLL"); |
| 150 |
m_tokens.Add("_ALIGNAS(%0)=alignas(%0)"); |
| 151 |
m_tokens.Add("_ALIGNAS_TYPE(%0)=alignas(%0)"); |
| 152 |
m_tokens.Add("_ANONYMOUS_STRUCT"); |
| 153 |
m_tokens.Add("_ANONYMOUS_UNION"); |
| 154 |
m_tokens.Add("_ATTRIBUTE(%0)"); |
| 155 |
m_tokens.Add("_CRTIMP"); |
| 156 |
m_tokens.Add("_CRTIMP2"); |
| 157 |
m_tokens.Add("_CRTIMP2_PURE"); |
| 158 |
m_tokens.Add("_CRTIMP_ALTERNATIVE"); |
| 159 |
m_tokens.Add("_CRTIMP_NOIA64"); |
| 160 |
m_tokens.Add("_CRTIMP_PURE"); |
| 161 |
m_tokens.Add("_CRT_ALIGN(%0)"); |
| 162 |
m_tokens.Add("_CRT_DEPRECATE_TEXT(%0)"); |
| 163 |
m_tokens.Add("_CRT_INSECURE_DEPRECATE_GLOBALS(%0)"); |
| 164 |
m_tokens.Add("_CRT_INSECURE_DEPRECATE_MEMORY(%0)"); |
| 165 |
m_tokens.Add("_CRT_OBSOLETE(%0)"); |
| 166 |
m_tokens.Add("_CRT_STRINGIZE(%0)=\"%0\""); |
| 167 |
m_tokens.Add("_CRT_UNUSED(%0)=%0"); |
| 168 |
m_tokens.Add("_CRT_WIDE(%0)=L\"%0\""); |
| 169 |
m_tokens.Add("_GLIBCXX14_CONSTEXPR"); |
| 170 |
m_tokens.Add("_GLIBCXX17_CONSTEXPR"); |
| 171 |
m_tokens.Add("_GLIBCXX17_DEPRECATED"); |
| 172 |
m_tokens.Add("_GLIBCXX17_INLINE"); |
| 173 |
m_tokens.Add("_GLIBCXX20_CONSTEXPR"); |
| 174 |
m_tokens.Add("_GLIBCXX20_DEPRECATED(%0)"); |
| 175 |
m_tokens.Add("_GLIBCXX_BEGIN_EXTERN_C=extern \"C\" {"); |
| 176 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE(%0)=namespace %0{"); |
| 177 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_ALGO"); |
| 178 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_CONTAINER"); |
| 179 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_CXX11"); |
| 180 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_LDBL"); |
| 181 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11"); |
| 182 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_TR1=namespace tr1{"); |
| 183 |
m_tokens.Add("_GLIBCXX_BEGIN_NAMESPACE_VERSION"); |
| 184 |
m_tokens.Add("_GLIBCXX_BEGIN_NESTED_NAMESPACE(%0, %1)=namespace %0{"); |
| 185 |
m_tokens.Add("_GLIBCXX_CONST"); |
| 186 |
m_tokens.Add("_GLIBCXX_CONSTEXPR"); |
| 187 |
m_tokens.Add("_GLIBCXX_DEPRECATED"); |
| 188 |
m_tokens.Add("_GLIBCXX_DEPRECATED_SUGGEST(%0)"); |
| 189 |
m_tokens.Add("_GLIBCXX_END_EXTERN_C=}"); |
| 190 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE=}"); |
| 191 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_ALGO"); |
| 192 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_CONTAINER"); |
| 193 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_CXX11"); |
| 194 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_LDBL"); |
| 195 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11"); |
| 196 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_TR1=}"); |
| 197 |
m_tokens.Add("_GLIBCXX_END_NAMESPACE_VERSION"); |
| 198 |
m_tokens.Add("_GLIBCXX_END_NESTED_NAMESPACE=}"); |
| 199 |
m_tokens.Add("_GLIBCXX_NAMESPACE_CXX11"); |
| 200 |
m_tokens.Add("_GLIBCXX_NAMESPACE_LDBL"); |
| 201 |
m_tokens.Add("_GLIBCXX_NAMESPACE_LDBL_OR_CXX11"); |
| 202 |
m_tokens.Add("_GLIBCXX_NODISCARD"); |
| 203 |
m_tokens.Add("_GLIBCXX_NOEXCEPT"); |
| 204 |
m_tokens.Add("_GLIBCXX_NOEXCEPT_IF(%0)"); |
| 205 |
m_tokens.Add("_GLIBCXX_NOEXCEPT_PARM"); |
| 206 |
m_tokens.Add("_GLIBCXX_NOEXCEPT_QUAL"); |
| 207 |
m_tokens.Add("_GLIBCXX_NORETURN"); |
| 208 |
m_tokens.Add("_GLIBCXX_NOTHROW"); |
| 209 |
m_tokens.Add("_GLIBCXX_PSEUDO_VISIBILITY(%0)"); |
| 210 |
m_tokens.Add("_GLIBCXX_PURE"); |
| 211 |
m_tokens.Add("_GLIBCXX_STD=std"); |
| 212 |
m_tokens.Add("_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(%0)"); |
| 213 |
m_tokens.Add("_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(%0)"); |
| 214 |
m_tokens.Add("_GLIBCXX_THROW(%0)"); |
| 215 |
m_tokens.Add("_GLIBCXX_THROW_OR_ABORT(%0)"); |
| 216 |
m_tokens.Add("_GLIBCXX_TXN_SAFE"); |
| 217 |
m_tokens.Add("_GLIBCXX_TXN_SAFE_DYN"); |
| 218 |
m_tokens.Add("_GLIBCXX_USE_CONSTEXPR"); |
| 219 |
m_tokens.Add("_GLIBCXX_USE_NOEXCEPT"); |
| 220 |
m_tokens.Add("_GLIBCXX_VISIBILITY(%0)"); |
| 221 |
m_tokens.Add("_LIBCPP_ALWAYS_INLINE"); |
| 222 |
m_tokens.Add("_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM=namespace std { namespace filesystem {"); |
| 223 |
m_tokens.Add("_LIBCPP_BEGIN_NAMESPACE_STD=namespace std{"); |
| 224 |
m_tokens.Add("_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS"); |
| 225 |
m_tokens.Add("_LIBCPP_CONCAT(%0,%1)=%0%1"); |
| 226 |
m_tokens.Add("_LIBCPP_CONCAT1(%0,%1)=%0%1"); |
| 227 |
m_tokens.Add("_LIBCPP_CONSTEVAL"); |
| 228 |
m_tokens.Add("_LIBCPP_CONSTEXPR"); |
| 229 |
m_tokens.Add("_LIBCPP_CONSTEXPR_AFTER_CXX11"); |
| 230 |
m_tokens.Add("_LIBCPP_CONSTEXPR_AFTER_CXX14"); |
| 231 |
m_tokens.Add("_LIBCPP_CONSTEXPR_AFTER_CXX17"); |
| 232 |
m_tokens.Add("_LIBCPP_CONSTEXPR_IF_NODEBUG"); |
| 233 |
m_tokens.Add("_LIBCPP_CRT_FUNC"); |
| 234 |
m_tokens.Add("_LIBCPP_DECLARE_STRONG_ENUM(%0)=enum class %0"); |
| 235 |
m_tokens.Add("_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(%0)"); |
| 236 |
m_tokens.Add("_LIBCPP_DECLSPEC_EMPTY_BASES"); |
| 237 |
m_tokens.Add("_LIBCPP_DEFAULT"); |
| 238 |
m_tokens.Add("_LIBCPP_DEPRECATED"); |
| 239 |
m_tokens.Add("_LIBCPP_DEPRECATED_IN_CXX11"); |
| 240 |
m_tokens.Add("_LIBCPP_DEPRECATED_IN_CXX14"); |
| 241 |
m_tokens.Add("_LIBCPP_DEPRECATED_IN_CXX17"); |
| 242 |
m_tokens.Add("_LIBCPP_DEPRECATED_IN_CXX20"); |
| 243 |
m_tokens.Add("_LIBCPP_DEPRECATED_WITH_CHAR8_T"); |
| 244 |
m_tokens.Add("_LIBCPP_DIAGNOSE_ERROR(%0)"); |
| 245 |
m_tokens.Add("_LIBCPP_DIAGNOSE_WARNING(%0)"); |
| 246 |
m_tokens.Add("_LIBCPP_DISABLE_EXTENSION_WARNING"); |
| 247 |
m_tokens.Add("_LIBCPP_DLL_VIS"); |
| 248 |
m_tokens.Add("_LIBCPP_END_NAMESPACE_FILESYSTEM=} }"); |
| 249 |
m_tokens.Add("_LIBCPP_END_NAMESPACE_STD=}"); |
| 250 |
m_tokens.Add("_LIBCPP_EQUAL_DELETE"); |
| 251 |
m_tokens.Add("_LIBCPP_EXCEPTION_ABI"); |
| 252 |
m_tokens.Add("_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION"); |
| 253 |
m_tokens.Add("_LIBCPP_EXPLICIT"); |
| 254 |
m_tokens.Add("_LIBCPP_EXPLICIT_AFTER_CXX11"); |
| 255 |
m_tokens.Add("_LIBCPP_EXPORTED_FROM_ABI"); |
| 256 |
m_tokens.Add("_LIBCPP_EXTERN_TEMPLATE(%0)"); |
| 257 |
m_tokens.Add("_LIBCPP_EXTERN_TEMPLATE_DEFINE(%0)"); |
| 258 |
m_tokens.Add("_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(%0)"); |
| 259 |
m_tokens.Add("_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS"); |
| 260 |
m_tokens.Add("_LIBCPP_FALLTHROUGH(%0)"); |
| 261 |
m_tokens.Add("_LIBCPP_FORMAT_PRINTF(%0,%1)"); |
| 262 |
m_tokens.Add("_LIBCPP_FUNC_VIS"); |
| 263 |
m_tokens.Add("_LIBCPP_INIT_PRIORITY_MAX"); |
| 264 |
m_tokens.Add("_LIBCPP_INLINE_VAR"); |
| 265 |
m_tokens.Add("_LIBCPP_INLINE_VISIBILITY"); |
| 266 |
m_tokens.Add("_LIBCPP_INTERNAL_LINKAGE"); |
| 267 |
m_tokens.Add("_LIBCPP_NOALIAS"); |
| 268 |
m_tokens.Add("_LIBCPP_NODEBUG"); |
| 269 |
m_tokens.Add("_LIBCPP_NODEBUG_TYPE"); |
| 270 |
m_tokens.Add("_LIBCPP_NODISCARD_AFTER_CXX17"); |
| 271 |
m_tokens.Add("_LIBCPP_NODISCARD_ATTRIBUTE"); |
| 272 |
m_tokens.Add("_LIBCPP_NODISCARD_EXT"); |
| 273 |
m_tokens.Add("_LIBCPP_NORETURN"); |
| 274 |
m_tokens.Add("_LIBCPP_NO_DESTROY"); |
| 275 |
m_tokens.Add("_LIBCPP_OVERRIDABLE_FUNC_VIS"); |
| 276 |
m_tokens.Add("_LIBCPP_PREFERRED_NAME(%0)"); |
| 277 |
m_tokens.Add("_LIBCPP_SAFE_STATIC"); |
| 278 |
m_tokens.Add("_LIBCPP_THREAD_SAFETY_ANNOTATION(%0)"); |
| 279 |
m_tokens.Add("_LIBCPP_TOSTRING(%0)=\"%0\""); |
| 280 |
m_tokens.Add("_LIBCPP_TOSTRING2(%0)=\"%0\""); |
| 281 |
m_tokens.Add("_LIBCPP_TYPE_VIS"); |
| 282 |
m_tokens.Add("_LIBCPP_TYPE_VIS_ONLY"); |
| 283 |
m_tokens.Add("_LIBCPP_UNUSED_VAR(%0)=%0"); |
| 284 |
m_tokens.Add("_LIBCPP_WEAK"); |
| 285 |
m_tokens.Add("_MCRTIMP"); |
| 286 |
m_tokens.Add("_MRTIMP2"); |
| 287 |
m_tokens.Add("_NOEXCEPT"); |
| 288 |
m_tokens.Add("noexcept"); |
| 289 |
m_tokens.Add("_NOEXCEPT_(%0)"); |
| 290 |
m_tokens.Add("_Noreturn"); |
| 291 |
m_tokens.Add("_PSTL_ASSERT(%0)"); |
| 292 |
m_tokens.Add("_PSTL_ASSERT_MSG(%0,%1)"); |
| 293 |
m_tokens.Add("_STD_BEGIN=namespace std{"); |
| 294 |
m_tokens.Add("_STD_END=}"); |
| 295 |
m_tokens.Add("_STRUCT_NAME(%0)"); |
| 296 |
m_tokens.Add("_Static_assert(%0,%1)"); |
| 297 |
m_tokens.Add("_T"); |
| 298 |
m_tokens.Add("_UNION_NAME(%0)"); |
| 299 |
m_tokens.Add("_VSTD=std"); |
| 300 |
m_tokens.Add("_VSTD_FS=std::filesystem"); |
| 301 |
m_tokens.Add("__BEGIN_DECLS=extern \"C\" {"); |
| 302 |
m_tokens.Add("__CLRCALL_OR_CDECL"); |
| 303 |
m_tokens.Add("__CONCAT(%0,%1)=%0%1"); |
| 304 |
m_tokens.Add("__CRTDECL"); |
| 305 |
m_tokens.Add("__CRT_INLINE"); |
| 306 |
m_tokens.Add("__CRT_STRINGIZE(%0)=\"%0\""); |
| 307 |
m_tokens.Add("__CRT_UUID_DECL(%0,%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11)"); |
| 308 |
m_tokens.Add("__CRT_WIDE(%0)=L\"%0\""); |
| 309 |
m_tokens.Add("__END_DECLS=}"); |
| 310 |
m_tokens.Add("__GOMP_NOTHROW"); |
| 311 |
m_tokens.Add("__LEAF"); |
| 312 |
m_tokens.Add("__LEAF_ATTR"); |
| 313 |
m_tokens.Add("__MINGW_ATTRIB_CONST"); |
| 314 |
m_tokens.Add("__MINGW_ATTRIB_DEPRECATED"); |
| 315 |
m_tokens.Add("__MINGW_ATTRIB_DEPRECATED_MSG(%0)"); |
| 316 |
m_tokens.Add("__MINGW_ATTRIB_MALLOC"); |
| 317 |
m_tokens.Add("__MINGW_ATTRIB_NONNULL(%0)"); |
| 318 |
m_tokens.Add("__MINGW_ATTRIB_NORETURN"); |
| 319 |
m_tokens.Add("__MINGW_ATTRIB_NO_OPTIMIZE"); |
| 320 |
m_tokens.Add("__MINGW_ATTRIB_PURE"); |
| 321 |
m_tokens.Add("__MINGW_ATTRIB_UNUSED"); |
| 322 |
m_tokens.Add("__MINGW_ATTRIB_USED"); |
| 323 |
m_tokens.Add("__MINGW_BROKEN_INTERFACE(%0)"); |
| 324 |
m_tokens.Add("__MINGW_IMPORT"); |
| 325 |
m_tokens.Add("__MINGW_INTRIN_INLINE=extern"); |
| 326 |
m_tokens.Add("__MINGW_NOTHROW"); |
| 327 |
m_tokens.Add("__MINGW_PRAGMA_PARAM(%0)"); |
| 328 |
m_tokens.Add("__N(%0)=%0"); |
| 329 |
m_tokens.Add("__NTH(%0)=%0"); |
| 330 |
m_tokens.Add("__NTHNL(%0)=%0"); |
| 331 |
m_tokens.Add("__P(%0)=%0"); |
| 332 |
m_tokens.Add("__PMT(%0)=%0"); |
| 333 |
m_tokens.Add("__PSTL_ASSERT(%0)"); |
| 334 |
m_tokens.Add("__PSTL_ASSERT_MSG(%0,%1)"); |
| 335 |
m_tokens.Add("__STRING(%0)=\"%0\""); |
| 336 |
m_tokens.Add("__THROW"); |
| 337 |
m_tokens.Add("__THROWNL"); |
| 338 |
m_tokens.Add("__UNUSED_PARAM(%0)=%0"); |
| 339 |
m_tokens.Add("__always_inline"); |
| 340 |
m_tokens.Add("__attribute__(%0)"); |
| 341 |
m_tokens.Add("__attribute_alloc_size__(%0)"); |
| 342 |
m_tokens.Add("__attribute_artificial__"); |
| 343 |
m_tokens.Add("__attribute_const__"); |
| 344 |
m_tokens.Add("__attribute_copy__(%0)"); |
| 345 |
m_tokens.Add("__attribute_deprecated__"); |
| 346 |
m_tokens.Add("__attribute_deprecated_msg__(%0)"); |
| 347 |
m_tokens.Add("__attribute_format_arg__(%0)"); |
| 348 |
m_tokens.Add("__attribute_format_strfmon__(%0,%1)"); |
| 349 |
m_tokens.Add("__attribute_malloc__"); |
| 350 |
m_tokens.Add("__attribute_noinline__"); |
| 351 |
m_tokens.Add("__attribute_nonstring__"); |
| 352 |
m_tokens.Add("__attribute_pure__"); |
| 353 |
m_tokens.Add("__attribute_used__"); |
| 354 |
m_tokens.Add("__attribute_warn_unused_result__"); |
| 355 |
m_tokens.Add("__cdecl"); |
| 356 |
m_tokens.Add("__const=const"); |
| 357 |
m_tokens.Add("__cpp_deduction_guides=0"); |
| 358 |
m_tokens.Add("__errordecl(%0,%1)=extern void %0 (void)"); |
| 359 |
m_tokens.Add("__extension__"); |
| 360 |
m_tokens.Add("__extern_always_inline=extern"); |
| 361 |
m_tokens.Add("__extern_inline=extern"); |
| 362 |
m_tokens.Add("__flexarr=[]"); |
| 363 |
m_tokens.Add("__forceinline"); |
| 364 |
m_tokens.Add("__fortify_function=extern"); |
| 365 |
m_tokens.Add("__glibc_likely(%0)=(%0)"); |
| 366 |
m_tokens.Add("__glibc_macro_warning(%0)"); |
| 367 |
m_tokens.Add("__glibc_macro_warning1(%0)"); |
| 368 |
m_tokens.Add("__glibc_unlikely(%0)=(%0)"); |
| 369 |
m_tokens.Add("__glibcxx_assert(%0)"); |
| 370 |
m_tokens.Add("__glibcxx_assert_impl(%0)"); |
| 371 |
m_tokens.Add("__inline"); |
| 372 |
m_tokens.Add("__nonnull(%0)"); |
| 373 |
m_tokens.Add("__nothrow"); |
| 374 |
m_tokens.Add("__restrict"); |
| 375 |
m_tokens.Add("__restrict__"); |
| 376 |
m_tokens.Add("__restrict_arr"); |
| 377 |
m_tokens.Add("__stdcall"); |
| 378 |
m_tokens.Add("__warnattr(%0)"); |
| 379 |
m_tokens.Add("__warndecl(%0,%1)=extern void %0 (void)"); |
| 380 |
m_tokens.Add("__wur"); |
| 381 |
m_tokens.Add("_inline"); |
| 382 |
m_tokens.Add("emit"); |
| 383 |
m_tokens.Add("static_assert(%0)"); |
| 384 |
m_tokens.Add("wxDECLARE_EVENT(%0,%1)=int %0;"); |
| 385 |
m_tokens.Add("wxDECLARE_EXPORTED_EVENT(%0,%1,%2)=int %1;"); |
| 386 |
m_tokens.Add("wxDEPRECATED(%0)=%0"); |
| 387 |
m_tokens.Add("wxMSVC_FWD_MULTIPLE_BASES"); |
| 388 |
m_tokens.Add("wxOVERRIDE"); |
| 389 |
m_tokens.Add("wxStatusBar=wxStatusBarBase"); |
| 390 |
m_tokens.Add("wxT"); |
| 391 |
m_tokens.Add("wxWindowNative=wxWindowBase"); |
| 392 |
|
| 393 |
#if defined(__WXGTK__) |
| 394 |
m_tokens.Add("wxTopLevelWindowNative=wxTopLevelWindowGTK"); |
| 395 |
m_tokens.Add("wxWindow=wxWindowGTK"); |
| 396 |
#elif defined(__WXMSW__) |
| 397 |
m_tokens.Add("wxTopLevelWindowNative=wxTopLevelWindowMSW"); |
| 398 |
m_tokens.Add("wxWindow=wxWindowMSW"); |
| 399 |
#else |
| 400 |
m_tokens.Add("wxTopLevelWindowNative=wxTopLevelWindowMac"); |
| 401 |
m_tokens.Add("wxWindow=wxWindowMac"); |
| 402 |
#endif |
| 403 |
} |
| 404 |
|
| 405 |
void TagsOptionsData::AddDefaultTypes() |
| 406 |
{ |
| 407 |
// m_types.Add("std::vector::reference=_Tp"); |
| 408 |
// m_types.Add("std::vector::const_reference=_Tp"); |
| 409 |
// m_types.Add("std::vector::iterator=_Tp"); |
| 410 |
// m_types.Add("std::vector::const_iterator=_Tp"); |
| 411 |
// m_types.Add("std::queue::reference=_Tp"); |
| 412 |
// m_types.Add("std::queue::const_reference=_Tp"); |
| 413 |
// m_types.Add("std::priority_queue::reference=_Tp"); |
| 414 |
// m_types.Add("std::priority_queue::const_reference=_Tp"); |
| 415 |
// m_types.Add("std::set::const_iterator=_Key"); |
| 416 |
// m_types.Add("std::set::iterator=_Key"); |
| 417 |
// m_types.Add("std::unordered_set::const_iterator=_Key"); |
| 418 |
// m_types.Add("std::unordered_set::iterator=_Key"); |
| 419 |
// m_types.Add("std::deque::reference=_Tp"); |
| 420 |
// m_types.Add("std::deque::const_reference=_Tp"); |
| 421 |
// m_types.Add("std::map::iterator=std::pair<_Key, _Tp>"); |
| 422 |
// m_types.Add("std::map::const_iterator=std::pair<_Key,_Tp>"); |
| 423 |
// m_types.Add("std::unordered_map::iterator=std::pair<_Key, _Tp>"); |
| 424 |
// m_types.Add("std::unordered_map::mapped_type=_Tp"); |
| 425 |
// m_types.Add("std::unordered_map::const_iterator=std::pair<_Key,_Tp>"); |
| 426 |
// m_types.Add("std::unordered_map::value_type=std::pair<_Key,_Tp>"); |
| 427 |
// m_types.Add("std::multimap::iterator=std::pair<_Key,_Tp>"); |
| 428 |
// m_types.Add("std::multimap::const_iterator=std::pair<_Key,_Tp>"); |
| 429 |
// m_types.Add("wxOrderedMap::iterator=std::pair<Key,Value>"); |
| 430 |
// m_types.Add("wxOrderedMap::const_iterator=std::pair<Key,Value>"); |
| 431 |
// m_types.Add("boost::shared_ptr::type=T"); |
| 432 |
// m_types.Add("std::unique_ptr::pointer=_Tp"); |
| 433 |
// m_types.Add("_Ptr<_Tp,_Dp>::type=_Tp"); |
| 434 |
// m_types.Add("std::shared_ptr::element_type=_Tp"); |
| 435 |
} |
| 436 |
|
| 437 |
wxString TagsOptionsData::ToString() const |
| 438 |
{ |
| 439 |
wxString options(wxEmptyString); |
| 440 |
|
| 441 |
static wxString file_name; |
| 442 |
wxString file_content; |
| 443 |
|
| 444 |
if(file_name.IsEmpty()) { |
| 445 |
char* ctagsReplacement = getenv("CTAGS_REPLACEMENTS"); |
| 446 |
if(ctagsReplacement) { |
| 447 |
file_name = wxString(ctagsReplacement, wxConvUTF8).c_str(); |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
const wxStringTable_t& tokensMap = GetTokensWxMap(); |
| 452 |
wxStringTable_t::const_iterator iter = tokensMap.begin(); |
| 453 |
|
| 454 |
if(tokensMap.empty() == false) { |
| 455 |
for(; iter != tokensMap.end(); ++iter) { |
| 456 |
if(!iter->second.IsEmpty() || (iter->second.IsEmpty() && iter->first.Find("%0") != wxNOT_FOUND)) { |
| 457 |
// Key = Value pair. Place this one in the output file |
| 458 |
file_content << iter->first << "=" << iter->second << "\n"; |
| 459 |
} else { |
| 460 |
|
| 461 |
if(options.IsEmpty()) { |
| 462 |
options = " -I"; |
| 463 |
} |
| 464 |
|
| 465 |
options << iter->first; |
| 466 |
options << ","; |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
if(options.IsEmpty() == false) { |
| 471 |
options.RemoveLast(); |
| 472 |
} |
| 473 |
|
| 474 |
options += " "; |
| 475 |
} |
| 476 |
|
| 477 |
// write the file content |
| 478 |
if(file_name.IsEmpty() == false) { |
| 479 |
wxFFile fp(file_name, "w+b"); |
| 480 |
if(fp.IsOpened()) { |
| 481 |
fp.Write(file_content); |
| 482 |
fp.Close(); |
| 483 |
} |
| 484 |
} |
| 485 |
|
| 486 |
// if(GetLanguages().IsEmpty() == false) { |
| 487 |
// options += " --language-force="; |
| 488 |
// options += GetLanguages().Item(0); |
| 489 |
// options += " "; |
| 490 |
// } |
| 491 |
return options; |
| 492 |
} |
| 493 |
|
| 494 |
void TagsOptionsData::SetLanguageSelection(const wxString& lang) |
| 495 |
{ |
| 496 |
int where = m_languages.Index(lang); |
| 497 |
if(where != wxNOT_FOUND) { |
| 498 |
m_languages.RemoveAt(where); |
| 499 |
} |
| 500 |
m_languages.Insert(lang, 0); |
| 501 |
} |
| 502 |
|
| 503 |
std::map<std::string, std::string> TagsOptionsData::GetTokensMap() const |
| 504 |
{ |
| 505 |
std::map<std::string, std::string> tokens; |
| 506 |
for(size_t i = 0; i < m_tokens.GetCount(); i++) { |
| 507 |
// const wxCharBuffer bufKey = _C( |
| 508 |
wxString item = m_tokens.Item(i); |
| 509 |
item.Trim().Trim(false); |
| 510 |
wxString k = item.BeforeFirst('='); |
| 511 |
wxString v = item.AfterFirst('='); |
| 512 |
|
| 513 |
const wxCharBuffer bufKey = _C(k); |
| 514 |
std::string key = bufKey.data(); |
| 515 |
std::string value; |
| 516 |
if(!v.empty()) { |
| 517 |
const wxCharBuffer bufValue = _C(v); |
| 518 |
value = bufValue.data(); |
| 519 |
} |
| 520 |
tokens[key] = value; |
| 521 |
} |
| 522 |
return tokens; |
| 523 |
} |
| 524 |
|
| 525 |
const wxStringTable_t& TagsOptionsData::GetTokensWxMap() const { return m_tokensWxMap; } |
| 526 |
|
| 527 |
wxStringTable_t TagsOptionsData::GetTypesMap() const |
| 528 |
{ |
| 529 |
wxStringTable_t tokens; |
| 530 |
for(size_t i = 0; i < m_types.GetCount(); i++) { |
| 531 |
wxString item = m_types.Item(i); |
| 532 |
item.Trim().Trim(false); |
| 533 |
wxString k = item.BeforeFirst('='); |
| 534 |
wxString v = item.AfterFirst('='); |
| 535 |
tokens[k] = v; |
| 536 |
} |
| 537 |
return tokens; |
| 538 |
} |
| 539 |
|
| 540 |
void TagsOptionsData::SetTokens(const wxString& tokens) |
| 541 |
{ |
| 542 |
this->m_tokens = ::wxStringTokenize(tokens, "\r\n", wxTOKEN_STRTOK); |
| 543 |
DoUpdateTokensWxMapReversed(); |
| 544 |
DoUpdateTokensWxMap(); |
| 545 |
} |
| 546 |
|
| 547 |
void TagsOptionsData::DoUpdateTokensWxMap() |
| 548 |
{ |
| 549 |
m_tokensWxMap.clear(); |
| 550 |
for(size_t i = 0; i < m_tokens.GetCount(); i++) { |
| 551 |
wxString item = m_tokens.Item(i).Trim().Trim(false); |
| 552 |
wxString k = item.BeforeFirst('='); |
| 553 |
wxString v = item.AfterFirst('='); |
| 554 |
m_tokensWxMap[k] = v; |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
void TagsOptionsData::DoUpdateTokensWxMapReversed() |
| 559 |
{ |
| 560 |
m_tokensWxMapReversed.clear(); |
| 561 |
for(size_t i = 0; i < m_tokens.GetCount(); i++) { |
| 562 |
wxString item = m_tokens.Item(i).Trim().Trim(false); |
| 563 |
wxString k = item.AfterFirst('='); |
| 564 |
wxString v = item.BeforeFirst('='); |
| 565 |
if(_IsValidCppIndetifier(k) && !_IsCppKeyword(k)) { |
| 566 |
m_tokensWxMapReversed[k] = v; |
| 567 |
} |
| 568 |
} |
| 569 |
} |
| 570 |
|
| 571 |
const wxStringTable_t& TagsOptionsData::GetTokensReversedWxMap() const { return m_tokensWxMapReversed; } |
| 572 |
|
| 573 |
void TagsOptionsData::FromJSON(const JSONItem& json) |
| 574 |
{ |
| 575 |
m_version = json.namedObject("version").toSize_t(); |
| 576 |
m_ccFlags = json.namedObject("m_ccFlags").toSize_t(m_ccFlags); |
| 577 |
m_ccColourFlags = json.namedObject("m_ccColourFlags").toSize_t(m_ccColourFlags); |
| 578 |
m_tokens = json.namedObject("m_tokens").toArrayString(); |
| 579 |
m_types = json.namedObject("m_types").toArrayString(); |
| 580 |
m_fileSpec = json.namedObject("m_fileSpec").toString(m_fileSpec); |
| 581 |
m_languages = json.namedObject("m_languages").toArrayString(); |
| 582 |
m_minWordLen = json.namedObject("m_minWordLen").toInt(m_minWordLen); |
| 583 |
m_parserSearchPaths = json.namedObject("m_parserSearchPaths").toArrayString(); |
| 584 |
m_parserEnabled = json.namedObject("m_parserEnabled").toBool(); |
| 585 |
m_parserExcludePaths = json.namedObject("m_parserExcludePaths").toArrayString(); |
| 586 |
m_maxItemToColour = json.namedObject("m_maxItemToColour").toInt(); |
| 587 |
m_macrosFiles = json.namedObject("m_macrosFiles").toString(); |
| 588 |
m_clangOptions = json.namedObject("m_clangOptions").toSize_t(); |
| 589 |
m_clangBinary = json.namedObject("m_clangBinary").toString(); |
| 590 |
m_clangCmpOptions = json.namedObject("m_clangCmpOptions").toString(); |
| 591 |
m_clangSearchPaths = json.namedObject("m_clangSearchPaths").toArrayString(); |
| 592 |
m_clangMacros = json.namedObject("m_clangMacros").toString(); |
| 593 |
m_clangCachePolicy = json.namedObject("m_clangCachePolicy").toString(); |
| 594 |
m_ccNumberOfDisplayItems = json.namedObject("m_ccNumberOfDisplayItems").toSize_t(m_ccNumberOfDisplayItems); |
| 595 |
|
| 596 |
if(!m_fileSpec.Contains("*.hxx")) { |
| 597 |
m_fileSpec = "*.cpp;*.cc;*.cxx;*.h;*.hpp;*.c;*.c++;*.tcc;*.hxx;*.h++"; |
| 598 |
} |
| 599 |
|
| 600 |
DoUpdateTokensWxMapReversed(); |
| 601 |
DoUpdateTokensWxMap(); |
| 602 |
m_ccFlags |= CC_ACCURATE_SCOPE_RESOLVING; |
| 603 |
} |
| 604 |
|
| 605 |
JSONItem TagsOptionsData::ToJSON() const |
| 606 |
{ |
| 607 |
JSONItem json = JSONItem::createObject(GetName()); |
| 608 |
json.addProperty("version", m_version); |
| 609 |
json.addProperty("m_ccFlags", m_ccFlags); |
| 610 |
json.addProperty("m_ccColourFlags", m_ccColourFlags); |
| 611 |
json.addProperty("m_tokens", m_tokens); |
| 612 |
json.addProperty("m_types", m_types); |
| 613 |
json.addProperty("m_fileSpec", m_fileSpec); |
| 614 |
json.addProperty("m_languages", m_languages); |
| 615 |
json.addProperty("m_minWordLen", m_minWordLen); |
| 616 |
json.addProperty("m_parserSearchPaths", m_parserSearchPaths); |
| 617 |
json.addProperty("m_parserEnabled", m_parserEnabled); |
| 618 |
json.addProperty("m_parserExcludePaths", m_parserExcludePaths); |
| 619 |
json.addProperty("m_maxItemToColour", m_maxItemToColour); |
| 620 |
json.addProperty("m_macrosFiles", m_macrosFiles); |
| 621 |
json.addProperty("m_clangOptions", m_clangOptions); |
| 622 |
json.addProperty("m_clangBinary", m_clangBinary); |
| 623 |
json.addProperty("m_clangCmpOptions", m_clangCmpOptions); |
| 624 |
json.addProperty("m_clangSearchPaths", m_clangSearchPaths); |
| 625 |
json.addProperty("m_clangMacros", m_clangMacros); |
| 626 |
json.addProperty("m_clangCachePolicy", m_clangCachePolicy); |
| 627 |
json.addProperty("m_ccNumberOfDisplayItems", m_ccNumberOfDisplayItems); |
| 628 |
return json; |
| 629 |
} |
| 630 |
|
| 631 |
wxString TagsOptionsData::DoJoinArray(const wxArrayString& arr) const |
| 632 |
{ |
| 633 |
wxString s; |
| 634 |
for(size_t i = 0; i < arr.GetCount(); ++i) { |
| 635 |
s << arr.Item(i) << "\n"; |
| 636 |
} |
| 637 |
|
| 638 |
if(s.IsEmpty() == false) { |
| 639 |
s.RemoveLast(); |
| 640 |
} |
| 641 |
|
| 642 |
return s; |
| 643 |
} |
| 644 |
|
| 645 |
void TagsOptionsData::Merge(const TagsOptionsData& tod) |
| 646 |
{ |
| 647 |
clConfig conf; |
| 648 |
m_tokens = conf.MergeArrays(m_tokens, tod.m_tokens); |
| 649 |
m_types = conf.MergeArrays(m_types, tod.m_types); |
| 650 |
DoUpdateTokensWxMapReversed(); |
| 651 |
DoUpdateTokensWxMap(); |
| 652 |
if(m_version != TagsOptionsData::CURRENT_VERSION) { |
| 653 |
m_ccNumberOfDisplayItems = tod.m_ccNumberOfDisplayItems; |
| 654 |
} |
| 655 |
m_version = TagsOptionsData::CURRENT_VERSION; |
| 656 |
} |
| 657 |
|
| 658 |
void TagsOptionsData::SyncData() |
| 659 |
{ |
| 660 |
DoUpdateTokensWxMap(); |
| 661 |
DoUpdateTokensWxMapReversed(); |
| 662 |
} |
| 663 |
|
| 664 |
std::vector<std::pair<wxString, wxString>> TagsOptionsData::GetTypes() const |
| 665 |
{ |
| 666 |
std::vector<std::pair<wxString, wxString>> arr; |
| 667 |
arr.reserve(m_types.size()); |
| 668 |
|
| 669 |
for(const auto& line : m_types) { |
| 670 |
std::pair<wxString, wxString> p; |
| 671 |
p.first = line.BeforeFirst('='); |
| 672 |
p.second = line.AfterFirst('='); |
| 673 |
arr.emplace_back(p); |
| 674 |
} |
| 675 |
return arr; |
| 676 |
} |