diff options
| author | Eli Zaretskii | 2016-02-02 19:16:22 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-02-02 19:16:22 +0200 |
| commit | 58bfb6a4f597b98f01169f42410df3184c451408 (patch) | |
| tree | 1a3ca89e5af7fd58aa9ae60b0129e87264faf746 /lib-src | |
| parent | c04e91134f256be298d8739d493aa8df7e8d05ec (diff) | |
| download | emacs-58bfb6a4f597b98f01169f42410df3184c451408.tar.gz emacs-58bfb6a4f597b98f01169f42410df3184c451408.zip | |
More improvements for Ruby support in 'etags'
* lib-src/etags.c (Ruby_functions): Tag Ruby accessors and
alias_method. Identify constants even if the assignment is not
followed by whitespace. (Bug#22241)
* test/etags/ruby-src/test1.ruby: Add tests for constants,
accessors, and alias_method.
* 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 changes in Ruby tests.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index bdfced5bc9c..769a22027f7 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -4642,7 +4642,7 @@ Ruby_functions (FILE *inf) | |||
| 4642 | if (cp > name + 1) | 4642 | if (cp > name + 1) |
| 4643 | { | 4643 | { |
| 4644 | bp = skip_spaces (cp); | 4644 | bp = skip_spaces (cp); |
| 4645 | if (*bp == '=' && c_isspace (bp[1])) | 4645 | if (*bp == '=' && !(bp[1] == '=' || bp[1] == '>')) |
| 4646 | { | 4646 | { |
| 4647 | if (colon && !c_isspace (colon[1])) | 4647 | if (colon && !c_isspace (colon[1])) |
| 4648 | name = colon + 1; | 4648 | name = colon + 1; |
| @@ -4656,7 +4656,7 @@ Ruby_functions (FILE *inf) | |||
| 4656 | || LOOKING_AT (cp, "module")) | 4656 | || LOOKING_AT (cp, "module")) |
| 4657 | { | 4657 | { |
| 4658 | const char self_name[] = "self."; | 4658 | const char self_name[] = "self."; |
| 4659 | const size_t self_size1 = sizeof ("self.") - 1; | 4659 | const size_t self_size1 = sizeof (self_name) - 1; |
| 4660 | 4660 | ||
| 4661 | name = cp; | 4661 | name = cp; |
| 4662 | 4662 | ||
| @@ -4688,6 +4688,60 @@ Ruby_functions (FILE *inf) | |||
| 4688 | make_tag (name, cp - name, true, | 4688 | make_tag (name, cp - name, true, |
| 4689 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4689 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| 4690 | } | 4690 | } |
| 4691 | else | ||
| 4692 | { | ||
| 4693 | /* Tag accessors and aliases. */ | ||
| 4694 | while (*cp && *cp != '#') | ||
| 4695 | { | ||
| 4696 | bool reader = false, writer = false, alias = false; | ||
| 4697 | |||
| 4698 | if (LOOKING_AT (cp, "attr_reader")) | ||
| 4699 | reader = true; | ||
| 4700 | else if (LOOKING_AT (cp, "attr_writer")) | ||
| 4701 | writer = true; | ||
| 4702 | else if (LOOKING_AT (cp, "attr_accessor")) | ||
| 4703 | { | ||
| 4704 | reader = true; | ||
| 4705 | writer = true; | ||
| 4706 | } | ||
| 4707 | else if (LOOKING_AT (cp, "alias_method")) | ||
| 4708 | alias = true; | ||
| 4709 | if (reader || writer || alias) | ||
| 4710 | { | ||
| 4711 | do { | ||
| 4712 | char *np = cp; | ||
| 4713 | |||
| 4714 | cp = skip_name (cp); | ||
| 4715 | if (reader) | ||
| 4716 | make_tag (np, cp - np, true, | ||
| 4717 | lb.buffer, cp - lb.buffer + 1, | ||
| 4718 | lineno, linecharno); | ||
| 4719 | if (writer) | ||
| 4720 | { | ||
| 4721 | size_t name_len = cp - np + 1; | ||
| 4722 | char *wr_name = xnew (name_len + 1, char); | ||
| 4723 | |||
| 4724 | memcpy (wr_name, np, name_len - 1); | ||
| 4725 | memcpy (wr_name + name_len - 1, "=", 2); | ||
| 4726 | pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1, | ||
| 4727 | lineno, linecharno); | ||
| 4728 | } | ||
| 4729 | if (alias) | ||
| 4730 | { | ||
| 4731 | make_tag (np, cp - np, true, | ||
| 4732 | lb.buffer, cp - lb.buffer + 1, | ||
| 4733 | lineno, linecharno); | ||
| 4734 | while (*cp && *cp != '#' && *cp != ';') | ||
| 4735 | cp++; | ||
| 4736 | } | ||
| 4737 | } while (*cp == ',' | ||
| 4738 | && (cp = skip_spaces (cp + 1), *cp && *cp != '#')); | ||
| 4739 | } | ||
| 4740 | cp = skip_name (cp); | ||
| 4741 | while (*cp && *cp != '#' && notinname (*cp)) | ||
| 4742 | cp++; | ||
| 4743 | } | ||
| 4744 | } | ||
| 4691 | } | 4745 | } |
| 4692 | } | 4746 | } |
| 4693 | 4747 | ||