Changeset View
Changeset View
Standalone View
Standalone View
addons/kate-ctags/ctagskinds.cpp
Show All 14 Lines | |||||
15 | 15 | | |||
16 | struct CTagsKindMapping { | 16 | struct CTagsKindMapping { | ||
17 | char abbrev; | 17 | char abbrev; | ||
18 | const char *verbose; | 18 | const char *verbose; | ||
19 | }; | 19 | }; | ||
20 | 20 | | |||
21 | struct CTagsExtensionMapping { | 21 | struct CTagsExtensionMapping { | ||
22 | const char *extension; | 22 | const char *extension; | ||
23 | CTagsKindMapping *kinds; | 23 | const CTagsKindMapping *kinds; | ||
24 | }; | 24 | }; | ||
25 | 25 | | |||
26 | static CTagsKindMapping kindMappingAsm[] = {{'d', I18N_NOOP2("Tag Type", "define")}, {'l', I18N_NOOP2("Tag Type", "label")}, {'m', I18N_NOOP2("Tag Type", "macro")}, {0, nullptr}}; | 26 | static const CTagsKindMapping kindMappingAsm[] = {{'d', I18N_NOOP2("Tag Type", "define")}, {'l', I18N_NOOP2("Tag Type", "label")}, {'m', I18N_NOOP2("Tag Type", "macro")}, {0, nullptr}}; | ||
27 | 27 | | |||
28 | static CTagsKindMapping kindMappingAsp[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | 28 | static const CTagsKindMapping kindMappingAsp[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | ||
29 | 29 | | |||
30 | static CTagsKindMapping kindMappingAwk[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 30 | static const CTagsKindMapping kindMappingAwk[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
31 | 31 | | |||
32 | static CTagsKindMapping kindMappingBeta[] = {{'f', I18N_NOOP2("Tag Type", "fragment definition")}, {'p', I18N_NOOP2("Tag Type", "any pattern")}, {'s', I18N_NOOP2("Tag Type", "slot")}, {'v', I18N_NOOP2("Tag Type", "pattern")}, {0, nullptr}}; | 32 | static const CTagsKindMapping kindMappingBeta[] = {{'f', I18N_NOOP2("Tag Type", "fragment definition")}, {'p', I18N_NOOP2("Tag Type", "any pattern")}, {'s', I18N_NOOP2("Tag Type", "slot")}, {'v', I18N_NOOP2("Tag Type", "pattern")}, {0, nullptr}}; | ||
33 | 33 | | |||
34 | static CTagsKindMapping kindMappingC[] = {{'c', I18N_NOOP2("Tag Type", "class")}, | 34 | static const CTagsKindMapping kindMappingC[] = {{'c', I18N_NOOP2("Tag Type", "class")}, | ||
35 | {'d', I18N_NOOP2("Tag Type", "macro")}, | 35 | {'d', I18N_NOOP2("Tag Type", "macro")}, | ||
36 | {'e', I18N_NOOP2("Tag Type", "enumerator")}, | 36 | {'e', I18N_NOOP2("Tag Type", "enumerator")}, | ||
37 | {'f', I18N_NOOP2("Tag Type", "function")}, | 37 | {'f', I18N_NOOP2("Tag Type", "function")}, | ||
38 | {'g', I18N_NOOP2("Tag Type", "enumeration")}, | 38 | {'g', I18N_NOOP2("Tag Type", "enumeration")}, | ||
39 | {'m', I18N_NOOP2("Tag Type", "member")}, | 39 | {'m', I18N_NOOP2("Tag Type", "member")}, | ||
40 | {'n', I18N_NOOP2("Tag Type", "namespace")}, | 40 | {'n', I18N_NOOP2("Tag Type", "namespace")}, | ||
41 | {'p', I18N_NOOP2("Tag Type", "prototype")}, | 41 | {'p', I18N_NOOP2("Tag Type", "prototype")}, | ||
42 | {'s', I18N_NOOP2("Tag Type", "struct")}, | 42 | {'s', I18N_NOOP2("Tag Type", "struct")}, | ||
43 | {'t', I18N_NOOP2("Tag Type", "typedef")}, | 43 | {'t', I18N_NOOP2("Tag Type", "typedef")}, | ||
44 | {'u', I18N_NOOP2("Tag Type", "union")}, | 44 | {'u', I18N_NOOP2("Tag Type", "union")}, | ||
45 | {'v', I18N_NOOP2("Tag Type", "variable")}, | 45 | {'v', I18N_NOOP2("Tag Type", "variable")}, | ||
46 | {'x', I18N_NOOP2("Tag Type", "external variable")}, | 46 | {'x', I18N_NOOP2("Tag Type", "external variable")}, | ||
47 | {0, nullptr}}; | 47 | {0, nullptr}}; | ||
48 | 48 | | |||
49 | static CTagsKindMapping kindMappingCobol[] = {{'p', I18N_NOOP2("Tag Type", "paragraph")}, {0, nullptr}}; | 49 | static const CTagsKindMapping kindMappingCobol[] = {{'p', I18N_NOOP2("Tag Type", "paragraph")}, {0, nullptr}}; | ||
50 | 50 | | |||
51 | static CTagsKindMapping kindMappingEiffel[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "feature")}, {'l', I18N_NOOP2("Tag Type", "local entity")}, {0, nullptr}}; | 51 | static const CTagsKindMapping kindMappingEiffel[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "feature")}, {'l', I18N_NOOP2("Tag Type", "local entity")}, {0, nullptr}}; | ||
52 | 52 | | |||
53 | static CTagsKindMapping kindMappingFortran[] = {{'b', I18N_NOOP2("Tag Type", "block")}, | 53 | static const CTagsKindMapping kindMappingFortran[] = {{'b', I18N_NOOP2("Tag Type", "block")}, | ||
54 | {'c', I18N_NOOP2("Tag Type", "common")}, | 54 | {'c', I18N_NOOP2("Tag Type", "common")}, | ||
55 | {'e', I18N_NOOP2("Tag Type", "entry")}, | 55 | {'e', I18N_NOOP2("Tag Type", "entry")}, | ||
56 | {'f', I18N_NOOP2("Tag Type", "function")}, | 56 | {'f', I18N_NOOP2("Tag Type", "function")}, | ||
57 | {'i', I18N_NOOP2("Tag Type", "interface")}, | 57 | {'i', I18N_NOOP2("Tag Type", "interface")}, | ||
58 | {'k', I18N_NOOP2("Tag Type", "type component")}, | 58 | {'k', I18N_NOOP2("Tag Type", "type component")}, | ||
59 | {'l', I18N_NOOP2("Tag Type", "label")}, | 59 | {'l', I18N_NOOP2("Tag Type", "label")}, | ||
60 | {'L', I18N_NOOP2("Tag Type", "local")}, | 60 | {'L', I18N_NOOP2("Tag Type", "local")}, | ||
61 | {'m', I18N_NOOP2("Tag Type", "module")}, | 61 | {'m', I18N_NOOP2("Tag Type", "module")}, | ||
62 | {'n', I18N_NOOP2("Tag Type", "namelist")}, | 62 | {'n', I18N_NOOP2("Tag Type", "namelist")}, | ||
63 | {'p', I18N_NOOP2("Tag Type", "program")}, | 63 | {'p', I18N_NOOP2("Tag Type", "program")}, | ||
64 | {'s', I18N_NOOP2("Tag Type", "subroutine")}, | 64 | {'s', I18N_NOOP2("Tag Type", "subroutine")}, | ||
65 | {'t', I18N_NOOP2("Tag Type", "type")}, | 65 | {'t', I18N_NOOP2("Tag Type", "type")}, | ||
66 | {'v', I18N_NOOP2("Tag Type", "variable")}, | 66 | {'v', I18N_NOOP2("Tag Type", "variable")}, | ||
67 | {0, nullptr}}; | 67 | {0, nullptr}}; | ||
68 | 68 | | |||
69 | static CTagsKindMapping kindMappingJava[] = | 69 | static const CTagsKindMapping kindMappingJava[] = | ||
70 | {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "field")}, {'i', I18N_NOOP2("Tag Type", "interface")}, {'m', I18N_NOOP2("Tag Type", "method")}, {'p', I18N_NOOP2("Tag Type", "package")}, {0, nullptr}}; | 70 | {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "field")}, {'i', I18N_NOOP2("Tag Type", "interface")}, {'m', I18N_NOOP2("Tag Type", "method")}, {'p', I18N_NOOP2("Tag Type", "package")}, {0, nullptr}}; | ||
71 | 71 | | |||
72 | static CTagsKindMapping kindMappingLisp[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 72 | static const CTagsKindMapping kindMappingLisp[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
73 | 73 | | |||
74 | static CTagsKindMapping kindMappingMake[] = {{'m', I18N_NOOP2("Tag Type", "macro")}, {0, nullptr}}; | 74 | static const CTagsKindMapping kindMappingMake[] = {{'m', I18N_NOOP2("Tag Type", "macro")}, {0, nullptr}}; | ||
75 | 75 | | |||
76 | static CTagsKindMapping kindMappingPascal[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'p', I18N_NOOP2("Tag Type", "procedure")}, {0, nullptr}}; | 76 | static const CTagsKindMapping kindMappingPascal[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'p', I18N_NOOP2("Tag Type", "procedure")}, {0, nullptr}}; | ||
77 | 77 | | |||
78 | static CTagsKindMapping kindMappingPerl[] = {{'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | 78 | static const CTagsKindMapping kindMappingPerl[] = {{'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | ||
79 | 79 | | |||
80 | static CTagsKindMapping kindMappingPHP[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 80 | static const CTagsKindMapping kindMappingPHP[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
81 | 81 | | |||
82 | static CTagsKindMapping kindMappingPython[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 82 | static const CTagsKindMapping kindMappingPython[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
83 | 83 | | |||
84 | static CTagsKindMapping kindMappingRexx[] = {{'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | 84 | static const CTagsKindMapping kindMappingRexx[] = {{'s', I18N_NOOP2("Tag Type", "subroutine")}, {0, nullptr}}; | ||
85 | 85 | | |||
86 | static CTagsKindMapping kindMappingRuby[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {'m', I18N_NOOP2("Tag Type", "mixin")}, {0, nullptr}}; | 86 | static const CTagsKindMapping kindMappingRuby[] = {{'c', I18N_NOOP2("Tag Type", "class")}, {'f', I18N_NOOP2("Tag Type", "function")}, {'m', I18N_NOOP2("Tag Type", "mixin")}, {0, nullptr}}; | ||
87 | 87 | | |||
88 | static CTagsKindMapping kindMappingScheme[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'s', I18N_NOOP2("Tag Type", "set")}, {0, nullptr}}; | 88 | static const CTagsKindMapping kindMappingScheme[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'s', I18N_NOOP2("Tag Type", "set")}, {0, nullptr}}; | ||
89 | 89 | | |||
90 | static CTagsKindMapping kindMappingSh[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 90 | static const CTagsKindMapping kindMappingSh[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
91 | 91 | | |||
92 | static CTagsKindMapping kindMappingSlang[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'n', I18N_NOOP2("Tag Type", "namespace")}, {0, nullptr}}; | 92 | static const CTagsKindMapping kindMappingSlang[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {'n', I18N_NOOP2("Tag Type", "namespace")}, {0, nullptr}}; | ||
93 | 93 | | |||
94 | static CTagsKindMapping kindMappingTcl[] = {{'p', I18N_NOOP2("Tag Type", "procedure")}, {0, nullptr}}; | 94 | static const CTagsKindMapping kindMappingTcl[] = {{'p', I18N_NOOP2("Tag Type", "procedure")}, {0, nullptr}}; | ||
95 | 95 | | |||
96 | static CTagsKindMapping kindMappingVim[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | 96 | static const CTagsKindMapping kindMappingVim[] = {{'f', I18N_NOOP2("Tag Type", "function")}, {0, nullptr}}; | ||
97 | 97 | | |||
98 | static CTagsExtensionMapping extensionMapping[] = { | 98 | static CTagsExtensionMapping extensionMapping[] = { | ||
99 | {"asm", kindMappingAsm}, {"s", kindMappingAsm}, {"S", kindMappingAsm}, {"asp", kindMappingAsp}, {"asa", kindMappingAsp}, {"awk", kindMappingAwk}, {"c++", kindMappingC}, {"cc", kindMappingC}, | 99 | {"asm", kindMappingAsm}, {"s", kindMappingAsm}, {"S", kindMappingAsm}, {"asp", kindMappingAsp}, {"asa", kindMappingAsp}, {"awk", kindMappingAwk}, {"c++", kindMappingC}, {"cc", kindMappingC}, | ||
100 | {"cp", kindMappingC}, {"cpp", kindMappingC}, {"cxx", kindMappingC}, {"h", kindMappingC}, {"h++", kindMappingC}, {"hh", kindMappingC}, {"hp", kindMappingC}, {"hpp", kindMappingC}, | 100 | {"cp", kindMappingC}, {"cpp", kindMappingC}, {"cxx", kindMappingC}, {"h", kindMappingC}, {"h++", kindMappingC}, {"hh", kindMappingC}, {"hp", kindMappingC}, {"hpp", kindMappingC}, | ||
101 | {"hxx", kindMappingC}, {"beta", kindMappingBeta}, {"cob", kindMappingCobol}, {"COB", kindMappingCobol}, {"e", kindMappingEiffel}, {"f", kindMappingFortran}, {"for", kindMappingFortran}, {"ftn", kindMappingFortran}, | 101 | {"hxx", kindMappingC}, {"beta", kindMappingBeta}, {"cob", kindMappingCobol}, {"COB", kindMappingCobol}, {"e", kindMappingEiffel}, {"f", kindMappingFortran}, {"for", kindMappingFortran}, {"ftn", kindMappingFortran}, | ||
102 | {"f77", kindMappingFortran}, {"f90", kindMappingFortran}, {"f95", kindMappingFortran}, {"java", kindMappingJava}, {"cl", kindMappingLisp}, {"clisp", kindMappingLisp}, {"el", kindMappingLisp}, {"l", kindMappingLisp}, | 102 | {"f77", kindMappingFortran}, {"f90", kindMappingFortran}, {"f95", kindMappingFortran}, {"java", kindMappingJava}, {"cl", kindMappingLisp}, {"clisp", kindMappingLisp}, {"el", kindMappingLisp}, {"l", kindMappingLisp}, | ||
103 | {"lisp", kindMappingLisp}, {"lsp", kindMappingLisp}, {"ml", kindMappingLisp}, {"mak", kindMappingMake}, {"p", kindMappingPascal}, {"pas", kindMappingPascal}, {"pl", kindMappingPerl}, {"pm", kindMappingPerl}, | 103 | {"lisp", kindMappingLisp}, {"lsp", kindMappingLisp}, {"ml", kindMappingLisp}, {"mak", kindMappingMake}, {"p", kindMappingPascal}, {"pas", kindMappingPascal}, {"pl", kindMappingPerl}, {"pm", kindMappingPerl}, | ||
104 | {"perl", kindMappingPerl}, {"php", kindMappingPHP}, {"php3", kindMappingPHP}, {"phtml", kindMappingPHP}, {"py", kindMappingPython}, {"python", kindMappingPython}, {"cmd", kindMappingRexx}, {"rexx", kindMappingRexx}, | 104 | {"perl", kindMappingPerl}, {"php", kindMappingPHP}, {"php3", kindMappingPHP}, {"phtml", kindMappingPHP}, {"py", kindMappingPython}, {"python", kindMappingPython}, {"cmd", kindMappingRexx}, {"rexx", kindMappingRexx}, | ||
105 | {"rx", kindMappingRexx}, {"rb", kindMappingRuby}, {"sch", kindMappingScheme}, {"scheme", kindMappingScheme}, {"scm", kindMappingScheme}, {"sm", kindMappingScheme}, {"SCM", kindMappingScheme}, {"SM", kindMappingScheme}, | 105 | {"rx", kindMappingRexx}, {"rb", kindMappingRuby}, {"sch", kindMappingScheme}, {"scheme", kindMappingScheme}, {"scm", kindMappingScheme}, {"sm", kindMappingScheme}, {"SCM", kindMappingScheme}, {"SM", kindMappingScheme}, | ||
106 | {"sh", kindMappingSh}, {"SH", kindMappingSh}, {"bsh", kindMappingSh}, {"bash", kindMappingSh}, {"ksh", kindMappingSh}, {"zsh", kindMappingSh}, {"sl", kindMappingSlang}, {"tcl", kindMappingTcl}, | 106 | {"sh", kindMappingSh}, {"SH", kindMappingSh}, {"bsh", kindMappingSh}, {"bash", kindMappingSh}, {"ksh", kindMappingSh}, {"zsh", kindMappingSh}, {"sl", kindMappingSlang}, {"tcl", kindMappingTcl}, | ||
107 | {"wish", kindMappingTcl}, {"vim", kindMappingVim}, {nullptr, nullptr}}; | 107 | {"wish", kindMappingTcl}, {"vim", kindMappingVim}, {nullptr, nullptr}}; | ||
108 | 108 | | |||
109 | static CTagsKindMapping *findKindMapping(const QString &extension) | 109 | static const CTagsKindMapping *findKindMapping(const QString &extension) | ||
110 | { | 110 | { | ||
111 | const char *pextension = extension.toLocal8Bit().constData(); | 111 | const char *pextension = extension.toLocal8Bit().constData(); | ||
112 | 112 | | |||
113 | CTagsExtensionMapping *pem = extensionMapping; | 113 | CTagsExtensionMapping *pem = extensionMapping; | ||
114 | while (pem->extension != nullptr) { | 114 | while (pem->extension != nullptr) { | ||
115 | if (strcmp(pem->extension, pextension) == 0) | 115 | if (strcmp(pem->extension, pextension) == 0) | ||
116 | return pem->kinds; | 116 | return pem->kinds; | ||
117 | ++pem; | 117 | ++pem; | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | return nullptr; | 120 | return nullptr; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | QString CTagsKinds::findKind(const char *kindChar, const QString &extension) | 123 | QString CTagsKinds::findKind(const char *kindChar, const QString &extension) | ||
124 | { | 124 | { | ||
125 | if (kindChar == nullptr) | 125 | if (kindChar == nullptr) | ||
126 | return QString(); | 126 | return QString(); | ||
127 | 127 | | |||
128 | CTagsKindMapping *kindMapping = findKindMapping(extension); | 128 | const CTagsKindMapping *kindMapping = findKindMapping(extension); | ||
129 | if (kindMapping) { | 129 | if (kindMapping) { | ||
130 | CTagsKindMapping *pkm = kindMapping; | 130 | const CTagsKindMapping *pkm = kindMapping; | ||
131 | while (pkm->verbose != nullptr) { | 131 | while (pkm->verbose != nullptr) { | ||
132 | if (pkm->abbrev == *kindChar) | 132 | if (pkm->abbrev == *kindChar) | ||
133 | return i18nc("Tag Type", pkm->verbose); | 133 | return i18nc("Tag Type", pkm->verbose); | ||
134 | ++pkm; | 134 | ++pkm; | ||
135 | } | 135 | } | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | return QString(); | 138 | return QString(); | ||
139 | } | 139 | } |