Skip to content

Conversation

@N1ebieski
Copy link
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
    }
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant