@@ -59,6 +59,8 @@ public class Ctags implements Resettable {
5959 private static final Logger LOGGER = LoggerFactory .getLogger (Ctags .class );
6060
6161 private volatile boolean closing ;
62+ private final LangTreeMap defaultLangMap = new LangTreeMap ();
63+ private LangMap langMap ;
6264 private Process ctags ;
6365 private OutputStreamWriter ctagsIn ;
6466 private BufferedReader ctagsOut ;
@@ -88,6 +90,10 @@ public void setBinary(String binary) {
8890 this .binary = binary ;
8991 }
9092
93+ public void setLangMap (LangMap langMap ) {
94+ this .langMap = langMap ;
95+ }
96+
9197 public int getTabSize () {
9298 return tabSize ;
9399 }
@@ -152,13 +158,15 @@ private void initialize() throws IOException {
152158 command .add ("--filter-terminator=" + CTAGS_FILTER_TERMINATOR + "\n " );
153159 command .add ("--fields=-anf+iKnS" );
154160 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
162170
163171 //Ideally all below should be in ctags, or in outside config file,
164172 //we might run out of command line SOON
@@ -185,6 +193,12 @@ private void initialize() throws IOException {
185193
186194 //PLEASE add new languages ONLY with POSIX syntax (see above wiki link)
187195
196+ if (langMap != null ) {
197+ command .addAll (langMap .mergeSecondary (defaultLangMap ).getCtagsArgs ());
198+ } else {
199+ command .addAll (defaultLangMap .getCtagsArgs ());
200+ }
201+
188202 /* Add extra command line options for ctags. */
189203 if (CTagsExtraOptionsFile != null ) {
190204 LOGGER .log (Level .INFO , "Adding extra options to ctags" );
@@ -229,7 +243,7 @@ private void initialize() throws IOException {
229243
230244 private void addRustSupport (List <String > command ) {
231245 command .add ("--langdef=rust" );
232- command .add ("--langmap=rust:+.rs" );
246+ defaultLangMap .add (".RS" , "rust" ); // Upper-case file spec
233247
234248 // The following are not supported yet in Universal Ctags b13cb551
235249 command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?(static|const)[[:space:]]+(mut[[:space:]]+)?" +
@@ -242,26 +256,27 @@ private void addRustSupport(List<String> command) {
242256 }
243257
244258 private void addPowerShellSupport (List <String > command ) {
245- command .add ("--langdef=Posh" );
246- command .add ("--langmap=Posh:+.ps1,Posh:+.psm1" );
247- command .add ("--regex-Posh=/\\ $(\\ {[^}]+\\ })/\\ 1/v,variable/" );
248- command .add ("--regex-Posh=/\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1/v,variable/" );
249- command .add ("--regex-Posh=/^[[:space:]]*(:[^[:space:]]+)/\\ 1/l,label/" );
250-
251- command .add ("--_fielddef-Posh=signature,signatures" );
252- command .add ("--fields-Posh=+{signature}" );
259+ command .add ("--langdef=powershell" );
260+ defaultLangMap .add (".PS1" , "powershell" ); // Upper-case file spec
261+ defaultLangMap .add (".PSM1" , "powershell" ); // Upper-case file spec
262+ command .add ("--regex-powershell=/\\ $(\\ {[^}]+\\ })/\\ 1/v,variable/" );
263+ command .add ("--regex-powershell=/\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1/v,variable/" );
264+ command .add ("--regex-powershell=/^[[:space:]]*(:[^[:space:]]+)/\\ 1/l,label/" );
265+
266+ command .add ("--_fielddef-powershell=signature,signatures" );
267+ command .add ("--fields-powershell=+{signature}" );
253268 // escaped variable markers
254- command .add ("--regex-Posh =/`\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
255- command .add ("--regex-Posh =/`\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
256- command .add ("--regex-Posh =/#.*\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
257- command .add ("--regex-Posh =/#.*\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
258- command .add ("--regex-Posh =/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*" +
269+ command .add ("--regex-powershell =/`\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
270+ command .add ("--regex-powershell =/`\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
271+ command .add ("--regex-powershell =/#.*\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
272+ command .add ("--regex-powershell =/#.*\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
273+ command .add ("--regex-powershell =/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*" +
259274 "(\\ (([^)]+)\\ ))?/\\ 2/f,function,functions/{icase}{exclusive}{_field=signature:(\\ 4)}" );
260275 }
261276
262277 private void addPascalSupport (List <String > command ) {
263278 command .add ("--langdef=pascal" );
264- command .add ("--langmap=pascal:+.pas" );
279+ defaultLangMap .add (".PAS" , "pascal" ); // Upper-case file spec
265280 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*\\ ([[:space:]]*[[:alnum:]_][[:space:]]*\\ )/\\ 1/t,Type/" );
266281 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*class[[:space:]]*[^;]*$/\\ 1/c,Class/" );
267282 command .add ("--regex-pascal=/([[:alnum:]_]+)[[:space:]]*=[[:space:]]*interface[[:space:]]*[^;]*$/\\ 1/i,interface/" );
@@ -276,7 +291,7 @@ private void addPascalSupport(List<String> command) {
276291
277292 private void addSwiftSupport (List <String > command ) {
278293 command .add ("--langdef=swift" );
279- command .add ("--langmap=swift:+. swift" );
294+ defaultLangMap .add (".SWIFT" , " swift" ); // Upper-case file spec
280295 command .add ("--regex-swift=/enum[[:space:]]+([^\\ {\\ }]+).*$/\\ 1/n,enum,enums/" );
281296 command .add ("--regex-swift=/typealias[[:space:]]+([^:=]+).*$/\\ 1/t,typealias,typealiases/" );
282297 command .add ("--regex-swift=/protocol[[:space:]]+([^:\\ {]+).*$/\\ 1/p,protocol,protocols/" );
@@ -289,8 +304,8 @@ private void addSwiftSupport(List<String> command) {
289304
290305 private void addKotlinSupport (List <String > command ) {
291306 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
294309 command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
295310 "(private[^ ]*|protected)?[[:space:]]*class[[:space:]]+([[:alnum:]_:]+)/\\ 4/c,classes/" );
296311 command .add ("--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
@@ -313,9 +328,9 @@ private void addKotlinSupport(List<String> command) {
313328
314329 private void addClojureSupport (List <String > command ) {
315330 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
319334
320335 command .add ("--regex-clojure=/\\ ([[:space:]]*create-ns[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/n,namespace/" );
321336 command .add ("--regex-clojure=/\\ ([[:space:]]*def[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/d,definition/" );
@@ -331,8 +346,8 @@ private void addClojureSupport(List<String> command) {
331346
332347 private void addHaskellSupport (List <String > command ) {
333348 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
336351 command .add ("--regex-haskell=/^[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/c,classes/" );
337352 command .add ("--regex-haskell=/^[[:space:]]*data[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
338353 command .add ("--regex-haskell=/^[[:space:]]*newtype[[:space:]]+([a-zA-Z0-9_]+)/\\ 1/t,types/" );
@@ -345,7 +360,7 @@ private void addHaskellSupport(List<String> command) {
345360
346361 private void addScalaSupport (List <String > command ) {
347362 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
349364 command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
350365 "(private|protected)?[[:space:]]*class[[:space:]]+([a-zA-Z0-9_]+)/\\ 4/c,classes/" );
351366 command .add ("--regex-scala=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*" +
0 commit comments