diff options
| author | Eli Zaretskii | 2016-02-03 18:24:20 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-02-03 18:24:20 +0200 |
| commit | 504696d75dbd9b8159490ec4cd9da2b5578f2934 (patch) | |
| tree | 7ee9b67365486af65f179e62860d4c2fcb2d3155 /lib-src | |
| parent | 8784ebf3a9f94c64cd09149c4906a3f494a1251d (diff) | |
| download | emacs-504696d75dbd9b8159490ec4cd9da2b5578f2934.tar.gz emacs-504696d75dbd9b8159490ec4cd9da2b5578f2934.zip | |
Etags: yet another improvement in Ruby tags
* lib-src/etags.c (Ruby_functions): Handle continuation lines in
Ruby accessor definitions. (Bug#22241)
* test/etags/ruby-src/test1.ru (A::B#X): Add some more tests for
accessors and multiline definitions.
* 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 tags.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 77 |
1 files changed, 53 insertions, 24 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index ca6fe51bdb6..bb2758941a4 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -4630,6 +4630,7 @@ static void | |||
| 4630 | Ruby_functions (FILE *inf) | 4630 | Ruby_functions (FILE *inf) |
| 4631 | { | 4631 | { |
| 4632 | char *cp = NULL; | 4632 | char *cp = NULL; |
| 4633 | bool reader = false, writer = false, alias = false, continuation = false; | ||
| 4633 | 4634 | ||
| 4634 | LOOP_ON_INPUT_LINES (inf, lb, cp) | 4635 | LOOP_ON_INPUT_LINES (inf, lb, cp) |
| 4635 | { | 4636 | { |
| @@ -4638,7 +4639,9 @@ Ruby_functions (FILE *inf) | |||
| 4638 | char *name; | 4639 | char *name; |
| 4639 | 4640 | ||
| 4640 | cp = skip_spaces (cp); | 4641 | cp = skip_spaces (cp); |
| 4641 | if (c_isalpha (*cp) && c_isupper (*cp)) /* constants */ | 4642 | if (!continuation |
| 4643 | /* Constants. */ | ||
| 4644 | && c_isalpha (*cp) && c_isupper (*cp)) | ||
| 4642 | { | 4645 | { |
| 4643 | char *bp, *colon = NULL; | 4646 | char *bp, *colon = NULL; |
| 4644 | 4647 | ||
| @@ -4661,9 +4664,11 @@ Ruby_functions (FILE *inf) | |||
| 4661 | } | 4664 | } |
| 4662 | } | 4665 | } |
| 4663 | } | 4666 | } |
| 4664 | else if ((is_method = LOOKING_AT (cp, "def")) /* module/class/method */ | 4667 | else if (!continuation |
| 4665 | || (is_class = LOOKING_AT (cp, "class")) | 4668 | /* Modules, classes, methods. */ |
| 4666 | || LOOKING_AT (cp, "module")) | 4669 | && ((is_method = LOOKING_AT (cp, "def")) |
| 4670 | || (is_class = LOOKING_AT (cp, "class")) | ||
| 4671 | || LOOKING_AT (cp, "module"))) | ||
| 4667 | { | 4672 | { |
| 4668 | const char self_name[] = "self."; | 4673 | const char self_name[] = "self."; |
| 4669 | const size_t self_size1 = sizeof (self_name) - 1; | 4674 | const size_t self_size1 = sizeof (self_name) - 1; |
| @@ -4701,21 +4706,27 @@ Ruby_functions (FILE *inf) | |||
| 4701 | else | 4706 | else |
| 4702 | { | 4707 | { |
| 4703 | /* Tag accessors and aliases. */ | 4708 | /* Tag accessors and aliases. */ |
| 4709 | |||
| 4710 | if (!continuation) | ||
| 4711 | reader = writer = alias = false; | ||
| 4712 | |||
| 4704 | while (*cp && *cp != '#') | 4713 | while (*cp && *cp != '#') |
| 4705 | { | 4714 | { |
| 4706 | bool reader = false, writer = false, alias = false; | 4715 | if (!continuation) |
| 4707 | |||
| 4708 | if (LOOKING_AT (cp, "attr_reader")) | ||
| 4709 | reader = true; | ||
| 4710 | else if (LOOKING_AT (cp, "attr_writer")) | ||
| 4711 | writer = true; | ||
| 4712 | else if (LOOKING_AT (cp, "attr_accessor")) | ||
| 4713 | { | 4716 | { |
| 4714 | reader = true; | 4717 | reader = writer = alias = false; |
| 4715 | writer = true; | 4718 | if (LOOKING_AT (cp, "attr_reader")) |
| 4719 | reader = true; | ||
| 4720 | else if (LOOKING_AT (cp, "attr_writer")) | ||
| 4721 | writer = true; | ||
| 4722 | else if (LOOKING_AT (cp, "attr_accessor")) | ||
| 4723 | { | ||
| 4724 | reader = true; | ||
| 4725 | writer = true; | ||
| 4726 | } | ||
| 4727 | else if (LOOKING_AT (cp, "alias_method")) | ||
| 4728 | alias = true; | ||
| 4716 | } | 4729 | } |
| 4717 | else if (LOOKING_AT (cp, "alias_method")) | ||
| 4718 | alias = true; | ||
| 4719 | if (reader || writer || alias) | 4730 | if (reader || writer || alias) |
| 4720 | { | 4731 | { |
| 4721 | do { | 4732 | do { |
| @@ -4725,9 +4736,12 @@ Ruby_functions (FILE *inf) | |||
| 4725 | np++; | 4736 | np++; |
| 4726 | cp = skip_name (cp); | 4737 | cp = skip_name (cp); |
| 4727 | if (reader) | 4738 | if (reader) |
| 4728 | make_tag (np, cp - np, true, | 4739 | { |
| 4729 | lb.buffer, cp - lb.buffer + 1, | 4740 | make_tag (np, cp - np, true, |
| 4730 | lineno, linecharno); | 4741 | lb.buffer, cp - lb.buffer + 1, |
| 4742 | lineno, linecharno); | ||
| 4743 | continuation = false; | ||
| 4744 | } | ||
| 4731 | if (writer) | 4745 | if (writer) |
| 4732 | { | 4746 | { |
| 4733 | size_t name_len = cp - np + 1; | 4747 | size_t name_len = cp - np + 1; |
| @@ -4737,19 +4751,34 @@ Ruby_functions (FILE *inf) | |||
| 4737 | memcpy (wr_name + name_len - 1, "=", 2); | 4751 | memcpy (wr_name + name_len - 1, "=", 2); |
| 4738 | pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1, | 4752 | pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1, |
| 4739 | lineno, linecharno); | 4753 | lineno, linecharno); |
| 4754 | continuation = false; | ||
| 4740 | } | 4755 | } |
| 4741 | if (alias) | 4756 | if (alias) |
| 4742 | { | 4757 | { |
| 4743 | make_tag (np, cp - np, true, | 4758 | if (!continuation) |
| 4744 | lb.buffer, cp - lb.buffer + 1, | 4759 | make_tag (np, cp - np, true, |
| 4745 | lineno, linecharno); | 4760 | lb.buffer, cp - lb.buffer + 1, |
| 4761 | lineno, linecharno); | ||
| 4762 | continuation = false; | ||
| 4746 | while (*cp && *cp != '#' && *cp != ';') | 4763 | while (*cp && *cp != '#' && *cp != ';') |
| 4747 | cp++; | 4764 | { |
| 4765 | if (*cp == ',') | ||
| 4766 | continuation = true; | ||
| 4767 | else if (!c_isspace (*cp)) | ||
| 4768 | continuation = false; | ||
| 4769 | cp++; | ||
| 4770 | } | ||
| 4771 | if (*cp == ';') | ||
| 4772 | continuation = false; | ||
| 4748 | } | 4773 | } |
| 4749 | } while (*cp == ',' | 4774 | cp = skip_spaces (cp); |
| 4775 | } while ((alias | ||
| 4776 | ? (*cp == ',') | ||
| 4777 | : (continuation = (*cp == ','))) | ||
| 4750 | && (cp = skip_spaces (cp + 1), *cp && *cp != '#')); | 4778 | && (cp = skip_spaces (cp + 1), *cp && *cp != '#')); |
| 4751 | } | 4779 | } |
| 4752 | cp = skip_name (cp); | 4780 | if (*cp != '#') |
| 4781 | cp = skip_name (cp); | ||
| 4753 | while (*cp && *cp != '#' && notinname (*cp)) | 4782 | while (*cp && *cp != '#' && notinname (*cp)) |
| 4754 | cp++; | 4783 | cp++; |
| 4755 | } | 4784 | } |