Remove content
parent
663ccd5f23
commit
c4d0ace918
|
@ -46,13 +46,6 @@ class PhpDocument
|
|||
*/
|
||||
private $uri;
|
||||
|
||||
/**
|
||||
* The content of the document
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* The AST of the document
|
||||
*
|
||||
|
@ -133,8 +126,6 @@ class PhpDocument
|
|||
*/
|
||||
public function updateContent(string $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
// Unregister old definitions
|
||||
if (isset($this->definitions)) {
|
||||
foreach ($this->definitions as $fqn => $definition) {
|
||||
|
@ -182,10 +173,10 @@ class PhpDocument
|
|||
*/
|
||||
public function getFormattedText()
|
||||
{
|
||||
if (empty($this->content)) {
|
||||
if (empty($this->getContent())) {
|
||||
return [];
|
||||
}
|
||||
return Formatter::format($this->content, $this->uri);
|
||||
return Formatter::format($this->getContent(), $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +186,7 @@ class PhpDocument
|
|||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
return $this->sourceFileNode->fileContents;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,12 +247,10 @@ class PhpDocument
|
|||
*/
|
||||
public function getRange(Range $range)
|
||||
{
|
||||
if ($this->content === null) {
|
||||
return null;
|
||||
}
|
||||
$start = $range->start->toOffset($this->content);
|
||||
$length = $range->end->toOffset($this->content) - $start;
|
||||
return substr($this->content, $start, $length);
|
||||
$content = $this->getContent();
|
||||
$start = $range->start->toOffset($content);
|
||||
$length = $range->end->toOffset($content) - $start;
|
||||
return substr($content, $start, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,6 @@ class TreeAnalyzer
|
|||
$this->parser = $parser;
|
||||
$this->docBlockFactory = $docBlockFactory;
|
||||
$this->definitionResolver = $definitionResolver;
|
||||
$this->content = $content;
|
||||
$this->sourceFileNode = $this->parser->parseSourceFile($content, $uri);
|
||||
|
||||
// TODO - docblock errors
|
||||
|
@ -76,7 +75,7 @@ class TreeAnalyzer
|
|||
}
|
||||
|
||||
if (($error = PhpParser\DiagnosticsProvider::checkDiagnostics($node)) !== null) {
|
||||
$range = PhpParser\PositionUtilities::getRangeFromPosition($error->start, $error->length, $this->content);
|
||||
$range = PhpParser\PositionUtilities::getRangeFromPosition($error->start, $error->length, $this->sourceFileNode->fileContents);
|
||||
|
||||
$this->diagnostics[] = new Diagnostic(
|
||||
$error->message,
|
||||
|
|
Loading…
Reference in New Issue