Commit 58bfb6a4 authored by Eli Zaretskii's avatar Eli Zaretskii

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.
parent c04e9113
......@@ -4642,7 +4642,7 @@ Ruby_functions (FILE *inf)
if (cp > name + 1)
{
bp = skip_spaces (cp);
if (*bp == '=' && c_isspace (bp[1]))
if (*bp == '=' && !(bp[1] == '=' || bp[1] == '>'))
{
if (colon && !c_isspace (colon[1]))
name = colon + 1;
......@@ -4656,7 +4656,7 @@ Ruby_functions (FILE *inf)
|| LOOKING_AT (cp, "module"))
{
const char self_name[] = "self.";
const size_t self_size1 = sizeof ("self.") - 1;
const size_t self_size1 = sizeof (self_name) - 1;
name = cp;
......@@ -4688,6 +4688,60 @@ Ruby_functions (FILE *inf)
make_tag (name, cp - name, true,
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
}
else
{
/* Tag accessors and aliases. */
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"))
{
reader = true;
writer = true;
}
else if (LOOKING_AT (cp, "alias_method"))
alias = true;
if (reader || writer || alias)
{
do {
char *np = cp;
cp = skip_name (cp);
if (reader)
make_tag (np, cp - np, true,
lb.buffer, cp - lb.buffer + 1,
lineno, linecharno);
if (writer)
{
size_t name_len = cp - np + 1;
char *wr_name = xnew (name_len + 1, char);
memcpy (wr_name, np, name_len - 1);
memcpy (wr_name + name_len - 1, "=", 2);
pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1,
lineno, linecharno);
}
if (alias)
{
make_tag (np, cp - np, true,
lb.buffer, cp - lb.buffer + 1,
lineno, linecharno);
while (*cp && *cp != '#' && *cp != ';')
cp++;
}
} while (*cp == ','
&& (cp = skip_spaces (cp + 1), *cp && *cp != '#'));
}
cp = skip_name (cp);
while (*cp && *cp != '#' && notinname (*cp))
cp++;
}
}
}
}
......
......@@ -177,6 +177,15 @@ $user_comment_lc php-src/lce_functions.php 115
/wh ps-src/rfc1245.ps /^\/wh { $/
/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$/
:bar= ruby-src/test1.ruby /^ attr_writer :bar$/
:foo ruby-src/test1.ruby /^ attr_reader :foo$/
:qux ruby-src/test1.ruby /^ alias_method :qux, :tee$/
:read1 ruby-src/test1.ruby /^ attr_reader :read1, :read2; attr_writer :wri/
:read2 ruby-src/test1.ruby /^ attr_reader :read1, :read2; attr_writer :wri/
:tee ruby-src/test1.ruby /^ attr_accessor :tee$/
:tee= ruby-src/test1.ruby /^ attr_accessor :tee$/
:write1= ruby-src/test1.ruby /^ attr_reader :read1, :read2; attr_writer :wri/
:write2= ruby-src/test1.ruby /^ attr_reader :read1, :read2; attr_writer :wri/
< tex-src/texinfo.tex /^\\def<{{\\tt \\less}}$/
<< ruby-src/test.rb /^ def <<(y)$/
<= ruby-src/test.rb /^ def <=(y)$/
......@@ -460,7 +469,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.ruby 26
Constant ruby-src/test1.ruby 35
ControlEdit pyt-src/server.py /^class ControlEdit(Frame):$/
Controls pyt-src/server.py /^class Controls:$/
CopyTextString pas-src/common.pas /^function CopyTextString;(*($/
......@@ -522,6 +531,7 @@ DOS_NT c-src/etags.c 117
DOS_NT c-src/etags.c 118
DUMPED c-src/emacs/src/gmalloc.c 80
Debug cp-src/functions.cpp /^void Debug ( int lineno, int level, char* func , c/
Def_ ruby-src/test1.ruby 12
DisposeANameList pas-src/common.pas /^procedure DisposeANameList( $/
DisposeNameList pas-src/common.pas /^procedure DisposeNameList;$/
ELEM_I c-src/h.h 3
......@@ -1457,6 +1467,7 @@ WorkingDays cp-src/functions.cpp /^int WorkingDays(Date a, Date b){$/
Write_Lock/p ada-src/2ataspri.adb /^ procedure Write_Lock (L : in out Lock; Ceiling_/
Write_Lock/p ada-src/2ataspri.ads /^ procedure Write_Lock (L : in out Lock; Ceiling_/
X c-src/h.h 100
X ruby-src/test1.ruby /^ def X$/
XBOOL_VECTOR c-src/emacs/src/lisp.h /^XBOOL_VECTOR (Lisp_Object a)$/
XBUFFER c-src/emacs/src/lisp.h /^XBUFFER (Lisp_Object a)$/
XBUFFER_OBJFWD c-src/emacs/src/lisp.h /^XBUFFER_OBJFWD (union Lisp_Fwd *a)$/
......@@ -1534,6 +1545,7 @@ XUNTAG c-src/emacs/src/lisp.h /^# define XUNTAG(a, type) lisp_h_XUNTAG (a, type
XUNTAG c-src/emacs/src/lisp.h /^XUNTAG (Lisp_Object a, int type)$/
XWINDOW c-src/emacs/src/lisp.h /^XWINDOW (Lisp_Object a)$/
XX cp-src/x.cc 1
Xyzzy ruby-src/test1.ruby 13
Y c-src/h.h 100
YACC c-src/etags.c 2199
YELLOW cp-src/screen.hpp 26
......
......@@ -3009,17 +3009,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -3580,17 +3580,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -3356,17 +3356,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -3173,17 +3173,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -4091,17 +4091,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -4091,17 +4091,29 @@ module ModuleExample1,0
def module_instance_method46,1051
def ModuleExample.module_class_methodmodule_class_method49,1131
ruby-src/test1.ruby,191
ruby-src/test1.ruby,635
class A1,0
def a(2,8
def b(5,38
module A9,57
class B10,66
ABC 11,76
def foo!13,89
def self._bar?(_bar?16,111
def qux=(qux=20,162
A::Constant Constant26,211
Def_ 12,88
Xyzzy 13,106
def foo!15,121
def self._bar?(_bar?18,143
def qux=(qux=22,194
def X25,232
attr_reader :foo26,242
attr_reader :read1,27,265
attr_reader :read1, :read2;27,265
attr_reader :read1, :read2; attr_writer :write1,:write1=27,265
attr_reader :read1, :read2; attr_writer :write1, :write2:write2=27,265
attr_writer :bar:bar=28,328
attr_accessor :tee29,351
attr_accessor :tee:tee=29,351
alias_method :qux,30,376
A::Constant Constant35,425
tex-src/testenv.tex,52
\newcommand{\nm}\nm4,77
......
......@@ -9,6 +9,8 @@ end
module A
class B
ABC = 4
Def_ = 'blah'
Xyzzy =10
def foo!
end
......@@ -20,6 +22,13 @@ module A
def qux=(tee)
end
end
def X
attr_reader :foo
attr_reader :read1, :read2; attr_writer :write1, :write2
attr_writer :bar
attr_accessor :tee
alias_method :qux, :tee
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment