summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-12-11 11:17:31 +0200
committerEli Zaretskii <eliz@gnu.org>2015-12-11 11:17:31 +0200
commitcabe9044380df45c1d5d57243955b49de721861a (patch)
tree126cc068eceedef7451a1b2695b238167bb1d167
parent95b6e13c13e4de9cdd0c3659d4864b17bafd040e (diff)
Improve and document Ruby support in 'etags'
* lib-src/etags.c (Ruby_suffixes): Add ".ruby". (Ruby_functions): Support "module" and overloaded operators. (Ruby_help): Mention "module". * test/etags/ruby-src/test.rb: * test/etags/ruby-src/test1.ruby: New files. * test/etags/Makefile (RBSRC): New tests. (SRCS): Add ${RBSRC}. * 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 new Ruby tests. * doc/man/etags.1: Mention Ruby support. * etc/NEWS: Mention Ruby support.
-rw-r--r--doc/man/etags.12
-rw-r--r--etc/NEWS8
-rw-r--r--lib-src/etags.c18
-rw-r--r--test/etags/CTAGS.good21
-rw-r--r--test/etags/ETAGS.good_125
-rw-r--r--test/etags/ETAGS.good_225
-rw-r--r--test/etags/ETAGS.good_325
-rw-r--r--test/etags/ETAGS.good_425
-rw-r--r--test/etags/ETAGS.good_525
-rw-r--r--test/etags/ETAGS.good_625
-rw-r--r--test/etags/Makefile3
-rw-r--r--test/etags/ruby-src/test.rb54
-rw-r--r--test/etags/ruby-src/test1.ruby7
13 files changed, 253 insertions, 10 deletions
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index fab8901427..7cb6b6cb6a 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -51,7 +51,7 @@ format understood by
\&. Both forms of the program understand
the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Erlang,
Forth, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Pascal, Perl,
-PHP, PostScript, Python, Prolog, Scheme and
+Ruby, PHP, PostScript, Python, Prolog, Scheme and
most assembler\-like syntaxes.
Both forms read the files specified on the command line, and write a tag
table (defaults: \fBTAGS\fP for \fBetags\fP, \fBtags\fP for
diff --git a/etc/NEWS b/etc/NEWS
index 4bcf32658c..0c9296acab 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1444,9 +1444,10 @@ is strongly dedicated to its buffer.
** Tearoff menus and detachable toolbars for Gtk+ has been removed.
Those features have been deprecated in Gtk+ for a long time.
-** Miscellaneous
+** Etags
*** etags no longer qualifies class members by default.
+
By default, `etags' will not qualify class members for C-like
object-oriented languages with their class names and namespaces, and
will remove qualifications used explicitly in the code from the tag
@@ -1460,6 +1461,11 @@ using -Q might make some class members become "unknown" to `M-.'
(`xref-find-definitions'); if so, you can use `C-u M-.' to specify the
qualified names by hand.
+*** New language Ruby
+
+Names of modules, classes, methods, and functions are tagged.
+Overloaded operators are also tagged.
+
* Changes in Emacs 25.1 on Non-Free Operating Systems
diff --git a/lib-src/etags.c b/lib-src/etags.c
index c91cef40bf..cd49f7199b 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -724,10 +724,10 @@ static const char Python_help [] =
generate a tag.";
static const char *Ruby_suffixes [] =
- { "rb", NULL };
+ { "rb", "ruby", NULL };
static const char Ruby_help [] =
- "In Ruby code, 'def' or 'class' at the beginning of a line\n\
-generate a tag.";
+ "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\
+a line generate a tag.";
/* Can't do the `SCM' or `scm' prefix with a version number. */
static const char *Scheme_suffixes [] =
@@ -4552,15 +4552,19 @@ Ruby_functions (FILE *inf)
LOOP_ON_INPUT_LINES (inf, lb, cp)
{
cp = skip_spaces (cp);
- if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
+ if (LOOKING_AT (cp, "def")
+ || LOOKING_AT (cp, "class")
+ || LOOKING_AT (cp, "module"))
{
char *name = cp;
- while (!notinname (*cp))
+ /* Ruby method names can end in a '='. Also, operator overloading can
+ define operators whose names include '='. */
+ while (!notinname (*cp) || *cp == '=')
cp++;
- make_tag(name, cp -name, true,
- lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+ make_tag (name, cp - name, true,
+ lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
}
}
}
diff --git a/test/etags/CTAGS.good b/test/etags/CTAGS.good
index c98e1388d3..3186ff667e 100644
--- a/test/etags/CTAGS.good
+++ b/test/etags/CTAGS.good
@@ -46,6 +46,7 @@ $user_comment_lc php-src/lce_functions.php 115
($string,$flag,@string,@temp,@last perl-src/yagrip.pl 40
(a-forth-constant forth-src/test-forth.fth /^constant (a-forth-constant$/
(another-forth-word forth-src/test-forth.fth /^: (another-forth-word) ( -- )$/
++ ruby-src/test.rb /^ def +(y)$/
+ tex-src/texinfo.tex /^\\def+{{\\tt \\char 43}}$/
/.notdef ps-src/rfc1245.ps /^\/.notdef \/.notdef \/.notdef \/.notdef \/.notdef \/.not/
/.notdef ps-src/rfc1245.ps /^\/.notdef \/.notdef \/.notdef \/.notdef \/.notdef \/.not/
@@ -177,6 +178,9 @@ $user_comment_lc php-src/lce_functions.php 115
/yen ps-src/rfc1245.ps /^\/yen \/.notdef \/.notdef \/.notdef \/.notdef \/.notdef /
:a-forth-dictionary-entry forth-src/test-forth.fth /^create :a-forth-dictionary-entry$/
< tex-src/texinfo.tex /^\\def<{{\\tt \\less}}$/
+<< ruby-src/test.rb /^ def <<(y)$/
+<= ruby-src/test.rb /^ def <=(y)$/
+<=> ruby-src/test.rb /^ def <=>(y)$/
= tex-src/texinfo.tex /^\\global\\let\\section = \\numberedsec$/
= tex-src/texinfo.tex /^\\global\\let\\subsection = \\numberedsubsec$/
= tex-src/texinfo.tex /^\\global\\let\\subsubsection = \\numberedsubsubsec$/
@@ -191,6 +195,8 @@ $user_comment_lc php-src/lce_functions.php 115
= tex-src/texinfo.tex /^\\global\\let\\subsubsection = \\numberedsubsubsec$/
= tex-src/texinfo.tex /^\\global\\def={{\\tt \\char 61}}}$/
=/f ada-src/etags-test-for.ada /^ function "=" (L, R : System.Address) return Boo/
+== ruby-src/test.rb /^ def ==(y)$/
+=== ruby-src/test.rb /^ def ===(y)$/
=\indexdummyfont tex-src/texinfo.tex /^\\let\\cite=\\indexdummyfont$/
=\relax tex-src/texinfo.tex /^\\let\\chapter=\\relax$/
=\relax tex-src/texinfo.tex /^\\let\\section=\\relax$/
@@ -220,6 +226,7 @@ A cp-src/c.C 73
A cp-src/c.C 117
A cp-src/fail.C 7
A cp-src/fail.C 23
+A ruby-src/test1.ruby /^class A$/
ADDRESS c-src/emacs/src/gmalloc.c /^#define ADDRESS(B) ((void *) (((B) - 1) * BLOCKSIZ/
ALIGNOF_STRUCT_LISP_VECTOR c-src/emacs/src/lisp.h 1378
ALLOCATED_BEFORE_DUMPING c-src/emacs/src/gmalloc.c /^#define ALLOCATED_BEFORE_DUMPING(P) \\$/
@@ -430,6 +437,8 @@ Circle.getPos lua-src/test.lua /^function Circle.getPos ()$/
Cjava_entries c-src/etags.c /^Cjava_entries (FILE *inf)$/
Cjava_help c-src/etags.c 551
Cjava_suffixes c-src/etags.c 549
+ClassExample ruby-src/test.rb /^ class ClassExample$/
+ClassExample.singleton_class_method ruby-src/test.rb /^ def ClassExample.singleton_class_method$/
Clear/p ada-src/2ataspri.adb /^ procedure Clear (Cell : in out TAS_Cell) is$/
Clear/p ada-src/2ataspri.ads /^ procedure Clear (Cell : in out TAS_Cell)/
Cobol_help c-src/etags.c 558
@@ -929,6 +938,8 @@ Mconway.cpp cp-src/conway.cpp /^void main(void)$/
Metags c-src/etags.c /^main (int argc, char **argv)$/
Mfail cp-src/fail.C /^main()$/
Mkai-test.pl perl-src/kai-test.pl /^package main;$/
+ModuleExample ruby-src/test.rb /^module ModuleExample$/
+ModuleExample.singleton_module_method ruby-src/test.rb /^ def ModuleExample.singleton_module_method$/
More_Lisp_Bits c-src/emacs/src/lisp.h 801
MoveLayerAfter lua-src/allegro.lua /^function MoveLayerAfter (this_one)$/
MoveLayerBefore lua-src/allegro.lua /^function MoveLayerBefore (this_one)$/
@@ -1652,6 +1663,8 @@ Yacc_entries c-src/etags.c /^Yacc_entries (FILE *inf)$/
Yacc_help c-src/etags.c 693
Yacc_suffixes c-src/etags.c 691
Z c-src/h.h 100
+[] ruby-src/test.rb /^ def [](y)$/
+[]= ruby-src/test.rb /^ def []=(y, val)$/
\ tex-src/texinfo.tex /^\\def\\ {{\\fontdimen2\\font=\\tclosesave{} }}%$/
\ tex-src/texinfo.tex /^\\gdef\\sepspaces{\\def {\\ }}}$/
\' tex-src/texinfo.tex /^\\def\\'{{'}}$/
@@ -2358,6 +2371,7 @@ _malloc_thread_enabled_p c-src/emacs/src/gmalloc.c 519
_realloc c-src/emacs/src/gmalloc.c /^_realloc (void *ptr, size_t size)$/
_realloc_internal c-src/emacs/src/gmalloc.c /^_realloc_internal (void *ptr, size_t size)$/
_realloc_internal_nolock c-src/emacs/src/gmalloc.c /^_realloc_internal_nolock (void *ptr, size_t size)$/
+` ruby-src/test.rb /^ def `(command)$/
a c.c 152
a c.c 180
a c.c /^a()$/
@@ -2365,6 +2379,7 @@ a c.c /^a ()$/
a c-src/h.h 40
a c-src/h.h 103
a cp-src/c.C 132
+a ruby-src/test1.ruby /^ def a()$/
a-forth-constant! forth-src/test-forth.fth /^99 constant a-forth-constant!$/
a-forth-value? forth-src/test-forth.fth /^55 value a-forth-value?$/
a-forth-word forth-src/test-forth.fth /^: a-forth-word ( a b c -- a*b+c ) + * ;$/
@@ -2489,6 +2504,7 @@ b c-src/h.h 41
b c-src/h.h 103
b c-src/h.h 104
b cp-src/c.C 132
+b ruby-src/test1.ruby /^ def b()$/
backslash=0 tex-src/texinfo.tex /^\\let\\indexbackslash=0 %overridden during \\printin/
bar c-src/c.c /^void bar() {while(0) {}}$/
bar c.c 143
@@ -2604,6 +2620,10 @@ childDidExit objc-src/Subprocess.m /^- childDidExit$/
chunks_free c-src/emacs/src/gmalloc.c 313
chunks_used c-src/emacs/src/gmalloc.c 311
cjava c-src/etags.c 2936
+class_method ruby-src/test.rb /^ def class_method$/
+class_method_equals= ruby-src/test.rb /^ def class_method_equals=$/
+class_method_exclamation! ruby-src/test.rb /^ def class_method_exclamation!$/
+class_method_question? ruby-src/test.rb /^ def class_method_question?$/
classifyLine php-src/lce_functions.php /^ function classifyLine($line)$/
clear cp-src/conway.hpp /^ void clear(void) { alive = 0; }$/
clear-abbrev-table c-src/abbrev.c /^DEFUN ("clear-abbrev-table", Fclear_abbrev_table, /
@@ -3428,6 +3448,7 @@ miti html-src/softwarelibero.html /^Sfatiamo alcuni miti$/
modifier_names c-src/emacs/src/keyboard.c 6319
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_method ruby-src/test.rb /^ def module_method$/
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
diff --git a/test/etags/ETAGS.good_1 b/test/etags/ETAGS.good_1
index 5a5e5d2c3c..1c4664d47a 100644
--- a/test/etags/ETAGS.good_1
+++ b/test/etags/ETAGS.good_1
@@ -2973,6 +2973,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/ETAGS.good_2 b/test/etags/ETAGS.good_2
index 3e5285af1c..5f82e8c6b1 100644
--- a/test/etags/ETAGS.good_2
+++ b/test/etags/ETAGS.good_2
@@ -3544,6 +3544,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/ETAGS.good_3 b/test/etags/ETAGS.good_3
index 2f91126e1d..8ab9dc3748 100644
--- a/test/etags/ETAGS.good_3
+++ b/test/etags/ETAGS.good_3
@@ -3317,6 +3317,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/ETAGS.good_4 b/test/etags/ETAGS.good_4
index 71fc2cbda8..39a2f6efe7 100644
--- a/test/etags/ETAGS.good_4
+++ b/test/etags/ETAGS.good_4
@@ -3137,6 +3137,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/ETAGS.good_5 b/test/etags/ETAGS.good_5
index ca55b3b0ad..a820d81208 100644
--- a/test/etags/ETAGS.good_5
+++ b/test/etags/ETAGS.good_5
@@ -4052,6 +4052,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/ETAGS.good_6 b/test/etags/ETAGS.good_6
index 1ec846334e..c305147044 100644
--- a/test/etags/ETAGS.good_6
+++ b/test/etags/ETAGS.good_6
@@ -4052,6 +4052,31 @@ class Configure(760,24879
def save(797,26022
def nosave(807,26310
+ruby-src/test.rb,594
+module ModuleExample1,0
+ class ClassExample2,21
+ def class_method3,44
+ def ClassExample.singleton_class_method6,116
+ def class_method_exclamation!9,221
+ def class_method_question?12,319
+ def class_method_equals=class_method_equals=15,411
+ def `(18,499
+ def +(21,589
+ def [](24,637
+ def []=([]=27,687
+ def <<(30,749
+ def ==(==33,799
+ def <=(<=36,869
+ def <=>(<=>39,940
+ def ===(===42,987
+ def module_method46,1048
+ def ModuleExample.singleton_module_method49,1110
+
+ruby-src/test1.ruby,37
+class A1,0
+ def a(2,8
+ def b(5,38
+
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
\section{blah}blah8,139
diff --git a/test/etags/Makefile b/test/etags/Makefile
index 1c50f72597..00d5b9f52b 100644
--- a/test/etags/Makefile
+++ b/test/etags/Makefile
@@ -23,12 +23,13 @@ PHPSRC=$(addprefix ./php-src/,lce_functions.php ptest.php sendmail.php)
PSSRC=$(addprefix ./ps-src/,rfc1245.ps)
PROLSRC=$(addprefix ./prol-src/,ordsets.prolog natded.prolog)
PYTSRC=$(addprefix ./pyt-src/,server.py)
+RBSRC=$(addprefix ./ruby-src/,test.rb test1.ruby)
TEXSRC=$(addprefix ./tex-src/,testenv.tex gzip.texi texinfo.tex nonewline.tex)
YSRC=$(addprefix ./y-src/,parse.y parse.c atest.y cccp.c cccp.y)
SRCS=${ADASRC} ${ASRC} ${CSRC} ${CPSRC} ${ELSRC} ${ERLSRC} ${FSRC}\
${FORTHSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC} ${OBJCSRC}\
${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC} ${PROLSRC} ${PYTSRC}\
- ${TEXSRC} ${YSRC}
+ ${RBSRC} ${TEXSRC} ${YSRC}
NONSRCS=./f-src/entry.strange ./erl-src/lists.erl ./cp-src/clheir.hpp.gz
ETAGS_PROG=../../lib-src/etags
diff --git a/test/etags/ruby-src/test.rb b/test/etags/ruby-src/test.rb
new file mode 100644
index 0000000000..9254c5bffa
--- /dev/null
+++ b/test/etags/ruby-src/test.rb
@@ -0,0 +1,54 @@
+module ModuleExample
+ class ClassExample
+ def class_method
+ puts "in class_method"
+ end
+ def ClassExample.singleton_class_method
+ puts "in singleton_class_method"
+ end
+ def class_method_exclamation!
+ puts "in class_method_exclamation!"
+ end
+ def class_method_question?
+ puts "in class_method_question?"
+ end
+ def class_method_equals=
+ puts "in class_method_equals="
+ end
+ def `(command)
+ return "just testing a backquote override"
+ end
+ def +(y)
+ @x + y
+ end
+ def [](y)
+ @ary[y]
+ end
+ def []=(y, val)
+ @ary[y] = val
+ end
+ def <<(y)
+ @x << y
+ end
+ def ==(y)
+ @ary.length == y.ary.length
+ end
+ def <=(y)
+ '@ary.length < y.ary.length'
+ end
+ def <=>(y)
+ nil
+ end
+ def ===(y)
+ self == y
+ end
+ end
+ def module_method
+ puts "in module_method"
+ end
+ def ModuleExample.singleton_module_method
+ puts "in singleton_module_method"
+ end
+end
+
+ModuleExample::ClassExample.singleton_class_method
diff --git a/test/etags/ruby-src/test1.ruby b/test/etags/ruby-src/test1.ruby
new file mode 100644
index 0000000000..43b1a14b95
--- /dev/null
+++ b/test/etags/ruby-src/test1.ruby
@@ -0,0 +1,7 @@
+class A
+ def a()
+ super(" do ")
+ end
+ def b()
+ end
+end