LocalQuickFixAndIntentionActionOnPsiElement.invoke() - why not use the parameter values?

Looking at various implementations of LocalQuickFixAndIntentionActionOnPsiElement.invoke(), I see that many of them ignore the project and file that are passed as parameter values and instead get the values from the PsiElements. For example, in com.intellij.codeInsight.daemon.impl.quickfix.AddReturnFix.invoke(), I see calls to myMethod.getContainingFile() and myMethod.getProject() even though the project and file are passed to invoke(). Is there some way that the project and file passed to invoke() can be different from those derived from the myMethod field?

Is there some documentation somewhere that explains this?

1 comment

Hi Peter,

the file and project correspond to the open file in the editor and its project. If you pass another element as current, e.g. super method located somewhere else, then you need to check what "file" you need. In most cases they are the same though. I don't think that there is the documentation about that, sorry.



Please sign in to leave a comment.