* FilePositionMap can be used to get the line number for a large number of nodes (starting from 1).
* It works the most efficiently when the requested node is close to the previously requested node.
*
* Other designs that weren't chosen:
* - Precomputing all of the start/end offsets when initializing was slower - Some offsets weren't needed, and walking the tree was slower.
* - Caching line numbers for previously requested offsets wasn't really necessary, since offsets are usually close together and weren't requested repeatedly.
*/
classFilePositionMap{
/** @var string the full file contents */
private$fileContents;
/** @var int - Precomputed strlen($file_contents) */
private$fileContentsLength;
/** @var int the 0-based byte offset of the most recent request for a line number. */
private$currentOffset;
/** @var int the 1-based line number for $this->currentOffset (updated whenever currentOffset is updated) */