klesun / deep-assoc-completion

A phpstorm plugin for associative array key typing and completion
Other
266 stars 17 forks source link

Support argumentsSet as array value in phpstorm.meta #186

Closed tminich closed 3 years ago

tminich commented 3 years ago

Not sure how reasonable/feasible this is, but would it be possible to support argumentsSet as argument values in definitions in phpstorm.meta?

Example:

    expectedArguments(\Response::askUser(), 1, [
        'title' => argumentsSet('laravel-translation-keys'),
    ]);

(The set being defined earlier) This should give me completion after typing \Response::askUser('first argument', ['title' => <here>]).

klesun commented 3 years ago

Hm... it was long ago, but I think at least locally argumentsSet() were supposed to work. I could take a look when I'll get to the project next time, but that most likely won't be soon. Possibly a PR would be a more hopeful option.

It probably would be somewhere around here: https://github.com/klesun/deep-assoc-completion/blob/125a67b7e834b73de92b2ca99112466ce2853a63/src/org/klesun/deep_assoc_completion/resolvers/MethCallRes.java#L147

And here are some relevant tests: https://github.com/klesun-misc/deep-assoc-lsp-tests/blob/3ed6c720dc464ff4d6d62509094a5fba61eeca6f/testFixture/phpstorm_tests/meta/.phpstorm.meta.php#L84

klesun commented 3 years ago

Also this may be relevant to your request: https://github.com/klesun/deep-assoc-completion/issues/75#issuecomment-505425049

tminich commented 3 years ago

Maybe that's the issue. Possibly there is a different way to achieve what I want, my luck with being able to work on IntelliJ IDE plugins has been bad so far and ended in version hell XD The argument set I need to reference is just a list of strings, so maybe there is a way to set the array argument in a way the plugin recognizes the value should come from that list?

klesun commented 3 years ago

Maybe try:

    expectedArguments(\Response::askUser(), 1, [
        'title' => 'stringA' ?: 'stringB' ?: 'stringC',
    ]);

If I remember right the value of the array passed to expectedArguments() is just passed as a string to the plugin, and I just parse it the same way I do comments.

tminich commented 3 years ago

Works, thanks a lot :)