ifc-expressions
Version:
Parsing and evaluation of IFC expressions
46 lines (45 loc) • 1.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextPosition = void 0;
class TextPosition {
constructor(line, column) {
this._line = line;
this._column = column;
if (this._line < 1 || this._column < 1) {
throw new Error(`Cannot create text position ${this.toString()}. Text positions are 1-based. No line or column values below 1 are allowed.`);
}
}
static of(line, column) {
return new TextPosition(line, column);
}
toString() {
return this._line + ":" + this._column;
}
get line() {
return this._line;
}
get column() {
return this._column;
}
isFirstLine() {
return this._line === 1;
}
isFirstColumn() {
return this._column === 1;
}
isAtBeginning() {
return this.isFirstLine() && this.isFirstColumn();
}
isAtSameLine(other) {
return this._line === other?._line;
}
isAtSameColumn(other) {
return this.column === other?.column;
}
isBefore(other) {
const linediff = this._line - other._line;
return linediff < 0 || (linediff === 0 && this._column < other._column);
}
}
exports.TextPosition = TextPosition;
//# sourceMappingURL=TextPosition.js.map