erl_anno (stdlib v3.15.2)
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 annotations as described in the following.
The Erlang Token Scanner returns tokens with a subset of the following annotations, depending on the options:
column
The column where the token begins.
location
The line and column where the token begins, or just the line if the column is unknown.
text
The token's text.
From this, the following annotation is derived:
line
The line where the token begins.
This module also supports the following annotations, which are used by various modules:
file
A filename.
generated
A Boolean indicating if the abstract code is compiler-generated. The Erlang Compiler does not emit warnings for such code.
record
A Boolean indicating if the origin of the abstract code is a record. Used by Dialyzer to assign types to tuple elements.
The functions column()
, end_location()
, line()
, location()
, and text()
in the erl_scan
module can be used for inspecting annotations in tokens.
The functions anno_from_term()
, anno_to_term()
, fold_anno()
, map_anno()
, mapfold_anno()
, and new_anno()
, in the erl_parse
module can be used for manipulating annotations in abstract code.
See Also
Link to this section Summary
Types
A collection of annotations.
The term representing a collection of annotations. It is either a location()
or a list of key-value pairs.
Functions
Returns the column of the annotations Anno.
Returns the end location of the text of the annotations Anno. If there is no text, undefined
is returned.
Returns the filename of the annotations Anno. If there is no filename, undefined
is returned.
Returns annotations with representation Term.
Returns true
if annotations Anno is marked as generated. The default is to return false
.
Returns true
if Term is a collection of annotations, otherwise false
.
Returns the line of the annotations Anno.
Returns the location of the annotations Anno.
Creates a new collection of annotations given a location.
Modifies the filename of the annotations Anno.
Modifies the generated marker of the annotations Anno.
Modifies the line of the annotations Anno.
Modifies the location of the annotations Anno.
Modifies the record marker of the annotations Anno.
Modifies the text of the annotations Anno.
Returns the text of the annotations Anno. If there is no text, undefined
is returned.
Returns the term representing the annotations Anno.
Link to this section Types
Specs
anno()
A collection of annotations.
-type anno_term() :: term().
Specs
anno_term() :: term().
The term representing a collection of annotations. It is either a location()
or a list of key-value pairs.
-type column() :: term().
Specs
column() :: pos_integer().
-type line() :: term().
Specs
line() :: non_neg_integer().
-type location() :: term().
Specs
-type text() :: term().
Specs
text() :: string().
Link to this section Functions
Specs
Returns the column of the annotations Anno.
Specs
Returns the end location of the text of the annotations Anno. If there is no text, undefined
is returned.
Specs
Returns the filename of the annotations Anno. If there is no filename, undefined
is returned.
Specs
Returns annotations with representation Term.
See also to_term().
Specs
Returns true
if annotations Anno is marked as generated. The default is to return false
.
Specs
is_anno(Term) -> boolean() when Term :: any().
Returns true
if Term is a collection of annotations, otherwise false
.
Specs
Returns the line of the annotations Anno.
Specs
Returns the location of the annotations Anno.
Specs
Creates a new collection of annotations given a location.
Specs
Modifies the filename of the annotations Anno.
Specs
Modifies the generated marker of the annotations Anno.
Specs
Modifies the line of the annotations Anno.
Specs
Modifies the location of the annotations Anno.
Specs
set_record(Record, Anno) -> Anno when Record :: record(), Anno :: anno().
Modifies the record marker of the annotations Anno.
Specs
Modifies the text of the annotations Anno.
Specs
Returns the text of the annotations Anno. If there is no text, undefined
is returned.
Specs
Returns the term representing the annotations Anno.
See also from_term().