Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/Parsers/CallExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down