implement rename of class member fields
parent
207c6a2a68
commit
1f157d7424
|
@ -192,7 +192,7 @@ class TextDocument
|
||||||
// by traversing the AST
|
// by traversing the AST
|
||||||
if (
|
if (
|
||||||
|
|
||||||
($node instanceof Node\Expression\Variable && !($node->getParent()->getParent() instanceof Node\PropertyDeclaration))
|
($node instanceof Node\Expression\Variable && !($node->getParent()->getParent() instanceof Node\PropertyDeclaration) && !($node->getParent()->getParent()->getParent() instanceof Node\PropertyDeclaration))
|
||||||
|| $node instanceof Node\Parameter
|
|| $node instanceof Node\Parameter
|
||||||
|| $node instanceof Node\UseVariableName
|
|| $node instanceof Node\UseVariableName
|
||||||
) {
|
) {
|
||||||
|
@ -212,10 +212,14 @@ class TextDocument
|
||||||
if ($descendantNode instanceof Node\Expression\Variable &&
|
if ($descendantNode instanceof Node\Expression\Variable &&
|
||||||
$descendantNode->getName() === $node->getName()
|
$descendantNode->getName() === $node->getName()
|
||||||
) {
|
) {
|
||||||
$locations[] = LocationFactory::fromNode($descendantNode);
|
$location = LocationFactory::fromNode($descendantNode);
|
||||||
|
$location->range->start->character++;
|
||||||
|
$locations[] = $location;
|
||||||
} else if (($descendantNode instanceof Node\Parameter)
|
} else if (($descendantNode instanceof Node\Parameter)
|
||||||
&& $context->includeDeclaration && $descendantNode->getName() === $node->getName() ) {
|
&& $context->includeDeclaration && $descendantNode->getName() === $node->getName() ) {
|
||||||
$locations[] = LocationFactory::fromToken($descendantNode, $descendantNode->variableName);
|
$location = LocationFactory::fromToken($descendantNode, $descendantNode->variableName);
|
||||||
|
$location->range->start->character++;
|
||||||
|
$locations[] = $location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,10 +245,33 @@ class TextDocument
|
||||||
$refs = $document->getReferenceNodesByFqn($fqn);
|
$refs = $document->getReferenceNodesByFqn($fqn);
|
||||||
if ($refs !== null) {
|
if ($refs !== null) {
|
||||||
foreach ($refs as $ref) {
|
foreach ($refs as $ref) {
|
||||||
|
if ($ref instanceof Node\Expression\MemberAccessExpression) {
|
||||||
|
$locations[] = LocationFactory::fromToken($ref, $ref -> memberName);
|
||||||
|
} else {
|
||||||
$locations[] = LocationFactory::fromNode($ref);
|
$locations[] = LocationFactory::fromNode($ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($context->includeDeclaration) {
|
||||||
|
$refs = $document->getDefinitionNodeByFqn($fqn);
|
||||||
|
if ($refs !== null){
|
||||||
|
foreach ($refs as $ref) {
|
||||||
|
if ($ref !== null){
|
||||||
|
if ($ref instanceof Node\Expression\AssignmentExpression) {
|
||||||
|
$location = LocationFactory::fromNode($ref->leftOperand);
|
||||||
|
$location->range->start->character++;
|
||||||
|
$locations[] = $location;
|
||||||
|
}elseif ($ref instanceof Node\DelimitedList\ExpressionList) {
|
||||||
|
$location = LocationFactory::fromNode($ref);
|
||||||
|
$location->range->start->character++;
|
||||||
|
$locations[] = $location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $locations;
|
return $locations;
|
||||||
});
|
});
|
||||||
|
@ -266,12 +293,6 @@ class TextDocument
|
||||||
return coroutine( function () use ($textDocument, $position, $newName) {
|
return coroutine( function () use ($textDocument, $position, $newName) {
|
||||||
$document = yield $this->documentLoader->getOrLoad($textDocument->uri);
|
$document = yield $this->documentLoader->getOrLoad($textDocument->uri);
|
||||||
$node = $document->getNodeAtPosition($position);
|
$node = $document->getNodeAtPosition($position);
|
||||||
if (
|
|
||||||
$node instanceof Node\Expression\Variable ||
|
|
||||||
$node instanceof Node\Parameter
|
|
||||||
) {
|
|
||||||
$newName = '$' . $newName;
|
|
||||||
}
|
|
||||||
$locations = yield $this->references(new ReferenceContext(true), $textDocument, $position);
|
$locations = yield $this->references(new ReferenceContext(true), $textDocument, $position);
|
||||||
$edits = [$textDocument->uri => [] ];
|
$edits = [$textDocument->uri => [] ];
|
||||||
foreach ($locations as $location) {
|
foreach ($locations as $location) {
|
||||||
|
|
Loading…
Reference in New Issue