raesl.types
#
Some general types, inspired by the Language Server Protocol.
Module Contents#
Classes#
Position in a text document expressed as zero-based line and character offset. |
|
A range in a text document expressed as (zero-based) start and end positions. |
|
Represents a location inside a resource. Such as a line inside a text file. |
|
Enum where members are also (and must be) ints |
|
Represents a related message and source code location for a diagnostic. |
|
Represents a diagnostic, such as a compiler error or warning. |
- class raesl.types.Position(line: int = 0, character: int = 0)#
Position in a text document expressed as zero-based line and character offset.
A position is between two characters like an ‘insert’ cursor in an editor. Special values like for example -1 to denote the end of a line are not supported.
- Parameters:
line – Line position in a document (zero-based).
character – Character offset on a line in a document (zero-based). Assuming that the line is represented as a string, the ‘character’ value represents the gap between ‘character’ and ‘character + 1’.
- __eq__(other)#
Return self==value.
- __ge__(other)#
Return self>=value.
- __gt__(other)#
Return self>value.
- __le__(other)#
Return self<=value.
- __lt__(other)#
Return self<value.
- __ne__(other)#
Return self!=value.
- __hash__()#
Return hash(self).
- __iter__()#
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- class raesl.types.Range(start: Position, end: Position)#
A range in a text document expressed as (zero-based) start and end positions.
A range is comparable to a selection in an editor. Therefore the end position is exclusive. If you want to specify a range that contains a line including the ending character(s) then use an end position denoting the start of the next line.
- Parameters:
start – The range’s start position.
end – The range’s end position.
- __eq__(other)#
Return self==value.
- __hash__()#
Return hash(self).
- __iter__()#
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- class raesl.types.Location(uri: str, range: Range)#
Represents a location inside a resource. Such as a line inside a text file.
- Parameters:
uri – URI of this location.
range – Range of this location.
- get_key() Tuple[str, int, int] #
Get a tuple with identification for this position.
- __eq__(other)#
Return self==value.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- class raesl.types.DiagnosticSeverity#
Bases:
enum.IntEnum
Enum where members are also (and must be) ints
- Error = 1#
- Warning = 2#
- Information = 3#
- Hint = 4#
- class raesl.types.DiagnosticRelatedInformation(location: Location, message: str)#
Represents a related message and source code location for a diagnostic.
This should be used to point to code locations that cause or are related to a diagnostic, e.g when duplicating a symbol in a scope.
- Parameters:
location – The location of this related diagnostic information.
message – The message of this related diagnostic information.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- class raesl.types.Diagnostic(message: str, range: Range, severity: DiagnosticSeverity = DiagnosticSeverity.Error, code: str = None, source: str = None, related_information: List[DiagnosticRelatedInformation] = None)#
Represents a diagnostic, such as a compiler error or warning.
Diagnostic objects are only valid in the scope of a resource.
- Parameters:
message – The diagnostic’s message.
range – The range at which the message applies.
severity – The diagnostic’s severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.
code – The diagnostic’s code, which might appear in the user interface.
source – A human-readable string describing the source of this diagnostic, e.g. ‘esl’, or ‘esl compiler’.
related_information – A list of related diagnostic information, e.g. when symbol-names within a scope collide you can mark all definitions via this property.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- _print(style=repr)#