diff --git a/app/Parsers/InlineHtmlParser.php b/app/Parsers/InlineHtmlParser.php index 8ce758d..c59f886 100644 --- a/app/Parsers/InlineHtmlParser.php +++ b/app/Parsers/InlineHtmlParser.php @@ -95,7 +95,7 @@ protected function doEchoParse(BaseNode $node, $prefix, $content) } $range->start->line += $this->startLine + $node->position->startLine - 2; - $range->end->line += $this->startLine + $node->position->startLine - 2; + $range->end->line += $this->startLine + $node->position->startLine - 2; return $range; }; @@ -124,13 +124,19 @@ protected function parseLiteralNode(LiteralNode $node) protected function parseBladeDirective(DirectiveNode $node) { - if ($node->isClosingDirective || !$node->hasArguments()) { + $content = $node->toString(); + + if (!$node->hasArguments()) { + $content .= "('"; + } + + if ($node->isClosingDirective) { return; } $methodUsed = '@' . $node->content; $safetyPrefix = 'directive'; - $snippet = "getStartIndentationLevel()) . str_replace($methodUsed, $safetyPrefix . $node->content, $node->toString() . ';'); + $snippet = "getStartIndentationLevel()) . str_replace($methodUsed, $safetyPrefix . $node->content, $content . ';'); $sourceFile = (new Parser)->parseSourceFile($snippet); @@ -148,6 +154,10 @@ protected function parseBladeDirective(DirectiveNode $node) $result = Parse::parse($sourceFile); + if (count($result->children) === 0) { + return; + } + $child = $result->children[0]; $child->methodName = '@' . substr($child->methodName, mb_strlen($safetyPrefix));