Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript: avoid two-tokens tags #3994

Open
masatake opened this issue May 9, 2024 · 1 comment
Open

JavaScript: avoid two-tokens tags #3994

masatake opened this issue May 9, 2024 · 1 comment
Assignees

Comments

@masatake
Copy link
Member

masatake commented May 9, 2024

This issue is derived from #3363 (comment) .

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).

@jafl jafl self-assigned this May 9, 2024
@masatake
Copy link
Member Author

masatake commented May 9, 2024

When we will support import in the future, introducing unknown kind is one of choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants