View Source erl_anno (stdlib v6.0)

Abstract datatype for the annotations of the Erlang Compiler.

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

erl_parse, erl_scan

Summary

Types

A collection of annotations.

The term representing a collection of annotations. It is either a location/0 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.

Types

Link to this opaque

anno()

View Source (since OTP 18.0)
-opaque anno()

A collection of annotations.

Link to this type

anno_term()

View Source (since OTP 18.0)
-type anno_term() :: term().

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

Link to this type

column()

View Source (since OTP 18.0)
-type column() :: pos_integer().
Link to this type

filename()

View Source (not exported) (since OTP 18.0)
-type filename() :: file:filename_all().
Link to this type

generated()

View Source (not exported) (since OTP 18.0)
-type generated() :: boolean().
Link to this type

line()

View Source (since OTP 18.0)
-type line() :: non_neg_integer().
Link to this type

location()

View Source (since OTP 18.0)
-type location() :: line() | {line(), column()}.
Link to this type

record()

View Source (not exported) (since OTP 18.0)
-type record() :: boolean().
Link to this type

text()

View Source (since OTP 18.0)
-type text() :: string().

Functions

Link to this function

column(Anno)

View Source (since OTP 18.0)
-spec column(Anno) -> column() | undefined when Anno :: anno().

Returns the column of the annotations Anno.

Link to this function

end_location(Anno)

View Source (since OTP 18.0)
-spec end_location(Anno) -> location() | undefined when Anno :: anno().

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

Link to this function

file(Anno)

View Source (since OTP 18.0)
-spec file(Anno) -> filename() | undefined when Anno :: anno().

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

Link to this function

from_term(Term)

View Source (since OTP 18.0)
-spec from_term(Term) -> Anno when Term :: anno_term(), Anno :: anno().

Returns annotations with representation Term.

See also to_term().

Link to this function

generated(Anno)

View Source (since OTP 18.0)
-spec generated(Anno) -> generated() when Anno :: anno().

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

Link to this function

is_anno(Term)

View Source (since OTP 18.0)
-spec is_anno(Term) -> boolean() when Term :: any().

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

Link to this function

line(Anno)

View Source (since OTP 18.0)
-spec line(Anno) -> line() when Anno :: anno().

Returns the line of the annotations Anno.

Link to this function

location(Anno)

View Source (since OTP 18.0)
-spec location(Anno) -> location() when Anno :: anno().

Returns the location of the annotations Anno.

Link to this function

new(Location)

View Source (since OTP 18.0)
-spec new(Location) -> anno() when Location :: location().

Creates a new collection of annotations given a location.

Link to this function

set_file(File, Anno)

View Source (since OTP 18.0)
-spec set_file(File, Anno) -> Anno when File :: filename(), Anno :: anno().

Modifies the filename of the annotations Anno.

Link to this function

set_generated(Generated, Anno)

View Source (since OTP 18.0)
-spec set_generated(Generated, Anno) -> Anno when Generated :: generated(), Anno :: anno().

Modifies the generated marker of the annotations Anno.

Link to this function

set_line(Line, Anno)

View Source (since OTP 18.0)
-spec set_line(Line, Anno) -> Anno when Line :: line(), Anno :: anno().

Modifies the line of the annotations Anno.

Link to this function

set_location(Location, Anno)

View Source (since OTP 18.0)
-spec set_location(Location, Anno) -> Anno when Location :: location(), Anno :: anno().

Modifies the location of the annotations Anno.

Link to this function

set_record(Record, Anno)

View Source (since OTP 18.0)
-spec set_record(Record, Anno) -> Anno when Record :: record(), Anno :: anno().

Modifies the record marker of the annotations Anno.

Link to this function

set_text(Text, Anno)

View Source (since OTP 18.0)
-spec set_text(Text, Anno) -> Anno when Text :: text(), Anno :: anno().

Modifies the text of the annotations Anno.

Link to this function

text(Anno)

View Source (since OTP 18.0)
-spec text(Anno) -> text() | undefined when Anno :: anno().

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

Link to this function

to_term(Anno)

View Source (since OTP 18.0)
-spec to_term(Anno) -> anno_term() when Anno :: anno().

Returns the term representing the annotations Anno.

See also from_term().