aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc/src/erl_anno.xml
blob: f316f63d985390f1cd1c2dfa7e9568218ab7e8d4 (plain) (blame)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2015</year>
      <year>2016</year>
      <holder>Ericsson AB, All Rights Reserved</holder>
    </copyright>
    <legalnotice>
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  The Initial Developer of the Original Code is Ericsson AB.
    </legalnotice>

    <title>erl_anno</title>
    <prepared>Hans Bolinder</prepared>
    <responsible>Kenneth Lundin</responsible>
    <docno>1</docno>
    <approved></approved>
    <checked></checked>
    <date>2015-02-26</date>
    <rev>A</rev>
    <file>erl_anno.xml</file>
  </header>
  <module>erl_anno</module>
  <modulesummary>Abstract datatype for the annotations of the Erlang Compiler.
  </modulesummary>

  <description>
    <p>This module provides an abstract type that is used by the
      Erlang Compiler and its helper modules for holding data such as
      column, line number, and text. The data type is a collection of
      <marker id="annotations"/><em>annotations</em> as
      described in the following.</p>

    <p>The Erlang Token Scanner returns tokens with a subset of
      the following annotations, depending on the options:</p>

    <taglist>
      <tag><c>column</c></tag>
      <item><p>The column where the token begins.</p></item>
      <tag><c>location</c></tag>
      <item><p>The line and column where the token begins, or
        just the line if the column is unknown.</p></item>
      <tag><c>text</c></tag>
      <item><p>The token's text.</p></item>
    </taglist>

    <p>From this, the following annotation is derived:</p>

    <taglist>
      <tag><c>line</c></tag>
      <item><p>The line where the token begins.</p></item>
    </taglist>

    <p>This module also supports the following annotations,
      which are used by various modules:</p>

    <taglist>
      <tag><c>file</c></tag>
      <item><p>A filename.</p></item>
      <tag><c>generated</c></tag>
      <item><p>A Boolean indicating if the abstract code is
        compiler-generated. The Erlang Compiler does not emit warnings
        for such code.</p></item>
      <tag><c>record</c></tag>
      <item><p>A Boolean indicating if the origin of the abstract
        code is a record. Used by
        <seealso marker="dialyzer:dialyzer">Dialyzer</seealso>
        to assign types to tuple elements.</p>
      </item>
    </taglist>

    <p>The functions
      <seealso marker="erl_scan#column/1"><c>column()</c></seealso>,
      <seealso marker="erl_scan#end_location/1"><c>end_location()</c></seealso>,
      <seealso marker="erl_scan#line/1"><c>line()</c></seealso>,
      <seealso marker="erl_scan#location/1"><c>location()</c></seealso>, and
      <seealso marker="erl_scan#text/1"><c>text()</c></seealso>
      in the <c>erl_scan</c> module can be used for inspecting
      annotations in tokens.</p>

    <p>The functions
      <seealso marker="erl_parse#anno_from_term/1">
      <c>anno_from_term()</c></seealso>,
      <seealso marker="erl_parse#anno_to_term/1">
      <c>anno_to_term()</c></seealso>,
      <seealso marker="erl_parse#fold_anno/3"><c>fold_anno()</c></seealso>,
      <seealso marker="erl_parse#map_anno/2"><c>map_anno()</c></seealso>,
      <seealso marker="erl_parse#mapfold_anno/3">
      <c>mapfold_anno()</c></seealso>,
      and <seealso marker="erl_parse#new_anno/1"><c>new_anno()</c></seealso>,
      in the <c>erl_parse</c> module can be
      used for manipulating annotations in abstract code.</p>
  </description>

  <datatypes>
    <datatype>
      <name>anno()</name>
      <desc><p>A collection of annotations.</p>
      </desc>
    </datatype>
    <datatype>
      <name name="anno_term"></name>
      <desc>
        <p>The term representing a collection of annotations. It is
          either a <c>location()</c> or a list of key-value pairs.</p>
      </desc>
    </datatype>
    <datatype>
      <name name="column"></name>
    </datatype>
    <datatype>
      <name name="line"></name>
    </datatype>
    <datatype>
      <name name="location"></name>
    </datatype>
    <datatype>
      <name name="text"></name>
    </datatype>
  </datatypes>

  <funcs>
    <func>
      <name name="column" arity="1"/>
      <fsummary>Return the column.</fsummary>
      <type name="column"></type>
      <desc>
        <p>Returns the column of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="end_location" arity="1"/>
      <fsummary>Return the end location of the text.</fsummary>
      <type name="location"></type>
      <desc>
        <p>Returns the end location of the text of the
          annotations <anno>Anno</anno>. If there is no text,
          <c>undefined</c> is returned.</p>
      </desc>
    </func>

    <func>
      <name name="file" arity="1"/>
      <fsummary>Return the filename.</fsummary>
      <type name="filename"></type>
      <desc>
        <p>Returns the filename of the annotations <anno>Anno</anno>.
          If there is no filename, <c>undefined</c> is returned.</p>
      </desc>
    </func>

    <func>
      <name name="from_term" arity="1"/>
      <fsummary>Return annotations given a term.</fsummary>
      <desc>
        <p>Returns annotations with representation <anno>Term</anno>.</p>
        <p>See also <seealso marker="#to_term/1">to_term()</seealso>.</p>
      </desc>
    </func>

    <func>
      <name name="generated" arity="1"/>
      <fsummary>Return the generated Boolean.</fsummary>
      <type name="generated"></type>
      <desc>
        <p>Returns <c>true</c> if annotations <anno>Anno</anno>
          is marked as generated. The default is to return
          <c>false</c>.</p>
      </desc>
    </func>

    <func>
      <name name="is_anno" arity="1"/>
      <fsummary>Test for a collection of annotations.</fsummary>
      <desc>
        <p>Returns <c>true</c> if <anno>Term</anno> is a collection of
          annotations, otherwise <c>false</c>.</p>
      </desc>
    </func>

    <func>
      <name name="line" arity="1"/>
      <fsummary>Return the line.</fsummary>
      <type name="line"></type>
      <desc>
        <p>Returns the line of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="location" arity="1"/>
      <fsummary>Return the location.</fsummary>
      <type name="location"></type>
      <desc>
        <p>Returns the location of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="new" arity="1"/>
      <fsummary>Create a new collection of annotations.</fsummary>
      <type name="location"></type>
      <desc>
        <p>Creates a new collection of annotations given a location.</p>
      </desc>
    </func>

    <func>
      <name name="set_file" arity="2"/>
      <fsummary>Modify the filename.</fsummary>
      <type name="filename"></type>
      <desc>
        <p>Modifies the filename of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="set_generated" arity="2"/>
      <fsummary>Modify the generated marker.</fsummary>
      <type name="generated"></type>
      <desc>
        <p>Modifies the generated marker of the annotations <anno>Anno</anno>.
        </p>
      </desc>
    </func>

    <func>
      <name name="set_line" arity="2"/>
      <fsummary>Modify the line.</fsummary>
      <type name="line"></type>
      <desc>
        <p>Modifies the line of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="set_location" arity="2"/>
      <fsummary>Modify the location.</fsummary>
      <type name="location"></type>
      <desc>
        <p>Modifies the location of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="set_record" arity="2"/>
      <fsummary>Modify the record marker.</fsummary>
      <type name="record"></type>
      <desc>
        <p>Modifies the record marker of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>

    <func>
      <name name="set_text" arity="2"/>
      <fsummary>Modify the text.</fsummary>
      <type name="text"></type>
      <desc>
        <p>Modifies the text of the annotations <anno>Anno</anno>.</p>
      </desc>
    </func>
    <func>

      <name name="text" arity="1"/>
      <fsummary>Return the text.</fsummary>
      <type name="text"></type>
      <desc>
        <p>Returns the text of the annotations <anno>Anno</anno>.
          If there is no text, <c>undefined</c> is returned.</p>
      </desc>
    </func>

    <func>
      <name name="to_term" arity="1"/>
      <fsummary>Return the term representing a collection of annotations.
      </fsummary>
      <desc>
        <p>Returns the term representing the annotations <anno>Anno</anno>.</p>
        <p>See also <seealso marker="#from_term/1">from_term()</seealso>.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>See Also</title>
    <p><seealso marker="erl_parse"><c>erl_parse(3)</c></seealso>,
      <seealso marker="erl_scan"><c>erl_scan(3)</c></seealso></p>
  </section>
</erlref>