Fix misc. issues in language server
parent
105f9bf813
commit
a5fec9452b
|
@ -326,8 +326,9 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
|
|||
}
|
||||
}*/
|
||||
|
||||
else if (($node instanceof Tolerant\Node\Expression\CallExpression &&
|
||||
($access = $node->callableExpression) instanceof Tolerant\Node\Expression\MemberAccessExpression) || (
|
||||
else if (
|
||||
$node instanceof Tolerant\Node\Expression\CallExpression &&
|
||||
(($access = $node->callableExpression) instanceof Tolerant\Node\Expression\MemberAccessExpression ||
|
||||
($access = $node) instanceof Tolerant\Node\Expression\MemberAccessExpression
|
||||
)) {
|
||||
if ($access->memberName instanceof Tolerant\Node\Expression) {
|
||||
|
@ -336,7 +337,6 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
|
|||
}
|
||||
// Get the type of the left-hand expression
|
||||
$varType = $this->resolveExpressionNodeToType($access->dereferencableExpression);
|
||||
// var_dump($varType);
|
||||
if ($varType instanceof Types\Compound) {
|
||||
// For compound types, use the first FQN we find
|
||||
// (popular use case is ClassName|null)
|
||||
|
@ -363,7 +363,6 @@ class TolerantDefinitionResolver implements DefinitionResolverInterface
|
|||
// Left-hand expression could not be resolved to a class
|
||||
return null;
|
||||
} else {
|
||||
// var_dump("AAAHHHHH");
|
||||
$classFqn = substr((string)$varType->getFqsen(), 1);
|
||||
|
||||
// TODO
|
||||
|
|
|
@ -45,7 +45,8 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
|||
|
||||
// TODO - docblock errors
|
||||
|
||||
foreach ($this->stmts->getDescendantNodes() as $node) {
|
||||
foreach ($this->stmts->getDescendantNodesAndTokens() as $node) {
|
||||
if ($node instanceof Tolerant\Node) {
|
||||
$fqn = $definitionResolver::getDefinedFqn($node);
|
||||
// Only index definitions with an FQN (no variables)
|
||||
if ($fqn === null) {
|
||||
|
@ -54,6 +55,18 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
|||
$this->definitionNodes[$fqn] = $node;
|
||||
$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;
|
||||
|
@ -90,7 +103,7 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
|||
// Namespaced constant access and function calls also need to register a reference
|
||||
// to the global version because PHP falls back to global at runtime
|
||||
// http://php.net/manual/en/language.namespaces.fallback.php
|
||||
if ($definitionResolver::isConstantFetch($node) ||
|
||||
if (TolerantDefinitionResolver::isConstantFetch($node) ||
|
||||
($parent instanceof Tolerant\Node\Expression\CallExpression
|
||||
&& !(
|
||||
$node instanceof Tolerant\Node\Expression\ScopedPropertyAccessExpression
|
||||
|
@ -102,23 +115,10 @@ class TolerantTreeAnalyzer implements TreeAnalyzerInterface {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->diagnostics = [];
|
||||
foreach (Tolerant\DiagnosticsProvider::getDiagnostics($this->stmts) as $_error) {
|
||||
$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() {
|
||||
return $this->diagnostics;
|
||||
return $this->diagnostics ?? [];
|
||||
}
|
||||
|
||||
private function addReference(string $fqn, Tolerant\Node $node)
|
||||
|
|
Loading…
Reference in New Issue