We've implemented auto-import in our language plugin by overriding bindToElement() on the refrence and not only binding to the new type, but also adding the import statement. First, it that ok to do? It feels wrong to add a statement in the PSI tree during bindToElement(). If that's ok, I would like for the containing file to reparse after this, but it doesn't. What is the best way to force a reparse? Currently I am setting the text of the document to that of the PSI, which seems brutal. There must be a better way.
For laughs here's the code that syncs the PSI with the document, and forces a reparse:
public void syncPsi()
public void run()
PsiDocumentManagerImpl.getInstance( getProject() ).doPostponedOperationsAndUnblockDocument( getViewProvider().getDocument() );
getViewProvider().getDocument().setText( getText() );