diff options
| author | Eli Zaretskii | 2016-01-30 14:16:36 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-01-30 14:16:36 +0200 |
| commit | 25b79d7bc71079cd6ebb2700623e7e3b76b03287 (patch) | |
| tree | 1654109110b07b8ebf8fd9b9196e73f2d4553972 /lib-src | |
| parent | ccc3b3cd68312e1d69d9f9af943ee2b9a9d88198 (diff) | |
| download | emacs-25b79d7bc71079cd6ebb2700623e7e3b76b03287.tar.gz emacs-25b79d7bc71079cd6ebb2700623e7e3b76b03287.zip | |
Improve Ruby support in 'etags'
* lib-src/etags.c (Ruby_functions): Tag constants. Don't tag
singleton classes. Remove class qualifiers from tags generated
for method and constant names. (Bug#22241)
* doc/emacs/maintaining.texi (Tag Syntax): Mention that constants
are tagged by etags in Ruby.
* etc/NEWS: Mention that constants are tagged by etags in Ruby.
* test/etags/ruby-src/test1.ruby: Add more tests.
* test/etags/ETAGS.good_1:
* test/etags/ETAGS.good_2:
* test/etags/ETAGS.good_3:
* test/etags/ETAGS.good_4:
* test/etags/ETAGS.good_5:
* test/etags/ETAGS.good_6:
* test/etags/CTAGS.good: Adapt to the changes in etags and in Ruby
tests.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 54ed1b428e9..adc08a23678 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -4550,18 +4550,68 @@ Ruby_functions (FILE *inf) | |||
| 4550 | 4550 | ||
| 4551 | LOOP_ON_INPUT_LINES (inf, lb, cp) | 4551 | LOOP_ON_INPUT_LINES (inf, lb, cp) |
| 4552 | { | 4552 | { |
| 4553 | bool is_class = false; | ||
| 4554 | bool is_method = false; | ||
| 4555 | char *name; | ||
| 4556 | |||
| 4553 | cp = skip_spaces (cp); | 4557 | cp = skip_spaces (cp); |
| 4554 | if (LOOKING_AT (cp, "def") | 4558 | if (c_isalpha (*cp) && c_isupper (*cp)) /* constants */ |
| 4555 | || LOOKING_AT (cp, "class") | ||
| 4556 | || LOOKING_AT (cp, "module")) | ||
| 4557 | { | 4559 | { |
| 4558 | char *name = cp; | 4560 | char *bp, *colon = NULL; |
| 4561 | |||
| 4562 | name = cp; | ||
| 4563 | |||
| 4564 | for (cp++; c_isalnum (*cp) || *cp == '_' || *cp == ':'; cp++) | ||
| 4565 | { | ||
| 4566 | if (*cp == ':') | ||
| 4567 | colon = cp; | ||
| 4568 | } | ||
| 4569 | if (cp > name + 1) | ||
| 4570 | { | ||
| 4571 | bp = skip_spaces (cp); | ||
| 4572 | if (*bp == '=' && c_isspace (bp[1])) | ||
| 4573 | { | ||
| 4574 | if (colon && !c_isspace (colon[1])) | ||
| 4575 | name = colon + 1; | ||
| 4576 | make_tag (name, cp - name, false, | ||
| 4577 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | ||
| 4578 | } | ||
| 4579 | } | ||
| 4580 | } | ||
| 4581 | else if ((is_method = LOOKING_AT (cp, "def")) /* module/class/method */ | ||
| 4582 | || (is_class = LOOKING_AT (cp, "class")) | ||
| 4583 | || LOOKING_AT (cp, "module")) | ||
| 4584 | { | ||
| 4585 | const char self_name[] = "self."; | ||
| 4586 | const size_t self_size1 = sizeof ("self.") - 1; | ||
| 4587 | |||
| 4588 | name = cp; | ||
| 4559 | 4589 | ||
| 4560 | /* Ruby method names can end in a '='. Also, operator overloading can | 4590 | /* Ruby method names can end in a '='. Also, operator overloading can |
| 4561 | define operators whose names include '='. */ | 4591 | define operators whose names include '='. */ |
| 4562 | while (!notinname (*cp) || *cp == '=') | 4592 | while (!notinname (*cp) || *cp == '=') |
| 4563 | cp++; | 4593 | cp++; |
| 4564 | 4594 | ||
| 4595 | /* Remove "self." from the method name. */ | ||
| 4596 | if (cp - name > self_size1 | ||
| 4597 | && strneq (name, self_name, self_size1)) | ||
| 4598 | name += self_size1; | ||
| 4599 | |||
| 4600 | /* Remove the class/module qualifiers from method names. */ | ||
| 4601 | if (is_method) | ||
| 4602 | { | ||
| 4603 | char *q; | ||
| 4604 | |||
| 4605 | for (q = name; q < cp && *q != '.'; q++) | ||
| 4606 | ; | ||
| 4607 | if (q < cp - 1) /* punt if we see just "FOO." */ | ||
| 4608 | name = q + 1; | ||
| 4609 | } | ||
| 4610 | |||
| 4611 | /* Don't tag singleton classes. */ | ||
| 4612 | if (is_class && strneq (name, "<<", 2) && cp == name + 2) | ||
| 4613 | continue; | ||
| 4614 | |||
| 4565 | make_tag (name, cp - name, true, | 4615 | make_tag (name, cp - name, true, |
| 4566 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4616 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| 4567 | } | 4617 | } |