| Total Complexity | 4 | 
| Total Lines | 26 | 
| Duplicated Lines | 0 % | 
| 1 | from coalib.misc.Decorators import (enforce_signature, | ||
| 7 | @generate_repr("file", "line", "column") | ||
| 8 | @generate_ordering("file", "line", "column") | ||
| 9 | class SourcePosition(TextPosition): | ||
| 10 | @enforce_signature | ||
| 11 | def __init__(self, file: str, line=None, column=None): | ||
| 12 | """ | ||
| 13 | Creates a new result position object that represents the position of a | ||
| 14 | result in the source code. | ||
| 15 | |||
| 16 | :param file: The filename or None. | ||
| 17 | :param line: The line in file or None, the first line is 1. | ||
| 18 | :param column: The column indicating the character. The first one | ||
| 19 | in a line is 1. | ||
| 20 | :raises TypeError: Raised when line or columns are no integers. | ||
| 21 | :raises ValueError: If a line number without a file is provided. | ||
| 22 | """ | ||
| 23 | TextPosition.__init__(self, line, column) | ||
| 24 | |||
| 25 | if file is None and line is not None: | ||
| 26 |             raise ValueError("A line must be associated to a file.") | ||
| 27 | |||
| 28 | self._file = file | ||
| 29 | |||
| 30 | @property | ||
| 31 | def file(self): | ||
| 32 | return self._file | ||
| 33 |