letsdrink/ouzo-phpstorm-plugin

Improve controler/action references in routes

Closed this issue · 1 comments

woru commented

Plugin should check if:

  • current file is routes.php
  • current element is the first param in a call to Route::method
woru commented

There's an exception:

java.lang.ClassCastException: com.jetbrains.php.lang.psi.elements.impl.PhpPsiElementImpl cannot be cast to com.jetbrains.php.lang.psi.elements.ParameterList
    at com.github.letsdrink.intellijplugin.PsiUtils.isElementTheNthParameterInMethodCall(PsiUtils.java:56)
...

Things to fix:

  • PsiUtils.isElementTheNthParameterInMethodCall - check if nth parameter exists first.
  • Remove (inline) ControllerActionReferenceProvider.
  • ControllerPsiReferenceContributor - if the current file is not routes.php we can return immediately without getting routes methods.
  • OuzoUtils.isExpectedFile(psiElement, "routes.php") - we can check file path as well.
  • ControllerActionReferenceProvider:32 - use getClassMethod that returns optional. Currently if there's a wrong action name thus no action method, the plugin will throw an exception.