1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
.. _ctags-lang-gdscript(7):
==============================================================
ctags-lang-gdscript
==============================================================
Random notes about tagging GDScript source code with Universal Ctags
:Version: 6.2.1
:Manual group: Universal Ctags
:Manual section: 7
SYNOPSIS
--------
| **ctags** ... --languages=+GDScript ...
| **ctags** ... --language-force=GDScript ...
| **ctags** ... --map-GDScript=+.gd ...
DESCRIPTION
-----------
This man page gathers random notes about tagging GDScript source code
with Universal Ctags.
Storing Annotations
-------------------
Like the Python parser storing decorations to ``decorations`` field,
the GDScript parser stores annotations
starting from `@` to the language specific field, ``annotations``.
Though the field is enabled explicitly in following examples, the
field is enabled by default.
"input.gd"
.. code-block:: GDScript
@export
var s = "Hello"
@master
func f(msg):
print(msg)
"output.tags"
with "--options=NONE --sort=no --fields-GDScript=+{annotations} -o - input.gd"
.. code-block:: tags
s input.gd /^var s = "Hello"$/;" v annotations:export
f input.gd /^func f(msg):$/;" m annotations:master
Extracting `func`
-----------------
A language object defined with `func` keyword is tagged with ``method`` kind.
Like annotations, the parser stores keywords modifying `func` like `static` to
the ``annotations`` field.
"input.gd"
.. code-block:: GDScript
func f(x):
return x
static func f_s(x):
reutrn x
remote func f_r(x):
return x
"output.tags"
with "--options=NONE --sort=no --fields=+K --fields-GDScript=+{annotations} -o - input.gd"
.. code-block:: tags
f input.gd /^func f(x):$/;" method
f_s input.gd /^static func f_s(x):$/;" method annotations:static
f_r input.gd /^remote func f_r(x):$/;" method annotations:remote
Tagging implicitly defined classes
----------------------------------
"A file is a class!" in GDScript. A class is implicitly
defined. Functions, variables, constants, and signals are parts of the
class though the class is unnamed by default.
If the language specific extra, ``implicitClass``, is enabled, the
parser makes a anonymous tag for the class. The parser fills the scope
fields of the tags for all language objects defined in the file with
the anonymous tag.
Let's see an example demonstrating the effect of the extra.
Turning off the extra:
"input.gd"
.. code-block:: GDScript
func f(x):
return x
"output.tags"
with "--options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd"
.. code-block:: tags
f input.gd /^func f(x):$/;" method
Turning on the extra:
"input.gd"
.. code-block:: GDScript
func g(x):
return x
"output.tags"
with "--options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd"
.. code-block:: tags
anon_class_84011bee0100 input.gd /^func g(x):$/;" class
g input.gd /^func g(x):$/;" method scope:class:anon_class_84011bee0100
Tagging the name specified with `class_name`
---------------------------------------------
`class_name` is a keyword for giving a name to the implicitly defined
class. If ``implicitClass`` is turned off, the parser just extract
the name coming after the keyword with ``class`` kind. If
``implicitClass`` is turned on, the parser converts the anonymous tag
to a non-anonymous tag with the specified name. When converting,
the parser also updates scope fields of the other tags in the file.
Turning off the extra:
"input.gd"
.. code-block:: GDScript
class_name c
func f(x):
return x
"output.tags"
with "--options=NONE --fields=+KZ --extras-GDScript=-{implicitClass} -o - input.gd"
.. code-block:: tags
c input.gd /^class_name c$/;" class
f input.gd /^func f(x):$/;" method
Turning on the extra:
"input.gd"
.. code-block:: GDScript
class_name C
func g(x):
return x
"output.tags"
with "--options=NONE --fields=+KZ --extras-GDScript=+{implicitClass} -o - input.gd"
.. code-block:: tags
C input.gd /^class_name C$/;" class
g input.gd /^func g(x):$/;" method scope:class:C
Filling ``inherits`` field
--------------------------
`extends` keyword specifies the super class for the implicitly defined class.
If `implicitClass` extra is turned on, the parser fills ``inherits`` field
of the tag for the implicitly defined class with the name of super class.
"input.gd"
.. code-block:: GDScript
extends B
class_name C
"output.tags"
with "--options=NONE --fields=+Ki --extras-GDScript=+{implicitClass} -o - input.gd"
.. code-block:: tags
C input.gd /^class_name C$/;" class inherits:B
When `--extras=+r` is given, the parser extracts the class specified with the
`extends` keyword as a reference tag of ``class`` kind with ``extended`` role.
"input.gd"
.. code-block:: GDScript
extends B
"output.tags"
with "--options=NONE --fields=+rEK --extras=+r -o - input.gd"
.. code-block:: tags
B input.gd /^extends B$/;" class roles:extended extras:reference
SEE ALSO
--------
:ref:`ctags(1) <ctags(1)>`
|