-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main,json-writer: allow the writer to disable "fixed" fields
Close #2065. The tags format must include name, input, and pattern fields. When running ctags, disabling them are not allowed. To implement this rule, "fixed" fields were introduced to field.c. However, this rule is applicable only to the ctags writer. The other writer like json-writer doesn't need to follow the rule. The fixed field is implemented in field.c. Now, it moves to writer-ctags.c. As the result, json-writer can print the result with disabling "name", "input", and/or "pattern". Signed-off-by: Masatake YAMATO <[email protected]>
- Loading branch information
Showing
11 changed files
with
159 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void main(void) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright: 2019 Masatake YAMATO | ||
# License: GPL-2 | ||
|
||
. ../utils.sh | ||
|
||
CTAGS="$1" | ||
|
||
is_feature_available "${CTAGS}" json | ||
|
||
CTAGS="${CTAGS} --quiet --options=NONE" | ||
|
||
echo '# writer=default' | ||
${CTAGS} --machinable --list-fields | grep '^[NFP]' | ||
|
||
list_fields() | ||
{ | ||
local f=$1 | ||
shift | ||
|
||
echo "# writer=$f $o" | ||
${CTAGS} --output-format=$f --machinable $@ --list-fields | grep '^[NFP]' | ||
} | ||
|
||
for f in u-ctags e-ctags etags xref json; do | ||
list_fields $f | ||
done | ||
|
||
for f in xref json; do | ||
for o in N F P; do | ||
list_fields $f --fields=-$o | ||
done | ||
done | ||
|
||
for o in N F P; do | ||
O="--fields=-$o" | ||
echo "# writer=json $O" | ||
${CTAGS} --output-format=json $O input.c | ||
O="--fields=$o" | ||
echo "# writer=json $O" | ||
${CTAGS} --output-format=json $O input.c | ||
done | ||
|
||
O="--fields=" | ||
echo "# writer=json $O" | ||
${CTAGS} --output-format=json $O input.c |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# writer=default | ||
N name yes NONE s-- yes tag name | ||
F input yes NONE s-- yes input file | ||
P pattern yes NONE s-b yes pattern | ||
# writer=u-ctags | ||
N name yes NONE s-- yes tag name | ||
F input yes NONE s-- yes input file | ||
P pattern yes NONE s-b yes pattern | ||
# writer=e-ctags | ||
N name yes NONE s-- yes tag name | ||
F input yes NONE s-- yes input file | ||
P pattern yes NONE s-b yes pattern | ||
# writer=etags | ||
F input yes NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=xref | ||
F input yes NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=json | ||
F input yes NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=xref N | ||
F input yes NONE s-- no input file | ||
N name no NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=xref F | ||
F input no NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=xref P | ||
F input yes NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern no NONE s-b no pattern | ||
# writer=json N | ||
F input yes NONE s-- no input file | ||
N name no NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=json F | ||
F input no NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern yes NONE s-b no pattern | ||
# writer=json P | ||
F input yes NONE s-- no input file | ||
N name yes NONE s-- no tag name | ||
P pattern no NONE s-b no pattern | ||
# writer=json --fields=-N | ||
{"_type": "tag", "path": "input.c", "pattern": "/^void main(void) {}$/", "typeref": "typename:void", "kind": "function"} | ||
# writer=json --fields=N | ||
{"_type": "tag", "name": "main"} | ||
# writer=json --fields=-F | ||
{"_type": "tag", "name": "main", "pattern": "/^void main(void) {}$/", "typeref": "typename:void", "kind": "function"} | ||
# writer=json --fields=F | ||
{"_type": "tag", "path": "input.c"} | ||
# writer=json --fields=-P | ||
{"_type": "tag", "name": "main", "path": "input.c", "typeref": "typename:void", "kind": "function"} | ||
# writer=json --fields=P | ||
{"_type": "tag", "pattern": "/^void main(void) {}$/"} | ||
# writer=json --fields= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters