erl_anno

erl_anno

erl_anno
Abstract datatype for the annotations of the Erlang Compiler.
Module erl_anno was introduced in OTP 18.0.

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:

The column where the token begins.

The line and column where the token begins, or just the line if the column is unknown.

The token's text.

From this, the following annotation is derived:

The line where the token begins.

This module also supports the following annotations, which are used by various modules:

A filename.

A Boolean indicating if the abstract code is compiler-generated. The Erlang Compiler does not emit warnings for such code.

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.

A collection of annotations.

The term representing a collection of annotations. It is either a location() or a list of key-value pairs.

Types

Anno = anno()
location() = line() | {line(), column()}

Returns the end location of the text of the annotations Anno. If there is no text, undefined is returned.

Types

Anno = anno()
filename() = file:filename_all()

Returns the filename of the annotations Anno. If there is no filename, undefined is returned.

Types

Anno = anno()

Returns annotations with representation Term.

See also to_term().

Types

Anno = anno()
generated() = boolean()

Returns true if annotations Anno is marked as generated. The default is to return false.

Types

Term = any()

Returns true if Term is a collection of annotations, otherwise false.

Types

File = filename()
Anno = anno()
filename() = file:filename_all()

Modifies the filename of the annotations Anno.

Types

Generated = generated()
Anno = anno()
generated() = boolean()

Modifies the generated marker of the annotations Anno.

Types

Line = line()
Anno = anno()
line() = integer() >= 0

Modifies the line of the annotations Anno.

Types

Record = record()
Anno = anno()
record() = boolean()

Modifies the record marker of the annotations Anno.

Types

Text = text()
Anno = anno()
text() = string()

Modifies the text of the annotations Anno.

Types

Anno = anno()
text() = string()

Returns the text of the annotations Anno. If there is no text, undefined is returned.