[FIX] Checked changes and tested again
parent
680d2dbdbe
commit
dd3b6dc7e8
|
@ -6,4 +6,13 @@
|
|||
},
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.eol": "\n",
|
||||
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
"**/tests": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,50 @@
|
|||
<?php
|
||||
|
||||
class ThisChildClass extends TestClass {
|
||||
class ThisChildClass extends TestClass
|
||||
{
|
||||
|
||||
public function canSeeMethod()
|
||||
{
|
||||
$this->
|
||||
}
|
||||
}
|
||||
|
||||
class Foo extends Bar
|
||||
{
|
||||
|
||||
public function getRandom()
|
||||
{
|
||||
$this->c;
|
||||
return random_bytes(25);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar
|
||||
{
|
||||
|
||||
private $test;
|
||||
protected $seeme;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->test = 'Basic';
|
||||
}
|
||||
|
||||
public function getTest()
|
||||
{
|
||||
return $this->test;
|
||||
}
|
||||
|
||||
private function cantSee()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function canSee($arg)
|
||||
{
|
||||
# code...
|
||||
}
|
||||
}
|
||||
|
||||
$foo = new Foo();
|
||||
$foo->getRandom();
|
||||
|
|
|
@ -159,7 +159,6 @@ class CompletionProvider
|
|||
): CompletionList {
|
||||
// This can be made much more performant if the tree follows specific invariants.
|
||||
$node = $doc->getNodeAtPosition($pos);
|
||||
|
||||
// Get the node at the position under the cursor
|
||||
$offset = $node === null ? -1 : $pos->toOffset($node->getFileContents());
|
||||
if (
|
||||
|
@ -248,18 +247,17 @@ class CompletionProvider
|
|||
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
|
||||
);
|
||||
$isInMethodDeclaration = null !== $node->getFirstAncestor(\Microsoft\PhpParser\Node\MethodDeclaration::class);
|
||||
// The FQNs of the symbol and its parents (eg the implemented interfaces)
|
||||
foreach ($this->expandParentFqns($fqns) as $parentFqn) {
|
||||
// Add the object access operator to only get members of all parents
|
||||
$prefixes = [];
|
||||
foreach ($this->expandParentFqns($fqns) as $prefix) {
|
||||
$prefixes[] = $prefix . '->';
|
||||
}
|
||||
|
||||
// Collect all definitions that match any of the prefixes
|
||||
foreach ($this->index->getDefinitions() as $fqn => $def) {
|
||||
foreach ($prefixes as $prefix) {
|
||||
if (substr($fqn, 0, strlen($prefix)) === $prefix &&
|
||||
$prefix = $parentFqn . '->';
|
||||
$prefixLen = strlen($prefix);
|
||||
// Collect fqn definitions
|
||||
foreach ($this->index->getChildDefinitionsForFqn($parentFqn) as $fqn => $def) {
|
||||
if (substr($fqn, 0, $prefixLen) === $prefix &&
|
||||
$def->isMember &&
|
||||
$def->isVisible($prefix, $prefixes[0], $isInMethodDeclaration)) {
|
||||
$def->isVisible($prefix, $fqns[0] . '->', $isInMethodDeclaration)
|
||||
) {
|
||||
$list->items[] = CompletionItemFactory::fromDefinition($def);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue