Skip to content
This repository was archived by the owner on Nov 9, 2026. It is now read-only.

Fix InlineHtmlParser::parseBladeDirective for autocompletion - #15

Closed
N1ebieski wants to merge 1 commit into
laravel:mainfrom
N1ebieski:Fix-InlineHtmlParserparseBladeDirective-for-autocompletion-#6
Closed

N1ebieski wants to merge 1 commit into
laravel:mainfrom
N1ebieski:Fix-InlineHtmlParserparseBladeDirective-for-autocompletion-#6

Conversation

@N1ebieski

Copy link
Copy Markdown
Contributor

There is a bug with InlineHtmlParser::parseBladeDirective, probably related with https://github.com/Stillat/blade-parser

Currently, autocompletion for directives doesn't work at all, because the command:

php-parser autocomplete "@can('" --debug

returns:

================================================================================
================================================================================
                              STARTING TO PARSE
================================================================================
================================================================================

Microsoft\PhpParser\Node\SourceFileNode @can('
+ Context: App\Contexts\Base
* Parsing: App\Parsers\SourceFileNodeParser

 Microsoft\PhpParser\Node\Statement\InlineHtml @can('
 + Context: App\Contexts\Base
 * Parsing: App\Parsers\InlineHtmlParser
[]

I debugged this issue and figured out

DirectiveNode::content returns can without arguments, should be: can('

This PR fixes this issue:

================================================================================
================================================================================
                              STARTING TO PARSE
================================================================================
================================================================================

Microsoft\PhpParser\Node\SourceFileNode @can('
+ Context: App\Contexts\Base
* Parsing: App\Parsers\SourceFileNodeParser

 Microsoft\PhpParser\Node\Statement\InlineHtml @can('
 + Context: App\Contexts\Base
 * Parsing: App\Parsers\InlineHtmlParser


================================================================================
================================================================================
                              STARTING TO PARSE
================================================================================
================================================================================

Microsoft\PhpParser\Node\SourceFileNode <?php directivecan(';
+ Context: App\Contexts\Base
* Parsing: App\Parsers\SourceFileNodeParser

 Microsoft\PhpParser\Node\Statement\InlineHtml <?php 
 + Context: App\Contexts\Base
 * Parsing: App\Parsers\InlineHtmlParser

 Microsoft\PhpParser\Node\Statement\ExpressionStatement directivecan(
 + Context: App\Contexts\Base
 * Parsing: App\Parsers\ExpressionStatementParser

  Microsoft\PhpParser\Node\Expression\CallExpression directivecan(
  + Context: App\Contexts\MethodCall
  * Parsing: App\Parsers\CallExpressionParser

   Microsoft\PhpParser\Node\QualifiedName directivecan
{
    "type": "methodCall",
    "autocompleting": true,
    "methodName": "@can",
    "className": null,
    "arguments": {
        "type": "arguments",
        "autocompletingIndex": 0,
        "children": []
    },
    "parent": {
        "type": "base",
        "parent": null
    }
}

@joetannenbaum

Copy link
Copy Markdown
Collaborator

Thank you for this PR! I apologize it took us so long to respond.

I'm closing this out as the VS Code extension no longer uses this package, it now uses https://github.com/laravel/lsp.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants