Completion for inherited this
parent
f6ccdd4911
commit
2f50f4a430
|
@ -130,6 +130,10 @@ class CompletionProvider
|
||||||
$list = new CompletionList;
|
$list = new CompletionList;
|
||||||
$list->isIncomplete = true;
|
$list->isIncomplete = true;
|
||||||
|
|
||||||
|
//echo get_class($node->var);
|
||||||
|
//var_dump((string)$node->var->name);
|
||||||
|
//die();
|
||||||
|
|
||||||
// A non-free node means we do NOT suggest global symbols
|
// A non-free node means we do NOT suggest global symbols
|
||||||
if (
|
if (
|
||||||
$node instanceof Node\Expr\MethodCall
|
$node instanceof Node\Expr\MethodCall
|
||||||
|
|
|
@ -479,16 +479,22 @@ class DefinitionResolver
|
||||||
} else {
|
} else {
|
||||||
$classFqn = substr((string)$t->getFqsen(), 1);
|
$classFqn = substr((string)$t->getFqsen(), 1);
|
||||||
}
|
}
|
||||||
$fqn = $classFqn . '->' . $expr->name;
|
$extended = $this->expandParentFqns([$classFqn]);
|
||||||
|
foreach ($extended as $f) {
|
||||||
|
$fqn = $f . '->' . $expr->name;
|
||||||
if ($expr instanceof Node\Expr\MethodCall) {
|
if ($expr instanceof Node\Expr\MethodCall) {
|
||||||
$fqn .= '()';
|
$fqn .= '()';
|
||||||
}
|
}
|
||||||
$def = $this->index->getDefinition($fqn);
|
$def = $this->index->getDefinition($fqn);
|
||||||
if ($def !== null) {
|
if ($def !== null) {
|
||||||
|
if ($def->type instanceof Types\This || $def->type instanceof Types\Self_) {
|
||||||
|
return $this->resolveExpressionNodeToType($expr->var);
|
||||||
|
}
|
||||||
return $def->type;
|
return $def->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
$expr instanceof Node\Expr\StaticCall
|
$expr instanceof Node\Expr\StaticCall
|
||||||
|| $expr instanceof Node\Expr\StaticPropertyFetch
|
|| $expr instanceof Node\Expr\StaticPropertyFetch
|
||||||
|
@ -651,6 +657,26 @@ class DefinitionResolver
|
||||||
return new Types\Mixed;
|
return new Types\Mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the FQNs of all parent classes to an array of FQNs of classes
|
||||||
|
*
|
||||||
|
* @param string[] $fqns
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
private function expandParentFqns(array $fqns): array
|
||||||
|
{
|
||||||
|
$expanded = $fqns;
|
||||||
|
foreach ($fqns as $fqn) {
|
||||||
|
$def = $this->index->getDefinition($fqn);
|
||||||
|
if ($def) {
|
||||||
|
foreach ($this->expandParentFqns($def->extends) as $parent) {
|
||||||
|
$expanded[] = $parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $expanded;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes any class name node (from a static method call, or new node) and returns a Type object
|
* Takes any class name node (from a static method call, or new node) and returns a Type object
|
||||||
* Resolves keywords like self, static and parent
|
* Resolves keywords like self, static and parent
|
||||||
|
|
Loading…
Reference in New Issue