Skip to content

Commit

Permalink
JSON: emit full qualified tags
Browse files Browse the repository at this point in the history
Close universal-ctags#4164

The test input is taken from universal-ctags#4164 submitted by Karol
Jakusz-Gostomski.
  • Loading branch information
masatake committed Dec 30, 2024
1 parent a1fdd1f commit 53a7aeb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Units/parser-json.r/fq-tags.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--extras=+q
5 changes: 5 additions & 0 deletions Units/parser-json.r/fq-tags.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
c input.json /^ "c": "hello {{.Name}}"$/;" s object:welcome.x
welcome.x.c input.json /^ "c": "hello {{.Name}}"$/;" s object:welcome.x
x input.json /^ "x": {$/;" o object:welcome
welcome.x input.json /^ "x": {$/;" o object:welcome
welcome input.json /^ "welcome": {$/;" o
7 changes: 7 additions & 0 deletions Units/parser-json.r/fq-tags.d/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"welcome": {
"x": {
"c": "hello {{.Name}}"
}
}
}
11 changes: 11 additions & 0 deletions parsers/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ static void makeJsonTag (tokenInfo *const token, const jsonKind kind)
}

makeTagEntry (&e);

if (!vStringIsEmpty (token->scope) && isXtagEnabled (XTAG_QUALIFIED_TAGS))
{
vString *qname = vStringNewCopy(token->scope);
vStringPut(qname, '.');
vStringCat(qname, token->string);
e.name = vStringValue(qname);
markTagExtraBit(&e, XTAG_QUALIFIED_TAGS);
makeTagEntry (&e);
vStringDelete (qname);
}
}

#define DEPTH_LIMIT 512
Expand Down

0 comments on commit 53a7aeb

Please sign in to comment.