JavaScript: avoid two-tokens tags
This issue is derived from https://github.com/universal-ctags/ctags/pull/3363#discussion_r1593179625 .
The name of the parser: JavaScript
The command line you used to run ctags:
./ctags --options=NONE --excmd=combined --sort=no --fields=rZKs --extras=+r -o - foo.js
The content of the input file:
class T0 {
r0 = 1
}
T0.r0 = {
i0: 0
}
T1 = {
r1: 1
}
T1.r1 = {
i1: 0
}
T2 = {}
T2.r2 = 1
The tags output you are not satisfied with:
T0 foo.js 1;/^class T0 {$/;" class roles:def
r0 foo.js 2;/^ r0 = 1$/;" field scope:class:T0 roles:def
i0 foo.js 6;/^ i0: 0$/;" property scope:property:T0.r0 roles:def
T0.r0 foo.js 5;/^T0.r0 = {$/;" property roles:def
r1 foo.js 10;/^ r1: 1$/;" property scope:variable:T1 roles:def
T1 foo.js 9;/^T1 = {$/;" variable roles:def
i1 foo.js 14;/^ i1: 0$/;" property scope:property:T1.r1 roles:def
T1.r1 foo.js 13;/^T1.r1 = {$/;" property roles:def
The scope of i0 should be scope:field:T0.r0.
For line 4 of foo.js, where T0.r0 is assigned, r0 should be tagged again instead of tagging T0.r0 (a two tokens tag).
For line 13 of foo.js, where T1.r1 is assigned, r1 should be tagged again instead of tagging T0.r1 (a two tokens tag).
For line 17 of foo.js, where T2 is assigned (or dynamically defined), T1 should be tagged with "variable" kind or something.
For line 17 of foo.js, where T2.r2 is assigned (or dynamically defined), r2 should be tagged.
The tags output you expect:
T0 foo.js 1;/^class T0 {$/;" class roles:def
r0 foo.js 2;/^ r0 = 1$/;" field scope:class:T0 roles:def
i0 foo.js 6;/^ i0: 0$/;" property scope:field:T0.r0 roles:def
T0 foo.js 5;/^T0.r0 = {$/;" class roles:chainElt
r0 foo.js 5;/^T0.r0 = {$/;" field scope:class:T0 roles:def
r1 foo.js 10;/^ r1: 1$/;" property scope:variable:T1 roles:def
T1 foo.js 9;/^T1 = {$/;" variable roles:def
i1 foo.js 14;/^ i1: 0$/;" property scope:property:T1.r1 roles:def
T1 foo.js 13;/^T1.r1 = {$/;" variable roles:chainElt
r1 foo.js 13;/^T1.r1 = {$/;" property scope:variable:T1 roles:def
T2 foo.js 17;/^T2 = {}$/;" variable roles:def
r2 foo.js 18;/^T2.r2 = 1$/;" property scope:variable:T2 roles:def
T2 foo.js 18;/^T2.r2 = 1$/;" variable roles:chainElt
The version of ctags:
$ ctags --version
Universal Ctags 6.1.0(adcea47e3), Copyright (C) 2015-2023 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: May 8 2024, 23:15:34
URL: https://ctags.io/
Output version: 0.0
Optional compiled features: +wildcards, +regex, +iconv, +debug, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript, +pcre2
How do you get ctags binary:
git clone
Note:
Instead of the variable kind with chainElt role, we can add unknown kind (with chainElt).
When we will support import in the future, introducing unknown kind is one of choice.