I’m trying to write an IntelliJ plugin.
I’m already able to read it line by line with a Stream, taking the plain text from the PsiFile, and generating the XmlDocument starting from there, but that’s not the most efficient way to do it and I wouldn’t be able to edit it like that.
I have different XML files, with random nodes so I should find a way to get all the nodes in a single file, filter them by taking only those that have the “android:id” attribute.
Then take this list of nodes that have this attribute, and edit the value of this attribute.
I’m successfully getting the PsiFile from the action event, but I don’t understand how to:
- Cast the PsiFile to something like XmlFile or get the XmlDocument from PsiFile (if needed)
- Get a list of all the nodes of the XML file
- Edit that specific attribute value I need to edit (do I need to perform any other step to save the file? Or is it just enough to edit the nodes?)
I already went through this documentation, but the more I read it the more it makes me sick. There is no example provided, just things like “Implement this interface, and that’s it, you’re done!”.