Skip to content

Commit 1d0be58

Browse files
committed
main: consider foreign languages when solving the extra specifying _extra regex flag
The original code assumed the parser specified in a regex pattern was the owner of the extra specified with the _extra regex flag in the pattern. For an example, in the option --regex-Foo=/.../{_extra=anextra}... , ctags assumed "anextra" was a specific extra of "Foo" parser. The original code didn't consider an option like --regex-Foo=/.../{_language=Bar}{_extra=anextra}... In this case, ctags should consider "anextra" as a specific extra of "Bar" parser. NOTE: the language specified with _language flag must be declared with _foreignLanguage= in --langdef-Foo. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent 0e819f6 commit 1d0be58

File tree

14 files changed

+73
-6
lines changed

14 files changed

+73
-6
lines changed

Tmain/list-mline-regex-flags.d/stdout-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ p pcre2 use pcre2 regex engine
99
- warning="MESSAGE" print the given MESSAGE at WARNING level
1010
- _advanceTo=N[start|end] a group in pattern from where the next scan starts [0end]
1111
- _anonymous=PREFIX make an anonymous tag with PREFIX
12-
- _extra=EXTRA record the tag only when the extra is enabled
12+
- _extra=EXTRA record the tag only when the (foreign) extra is enabled
1313
- _field=FIELD:VALUE record the matched string(VALUE) to the (foreign) language specific FIELD of the tag
1414
- _guest=PARSERSPEC,N0[start|end],N1[start|end] run guest parser on the area
1515
- _language=LANG make a foreign tag for LANG

Tmain/list-mtable-regex-flags.d/stdout-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ p pcre2 use pcre2 regex engine
1515
- warning="MESSAGE" print the given MESSAGE at WARNING level
1616
- _advanceTo=N[start|end] a group in pattern from where the next scan starts [0end]
1717
- _anonymous=PREFIX make an anonymous tag with PREFIX
18-
- _extra=EXTRA record the tag only when the extra is enabled
18+
- _extra=EXTRA record the tag only when the (foreign) extra is enabled
1919
- _field=FIELD:VALUE record the matched string(VALUE) to the (foreign) language specific FIELD of the tag
2020
- _guest=PARSERSPEC,N0[start|end],N1[start|end] run guest parser on the area
2121
- _language=LANG make a foreign tag for LANG

Tmain/list-regex-flags.d/stdout-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ x exclusive skip testing the other pat
1010
- scope=ACTION use scope stack: ACTION = ref|push|pop|clear|set|replace|intervaltab
1111
- warning="MESSAGE" print the given MESSAGE at WARNING level
1212
- _anonymous=PREFIX make an anonymous tag with PREFIX
13-
- _extra=EXTRA record the tag only when the extra is enabled
13+
- _extra=EXTRA record the tag only when the (foreign) extra is enabled
1414
- _field=FIELD:VALUE record the matched string(VALUE) to the (foreign) language specific FIELD of the tag
1515
- _guest=PARSERSPEC,N0[start|end],N1[start|end] run guest parser on the area
1616
- _language=LANG make a foreign tag for LANG
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright: 2024 Masatake YAMATO
2+
# License: GPL-2
3+
4+
. ../utils.sh
5+
6+
CTAGS=$1
7+
8+
V=
9+
# V=valgrind
10+
11+
${V} ${CTAGS} --quiet --options=NONE \
12+
\
13+
--langdef=NOSUCHLANG'{_foreignLanguage=Kconfig}' \
14+
--_extradef-NOSUCHLANG='NOSUCHEXTRA,but this is not the part of Kconfig' \
15+
--regex-NOSUCHLANG='/^\# (CONFIG_[^ ]+) is not set/\1/c/{_language=Kconfig}{_extra=NOSUCHEXTRA}{exclusive}' \
16+
\
17+
--_force-quit=0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ctags: Warning: no such extra "NOSUCHEXTRA" in Kconfig
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
D:def00
2+
d:def01
3+
v:var0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
D:def10
2+
d:def11
3+
v:var1
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright: 2024 Masatake YAMATO
2+
# License: GPL-2
3+
4+
. ../utils.sh
5+
6+
CTAGS=$1
7+
8+
V=
9+
# V=valgrind
10+
11+
printf "# %s\n" --extras-X0=+'{iname}'
12+
${V} ${CTAGS} --quiet --options=NONE --options=./x0.ctags --options=./x1.ctags \
13+
--extras-X0=+'{iname}' --fields=+'{extras}{language}' -o - input-0.x1
14+
15+
printf "# %s\n" --extras-X0=-'{iname}'
16+
${V} ${CTAGS} --quiet --options=NONE --options=./x0.ctags --options=./x1.ctags \
17+
--extras-X0=-'{iname}' --fields=+'{extras}{language}' -o - input-1.x1

Tmain/parser-own-extras-for-foreign-lang.d/stderr-expected.txt

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# --extras-X0=+{iname}
2+
__def01__ input-0.x1 /^d:def01$/;" d language:X0 extras:iname
3+
def00 input-0.x1 /^D:def00$/;" d language:X0
4+
var0 input-0.x1 /^v:var0$/;" v language:X1
5+
# --extras-X0=-{iname}
6+
def10 input-1.x1 /^D:def10$/;" d language:X0
7+
var1 input-1.x1 /^v:var1$/;" v language:X1

0 commit comments

Comments
 (0)