laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
166 stars 7 forks source link

[Bug]: prefer navigating to the model property/method/scope if the doc comment exists #953

Open panstromek opened 6 months ago

panstromek commented 6 months ago

Bug description

Currently, if there's scope/relation/attribute mentioned in the doc comment in the class (usually generated with laravel-ide-helper), jump-to-definition jumps to the comment, instead of the actual definition of the thing. If you delete the comment, it jumps correctly.

Plugin version

No response

Operating system

None

Steps to reproduce

go to popular() call in the snippet below and invoke 'go to definition'


/**
 * App\User
 * @method static Builder|User popular()
 **/
class User {
    public function scopePopular(Builder $query): void {}
}

// code
$users = User::popular(); // 'go to definition' here will navigate to the comment, not to the scope

Relevant log output

No response

adelf commented 6 months ago

Hello. There is own Helper code generator by Laravel Idea. And this feature already works there.

telegram-cloud-photo-size-2-5460928575176823912-x

panstromek commented 6 months ago

Yes, I know this, but the problem is when enabling the plugin for existing codebase which has doc comments on every model. Generating helper files in the plugin doesn't help as the ones inline are always prioritized first.

panstromek commented 6 months ago

Note that I can't delete the doc comments, because they contain documentation (hand written comments) and also not everybody on the project uses this plugin.

panstromek commented 6 months ago

To be clear - I'm not talking about doc comments in generated files, but doc comments written directly in model class files. Maybe this wasn't obvious from the description.

adelf commented 6 months ago

Got it. I'll check what can be done.

MichelJonkman commented 6 months ago

Note that I can't delete the doc comments, because they contain documentation (hand written comments) and also not everybody on the project uses this plugin.

Another option would be to have laravel-ide-helper place the helper code in separate files and then developers using the plugin can exclude those files and use the built in helper generator.