File content saving
已回答
Hello, I have a problem about file saving, and psi operation is used.Take the example of saving an xml type file.
1. I get the document of the file and save the contents of the file
val document = readAction(file::findDocument)
val documentManager = FileDocumentManager.getInstance()
document.setText(strPayload)
documentManager.saveDocument(document)2. After saving I look for the psi file of the current file and parse it
val findFile = PsiManager.getInstance(project).findFile(file)
val xmlFile = findFile as XmlFile
xmlFile.accept(object : XmlRecursiveElementVisitor() {
override fun visitXmlTag(tag: XmlTag) {
})The problem is that when the xml file is saved and parsed again with psi, it is not the latest file content,I need your help
请先登录再写评论。
Hi,
Try to commit your document with
PsiDocumentManager:Thank you very much for your answer, the problem has been solved