/** * Returns the debug information. * * @param int $index The index * * @return \ILess\DebugInfo */ protected function getDebugInfo($index) { list($lineNumber) = Util::getLocation($this->input->getInput(), $index); return new DebugInfo($this->context->currentFileInfo->filename, $lineNumber); }
/** * Returns the current line and column. * * @param FileInfo|ImportedFile|string $currentFile The file * @param int $index Current position index * @param bool $excerpt Include the string excerpt? * * @return array */ protected function getLocation($currentFile, $index, $column = null, $excerpt = true) { $line = $col = $excerptContent = null; if ($index !== null && $currentFile) { $content = null; if ($currentFile instanceof FileInfo && $currentFile->importedFile) { $content = $currentFile->importedFile->getContent(); } elseif (is_string($currentFile) && Util::isPathAbsolute($currentFile) && is_readable($currentFile)) { $content = file_get_contents($currentFile); } if ($content) { list($line, $col, $excerptContent) = Util::getLocation($content, $index, $column, $excerpt); } } return [$line, $col, $excerptContent]; }