Reset definitions and references on content update
parent
d03db024c1
commit
edd721d291
|
@ -141,7 +141,24 @@ class PhpDocument
|
||||||
public function updateContent(string $content)
|
public function updateContent(string $content)
|
||||||
{
|
{
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$stmts = null;
|
|
||||||
|
// Unregister old definitions
|
||||||
|
if (isset($this->definitions)) {
|
||||||
|
foreach ($this->definitions as $fqn => $definition) {
|
||||||
|
$this->index->removeDefinition($fqn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unregister old references
|
||||||
|
if (isset($this->referenceNodes)) {
|
||||||
|
foreach ($this->referenceNodes as $fqn => $node) {
|
||||||
|
$this->index->removeReferenceUri($fqn, $this->uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->referenceNodes = null;
|
||||||
|
$this->definitions = null;
|
||||||
|
$this->definitionNodes = null;
|
||||||
|
|
||||||
$errorHandler = new ErrorHandler\Collecting;
|
$errorHandler = new ErrorHandler\Collecting;
|
||||||
$stmts = $this->parser->parse($content, $errorHandler);
|
$stmts = $this->parser->parse($content, $errorHandler);
|
||||||
|
@ -187,25 +204,12 @@ class PhpDocument
|
||||||
|
|
||||||
$traverser->traverse($stmts);
|
$traverser->traverse($stmts);
|
||||||
|
|
||||||
// Unregister old definitions
|
|
||||||
if (isset($this->definitions)) {
|
|
||||||
foreach ($this->definitions as $fqn => $definition) {
|
|
||||||
$this->index->removeDefinition($fqn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Register this document on the project for all the symbols defined in it
|
// Register this document on the project for all the symbols defined in it
|
||||||
$this->definitions = $definitionCollector->definitions;
|
$this->definitions = $definitionCollector->definitions;
|
||||||
$this->definitionNodes = $definitionCollector->nodes;
|
$this->definitionNodes = $definitionCollector->nodes;
|
||||||
foreach ($definitionCollector->definitions as $fqn => $definition) {
|
foreach ($definitionCollector->definitions as $fqn => $definition) {
|
||||||
$this->index->setDefinition($fqn, $definition);
|
$this->index->setDefinition($fqn, $definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister old references
|
|
||||||
if (isset($this->referenceNodes)) {
|
|
||||||
foreach ($this->referenceNodes as $fqn => $node) {
|
|
||||||
$this->index->removeReferenceUri($fqn, $this->uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Register this document on the project for references
|
// Register this document on the project for references
|
||||||
$this->referenceNodes = $referencesCollector->nodes;
|
$this->referenceNodes = $referencesCollector->nodes;
|
||||||
foreach ($referencesCollector->nodes as $fqn => $nodes) {
|
foreach ($referencesCollector->nodes as $fqn => $nodes) {
|
||||||
|
|
Loading…
Reference in New Issue