diff --git a/app/Parsers/CallExpressionParser.php b/app/Parsers/CallExpressionParser.php index 44b1f69..add8127 100644 --- a/app/Parsers/CallExpressionParser.php +++ b/app/Parsers/CallExpressionParser.php @@ -4,9 +4,11 @@ use App\Contexts\AbstractContext; use App\Contexts\MethodCall; +use App\Parser\Settings; use Microsoft\PhpParser\MissingToken; use Microsoft\PhpParser\Node\Expression\CallExpression; use Microsoft\PhpParser\Node\QualifiedName; +use Microsoft\PhpParser\PositionUtilities; class CallExpressionParser extends AbstractParser { @@ -25,6 +27,20 @@ public function parse(CallExpression $node) $this->context->methodName = (string) ($node->callableExpression->getResolvedName() ?? $node->callableExpression->getText()); } + if (Settings::$capturePosition) { + $range = PositionUtilities::getRangeFromPosition( + $node->getStartPosition(), + mb_strlen($node->getText()), + $node->getRoot()->getFullText(), + ); + + if (Settings::$calculatePosition !== null) { + $range = Settings::adjustPosition($range); + } + + $this->context->setPosition($range); + } + $this->context->autocompleting = $node->closeParen instanceof MissingToken; return $this->context;