diff options
| author | Laurent Stacul | 2025-03-31 20:30:27 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-03 08:50:59 +0300 |
| commit | 8db310ce8b4d453cda8114c3a06cd0f328f99a1b (patch) | |
| tree | f8fddfb6984ae4edb3148ef0059902fd830263ae /lib-src | |
| parent | 5039ad24a362d88ac43d79f9fa5a5ba11f0da61b (diff) | |
| download | emacs-8db310ce8b4d453cda8114c3a06cd0f328f99a1b.tar.gz emacs-8db310ce8b4d453cda8114c3a06cd0f328f99a1b.zip | |
Fix etags for Ruby module definitions with ::
Problem: In Ruby we can define a nested module/class the safe
way (in the sense, if the parent module does not exist, it will
define it:
module M
module N
end
end
If M already exists, we can also write:
module M::N; end
With the later notation, the tag generated by etags will be M::N.
When browsing the code, using xref-find-definitions when the point
is on N, will not be able to find the definition of N because the
implicit tag name is M::N.
This is the same problem with nested classes or even some rare
allowed definitions like explicitely defining a module/class from
the global namespace:
class ::A; end
Solution: We need to give an explicit tag name. To achieve this,
on module/class definition we truncate the name to the last found
column.
* lib-src/etags.c (Ruby_functions): Support "::" in module
definitions.
* test/manual/etags/README: Update instructions.
* test/manual/etags/ruby-src/test1.ru: Add identifiers with "::".
* test/manual/etags/CTAGS.good:
* test/manual/etags/CTAGS.good_crlf:
* test/manual/etags/CTAGS.good_update:
* test/manual/etags/ETAGS.good_1:
* test/manual/etags/ETAGS.good_2:
* test/manual/etags/ETAGS.good_3:
* test/manual/etags/ETAGS.good_4:
* test/manual/etags/ETAGS.good_5:
* test/manual/etags/ETAGS.good_6:
* test/manual/etags/ETAGS.good_7: Adapt expected results to the
change. (Bug#77421)
Copyright-paperwork-exempt: yes
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index d511bc39588..6dde9c42e13 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -5069,7 +5069,10 @@ Ruby_functions (FILE *inf) | |||
| 5069 | /* Ruby method names can end in a '='. Also, operator overloading can | 5069 | /* Ruby method names can end in a '='. Also, operator overloading can |
| 5070 | define operators whose names include '='. */ | 5070 | define operators whose names include '='. */ |
| 5071 | while (!notinname (*cp) || *cp == '=') | 5071 | while (!notinname (*cp) || *cp == '=') |
| 5072 | cp++; | 5072 | { |
| 5073 | cp++; | ||
| 5074 | if (*(cp - 1) == ':') name = cp; | ||
| 5075 | } | ||
| 5073 | 5076 | ||
| 5074 | /* Remove "self." from the method name. */ | 5077 | /* Remove "self." from the method name. */ |
| 5075 | if (cp - name > self_size1 | 5078 | if (cp - name > self_size1 |