[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 504696d: Etags: yet another improvement in Ruby t
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-25 504696d: Etags: yet another improvement in Ruby tags |
Date: |
Wed, 03 Feb 2016 16:25:37 +0000 |
branch: emacs-25
commit 504696d75dbd9b8159490ec4cd9da2b5578f2934
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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.
---
lib-src/etags.c | 77 +++++++++++++++++++++++++++++-------------
test/etags/CTAGS.good | 18 ++++++----
test/etags/ETAGS.good_1 | 24 ++++++++-----
test/etags/ETAGS.good_2 | 24 ++++++++-----
test/etags/ETAGS.good_3 | 24 ++++++++-----
test/etags/ETAGS.good_4 | 24 ++++++++-----
test/etags/ETAGS.good_5 | 24 ++++++++-----
test/etags/ETAGS.good_6 | 24 ++++++++-----
test/etags/ruby-src/test1.ru | 10 ++++--
9 files changed, 155 insertions(+), 94 deletions(-)
diff --git a/lib-src/etags.c b/lib-src/etags.c
index ca6fe51..bb27589 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -4630,6 +4630,7 @@ static void
Ruby_functions (FILE *inf)
{
char *cp = NULL;
+ bool reader = false, writer = false, alias = false, continuation = false;
LOOP_ON_INPUT_LINES (inf, lb, cp)
{
@@ -4638,7 +4639,9 @@ Ruby_functions (FILE *inf)
char *name;
cp = skip_spaces (cp);
- if (c_isalpha (*cp) && c_isupper (*cp)) /* constants */
+ if (!continuation
+ /* Constants. */
+ && c_isalpha (*cp) && c_isupper (*cp))
{
char *bp, *colon = NULL;
@@ -4661,9 +4664,11 @@ Ruby_functions (FILE *inf)
}
}
}
- else if ((is_method = LOOKING_AT (cp, "def")) /* module/class/method */
- || (is_class = LOOKING_AT (cp, "class"))
- || LOOKING_AT (cp, "module"))
+ else if (!continuation
+ /* Modules, classes, methods. */
+ && ((is_method = LOOKING_AT (cp, "def"))
+ || (is_class = LOOKING_AT (cp, "class"))
+ || LOOKING_AT (cp, "module")))
{
const char self_name[] = "self.";
const size_t self_size1 = sizeof (self_name) - 1;
@@ -4701,21 +4706,27 @@ Ruby_functions (FILE *inf)
else
{
/* Tag accessors and aliases. */
+
+ if (!continuation)
+ reader = writer = alias = false;
+
while (*cp && *cp != '#')
{
- bool reader = false, writer = false, alias = false;
-
- if (LOOKING_AT (cp, "attr_reader"))
- reader = true;
- else if (LOOKING_AT (cp, "attr_writer"))
- writer = true;
- else if (LOOKING_AT (cp, "attr_accessor"))
+ if (!continuation)
{
- reader = true;
- writer = true;
+ reader = writer = alias = false;
+ if (LOOKING_AT (cp, "attr_reader"))
+ reader = true;
+ else if (LOOKING_AT (cp, "attr_writer"))
+ writer = true;
+ else if (LOOKING_AT (cp, "attr_accessor"))
+ {
+ reader = true;
+ writer = true;
+ }
+ else if (LOOKING_AT (cp, "alias_method"))
+ alias = true;
}
- else if (LOOKING_AT (cp, "alias_method"))
- alias = true;
if (reader || writer || alias)
{
do {
@@ -4725,9 +4736,12 @@ Ruby_functions (FILE *inf)
np++;
cp = skip_name (cp);
if (reader)
- make_tag (np, cp - np, true,
- lb.buffer, cp - lb.buffer + 1,
- lineno, linecharno);
+ {
+ make_tag (np, cp - np, true,
+ lb.buffer, cp - lb.buffer + 1,
+ lineno, linecharno);
+ continuation = false;
+ }
if (writer)
{
size_t name_len = cp - np + 1;
@@ -4737,19 +4751,34 @@ Ruby_functions (FILE *inf)
memcpy (wr_name + name_len - 1, "=", 2);
pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1,
lineno, linecharno);
+ continuation = false;
}
if (alias)
{
- make_tag (np, cp - np, true,
- lb.buffer, cp - lb.buffer + 1,
- lineno, linecharno);
+ if (!continuation)
+ make_tag (np, cp - np, true,
+ lb.buffer, cp - lb.buffer + 1,
+ lineno, linecharno);
+ continuation = false;
while (*cp && *cp != '#' && *cp != ';')
- cp++;
+ {
+ if (*cp == ',')
+ continuation = true;
+ else if (!c_isspace (*cp))
+ continuation = false;
+ cp++;
+ }
+ if (*cp == ';')
+ continuation = false;
}
- } while (*cp == ','
+ cp = skip_spaces (cp);
+ } while ((alias
+ ? (*cp == ',')
+ : (continuation = (*cp == ',')))
&& (cp = skip_spaces (cp + 1), *cp && *cp != '#'));
}
- cp = skip_name (cp);
+ if (*cp != '#')
+ cp = skip_name (cp);
while (*cp && *cp != '#' && notinname (*cp))
cp++;
}
diff --git a/test/etags/CTAGS.good b/test/etags/CTAGS.good
index afb1096..b78c194 100644
--- a/test/etags/CTAGS.good
+++ b/test/etags/CTAGS.good
@@ -454,7 +454,7 @@ Condition_Variable/t ada-src/2ataspri.ads /^
type Condition_Variable is privat
Condition_Variable/t ada-src/2ataspri.ads /^ type Condition_Variable
is$/
Configure pyt-src/server.py /^class Configure(Frame, ControlEdit):$/
ConfirmQuit pyt-src/server.py /^def ConfirmQuit(frame, context):$/
-Constant ruby-src/test1.ru 35
+Constant ruby-src/test1.ru 39
ControlEdit pyt-src/server.py /^class ControlEdit(Frame):$/
Controls pyt-src/server.py /^class Controls:$/
CopyTextString pas-src/common.pas /^function CopyTextString;(*($/
@@ -2556,11 +2556,12 @@ bar c-src/c.c /^void bar() {while(0) {}}$/
bar c.c 143
bar c-src/h.h 19
bar cp-src/x.cc /^XX::bar()$/
-bar= ruby-src/test1.ru /^ attr_writer :bar$/
+bar= ruby-src/test1.ru /^ attr_writer :bar,$/
bas_syn prol-src/natded.prolog /^bas_syn(n(_)).$/
base c-src/emacs/src/lisp.h 2188
base cp-src/c.C /^double base (void) const { return rng_base; }$/
base cp-src/Range.h /^ double base (void) const { return rng_base; }$/
+baz= ruby-src/test1.ru /^ :baz,$/
bb c.c 275
bbb c.c 251
bbbbbb c-src/h.h 113
@@ -3514,6 +3515,7 @@ modifier_symbols c-src/emacs/src/keyboard.c 6327
modify_event_symbol c-src/emacs/src/keyboard.c /^modify_event_symbol
(ptrdiff_t symbol_num, int mod/
module_class_method ruby-src/test.rb /^ def
ModuleExample.module_class_method$/
module_instance_method ruby-src/test.rb /^ def
module_instance_method$/
+more= ruby-src/test1.ru /^ :more$/
more_aligned_int c.c 165
morecore_nolock c-src/emacs/src/gmalloc.c /^morecore_nolock
(size_t size)$/
morecore_recursing c-src/emacs/src/gmalloc.c 604
@@ -3879,7 +3881,7 @@ questo ../c/c.web 34
quiettest make-src/Makefile /^quiettest:$/
quit_char c-src/emacs/src/keyboard.c 192
quit_throw_to_read_char c-src/emacs/src/keyboard.c
/^quit_throw_to_read_char (bool from_signal)$/
-qux ruby-src/test1.ru /^ alias_method :qux, :tee$/
+qux ruby-src/test1.ru /^ alias_method :qux, :tee, attr_accessor
:bogu/
qux= ruby-src/test1.ru /^ def qux=(tee)$/
r0 c-src/sysdep.h 54
r1 c-src/sysdep.h 55
@@ -3904,8 +3906,8 @@ read cp-src/conway.hpp /^ char read() {
return alive; }$/
read php-src/lce_functions.php /^ function read()$/
read-key-sequence c-src/emacs/src/keyboard.c /^DEFUN
("read-key-sequence", Fread_key_sequence, Sr/
read-key-sequence-vector c-src/emacs/src/keyboard.c /^DEFUN
("read-key-sequence-vector", Fread_key_seque/
-read1 ruby-src/test1.ru /^ attr_reader :read1, :read2; attr_writer
:wri/
-read2 ruby-src/test1.ru /^ attr_reader :read1, :read2; attr_writer
:wri/
+read1 ruby-src/test1.ru /^ attr_reader :read1 , :read2;
attr_writer :wr/
+read2 ruby-src/test1.ru /^ attr_reader :read1 , :read2;
attr_writer :wr/
read_char c-src/emacs/src/keyboard.c /^read_char (int commandflag,
Lisp_Object map,$/
read_char_help_form_unwind c-src/emacs/src/keyboard.c
/^read_char_help_form_unwind (void)$/
read_char_minibuf_menu_prompt c-src/emacs/src/keyboard.c
/^read_char_minibuf_menu_prompt (int commandflag,$/
@@ -4164,6 +4166,7 @@ substitute c-src/etags.c /^substitute (char *in,
char *out, struct re_registe/
subsubsec=\relax tex-src/texinfo.tex
/^\\let\\appendixsubsubsec=\\relax$/
subsubsection perl-src/htlmify-cystic 27
subsubsection=\relax tex-src/texinfo.tex
/^\\let\\appendixsubsubsection=\\relax$/
+subtle ruby-src/test1.ru /^ :tee ; attr_reader
:subtle$/
subtree prol-src/natded.prolog /^subtree(T,T).$/
suffix c-src/etags.c 186
suffixes c-src/etags.c 195
@@ -4450,8 +4453,8 @@ womboid c-src/h.h 75
word_size c-src/emacs/src/lisp.h 1473
write php-src/lce_functions.php /^ function write()$/
write php-src/lce_functions.php /^ function write($save="yes")$/
-write1= ruby-src/test1.ru /^ attr_reader :read1, :read2;
attr_writer :wri/
-write2= ruby-src/test1.ru /^ attr_reader :read1, :read2;
attr_writer :wri/
+write1= ruby-src/test1.ru /^ attr_reader :read1 , :read2;
attr_writer :wr/
+write2= ruby-src/test1.ru /^ attr_reader :read1 , :read2;
attr_writer :wr/
write_abbrev c-src/abbrev.c /^write_abbrev (sym, stream)$/
write_classname c-src/etags.c /^write_classname (linebuffer *cn,
const char *quali/
write_lex prol-src/natded.prolog /^write_lex(File):-$/
@@ -4492,6 +4495,7 @@ xref-location-marker
el-src/emacs/lisp/progmodes/etags.el /^(cl-defmethod xref-l
xref-make-etags-location el-src/emacs/lisp/progmodes/etags.el
/^(defun xref-make-etags-location (tag-info file)$/
xrnew c-src/etags.c /^#define xrnew(op, n, Type) ((op) = (Type *) xreall/
xx make-src/Makefile /^xx="this line is here because of a fontlock
bug$/
+xyz ruby-src/test1.ru /^ alias_method :xyz,$/
y cp-src/conway.hpp 7
y cp-src/clheir.hpp 49
y cp-src/clheir.hpp 58
diff --git a/test/etags/ETAGS.good_1 b/test/etags/ETAGS.good_1
index 87ab88f..1390187 100644
--- a/test/etags/ETAGS.good_1
+++ b/test/etags/ETAGS.good_1
@@ -3061,7 +3061,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -3075,15 +3075,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ETAGS.good_2 b/test/etags/ETAGS.good_2
index 8615982..f8b1546 100644
--- a/test/etags/ETAGS.good_2
+++ b/test/etags/ETAGS.good_2
@@ -3631,7 +3631,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -3645,15 +3645,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ETAGS.good_3 b/test/etags/ETAGS.good_3
index 52d5a61..a1e895a 100644
--- a/test/etags/ETAGS.good_3
+++ b/test/etags/ETAGS.good_3
@@ -3408,7 +3408,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -3422,15 +3422,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ETAGS.good_4 b/test/etags/ETAGS.good_4
index 333274c..32390fa 100644
--- a/test/etags/ETAGS.good_4
+++ b/test/etags/ETAGS.good_4
@@ -3225,7 +3225,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -3239,15 +3239,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ETAGS.good_5 b/test/etags/ETAGS.good_5
index fdf2329..ee19bcf 100644
--- a/test/etags/ETAGS.good_5
+++ b/test/etags/ETAGS.good_5
@@ -4142,7 +4142,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -4156,15 +4156,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ETAGS.good_6 b/test/etags/ETAGS.good_6
index 95d59d3..f4d9ab8 100644
--- a/test/etags/ETAGS.good_6
+++ b/test/etags/ETAGS.good_6
@@ -4142,7 +4142,7 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
-ruby-src/test1.ru,655
+ruby-src/test1.ru,828
class A1,0
def a(2,8
def b(5,38
@@ -4156,15 +4156,19 @@ module A9,57
def qux=(qux=22,194
def X25,232
attr_reader :foofoo26,242
- attr_reader :read1,read127,265
- attr_reader :read1, :read2;read227,265
- attr_reader :read1, :read2; attr_writer :write1,write1=27,265
- attr_reader :read1, :read2; attr_writer :write1, :write2write2=27,265
- attr_writer :barbar=28,328
- attr_accessor :teetee29,351
- attr_accessor :teetee=29,351
- alias_method :qux,qux30,376
-A::Constant Constant35,425
+ attr_reader :read1 read127,265
+ attr_reader :read1 , :read2;read227,265
+ attr_reader :read1 , :read2; attr_writer :write1,write1=27,265
+ attr_reader :read1 , :read2; attr_writer :write1, :write2write2=27,265
+ attr_writer :bar,bar=28,329
+ :baz,baz=29,353
+ :moremore=30,377
+ attr_accessor :teetee31,401
+ attr_accessor :teetee=31,401
+ alias_method :qux,qux32,426
+ alias_method :xyz,xyz33,478
+ :tee ; attr_reader :subtlesubtle34,503
+A::Constant Constant39,568
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
diff --git a/test/etags/ruby-src/test1.ru b/test/etags/ruby-src/test1.ru
index 75dcd51..bc9dbec 100644
--- a/test/etags/ruby-src/test1.ru
+++ b/test/etags/ruby-src/test1.ru
@@ -24,10 +24,14 @@ module A
end
def X
attr_reader :foo
- attr_reader :read1, :read2; attr_writer :write1, :write2
- attr_writer :bar
+ attr_reader :read1 , :read2; attr_writer :write1, :write2
+ attr_writer :bar,
+ :baz,
+ :more
attr_accessor :tee
- alias_method :qux, :tee
+ alias_method :qux, :tee, attr_accessor :bogus
+ alias_method :xyz,
+ :tee ; attr_reader :subtle
end
end
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 504696d: Etags: yet another improvement in Ruby tags,
Eli Zaretskii <=