Get the class of a PSI element Follow
I am trying to listen to changes in a project and log what PSI class the change belongs to. I am implementing the PsiTreeChangeListener interface and it works as expected until I try to get the class by using something like "String className = event.getElement().getClass().getName();". It seems like when I add that it ruins the method, as even if I don't use "className" it wont run anything in the method after it. What could the issue be? Thanks!
Please sign in to leave a comment.
Please be more specific.
What do you want to achieve? What information are you trying to retrieve? What is the full implementation? How is it registered? What is the calling context (steps to reproduce)? What does it mean that it "ruins" the method? It's impossible to help you with so few details.
Hi, when a change is made in a project, I want to see what kind of psi element it belongs to. For example if I make a changes to a comment I want retrieve that it was a comment that was edited. I am creating class called "CustomDocumentListener" which implements the PsiTreeChangeListener interface as seen here:
Thanks for clarifying.
Unfortunately, I don't see what could be the issue's cause.
Is there anything in the idea.log in the IDE you test the plugin in?
If not, please share your sources (or minimal plugin example) I can use to reproduce the problem, with the example project and clear steps to reproduce. Please make sure all works without any additional steps like building dependencies, configuring repositories, etc.
I solved the issue by using the "getChild()" methods instead. For example these code lines work:
which is sufficient for my goal. I am still not sure why
does not work. There is not anything related to it in the idea.log file and I wont be able to provide a minimal plugin example right now. But either way the issue is solved. Thanks for your time! :)