@@ -56,7 +56,6 @@ public class Ctags implements Resettable {
5656 private OutputStreamWriter ctagsIn ;
5757 private BufferedReader ctagsOut ;
5858 private static final String CTAGS_FILTER_TERMINATOR = "__ctags_done_with_file__" ;
59- //default: setCtags(System.getProperty("org.opengrok.indexer.analysis.Ctags", "ctags"));
6059 private String binary ;
6160 private String CTagsExtraOptionsFile = null ;
6261 private int tabSize ;
@@ -124,16 +123,15 @@ private void initialize() throws IOException {
124123 command .add (binary );
125124 command .add ("--c-kinds=+l" );
126125
127- if (env .isUniversalCtags ()) {
128- command .add ("--langmap=clojure:+.cljs" );
129- command .add ("--langmap=clojure:+.cljx" );
126+ command .add ("--langmap=clojure:+.cljs" );
127+ command .add ("--langmap=clojure:+.cljx" );
128+
129+ // Workaround for bug #14924: Don't get local variables in Java
130+ // code since that creates many false positives.
131+ // CtagsTest : bug14924 "too many methods" guards for this
132+ // universal ctags are however safe, so enabling for them
133+ command .add ("--java-kinds=+l" );
130134
131- // Workaround for bug #14924: Don't get local variables in Java
132- // code since that creates many false positives.
133- // CtagsTest : bug14924 "too many methods" guards for this
134- // universal ctags are however safe, so enabling for them
135- command .add ("--java-kinds=+l" );
136- }
137135 command .add ("--sql-kinds=+l" );
138136 command .add ("--Fortran-kinds=+L" );
139137 command .add ("--C++-kinds=+l" );
@@ -163,10 +161,6 @@ private void initialize() throws IOException {
163161
164162 addHaskellSupport (command );
165163
166- if (!env .isUniversalCtags ()) {
167- addGoLangSupport (command );
168- }
169-
170164 //temporarily use our defs until ctags will fix https://github.com/universal-ctags/ctags/issues/988
171165 addClojureSupport (command );
172166
@@ -198,19 +192,14 @@ private void initialize() throws IOException {
198192 processBuilder = new ProcessBuilder (command );
199193
200194 ctags = processBuilder .start ();
201- ctagsIn = env .isUniversalCtags () ? new OutputStreamWriter (
202- ctags .getOutputStream (), StandardCharsets .UTF_8 ) :
203- new OutputStreamWriter (ctags .getOutputStream ());
204- ctagsOut = new BufferedReader (env .isUniversalCtags () ?
205- new InputStreamReader (ctags .getInputStream (),
206- StandardCharsets .UTF_8 ) : new InputStreamReader (
207- ctags .getInputStream ()));
195+ ctagsIn = new OutputStreamWriter (
196+ ctags .getOutputStream (), StandardCharsets .UTF_8 );
197+ ctagsOut = new BufferedReader (new InputStreamReader (ctags .getInputStream (),
198+ StandardCharsets .UTF_8 ));
208199
209200 errThread = new Thread (() -> {
210- try (BufferedReader error = new BufferedReader (
211- env .isUniversalCtags () ? new InputStreamReader (
212- ctags .getErrorStream (), StandardCharsets .UTF_8 ) :
213- new InputStreamReader (ctags .getErrorStream ()))) {
201+ try (BufferedReader error = new BufferedReader (new InputStreamReader (ctags .getErrorStream (),
202+ StandardCharsets .UTF_8 ))) {
214203 String s ;
215204 while ((s = error .readLine ()) != null ) {
216205 if (s .length () > 0 ) {
@@ -232,14 +221,7 @@ private void initialize() throws IOException {
232221 private void addRustSupport (List <String > command ) {
233222 command .add ("--langdef=rust" );
234223 command .add ("--langmap=rust:+.rs" );
235- if (!RuntimeEnvironment .getInstance ().isUniversalCtags ()) {
236- command .add ("--regex-rust=/^[[:space:]]*(#\\ [[^]]+\\ ][[:space:]]*)*(pub[[:space:]]+)?(extern[[:space:]]+)?(\\ \" [^\\ \" ]+\\ \" [[:space:]]+)?(unsafe[[:space:]]+)?fn[[:space:]]+([[:alnum:]_]+)/\\ 6/h,functions,function definitions/" );
237- command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?type[[:space:]]+([[:alnum:]_]+)/\\ 2/T,types,type definitions/" );
238- command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?enum[[:space:]]+([[:alnum:]_]+)/\\ 2/g,enum,enumeration names/" );
239- command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?struct[[:space:]]+([[:alnum:]_]+)/\\ 2/S,structure names/" );
240- command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?mod[[:space:]]+([[:alnum:]_]+)/\\ 2/N,modules,module names/" );
241- command .add ("--regex-rust=/^[[:space:]]*macro_rules![[:space:]]+([[:alnum:]_]+)/\\ 1/d,macros,macro definitions/" );
242- }
224+
243225 // The following are not supported yet in Universal Ctags b13cb551
244226 command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?(static|const)[[:space:]]+(mut[[:space:]]+)?([[:alnum:]_]+)/\\ 4/C,consts,static constants/" );
245227 command .add ("--regex-rust=/^[[:space:]]*(pub[[:space:]]+)?(unsafe[[:space:]]+)?impl([[:space:]\n ]*<[^>]*>)?[[:space:]]+(([[:alnum:]_:]+)[[:space:]]*(<[^>]*>)?[[:space:]]+(for)[[:space:]]+)?([[:alnum:]_]+)/\\ 5 \\ 7 \\ 8/I,impls,trait implementations/" );
@@ -254,20 +236,14 @@ private void addPowerShellSupport(List<String> command) {
254236 command .add ("--regex-Posh=/\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1/v,variable/" );
255237 command .add ("--regex-Posh=/^[[:space:]]*(:[^[:space:]]+)/\\ 1/l,label/" );
256238
257- if (!RuntimeEnvironment .getInstance ().isUniversalCtags ()) {
258- command .add ("--regex-Posh=/^[[:space:]]*([Ff]unction|[Ff]ilter)[[:space:]]+([^({[:space:]]+)[[:space:]]*(\\ (([^)]+)\\ ))?/\\ 2/f,function,functions/" );
259- } else {
260- command .add ("--_fielddef-Posh=signature,signatures" );
261- command .add ("--fields-Posh=+{signature}" );
262-
263- // escaped variable markers
264- command .add ("--regex-Posh=/`\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
265- command .add ("--regex-Posh=/`\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
266- command .add ("--regex-Posh=/#.*\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
267- command .add ("--regex-Posh=/#.*\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
268- command .add ("--regex-Posh=/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*(\\ (([^)]+)\\ ))?/\\ 2/f,function,functions/{icase}{exclusive}{_field=signature:(\\ 4)}" );
269-
270- }
239+ command .add ("--_fielddef-Posh=signature,signatures" );
240+ command .add ("--fields-Posh=+{signature}" );
241+ // escaped variable markers
242+ command .add ("--regex-Posh=/`\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
243+ command .add ("--regex-Posh=/`\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
244+ command .add ("--regex-Posh=/#.*\\ $([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\ 1//{exclusive}" );
245+ command .add ("--regex-Posh=/#.*\\ $(\\ {[^}]+\\ })/\\ 1//{exclusive}" );
246+ command .add ("--regex-Posh=/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*(\\ (([^)]+)\\ ))?/\\ 2/f,function,functions/{icase}{exclusive}{_field=signature:(\\ 4)}" );
271247 }
272248
273249 private void addPascalSupport (List <String > command ) {
@@ -317,10 +293,7 @@ private void addKotlinSupport(List<String> command) {
317293 private void addClojureSupport (List <String > command ) {
318294 command .add ("--langdef=clojure" ); // clojure support (patterns are from https://gist.github.com/kul/8704283)
319295 command .add ("--langmap=clojure:+.clj" );
320- if (!RuntimeEnvironment .getInstance ().isUniversalCtags ()) {
321- command .add ("--regex-clojure=/\\ ([[:space:]]*defn[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/f,function/" );
322- command .add ("--regex-clojure=/\\ ([[:space:]]*ns[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/n,namespace/" );
323- }
296+
324297 command .add ("--regex-clojure=/\\ ([[:space:]]*create-ns[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/n,namespace/" );
325298 command .add ("--regex-clojure=/\\ ([[:space:]]*def[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/d,definition/" );
326299 command .add ("--regex-clojure=/\\ ([[:space:]]*defn-[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/p,private function/" );
@@ -333,14 +306,6 @@ private void addClojureSupport(List<String> command) {
333306 command .add ("--regex-clojure=/\\ ([[:space:]]*intern[[:space:]]+([-[:alnum:]*+!_:\\ /.?]+)/\\ 1/v,intern/" );
334307 }
335308
336- private void addGoLangSupport (List <String > command ) {
337- command .add ("--langdef=golang" );
338- command .add ("--langmap=golang:+.go" );
339- command .add ("--regex-golang=/func([[:space:]]+([^)]+))?[[:space:]]+([a-zA-Z0-9_]+)/\\ 2/f,func/" );
340- command .add ("--regex-golang=/var[[:space:]]+([a-zA-Z_][a-zA-Z0-9_]+)/\\ 1/v,var/" );
341- command .add ("--regex-golang=/type[[:space:]]+([a-zA-Z_][a-zA-Z0-9_]+)/\\ 1/t,type/" );
342- }
343-
344309 private void addHaskellSupport (List <String > command ) {
345310 command .add ("--langdef=haskell" ); // below was added with #912
346311 command .add ("--langmap=haskell:+.hs" );
0 commit comments