-
Notifications
You must be signed in to change notification settings - Fork 64
Support for autocompletion rules in FormRequest #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for autocompletion rules in FormRequest #336
Conversation
src/parser/AutocompleteResult.ts
Outdated
| public fillingInArrayKey(): boolean { | ||
| if (this.result.type === "array") { | ||
| return ( | ||
| this.result.parent?.type !== "array_item" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N1ebieski thanks! This looks good to go.
Before we merge, could you share a quick example of when this check is needed?
this.result.parent?.type !== "array_item"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TitasGailius this is necessary because if you start writing a rule for a field name, for example:
public function rules(): array
{
return [
'id' => ['
];
}then inside fillingInArrayKey you will get:
As you see the result.parent.type is array_item. This is how we recognize that a user is trying to write a rule name. If you remove this condition, then this condition will evaluate to true.
For comparison, here is the scenario when a user starts writing a field name:
public function rules(): array
{
return [
'
];
}
As you see, result.parent.type is methodCall, so the extension knows that this is not a place for a rule name.
|
Thanks! |
Fixes #291, #474
This PR adds autocompletion rules names in FormRequest::rules method. It works for Livewire Forms as well.
This PR depends on laravel/vs-code-php-parser-cli#16 and requires much more testing.