Hello,
Food for thought:
Currently Counterclockwise does 2 things:
- it has an up-to-date list of symbols / keywords derived from the current editor. This of course does not need a running REPL, works as an heuristic for locals, and that's all. It won't go beyond the current file, won't show docstring or arglist of vars.
- it tries to use the last active REPL View, if there's one, and use it for either code completion or symbol resolution+metadata (for showing docstring, hyperlinks to other parts of source code).
Both these approaches rely on synchronized calls:
- in the first case, it asks for the parse tree synchronously. Since Counterclockwise uses Parsley, which is an incremental parser, it works well 99% of the time. But there's still this 1% where you work with a big file, e.g. clojure/core.clj, and you can feel the editor lag behind you.
- in the second case, any lag/problem with the network layer can affect your typing experience. This has been reported to me in the scariest way by a user the previous week: a corner case where the out of the box nrepl client will just hang forever because the remote connection was lost.
So I'm thinking more and more these days about another design: totally decoupling the gathering of "symbols dictionary" from the usage of this dictionary. A true temporal decoupling.
This means that the editor will never feel sluggish again. Maybe the information presented will be a little bit out of date, in a few percentage, but that would generally be for the greater good.
My idea so far will be to :
- have an atom on the Editor side containing a symbols dictionary. Updates to this dictionary will be done by background threads based on various events ( manual text change(s) to the editor - static analysis -, user interaction with a REPL - dynamic gathering of namespaces+vars -, updates of the project classpath - static analysis of jar dependencies - ).
- This will allow Counterclockwise to have an always responsive editor. Only background threads may be blocked by problematic parses, problematic nrepl connections, etc.
- This temporal decoupling also neatly decouples the production from the consumption of the "symbols dictionary". This will be an overall better design to enable additional contributions to the "symbols dictionary" without direct impact on the consumers.
So this is going a little bit agains the grain of what people are doing currently by overloading the server-side of things with knowledge, but I think it's the right direction to go, and the one I'll experiment with in the next weeks.