1813c1b26SHiroo HAYASHI.. _changes_tags_file: 2813c1b26SHiroo HAYASHI 3813c1b26SHiroo HAYASHIChanges to the tags file format 4813c1b26SHiroo HAYASHI--------------------------------------------------------------------- 5813c1b26SHiroo HAYASHI 6813c1b26SHiroo HAYASHI``F`` kind usage 7813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8813c1b26SHiroo HAYASHI 9813c1b26SHiroo HAYASHIYou cannot use ``F`` (``file``) kind in your .ctags because Universal Ctags 10813c1b26SHiroo HAYASHIreserves it. See :ref:`ctags-incompatibilities(7) <ctags-incompatibilities(7)>`. 11813c1b26SHiroo HAYASHI 12813c1b26SHiroo HAYASHIReference tags 13813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14813c1b26SHiroo HAYASHI 15813c1b26SHiroo HAYASHITraditionally ctags collects the information for locating where a 16813c1b26SHiroo HAYASHIlanguage object is DEFINED. 17813c1b26SHiroo HAYASHI 18813c1b26SHiroo HAYASHIIn addition Universal Ctags supports reference tags. If the extra-tag 19813c1b26SHiroo HAYASHI``r`` is enabled, Universal Ctags also collects the information for 20813c1b26SHiroo HAYASHIlocating where a language object is REFERENCED. This feature was 21813c1b26SHiroo HAYASHIproposed by @shigio in `#569 22813c1b26SHiroo HAYASHI<https://github.com/universal-ctags/ctags/issues/569>`_ for GNU GLOBAL. 23813c1b26SHiroo HAYASHI 24813c1b26SHiroo HAYASHIHere are some examples. Here is the target input file named reftag.c. 25813c1b26SHiroo HAYASHI 26813c1b26SHiroo HAYASHI.. code-block:: c 27813c1b26SHiroo HAYASHI 28813c1b26SHiroo HAYASHI #include <stdio.h> 29813c1b26SHiroo HAYASHI #include "foo.h" 30813c1b26SHiroo HAYASHI #define TYPE point 31813c1b26SHiroo HAYASHI struct TYPE { int x, y; }; 32813c1b26SHiroo HAYASHI TYPE p; 33813c1b26SHiroo HAYASHI #undef TYPE 34813c1b26SHiroo HAYASHI 35813c1b26SHiroo HAYASHI 36813c1b26SHiroo HAYASHITraditional output: 37813c1b26SHiroo HAYASHI 38813c1b26SHiroo HAYASHI.. code-block:: console 39813c1b26SHiroo HAYASHI 4045e335abSHiroo HAYASHI $ ctags -o - reftag.c 41813c1b26SHiroo HAYASHI TYPE reftag.c /^#define TYPE /;" d file: 42813c1b26SHiroo HAYASHI TYPE reftag.c /^struct TYPE { int x, y; };$/;" s file: 43813c1b26SHiroo HAYASHI p reftag.c /^TYPE p;$/;" v typeref:typename:TYPE 44813c1b26SHiroo HAYASHI x reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: 45813c1b26SHiroo HAYASHI y reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: 46813c1b26SHiroo HAYASHI 47813c1b26SHiroo HAYASHIOutput with the extra-tag ``r`` enabled: 48813c1b26SHiroo HAYASHI 49813c1b26SHiroo HAYASHI.. code-block:: console 50813c1b26SHiroo HAYASHI 5145e335abSHiroo HAYASHI $ ctags --list-extras | grep ^r 52813c1b26SHiroo HAYASHI r Include reference tags off 5345e335abSHiroo HAYASHI $ ctags -o - --extras=+r reftag.c 54813c1b26SHiroo HAYASHI TYPE reftag.c /^#define TYPE /;" d file: 55813c1b26SHiroo HAYASHI TYPE reftag.c /^#undef TYPE$/;" d file: 56813c1b26SHiroo HAYASHI TYPE reftag.c /^struct TYPE { int x, y; };$/;" s file: 57813c1b26SHiroo HAYASHI foo.h reftag.c /^#include "foo.h"/;" h 58813c1b26SHiroo HAYASHI p reftag.c /^TYPE p;$/;" v typeref:typename:TYPE 59813c1b26SHiroo HAYASHI stdio.h reftag.c /^#include <stdio.h>/;" h 60813c1b26SHiroo HAYASHI x reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: 61813c1b26SHiroo HAYASHI y reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: 62813c1b26SHiroo HAYASHI 63813c1b26SHiroo HAYASHI`#undef X` and two `#include` are newly collected. 64813c1b26SHiroo HAYASHI 65813c1b26SHiroo HAYASHI"roles" is a newly introduced field in Universal Ctags. The field 66813c1b26SHiroo HAYASHInamed is for recording how a tag is referenced. If a tag is definition 67813c1b26SHiroo HAYASHItag, the roles field has "def" as its value. 68813c1b26SHiroo HAYASHI 69813c1b26SHiroo HAYASHIUniversal Ctags prints the role information when the `r` 70813c1b26SHiroo HAYASHIfield is enabled with ``--fields=+r``. 71813c1b26SHiroo HAYASHI 72813c1b26SHiroo HAYASHI.. code-block:: console 73813c1b26SHiroo HAYASHI 7445e335abSHiroo HAYASHI $ ctags -o - --extras=+r --fields=+r reftag.c 75813c1b26SHiroo HAYASHI TYPE reftag.c /^#define TYPE /;" d file: 76813c1b26SHiroo HAYASHI TYPE reftag.c /^#undef TYPE$/;" d file: roles:undef 77813c1b26SHiroo HAYASHI TYPE reftag.c /^struct TYPE { int x, y; };$/;" s file: roles:def 78813c1b26SHiroo HAYASHI foo.h reftag.c /^#include "foo.h"/;" h roles:local 79813c1b26SHiroo HAYASHI p reftag.c /^TYPE p;$/;" v typeref:typename:TYPE roles:def 80813c1b26SHiroo HAYASHI stdio.h reftag.c /^#include <stdio.h>/;" h roles:system 81813c1b26SHiroo HAYASHI x reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: roles:def 82813c1b26SHiroo HAYASHI y reftag.c /^struct TYPE { int x, y; };$/;" m struct:TYPE typeref:typename:int file: roles:def 83813c1b26SHiroo HAYASHI 84813c1b26SHiroo HAYASHIThe `Reference tag marker` field, ``R``, is a specialized GNU global 85813c1b26SHiroo HAYASHIrequirement; D is used for the traditional definition tags, and R is 86813c1b26SHiroo HAYASHIused for the new reference tags. The field can be used only with 87813c1b26SHiroo HAYASHI``--_xformat``. 88813c1b26SHiroo HAYASHI 89813c1b26SHiroo HAYASHI.. code-block:: console 90813c1b26SHiroo HAYASHI 9145e335abSHiroo HAYASHI $ ctags -x --_xformat="%R %-16N %4n %-16F %C" --extras=+r reftag.c 92813c1b26SHiroo HAYASHI D TYPE 3 reftag.c #define TYPE point 93813c1b26SHiroo HAYASHI D TYPE 4 reftag.c struct TYPE { int x, y; }; 94813c1b26SHiroo HAYASHI D p 5 reftag.c TYPE p; 95813c1b26SHiroo HAYASHI D x 4 reftag.c struct TYPE { int x, y; }; 96813c1b26SHiroo HAYASHI D y 4 reftag.c struct TYPE { int x, y; }; 97813c1b26SHiroo HAYASHI R TYPE 6 reftag.c #undef TYPE 98813c1b26SHiroo HAYASHI R foo.h 2 reftag.c #include "foo.h" 99813c1b26SHiroo HAYASHI R stdio.h 1 reftag.c #include <stdio.h> 100813c1b26SHiroo HAYASHI 101813c1b26SHiroo HAYASHISee :ref:`Customizing xref output <xformat>` for more details about 102813c1b26SHiroo HAYASHI``--_xformat``. 103813c1b26SHiroo HAYASHI 104813c1b26SHiroo HAYASHIAlthough the facility for collecting reference tags is implemented, 105813c1b26SHiroo HAYASHIonly a few parsers currently utilize it. All available roles can be 106813c1b26SHiroo HAYASHIlisted with ``--list-roles``: 107813c1b26SHiroo HAYASHI 108813c1b26SHiroo HAYASHI.. code-block:: console 109813c1b26SHiroo HAYASHI 11045e335abSHiroo HAYASHI $ ctags --list-roles 111813c1b26SHiroo HAYASHI #LANGUAGE KIND(L/N) NAME ENABLED DESCRIPTION 112813c1b26SHiroo HAYASHI SystemdUnit u/unit Requires on referred in Requires key 113813c1b26SHiroo HAYASHI SystemdUnit u/unit Wants on referred in Wants key 114813c1b26SHiroo HAYASHI SystemdUnit u/unit After on referred in After key 115813c1b26SHiroo HAYASHI SystemdUnit u/unit Before on referred in Before key 116813c1b26SHiroo HAYASHI SystemdUnit u/unit RequiredBy on referred in RequiredBy key 117813c1b26SHiroo HAYASHI SystemdUnit u/unit WantedBy on referred in WantedBy key 118813c1b26SHiroo HAYASHI Yaml a/anchor alias on alias 119813c1b26SHiroo HAYASHI DTD e/element attOwner on attributes owner 120813c1b26SHiroo HAYASHI Automake c/condition branched on used for branching 121813c1b26SHiroo HAYASHI Cobol S/sourcefile copied on copied in source file 122813c1b26SHiroo HAYASHI Maven2 g/groupId dependency on dependency 123813c1b26SHiroo HAYASHI DTD p/parameterEntity elementName on element names 124813c1b26SHiroo HAYASHI DTD p/parameterEntity condition on conditions 125813c1b26SHiroo HAYASHI LdScript s/symbol entrypoint on entry points 126813c1b26SHiroo HAYASHI LdScript i/inputSection discarded on discarded when linking 127813c1b26SHiroo HAYASHI ... 128813c1b26SHiroo HAYASHI 129813c1b26SHiroo HAYASHI.. NOTE: --xformat is the only way to extract referenced tag 130813c1b26SHiroo HAYASHI 131813c1b26SHiroo HAYASHIThe first column shows the name of the parser. 132813c1b26SHiroo HAYASHIThe second column shows the letter/name of the kind. 133813c1b26SHiroo HAYASHIThe third column shows the name of the role. 134813c1b26SHiroo HAYASHIThe fourth column shows whether the role is enabled or not. 135813c1b26SHiroo HAYASHIThe fifth column shows the description of the role. 136813c1b26SHiroo HAYASHI 137813c1b26SHiroo HAYASHIYou can define a role in an optlib parser for capturing reference 138813c1b26SHiroo HAYASHItags. See :ref:`Capturing reference tags <roles>` for more 139813c1b26SHiroo HAYASHIdetails. 140813c1b26SHiroo HAYASHI 141813c1b26SHiroo HAYASHI``--roles-<LANG>.<KIND>`` is the option for enabling/disabling 142813c1b26SHiroo HAYASHIspecified roles. 143813c1b26SHiroo HAYASHI 144813c1b26SHiroo HAYASHIPseudo-tags 145813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 146813c1b26SHiroo HAYASHI 147813c1b26SHiroo HAYASHI.. IN MAN PAGE 148813c1b26SHiroo HAYASHI 149813c1b26SHiroo HAYASHISee :ref:`ctags-client-tools(7) <ctags-client-tools(7)>` about the 150813c1b26SHiroo HAYASHIconcept of the pseudo-tags. 151813c1b26SHiroo HAYASHI 152813c1b26SHiroo HAYASHI.. TODO move the following contents to ctags-client-tools(7). 153813c1b26SHiroo HAYASHI 154813c1b26SHiroo HAYASHI``TAG_KIND_DESCRIPTION`` 155813c1b26SHiroo HAYASHI......................................................................... 156813c1b26SHiroo HAYASHI 157813c1b26SHiroo HAYASHIThis is a newly introduced pseudo-tag. It is not emitted by default. 158813c1b26SHiroo HAYASHIIt is emitted only when ``--pseudo-tags=+TAG_KIND_DESCRIPTION`` is 159813c1b26SHiroo HAYASHIgiven. 160813c1b26SHiroo HAYASHI 161813c1b26SHiroo HAYASHIThis is for describing kinds; their letter, name, and description are 162813c1b26SHiroo HAYASHIenumerated in the tag. 163813c1b26SHiroo HAYASHI 164813c1b26SHiroo HAYASHIctags emits ``TAG_KIND_DESCRIPTION`` with following format:: 165813c1b26SHiroo HAYASHI 166813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!{parser} {letter},{name} /{description}/ 167813c1b26SHiroo HAYASHI 168813c1b26SHiroo HAYASHIA backslash and a slash in {description} is escaped with a backslash. 169813c1b26SHiroo HAYASHI 170813c1b26SHiroo HAYASHI 171813c1b26SHiroo HAYASHI``TAG_KIND_SEPARATOR`` 172813c1b26SHiroo HAYASHI......................................................................... 173813c1b26SHiroo HAYASHI 174813c1b26SHiroo HAYASHIThis is a newly introduced pseudo-tag. It is not emitted by default. 175813c1b26SHiroo HAYASHIIt is emitted only when ``--pseudo-tags=+TAG_KIND_SEPARATOR`` is 176813c1b26SHiroo HAYASHIgiven. 177813c1b26SHiroo HAYASHI 178813c1b26SHiroo HAYASHIThis is for describing separators placed between two kinds in a 179813c1b26SHiroo HAYASHIlanguage. 180813c1b26SHiroo HAYASHI 181813c1b26SHiroo HAYASHITag entries including the separators are emitted when ``--extras=+q`` 182813c1b26SHiroo HAYASHIis given; fully qualified tags contain the separators. The separators 183813c1b26SHiroo HAYASHIare used in scope information, too. 184813c1b26SHiroo HAYASHI 185813c1b26SHiroo HAYASHIctags emits ``TAG_KIND_SEPARATOR`` with following format:: 186813c1b26SHiroo HAYASHI 187813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!{parser} {sep} /{upper}{lower}/ 188813c1b26SHiroo HAYASHI 189813c1b26SHiroo HAYASHIor :: 190813c1b26SHiroo HAYASHI 191813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!{parser} {sep} /{lower}/ 192813c1b26SHiroo HAYASHI 193813c1b26SHiroo HAYASHIHere {parser} is the name of language. e.g. PHP. 194813c1b26SHiroo HAYASHI{lower} is the letter representing the kind of the lower item. 195813c1b26SHiroo HAYASHI{upper} is the letter representing the kind of the upper item. 196813c1b26SHiroo HAYASHI{sep} is the separator placed between the upper item and the lower 197813c1b26SHiroo HAYASHIitem. 198813c1b26SHiroo HAYASHI 199813c1b26SHiroo HAYASHIThe format without {upper} is for representing a root separator. The 200813c1b26SHiroo HAYASHIroot separator is used as prefix for an item which has no upper scope. 201813c1b26SHiroo HAYASHI 202813c1b26SHiroo HAYASHI`*` given as {upper} is a fallback wild card; if it is given, the 203813c1b26SHiroo HAYASHI{sep} is used in combination with any upper item and the item 204813c1b26SHiroo HAYASHIspecified with {lower}. 205813c1b26SHiroo HAYASHI 206813c1b26SHiroo HAYASHIEach backslash character used in {sep} is escaped with an extra 207813c1b26SHiroo HAYASHIbackslash character. 208813c1b26SHiroo HAYASHI 209813c1b26SHiroo HAYASHIExample output: 210813c1b26SHiroo HAYASHI 211813c1b26SHiroo HAYASHI.. code-block:: console 212813c1b26SHiroo HAYASHI 21345e335abSHiroo HAYASHI $ ctags -o - --extras=+p --pseudo-tags= --pseudo-tags=+TAG_KIND_SEPARATOR input.php 214813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!PHP :: /*c/ 215813c1b26SHiroo HAYASHI ... 216813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!PHP \\ /c/ 217813c1b26SHiroo HAYASHI ... 218813c1b26SHiroo HAYASHI !_TAG_KIND_SEPARATOR!PHP \\ /nc/ 219813c1b26SHiroo HAYASHI ... 220813c1b26SHiroo HAYASHI 221813c1b26SHiroo HAYASHIThe first line means ``::`` is used when combining something with an 222813c1b26SHiroo HAYASHIitem of the class kind. 223813c1b26SHiroo HAYASHI 224813c1b26SHiroo HAYASHIThe second line means ``\\`` is used when a class item is at the top 225813c1b26SHiroo HAYASHIlevel; no upper item is specified. 226813c1b26SHiroo HAYASHI 227813c1b26SHiroo HAYASHIThe third line means ``\\`` is used when for combining a namespace item 228813c1b26SHiroo HAYASHI(upper) and a class item (lower). 229813c1b26SHiroo HAYASHI 230813c1b26SHiroo HAYASHIOf course, ctags uses the more specific line when choosing a 231813c1b26SHiroo HAYASHIseparator; the third line has higher priority than the first. 232813c1b26SHiroo HAYASHI 233813c1b26SHiroo HAYASHI``TAG_OUTPUT_FILESEP`` 234813c1b26SHiroo HAYASHI......................................................................... 235813c1b26SHiroo HAYASHI 236813c1b26SHiroo HAYASHIThis pseudo-tag represents the separator used in file name: slash or 237813c1b26SHiroo HAYASHIbackslash. This is always 'slash' on Unix-like environments. 238813c1b26SHiroo HAYASHIThis is also 'slash' by default on Windows, however when 239813c1b26SHiroo HAYASHI``--output-format=e-tags`` or ``--use-slash-as-filename-separator=no`` 240813c1b26SHiroo HAYASHIis specified, it becomes 'backslash'. 241813c1b26SHiroo HAYASHI 242813c1b26SHiroo HAYASHI 243813c1b26SHiroo HAYASHI``TAG_OUTPUT_MODE`` 244813c1b26SHiroo HAYASHI......................................................................... 245813c1b26SHiroo HAYASHI 246813c1b26SHiroo HAYASHI.. NOT REVIEWED YET 247813c1b26SHiroo HAYASHI 248813c1b26SHiroo HAYASHIThis pseudo-tag represents output mode: u-ctags or e-ctags. 249813c1b26SHiroo HAYASHIThis is controlled by ``--output-format`` option. 250813c1b26SHiroo HAYASHI 251813c1b26SHiroo HAYASHISee also :ref:`Compatible output and weakness <compat-output>`. 252813c1b26SHiroo HAYASHI 253813c1b26SHiroo HAYASHITruncating the pattern for long input lines 254813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 255813c1b26SHiroo HAYASHI 256813c1b26SHiroo HAYASHISee ``--pattern-length-limit=N`` option in :ref:`ctags(1) <ctags(1)>`. 257813c1b26SHiroo HAYASHI 258813c1b26SHiroo HAYASHI.. _parser-specific-fields: 259813c1b26SHiroo HAYASHI 260813c1b26SHiroo HAYASHIParser specific fields 261813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 262813c1b26SHiroo HAYASHI 263813c1b26SHiroo HAYASHIA tag has a `name`, an `input` file name, and a `pattern` as basic 264813c1b26SHiroo HAYASHIinformation. Some fields like `language:`, `signature:`, etc are 265813c1b26SHiroo HAYASHIattached to the tag as optional information. 266813c1b26SHiroo HAYASHI 267813c1b26SHiroo HAYASHIIn Exuberant Ctags, fields are common to all languages. 268813c1b26SHiroo HAYASHIUniversal Ctags extends the concept of fields; a parser can define 269813c1b26SHiroo HAYASHIits specific field. This extension was proposed by @pragmaware in 270813c1b26SHiroo HAYASHI`#857 <https://github.com/universal-ctags/ctags/issues/857>`_. 271813c1b26SHiroo HAYASHI 272813c1b26SHiroo HAYASHIFor implementing the parser specific fields, the options for listing and 273813c1b26SHiroo HAYASHIenabling/disabling fields are also extended. 274813c1b26SHiroo HAYASHI 275813c1b26SHiroo HAYASHIIn the output of ``--list-fields``, the owner of the field is printed 276813c1b26SHiroo HAYASHIin the `LANGUAGE` column: 277813c1b26SHiroo HAYASHI 278813c1b26SHiroo HAYASHI.. code-block:: console 279813c1b26SHiroo HAYASHI 28045e335abSHiroo HAYASHI $ ctags --list-fields 281813c1b26SHiroo HAYASHI #LETTER NAME ENABLED LANGUAGE XFMT DESCRIPTION 282813c1b26SHiroo HAYASHI ... 283813c1b26SHiroo HAYASHI - end off C TRUE end lines of various constructs 284813c1b26SHiroo HAYASHI - properties off C TRUE properties (static, inline, mutable,...) 285813c1b26SHiroo HAYASHI - end off C++ TRUE end lines of various constructs 286813c1b26SHiroo HAYASHI - template off C++ TRUE template parameters 287813c1b26SHiroo HAYASHI - captures off C++ TRUE lambda capture list 288813c1b26SHiroo HAYASHI - properties off C++ TRUE properties (static, virtual, inline, mutable,...) 289813c1b26SHiroo HAYASHI - sectionMarker off reStructuredText TRUE character used for declaring section 290813c1b26SHiroo HAYASHI - version off Maven2 TRUE version of artifact 291813c1b26SHiroo HAYASHI 292813c1b26SHiroo HAYASHIe.g. reStructuredText is the owner of the sectionMarker field and 293813c1b26SHiroo HAYASHIboth C and C++ own the end field. 294813c1b26SHiroo HAYASHI 295813c1b26SHiroo HAYASHI``--list-fields`` takes one optional argument, `LANGUAGE`. If it is 296813c1b26SHiroo HAYASHIgiven, ``--list-fields`` prints only the fields for that parser: 297813c1b26SHiroo HAYASHI 298813c1b26SHiroo HAYASHI.. code-block:: console 299813c1b26SHiroo HAYASHI 30045e335abSHiroo HAYASHI $ ctags --list-fields=Maven2 301813c1b26SHiroo HAYASHI #LETTER NAME ENABLED LANGUAGE XFMT DESCRIPTION 302813c1b26SHiroo HAYASHI - version off Maven2 TRUE version of artifact 303813c1b26SHiroo HAYASHI 304813c1b26SHiroo HAYASHIA parser specific field only has a long name, no letter. For 305813c1b26SHiroo HAYASHIenabling/disabling such fields, the name must be passed to 306813c1b26SHiroo HAYASHI``--fields-<LANG>``. 307813c1b26SHiroo HAYASHI 308813c1b26SHiroo HAYASHIe.g. for enabling the `sectionMarker` field owned by the 309813c1b26SHiroo HAYASHI`reStructuredText` parser, use the following command line: 310813c1b26SHiroo HAYASHI 311813c1b26SHiroo HAYASHI.. code-block:: console 312813c1b26SHiroo HAYASHI 31345e335abSHiroo HAYASHI $ ctags --fields-reStructuredText=+{sectionMarker} ... 314813c1b26SHiroo HAYASHI 315813c1b26SHiroo HAYASHIThe wild card notation can be used for enabling/disabling parser specific 316813c1b26SHiroo HAYASHIfields, too. The following example enables all fields owned by the 317813c1b26SHiroo HAYASHI`C++` parser. 318813c1b26SHiroo HAYASHI 319813c1b26SHiroo HAYASHI.. code-block:: console 320813c1b26SHiroo HAYASHI 32145e335abSHiroo HAYASHI $ ctags --fields-C++='*' ... 322813c1b26SHiroo HAYASHI 323813c1b26SHiroo HAYASHI`*` can also be used for specifying languages. 324813c1b26SHiroo HAYASHI 325813c1b26SHiroo HAYASHIThe next example is for enabling `end` fields for all languages which 326813c1b26SHiroo HAYASHIhave such a field. 327813c1b26SHiroo HAYASHI 328813c1b26SHiroo HAYASHI.. code-block:: console 329813c1b26SHiroo HAYASHI 33045e335abSHiroo HAYASHI $ ctags --fields-'*'=+'{end}' ... 331813c1b26SHiroo HAYASHI ... 332813c1b26SHiroo HAYASHI 333813c1b26SHiroo HAYASHIIn this case, using wild card notation to specify the language, not 334813c1b26SHiroo HAYASHIonly fields owned by parsers but also common fields having the name 335813c1b26SHiroo HAYASHIspecified (`end` in this example) are enabled/disabled. 336813c1b26SHiroo HAYASHI 337813c1b26SHiroo HAYASHIUsing the wild card notation to specify the language is helpful to 338813c1b26SHiroo HAYASHIavoid incompatibilities between versions of Universal Ctags itself 339813c1b26SHiroo HAYASHI(SELF INCOMPATIBLY). 340813c1b26SHiroo HAYASHI 341813c1b26SHiroo HAYASHIIn Universal Ctags development, a parser developer may add a new 342813c1b26SHiroo HAYASHIparser specific field for a certain language. Sometimes other developers 343813c1b26SHiroo HAYASHIthen recognize it is meaningful not only for the original language 344813c1b26SHiroo HAYASHIbut also other languages. In this case the field may be promoted to a 345813c1b26SHiroo HAYASHIcommon field. Such a promotion will break the command line 346813c1b26SHiroo HAYASHIcompatibility for ``--fields-<LANG>`` usage. The wild card for 347813c1b26SHiroo HAYASHI`<LANG>` will help in avoiding this unwanted effect of the promotion. 348813c1b26SHiroo HAYASHI 349813c1b26SHiroo HAYASHIWith respect to the tags file format, nothing is changed when 350813c1b26SHiroo HAYASHIintroducing parser specific fields; `<fieldname>`:`<value>` is used as 351813c1b26SHiroo HAYASHIbefore and the name of field owner is never prefixed. The `language:` 352813c1b26SHiroo HAYASHIfield of the tag identifies the owner. 353813c1b26SHiroo HAYASHI 354813c1b26SHiroo HAYASHI 355813c1b26SHiroo HAYASHIParser specific extras 356813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357813c1b26SHiroo HAYASHI 358813c1b26SHiroo HAYASHI.. NOT REVIEWED YET 359813c1b26SHiroo HAYASHI 360813c1b26SHiroo HAYASHIAs man page of Exuberant Ctags says, ``--extras`` option specifies 361813c1b26SHiroo HAYASHIwhether to include extra tag entries for certain kinds of information. 362813c1b26SHiroo HAYASHIThis option is available in Universal Ctags, too. 363813c1b26SHiroo HAYASHI 364813c1b26SHiroo HAYASHIIn Universal Ctags it is extended; a parser can define its specific 365813c1b26SHiroo HAYASHIextra flags. They can be controlled with ``--extras-<LANG>=[+|-]{...}``. 366813c1b26SHiroo HAYASHI 367813c1b26SHiroo HAYASHISee some examples: 368813c1b26SHiroo HAYASHI 369813c1b26SHiroo HAYASHI.. code-block:: console 370813c1b26SHiroo HAYASHI 37145e335abSHiroo HAYASHI $ ctags --list-extras 372813c1b26SHiroo HAYASHI #LETTER NAME ENABLED LANGUAGE DESCRIPTION 373813c1b26SHiroo HAYASHI F fileScope TRUE NONE Include tags ... 374813c1b26SHiroo HAYASHI f inputFile FALSE NONE Include an entry ... 375813c1b26SHiroo HAYASHI p pseudo FALSE NONE Include pseudo tags 376813c1b26SHiroo HAYASHI q qualified FALSE NONE Include an extra ... 377813c1b26SHiroo HAYASHI r reference FALSE NONE Include reference tags 378813c1b26SHiroo HAYASHI g guest FALSE NONE Include tags ... 379813c1b26SHiroo HAYASHI - whitespaceSwapped TRUE Robot Include tags swapping ... 380813c1b26SHiroo HAYASHI 381813c1b26SHiroo HAYASHISee the `LANGUAGE` column. NONE means the extra flags are language 382813c1b26SHiroo HAYASHIindependent (common). They can be enabled or disabled with `--extras=` as before. 383813c1b26SHiroo HAYASHI 384813c1b26SHiroo HAYASHILook at `whitespaceSwapped`. Its language is `Robot`. This flag is enabled 385813c1b26SHiroo HAYASHIby default but can be disabled with `--extras-Robot=-{whitespaceSwapped}`. 386813c1b26SHiroo HAYASHI 387813c1b26SHiroo HAYASHI.. code-block:: console 388813c1b26SHiroo HAYASHI 389813c1b26SHiroo HAYASHI $ cat input.robot 390813c1b26SHiroo HAYASHI *** Keywords *** 391813c1b26SHiroo HAYASHI it's ok to be correct 392813c1b26SHiroo HAYASHI Python_keyword_2 393813c1b26SHiroo HAYASHI 39445e335abSHiroo HAYASHI $ ctags -o - input.robot 395813c1b26SHiroo HAYASHI it's ok to be correct input.robot /^it's ok to be correct$/;" k 396813c1b26SHiroo HAYASHI it's_ok_to_be_correct input.robot /^it's ok to be correct$/;" k 397813c1b26SHiroo HAYASHI 39845e335abSHiroo HAYASHI $ ctags -o - --extras-Robot=-'{whitespaceSwapped}' input.robot 399813c1b26SHiroo HAYASHI it's ok to be correct input.robot /^it's ok to be correct$/;" k 400813c1b26SHiroo HAYASHI 401813c1b26SHiroo HAYASHIWhen disabled the name `it's_ok_to_be_correct` is not included in the 402813c1b26SHiroo HAYASHItags output. In other words, the name `it's_ok_to_be_correct` is 403813c1b26SHiroo HAYASHIderived from the name `it's ok to be correct` when the extra flag is 404813c1b26SHiroo HAYASHIenabled. 405813c1b26SHiroo HAYASHI 406813c1b26SHiroo HAYASHIDiscussion 407813c1b26SHiroo HAYASHI......................................................................... 408813c1b26SHiroo HAYASHI 409813c1b26SHiroo HAYASHI.. NOT REVIEWED YET 410813c1b26SHiroo HAYASHI 411813c1b26SHiroo HAYASHI(This subsection should move to somewhere for developers.) 412813c1b26SHiroo HAYASHI 413813c1b26SHiroo HAYASHIThe question is what are extra tag entries. As far as I know none has 414813c1b26SHiroo HAYASHIanswered explicitly. I have two ideas in Universal Ctags. I 415813c1b26SHiroo HAYASHIwrite "ideas", not "definitions" here because existing parsers don't 416813c1b26SHiroo HAYASHIfollow the ideas. They are kept as is in variety reasons but the 417813c1b26SHiroo HAYASHIideas may be good guide for people who wants to write a new parser 418813c1b26SHiroo HAYASHIor extend an exiting parser. 419813c1b26SHiroo HAYASHI 420813c1b26SHiroo HAYASHIThe first idea is that a tag entry whose name is appeared in the input 421813c1b26SHiroo HAYASHIfile as is, the entry is NOT an extra. (If you want to control the 422813c1b26SHiroo HAYASHIinclusion of such entries, the classical ``--kind-<LANG>=[+|-]...`` is 423813c1b26SHiroo HAYASHIwhat you want.) 424813c1b26SHiroo HAYASHI 425813c1b26SHiroo HAYASHIQualified tags, whose inclusion is controlled by ``--extras=+q``, is 426813c1b26SHiroo HAYASHIexplained well with this idea. 427813c1b26SHiroo HAYASHILet's see an example: 428813c1b26SHiroo HAYASHI 429813c1b26SHiroo HAYASHI.. code-block:: console 430813c1b26SHiroo HAYASHI 431813c1b26SHiroo HAYASHI $ cat input.py 432813c1b26SHiroo HAYASHI class Foo: 433813c1b26SHiroo HAYASHI def func (self): 434813c1b26SHiroo HAYASHI pass 435813c1b26SHiroo HAYASHI 43645e335abSHiroo HAYASHI $ ctags -o - --extras=+q --fields=+E input.py 437813c1b26SHiroo HAYASHI Foo input.py /^class Foo:$/;" c 438813c1b26SHiroo HAYASHI Foo.func input.py /^ def func (self):$/;" m class:Foo extra:qualified 439813c1b26SHiroo HAYASHI func input.py /^ def func (self):$/;" m class:Foo 440813c1b26SHiroo HAYASHI 441813c1b26SHiroo HAYASHI`Foo` and `func` are in `input.py`. So they are no extra tags. In 442813c1b26SHiroo HAYASHIother hand, `Foo.func` is not in `input.py` as is. The name is 443813c1b26SHiroo HAYASHIgenerated by ctags as a qualified extra tag entry. 444813c1b26SHiroo HAYASHI`whitespaceSwapped` extra flag of `Robot` parser is also aligned well 445813c1b26SHiroo HAYASHIon the idea. 446813c1b26SHiroo HAYASHI 447813c1b26SHiroo HAYASHII don't say all parsers follows this idea. 448813c1b26SHiroo HAYASHI 449813c1b26SHiroo HAYASHI.. code-block:: console 450813c1b26SHiroo HAYASHI 451813c1b26SHiroo HAYASHI $ cat input.cc 452813c1b26SHiroo HAYASHI class A 453813c1b26SHiroo HAYASHI { 454813c1b26SHiroo HAYASHI A operator+ (int); 455813c1b26SHiroo HAYASHI }; 456813c1b26SHiroo HAYASHI 45745e335abSHiroo HAYASHI $ ctags --kinds-all='*' --fields= -o - input.cc 458813c1b26SHiroo HAYASHI A input.cc /^class A$/ 459813c1b26SHiroo HAYASHI operator + input.cc /^ A operator+ (int);$/ 460813c1b26SHiroo HAYASHI 461813c1b26SHiroo HAYASHIIn this example `operator+` is in `input.cc`. 462813c1b26SHiroo HAYASHIIn other hand, `operator +` is in the ctags output as non extra tag entry. 463813c1b26SHiroo HAYASHISee a whitespace between the keyword `operator` and `+` operator. 464813c1b26SHiroo HAYASHIThis is an exception of the first idea. 465813c1b26SHiroo HAYASHI 466813c1b26SHiroo HAYASHIThe second idea is that if the *inclusion* of a tag cannot be 467813c1b26SHiroo HAYASHIcontrolled well with ``--kind-<LANG>=[+|-]...``, the tag may be an 468813c1b26SHiroo HAYASHIextra. 469813c1b26SHiroo HAYASHI 470813c1b26SHiroo HAYASHI.. code-block:: console 471813c1b26SHiroo HAYASHI 472813c1b26SHiroo HAYASHI $ cat input.c 473813c1b26SHiroo HAYASHI static int foo (void) 474813c1b26SHiroo HAYASHI { 475813c1b26SHiroo HAYASHI return 0; 476813c1b26SHiroo HAYASHI } 477813c1b26SHiroo HAYASHI int bar (void) 478813c1b26SHiroo HAYASHI { 479813c1b26SHiroo HAYASHI return 1; 480813c1b26SHiroo HAYASHI } 481813c1b26SHiroo HAYASHI 48245e335abSHiroo HAYASHI $ ctags --sort=no -o - --extras=+F input.c 483813c1b26SHiroo HAYASHI foo input.c /^static int foo (void)$/;" f typeref:typename:int file: 484813c1b26SHiroo HAYASHI bar input.c /^int bar (void)$/;" f typeref:typename:int 485813c1b26SHiroo HAYASHI 48645e335abSHiroo HAYASHI $ ctags -o - --extras=-F input.c 487813c1b26SHiroo HAYASHI foo input.c /^static int foo (void)$/;" f typeref:typename:int file: 488813c1b26SHiroo HAYASHI 489813c1b26SHiroo HAYASHI $ 490813c1b26SHiroo HAYASHI 491813c1b26SHiroo HAYASHIFunction `foo` of C language is included only when `F` extra flag 492813c1b26SHiroo HAYASHIis enabled. Both `foo` and `bar` are functions. Their inclusions 493813c1b26SHiroo HAYASHIcan be controlled with `f` kind of C language: ``--kind-C=[+|-]f``. 494813c1b26SHiroo HAYASHI 495813c1b26SHiroo HAYASHIThe difference between static modifier or implicit extern modifier in 496813c1b26SHiroo HAYASHIa function definition is handled by `F` extra flag. 497813c1b26SHiroo HAYASHI 498813c1b26SHiroo HAYASHIBasically the concept kind is for handling the kinds of language 499813c1b26SHiroo HAYASHIobjects: functions, variables, macros, types, etc. The concept extra 500813c1b26SHiroo HAYASHIcan handle the other aspects like scope (static or extern). 501813c1b26SHiroo HAYASHI 502813c1b26SHiroo HAYASHIHowever, a parser developer can take another approach instead of 503813c1b26SHiroo HAYASHIintroducing parser specific extra; one can prepare `staticFunction` and 504813c1b26SHiroo HAYASHI`exportedFunction` as kinds of one's parser. The second idea is a 505813c1b26SHiroo HAYASHIjust guide; the parser developer must decide suitable approach for the 506813c1b26SHiroo HAYASHItarget language. 507813c1b26SHiroo HAYASHI 508813c1b26SHiroo HAYASHIAnyway, in the second idea, ``--extras`` is for controlling inclusion 509813c1b26SHiroo HAYASHIof tags. If what you want is not about inclusion, ``--param-<LANG>`` 510813c1b26SHiroo HAYASHIcan be used as the last resort. 511813c1b26SHiroo HAYASHI 512813c1b26SHiroo HAYASHI 513813c1b26SHiroo HAYASHIParser specific parameter 514813c1b26SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 515813c1b26SHiroo HAYASHI 516813c1b26SHiroo HAYASHI.. NOT REVIEWED YET 517813c1b26SHiroo HAYASHI 518813c1b26SHiroo HAYASHITo control the detail of a parser, ``--param-<LANG>`` option is introduced. 519813c1b26SHiroo HAYASHI``--kinds-<LANG>``, ``--fields-<LANG>``, ``--extras-<LANG>`` 520813c1b26SHiroo HAYASHIcan be used for customizing the behavior of a parser specified with ``<LANG>``. 521813c1b26SHiroo HAYASHI 522813c1b26SHiroo HAYASHI``--param-<LANG>`` should be used for aspects of the parser that 523813c1b26SHiroo HAYASHIthe options(kinds, fields, extras) cannot handle well. 524813c1b26SHiroo HAYASHI 525813c1b26SHiroo HAYASHIA parser defines a set of parameters. Each parameter has name and 526813c1b26SHiroo HAYASHItakes an argument. A user can set a parameter with following notation 527813c1b26SHiroo HAYASHI:: 528813c1b26SHiroo HAYASHI 529*8a87cfffSMasatake YAMATO --param-<LANG>.name=arg 530813c1b26SHiroo HAYASHI 531813c1b26SHiroo HAYASHIAn example of specifying a parameter 532813c1b26SHiroo HAYASHI:: 533813c1b26SHiroo HAYASHI 534*8a87cfffSMasatake YAMATO --param-CPreProcessor.if0=true 535813c1b26SHiroo HAYASHI 536813c1b26SHiroo HAYASHIHere `if0` is a name of parameter of CPreProcessor parser and 537813c1b26SHiroo HAYASHI`true` is the value of it. 538813c1b26SHiroo HAYASHI 539813c1b26SHiroo HAYASHIAll available parameters can be listed with ``--list-params`` option. 540813c1b26SHiroo HAYASHI 541813c1b26SHiroo HAYASHI.. code-block:: console 542813c1b26SHiroo HAYASHI 54345e335abSHiroo HAYASHI $ ctags --list-params 544813c1b26SHiroo HAYASHI #PARSER NAME DESCRIPTION 545813c1b26SHiroo HAYASHI CPreProcessor if0 examine code within "#if 0" branch (true or [false]) 546813c1b26SHiroo HAYASHI CPreProcessor ignore a token to be specially handled 547813c1b26SHiroo HAYASHI 548813c1b26SHiroo HAYASHI(At this time only CPreProcessor parser has parameters.) 549