-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does ctags have multiline regex support? #219
Comments
ctags --version
Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Oct 7 2014, 13:52:37
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex |
As far as I know ctags utilizes the regex engine in line oriented way. |
Thank you @masatake do you think I can make a workaround like using other regex engine or something? |
There are some approaches. If you don't have enough time, and you know well aobut a script language, you can use xcmd. If you have time and know C language, look at parseJavaAnnotation in c.c and extend it as you want. If you have enough time, tell us your idea how ctags should deal java's annotation(not only spring.) |
The beauty of ctags is the fact that anybody can extend it with project specific settings by writing just some small regex. Please take a look at what I did for AngularJS (http://bit.ly/16gcKd7). My ctags settings (and vim) figure out AngularJS controllers, directives, modules etc. This is something that IntelliJ cannot. AngularJS is hip now, tomorrow it will not be. I think that ctags should have basic support for languages but not for frameworks. The JavaScript and Java support is great. I just wanted to have something with vim+ctags that no IDE offers. Multiline regex would give me the possibility to lookaround for stuff before and after and build a tag based on that. This is not language specific, it should not be in ctags source code, it should be in people's ~/.ctags on github :P I have no C skills but I plan to learn. I see no need to extend parseJavaAnnotation now, it is great the way it is. I will check out xcmd and the two issues you pointed out. Thank you again @masatake |
(I think it is nice if we have multiline regex support, however I cannot have an image how to implement it well in the current ctags code base. See lregex.c. ) |
@masatake I understand implementing it is complicated with the current codebase. I took a look at ---xcmd=COMMAND syntax and I will try to use it. I only read the documentation and it seems it is too much for me. From what I get from the documentation it will be invoked twice, once some sort of init that returns an exit code 0, something else or 77 and after that once for each file. It seems that the COMMAND needs to keep some sort of internal state. I don't think current implementation is very good for my case since oneliners using |
After learning etags.c of emacs, I know how can we implment multiline regex parser in ctags. You can accumulate all input at iFileGetLine of read.c. |
Now Universal-ctags has the most of all facilities for implementing multline regex parser. |
Close universal-ctags#219 [jet@localhost ctags]$ cat foo.java @subscribe public void catchEvent(SomeEvent e) { return; } @subscribe public void recover(Exception e) { return; } [jet@localhost ctags]$ ./ctags \ --langdef=javaspring --langmap=javaspring:.java \ '--regex-javaspring=/@subscribe(\s)*([a-z ]+)\s*([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/{multiline=3}' \ -o - foo.java Event-SomeEvent foo.java /^public void catchEvent(SomeEvent e)$/;" r recover-Exception foo.java /^ recover(Exception e)$/;" r Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Close universal-ctags#219 [jet@localhost ctags]$ cat foo.java @subscribe public void catchEvent(SomeEvent e) { return; } @subscribe public void recover(Exception e) { return; } [jet@localhost ctags]$ ./ctags \ --langdef=javaspring --langmap=javaspring:.java \ '--regex-javaspring=/@subscribe(\s)*([a-z ]+)\s*([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/{multiline=3}' \ -o - foo.java Event-SomeEvent foo.java /^public void catchEvent(SomeEvent e)$/;" r recover-Exception foo.java /^ recover(Exception e)$/;" r Signed-off-by: Masatake YAMATO <yamato@redhat.com>
It works. Please, try #1224 if you have still interest. |
Close universal-ctags#219 $ cat foo.java @subscribe public void catchEvent(SomeEvent e) { return; } @subscribe public void recover(Exception e) { return; } $ ./ctags \ --langdef=javaspring --langmap=javaspring:.java \ '--regex-javaspring=/@subscribe(\s)*([a-z ]+)\s*([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/{_multiline=3}' \ -o - foo.java Event-SomeEvent foo.java /^public void catchEvent(SomeEvent e)$/;" r recover-Exception foo.java /^ recover(Exception e)$/;" r This is still experimental, so an underscore char is used as prefix for the regex flag. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Input taken from universal-ctags#219.
Close universal-ctags#219 $ cat foo.java @subscribe public void catchEvent(SomeEvent e) { return; } @subscribe public void recover(Exception e) { return; } $ ./ctags \ --langdef=javaspring --langmap=javaspring:.java \ '--regex-javaspring=/@subscribe(\s)*([a-z ]+)\s*([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/{_multiline=3}' \ -o - foo.java Event-SomeEvent foo.java /^public void catchEvent(SomeEvent e)$/;" r recover-Exception foo.java /^ recover(Exception e)$/;" r This is still experimental, so an underscore char is used as prefix for the regex flag. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Input taken from universal-ctags#219.
Close universal-ctags#219 $ cat foo.java @subscribe public void catchEvent(SomeEvent e) { return; } @subscribe public void recover(Exception e) { return; } $ ./ctags \ --langdef=javaspring --langmap=javaspring:.java \ '--regex-javaspring=/@subscribe(\s)*([a-z ]+)\s*([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/{_multiline=3}' \ -o - foo.java Event-SomeEvent foo.java /^public void catchEvent(SomeEvent e)$/;" r recover-Exception foo.java /^ recover(Exception e)$/;" r This is still experimental, so an underscore char is used as prefix for the regex flag. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Input taken from universal-ctags#219.
Hello,
I have some Java code
And I want to match it with something like this in my ~/.ctags
This should generate something like "catchEvent-SomeEvent" but it does not. If I remove the newline between @subscribe and public void it gets it.
Do you have any idea if I can do this with the current ctag implementation. Am I doing something wrong or ctags does not support multi-line regex now.
Thank you!
The text was updated successfully, but these errors were encountered: