@@ -59,6 +59,8 @@ public class Ctags implements Resettable {
59
59
private static final Logger LOGGER = LoggerFactory .getLogger (Ctags .class );
60
60
61
61
private volatile boolean closing ;
62
+ private final LangTreeMap defaultLangMap = new LangTreeMap ();
63
+ private LangMap langMap ;
62
64
private Process ctags ;
63
65
private OutputStreamWriter ctagsIn ;
64
66
private BufferedReader ctagsOut ;
@@ -88,6 +90,10 @@ public void setBinary(String binary) {
88
90
this .binary = binary ;
89
91
}
90
92
93
+ public void setLangMap (LangMap langMap ) {
94
+ this .langMap = langMap ;
95
+ }
96
+
91
97
public int getTabSize () {
92
98
return tabSize ;
93
99
}
@@ -152,13 +158,15 @@ private void initialize() throws IOException {
152
158
command .add ("--filter-terminator=" + CTAGS_FILTER_TERMINATOR + "\n " );
153
159
command .add ("--fields=-anf+iKnS" );
154
160
command .add ("--excmd=pattern" );
155
- command .add ("--langmap=sh:+.kshlib" ); // RFE #17849
156
- command .add ("--langmap=sql:+.plb" ); // RFE #19208
157
- command .add ("--langmap=sql:+.pls" ); // RFE #19208
158
- command .add ("--langmap=sql:+.pld" ); // RFE #19208
159
- command .add ("--langmap=sql:+.pks" ); // RFE #19208 ?
160
- command .add ("--langmap=sql:+.pkb" ); // # 1763
161
- command .add ("--langmap=sql:+.pck" ); // # 1763
161
+
162
+ defaultLangMap .clear ();
163
+ defaultLangMap .add (".KSHLIB" , "sh" ); // RFE #17849. Upper-case file spec
164
+ defaultLangMap .add (".PLB" , "sql" ); // RFE #19208. Upper-case file spec
165
+ defaultLangMap .add (".PLS" , "sql" ); // RFE #19208. Upper-case file spec
166
+ defaultLangMap .add (".PLD" , "sql" ); // RFE #19208. Upper-case file spec
167
+ defaultLangMap .add (".PKS" , "sql" ); // RFE #19208 ? Upper-case file spec
168
+ defaultLangMap .add (".PKB" , "sql" ); // # 1763. Upper-case file spec
169
+ defaultLangMap .add (".PCK" , "sql" ); // # 1763. Upper-case file spec
162
170
163
171
//Ideally all below should be in ctags, or in outside config file,
164
172
//we might run out of command line SOON
@@ -185,6 +193,12 @@ private void initialize() throws IOException {
185
193
186
194
//PLEASE add new languages ONLY with POSIX syntax (see above wiki link)
187
195
196
+ if (langMap != null ) {
197
+ command .addAll (langMap .mergeSecondary (defaultLangMap ).getCtagsArgs ());
198
+ } else {
199
+ command .addAll (defaultLangMap .getCtagsArgs ());
200
+ }
201
+
188
202
/* Add extra command line options for ctags. */
189
203
if (CTagsExtraOptionsFile != null ) {
190
204
LOGGER .log (Level .INFO , "Adding extra options to ctags" );
@@ -229,7 +243,7 @@ private void initialize() throws IOException {
229
243
230
244
private void addRustSupport (List <String > command ) {
231
245
command .add ("--langdef=rust" );
232
- command .add ("--langmap=rust:+.rs" );
246
+ defaultLangMap .add (".RS" , "rust" ); // Upper-case file spec
233
247
234
248
// The following are not supported yet in Universal Ctags b13cb551
235
249
command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?(static|const)[[:space:]]+(mut[[:space:]]+)?" +
@@ -243,7 +257,8 @@ private void addRustSupport(List<String> command) {
243
257
244
258
private void addPowerShellSupport (List <String > command ) {
245
259
command .add ("--langdef=powershell" );
246
- command .add ("--langmap=powershell:+.ps1,powershell:+.psm1" );
260
+ defaultLangMap .add (".PS1" , "powershell" ); // Upper-case file spec
261
+ defaultLangMap .add (".PSM1" , "powershell" ); // Upper-case file spec
247
262
command .add ("--regex-powershell=/\\ $(\\ {[^}]+\\ })/\\ 1/v,variable/" );
248
263
command .add ("--regex-powershell=/\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1/v,variable/" );
249
264
command .add ("--regex-powershell=/^[[:space:]]*(:[^[:space:]]+)/\\ 1/l,label/" );
@@ -261,7 +276,7 @@ private void addPowerShellSupport(List<String> command) {
261
276
262
277
private void addPascalSupport (List <String > command ) {
263
278
command .add ("--langdef=pascal" );
264
- command .add ("--langmap=pascal:+.pas" );
279
+ defaultLangMap .add (".PAS" , "pascal" ); // Upper-case file spec
265
280
command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*\\ ([[:space:]]*[[:alnum:]_][[:space:]]*\\ )/\\ 1/t,Type/" );
266
281
command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*class[[:space:]]*[^;]*$/\\ 1/c,Class/" );
267
282
command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*interface[[:space:]]*[^;]*$/\\ 1/i,interface/" );
@@ -276,7 +291,7 @@ private void addPascalSupport(List<String> command) {
276
291
277
292
private void addSwiftSupport (List <String > command ) {
278
293
command .add ("--langdef=swift" );
279
- command .add ("--langmap=swift:+. swift" );
294
+ defaultLangMap .add (".SWIFT" , " swift" ); // Upper-case file spec
280
295
command .add ("--regex-swift=/enum[[:space:]]+([^\\ {\\ }]+).*$/\\ 1/n,enum,enums/" );
281
296
command .add ("--regex-swift=/typealias[[:space:]]+([^:=]+).*$/\\ 1/t,typealias,typealiases/" );
282
297
command .add ("--regex-swift=/protocol[[:space:]]+([^:\\ {]+).*$/\\ 1/p,protocol,protocols/" );
@@ -289,8 +304,8 @@ private void addSwiftSupport(List<String> command) {
289
304
290
305
private void addKotlinSupport (List <String > command ) {
291
306
command .add ("--langdef=kotlin" );
292
- command .add ("--langmap=kotlin:+.kt" );
293
- command .add ("--langmap=kotlin:+.kts" );
307
+ defaultLangMap .add (".KT" , "kotlin" ); // Upper-case file spec
308
+ defaultLangMap .add (".KTS" , "kotlin" ); // Upper-case file spec
294
309
command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
295
310
"(private[^ ]*|protected)?[[:space:]]*class[[:space:]]+([[:alnum:]_:]+)/\\ 4/c,classes/" );
296
311
command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
@@ -313,9 +328,9 @@ private void addKotlinSupport(List<String> command) {
313
328
314
329
private void addClojureSupport (List <String > command ) {
315
330
command .add ("--langdef=clojure" ); // clojure support (patterns are from https://gist.github.com/kul/8704283)
316
- command .add ("--langmap=clojure:+.clj" );
317
- command .add ("--langmap=clojure:+.cljs" );
318
- command .add ("--langmap=clojure:+.cljx" );
331
+ defaultLangMap .add (".CLJ" , "clojure" ); // Upper-case file spec
332
+ defaultLangMap .add (".CLJS" , "clojure" ); // Upper-case file spec
333
+ defaultLangMap .add (".CLJX" , "clojure" ); // Upper-case file spec
319
334
320
335
command .add ("--regex-clojure=/\\ ([[:space:]]*create-ns[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/n,namespace/" );
321
336
command .add ("--regex-clojure=/\\ ([[:space:]]*def[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/d,definition/" );
@@ -331,8 +346,8 @@ private void addClojureSupport(List<String> command) {
331
346
332
347
private void addHaskellSupport (List <String > command ) {
333
348
command .add ("--langdef=haskell" ); // below was added with #912
334
- command .add ("--langmap=haskell:+.hs" );
335
- command .add ("--langmap=haskell:+.hsc" );
349
+ defaultLangMap .add (".HS" , "haskell" ); // Upper-case file spec
350
+ defaultLangMap .add (".HSC" , "haskell" ); // Upper-case file spec
336
351
command .add ("--regex-haskell=/^[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/c,classes/" );
337
352
command .add ("--regex-haskell=/^[[:space:]]*data[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
338
353
command .add ("--regex-haskell=/^[[:space:]]*newtype[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
@@ -345,7 +360,7 @@ private void addHaskellSupport(List<String> command) {
345
360
346
361
private void addScalaSupport (List <String > command ) {
347
362
command .add ("--langdef=scala" ); // below is bug 61 to get full scala support
348
- command .add ("--langmap=scala:+. scala" );
363
+ defaultLangMap .add (".SCALA" , " scala" ); // Upper-case file spec
349
364
command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
350
365
"(private|protected)?[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 4/c,classes/" );
351
366
command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
0 commit comments