How to delete PsiStatement
I have a valid reference to a PsiStatement. I invoked delete upon it. Nothing changed. What is the preferred way to delete a PsiStatement or PsiAnything?
It's pretty clear that , as far as that PsiElement is concerned, it's null after (but not before) I invoke its delete method, so I am guessing it's not implemented as a no-op... but the statement in the file still is sitting there.
Do I need to refresh the file somehow? I didn't need to refresh it when I added the statement, it just appeared nicely in my document like a good little PsiStatement....
Message was edited by:
softwarevisualization
Please sign in to leave a comment.
Hello softwarevisualization,
delete() is the correct way. Please make sure that you're deleting the element
that's actually added (see my note on the return value of add() method).
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Yes that was the issue.
Lesson learned:
you can't hang onto the PsiElement you yourself created from PsiElementFactory for the purpose of later manipulation. You have to get what is returned from add(), also a PsiElement, and use that as the reference to the element.