Only traverse tree 1x for definitions + references
parent
d62bdeac82
commit
7d68e3acc3
|
@ -49,26 +49,11 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
||||||
if ($node instanceof Tolerant\Node) {
|
if ($node instanceof Tolerant\Node) {
|
||||||
$fqn = $definitionResolver::getDefinedFqn($node);
|
$fqn = $definitionResolver::getDefinedFqn($node);
|
||||||
// Only index definitions with an FQN (no variables)
|
// Only index definitions with an FQN (no variables)
|
||||||
if ($fqn === null) {
|
if ($fqn !== null) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->definitionNodes[$fqn] = $node;
|
$this->definitionNodes[$fqn] = $node;
|
||||||
$this->definitions[$fqn] = $this->definitionResolver->createDefinitionFromNode($node, $fqn);
|
$this->definitions[$fqn] = $this->definitionResolver->createDefinitionFromNode($node, $fqn);
|
||||||
}
|
}
|
||||||
if (($_error = Tolerant\DiagnosticsProvider::checkDiagnostics($node)) !== null) {
|
|
||||||
$range = Tolerant\PositionUtilities::getRangeFromPosition($_error->start, $_error->length, $content);
|
|
||||||
|
|
||||||
$this->diagnostics[] = new Diagnostic(
|
|
||||||
$_error->message,
|
|
||||||
new Range(
|
|
||||||
new Position($range->start->line, $range->start->character),
|
|
||||||
new Position($range->end->line, $range->start->character)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->stmts->getDescendantNodes() as $node) {
|
|
||||||
$parent = $node->parent;
|
$parent = $node->parent;
|
||||||
if (
|
if (
|
||||||
($node instanceof Tolerant\Node\Expression\ScopedPropertyAccessExpression
|
($node instanceof Tolerant\Node\Expression\ScopedPropertyAccessExpression
|
||||||
|
@ -81,9 +66,7 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$fqn = $definitionResolver->resolveReferenceNodeToFqn($node);
|
$fqn = $definitionResolver->resolveReferenceNodeToFqn($node);
|
||||||
if ($fqn === null) {
|
if ($fqn !== null) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->addReference($fqn, $node);
|
$this->addReference($fqn, $node);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -117,6 +100,20 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (($_error = Tolerant\DiagnosticsProvider::checkDiagnostics($node)) !== null) {
|
||||||
|
$range = Tolerant\PositionUtilities::getRangeFromPosition($_error->start, $_error->length, $content);
|
||||||
|
|
||||||
|
$this->diagnostics[] = new Diagnostic(
|
||||||
|
$_error->message,
|
||||||
|
new Range(
|
||||||
|
new Position($range->start->line, $range->start->character),
|
||||||
|
new Position($range->end->line, $range->start->character)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getDiagnostics() {
|
public function getDiagnostics() {
|
||||||
return $this->diagnostics ?? [];
|
return $this->diagnostics ?? [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue