optimized param count calculation
parent
1c714f98b7
commit
f84b6a48b6
|
@ -5,6 +5,7 @@ namespace LanguageServer;
|
||||||
|
|
||||||
use Microsoft\PhpParser\Node\DelimitedList\ArgumentExpressionList;
|
use Microsoft\PhpParser\Node\DelimitedList\ArgumentExpressionList;
|
||||||
use Microsoft\PhpParser\Node\Expression\CallExpression;
|
use Microsoft\PhpParser\Node\Expression\CallExpression;
|
||||||
|
use Microsoft\PhpParser\Node\Expression\ArgumentExpression;
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Protocol\{
|
||||||
Range,
|
Range,
|
||||||
|
@ -46,14 +47,16 @@ class SignatureHelpProvider
|
||||||
public function provideSignature(PhpDocument $doc, Position $pos) : SignatureHelp
|
public function provideSignature(PhpDocument $doc, Position $pos) : SignatureHelp
|
||||||
{
|
{
|
||||||
$node = $doc->getNodeAtPosition($pos);
|
$node = $doc->getNodeAtPosition($pos);
|
||||||
$nodes = [$node];
|
$arge = null;
|
||||||
while ($node &&
|
while ($node &&
|
||||||
!($node instanceof ArgumentExpressionList) &&
|
!($node instanceof ArgumentExpressionList) &&
|
||||||
!($node instanceof CallExpression) &&
|
!($node instanceof CallExpression) &&
|
||||||
$node->parent
|
$node->parent
|
||||||
) {
|
) {
|
||||||
|
if ($node instanceof ArgumentExpression) {
|
||||||
|
$arge = $node;
|
||||||
|
}
|
||||||
$node = $node->parent;
|
$node = $node->parent;
|
||||||
$nodes[] = $node;
|
|
||||||
}
|
}
|
||||||
if (!($node instanceof ArgumentExpressionList) &&
|
if (!($node instanceof ArgumentExpressionList) &&
|
||||||
!($node instanceof CallExpression)
|
!($node instanceof CallExpression)
|
||||||
|
@ -64,7 +67,7 @@ class SignatureHelpProvider
|
||||||
if ($node instanceof ArgumentExpressionList) {
|
if ($node instanceof ArgumentExpressionList) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($node->getElements() as $param) {
|
foreach ($node->getElements() as $param) {
|
||||||
if (in_array($param, $nodes)) {
|
if ($param === $arge) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$count ++;
|
$count ++;
|
||||||
|
|
Loading…
Reference in New Issue