From e9e9b9988d889a06bc01d1a99fb6620e7d4fa115 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 13 May 2015 01:53:26 +0900 Subject: [PATCH] ruby: handle singleton method including ?!= in its name(sf.bug:364) This patch is intended a bug reported as sf.bug:364. https://sourceforge.net/p/ctags/bugs/364/ Writing a test case is helped by Dmitry Gutov. Signed-off-by: Masatake YAMATO --- tagmanager/ctags/ruby.c | 7 +++++++ tests/ctags/Makefile.am | 1 + tests/ctags/ruby-sf-bug-364.rb | 16 ++++++++++++++++ tests/ctags/ruby-sf-bug-364.rb.tags | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 tests/ctags/ruby-sf-bug-364.rb create mode 100644 tests/ctags/ruby-sf-bug-364.rb.tags diff --git a/tagmanager/ctags/ruby.c b/tagmanager/ctags/ruby.c index 726176609..fdb5335f8 100644 --- a/tagmanager/ctags/ruby.c +++ b/tagmanager/ctags/ruby.c @@ -194,6 +194,10 @@ static rubyKind parseIdentifier ( { also_ok = "_.?!="; } + else if (kind == K_SINGLETON) + { + also_ok = "_?!="; + } else if (kind == K_DESCRIBE || kind == K_CONTEXT) { also_ok = " ,\".#_?!='/-"; @@ -237,7 +241,10 @@ static rubyKind parseIdentifier ( vStringClear (name); return parseIdentifier (cp, name, K_SINGLETON); } + } + if (kind == K_METHOD || kind == K_SINGLETON) + { /* Recognize characters which mark the end of a method name. */ if (charIsIn (last_char, "?!=")) { diff --git a/tests/ctags/Makefile.am b/tests/ctags/Makefile.am index dc8327a49..be042da41 100644 --- a/tests/ctags/Makefile.am +++ b/tests/ctags/Makefile.am @@ -255,6 +255,7 @@ test_sources = \ regexp.js \ return-hint.zep \ return-types.go \ + ruby-sf-bug-364.rb \ rules.t2t \ sample.t2t \ secondary_fcn_name.js \ diff --git a/tests/ctags/ruby-sf-bug-364.rb b/tests/ctags/ruby-sf-bug-364.rb new file mode 100644 index 000000000..783397045 --- /dev/null +++ b/tests/ctags/ruby-sf-bug-364.rb @@ -0,0 +1,16 @@ +class D + def self.x? + end + def self.y! + end + def self.z=(a) + end + def self._a? + end + def self._b! + end + def self._c=(a) + end +end +D._c=1 +D.z=1 diff --git a/tests/ctags/ruby-sf-bug-364.rb.tags b/tests/ctags/ruby-sf-bug-364.rb.tags new file mode 100644 index 000000000..a0d452610 --- /dev/null +++ b/tests/ctags/ruby-sf-bug-364.rb.tags @@ -0,0 +1,8 @@ +# format=tagmanager +DÌ1Ö0 +_a?Ì64ÎDÖ0 +_b!Ì64ÎDÖ0 +_c=Ì64ÎDÖ0 +x?Ì64ÎDÖ0 +y!Ì64ÎDÖ0 +z=Ì64ÎDÖ0 -- 2.11.4.GIT