JetBrains/la-clojure — pull request #54 by cjkent (2013-05-17 07:57:30+00:00)
Title: Partial fix for CLJ-198 - Auto-import in the REPL inserts broken code

I'm not sure if this is the right approach but it fixes the problem in the REPL and doesn't seem to break auto-imports in regular files. There are some problems or things I'm unsure about:

* The import is on the same line as the typed text which is annoying. I tried to add a newline after the import but kept breaking the document. The existing code inserts a namespace declaration without a newline and I assume the newlines are inserted by the code formatter. Which doesn't do anything to a call to the import macro which my code generates.

* Is is reasonable and reliable to use PsiFile.getViewProvider().isPhysical() to decide whether we're in the REPL?

* Is there an easy way to find out the current namespace in the REPL? If there is then it might be better to use the existing code that generates a namespace declaration. The only way I can think of is to execute (.name *ns*) in the REPL and get the result without outputting anything to the console but that doesn't look like it would be simple.