About PsiJavaElementPattern matching interface method parameters Follow
Here is my method snippet:
I am writing a parameter matching expression, I can now match the parameters starting with @Param, but I have been unable to match the parameter c2, this is my expression psiElement(PsiParameterList.class).andNot(psiElement(PsiAnnotationParameterList.class) )
Please sign in to leave a comment.
You are matching the parameters list, but want to match a single parameter, so this is the first issue in your pattern.
I suggest using PsiViewer to understand the code tree - that will help you with implementing your required pattern:
I use PsiParameterPattern or change the expression to PsiParameter but still can't match this parameter, I am confused, how to write
Please share your code's current state.
If it's the same as provided in the first message, then please correct it according to my answer.
Here is the psi I got with psiview and my expression
I have tested all kinds of elements given by psiview, but I can't locate this parameter. . .
What element is tested against your pattern? It is not clear how you try to use this pattern.
If it is used for completion, then it will be a leaf element, and a possible issue is that you should match an element inside the parameter. Notice that in the tree under the PsiParameter you have more elements like PsiTypeElement (which has more children) and PsiIdentifier.
Try with e.g.:
If it doesn't help, then please provide more information and clarify as much as possible.
Here is my code and test code
This is the psi seen by psiview
I tested it, but still can't match any element, the getReferencesByElement method will not trigger
OK, in this case, you shouldn't use the "inside()" matcher then.
Again, please be more specific about the issue. What are expected and actual behaviors?
Did you register MybatisParamReferenceContributor in the plugin.xml file?
Thank you for your patient answer, I have configured it in the xml file, I want to query the parameters of the method, and then implement its reference
And what is the actual behavior? What is the exact error you are facing? How do you know it's not working?
I put the mouse cursor on the parameter of s8, and then in the window system environment, I hold down ctrl + left mouse button and click, it will not automatically jump to its reference address
But you are not providing any references:
Why do you expect any resolving to work in this case?
Because I am doing a parameter acquisition test, and now I have not matched the s8 parameter, so the implementation in the method has not been written for the time being
Make sure that the element you are trying to provide references for is an instance of com.intellij.psi.ContributedReferenceHost. It is not possible to provide references via PsiReferenceContributor for elements not implementing ContributedReferenceHost.
The element I want to reference can be referenced, because if my parameter is modified with @Param(), my other expression can be matched. Now all the problems are that my expression has been unable to match to the parameters of this method
Please show your working reference contributor.
This is my custom implemented language, implements ContributedReferenceHost,
please help me fix my expression to match parameter s8
I'm sorry, but I asked you to show me your working reference contributor, but you paste me your PSI elements which are completely irrelevant. I can't help you if you are not providing me with the information I'm asking you for.
Please get back to my previous comment and carefully verify it:
It is very likely the reason.
I'm not going to continue this topic due to limited time. Consider asking for help on the Community Slack: https://plugins.jetbrains.com/slack/
Both PsiParameter and PsiIdentifier are idea's own internal psi