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