1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Expose code location raw line number

This commit is contained in:
Brown 2019-08-06 17:11:25 -04:00
parent fc8d2bd563
commit 0051636a99
4 changed files with 11 additions and 6 deletions

View File

@ -27,7 +27,7 @@ class CodeLocation
public $file_name;
/** @var int */
protected $line_number;
public $raw_line_number;
/** @var int */
private $end_line_number = -1;
@ -123,7 +123,7 @@ class CodeLocation
$doc_comment = $stmt->getDocComment();
$this->preview_start = $doc_comment ? $doc_comment->getFilePos() : $this->file_start;
$this->docblock_start_line_number = $doc_comment ? $doc_comment->getLine() : null;
$this->line_number = $stmt->getLine();
$this->raw_line_number = $stmt->getLine();
}
/**
@ -324,7 +324,7 @@ class CodeLocation
*/
public function getLineNumber()
{
return $this->docblock_line_number ?: $this->line_number;
return $this->docblock_line_number ?: $this->raw_line_number;
}
/**
@ -409,4 +409,9 @@ class CodeLocation
{
return $this->file_name . ':' . $this->getLineNumber() . ':' . $this->getColumn();
}
public function getQuickSummary() : string
{
return $this->file_name . ':' . $this->raw_line_number;
}
}

View File

@ -25,6 +25,6 @@ class DocblockTypeLocation extends \Psalm\CodeLocation
$this->single_line = false;
$this->preview_start = $this->file_start;
$this->line_number = $line_number;
$this->raw_line_number = $line_number;
}
}

View File

@ -27,7 +27,7 @@ class ParseErrorLocation extends \Psalm\CodeLocation
$this->single_line = false;
$this->preview_start = $this->file_start;
$this->line_number = substr_count(
$this->raw_line_number = substr_count(
substr($file_contents, 0, $this->file_start),
"\n"
) + 1;

View File

@ -26,7 +26,7 @@ class Raw extends \Psalm\CodeLocation
$this->single_line = false;
$this->preview_start = $this->file_start;
$this->line_number = substr_count(
$this->raw_line_number = substr_count(
substr($file_contents, 0, $this->file_start),
"\n"
) + 1;