commiting document doesn't work for me


I'm quite unhappy with the folowing piece of code.

Waht it does (is supposed to do), is creating PsiClass and then PsiFile. The class is then attached to the file and the Document Manager is supposed to commit inmemory changes to permanent storage. The problem is that nothing appears in the file on disk. The IDEA editor however shows the contents that were added in

method. Synchronize command from IDEA menu flushes that contents to disk.

I tried to use different approach before - having the PsiDrectory of the package where I wanted to create the file, I used

method. Similar problem occcured, that later changes to the class structure were not persisted by the document manager.

Could someone give an example how to create java file, put some code (methods) in it and commit the changes, so they become visible for the rest of the world (it would be sufficient if ANT would be able to work on the file as stored on disk).