Reputation: 1856
I have some Java code
@Subscribe
public void catchEvent(SomeEvent
And I want to match it with something like this in my ~/.ctags
--langdef=javaspring
--langmap=javaspring:.java
--regex-javaspring=/@Subscribe(\s)*([a-z ]+)\s([a-zA-Z]*)\(([a-zA-Z]*)/\3-\4/
This should generate something like "catchEvent-SomeEvent" but it does not. If I remove the newline between @Subscribe and public void it gets it.
@Subscribe public void catchEvent(SomeEvent
rm -rf tags && ctags -R . && cat tags|grep Subs
catchEvent-SomeEvent PathToMyFile.java /^@Subscribe public void catchEvent(SomeEvent event) {$/;" r
I even tried using begin/end of line like this
--regex-javaspring=/^\s*@Subscribe[a-z \s]+\s([a-zA-Z]+)\(([a-zA-Z]+).*$/@Subscribe \1 \2*/
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!
Upvotes: 5
Views: 925
Reputation: 1029
For Universal Ctags you can use the --mline-regex-<LANG>
feature with the {mgroup=1}
option:
--mline-regex-javaspring=/^\s*@Subscribe[a-z \s]+\s([a-zA-Z]+)\(([a-zA-Z]+).*$/@Subscribe \1 \2*/{mgroup=1}
The mgroup
option is necessary to tell Ctags how to determine the line number of the expression.
Upvotes: 2