Hey all,
thanks to the reddit hype around
direct AST editing these past couple weeks, I've been thinking. That's a lot of time to spend thinking, so let me first apologize for the incoming wall of text. I promise it's going to make some sort of sense by the end.
The feature request
Essentially, I came up with a feature I didn't know I wanted until thinking about how to implement something like
Stride for Go (that's a whole other can of worms I am not going to touch on today). The idea evolved kind of like this:
- Since we're working with ASTs, we don't need to address code snippets by file_name:line_number anymore.
- When opening file_name:function, we don't really need to show the entirety of the file, just visualize that one function node.
- Many IDEs have a window showing all files, and, hierarchically, all top-level code elements inside them. You rarely ever need to view that and the code at the same time, but something like that should be accessible quickly, as a means of navigation.
- Since we have an AST in memory, we can perform intelligent searches, like 'list all functions that call this function', or 'all functions that take this type as an argument', ...
- As an implementation detail, you can probably reuse a lot of code between the project explorer and the search results.
- Why not just combine those two with the actual code view? Just use code folding to make search results easier to skim.
At this point, we have a powerful navigation feature, that is similar to what we see in
Eve, where we're only viewing the code we care about at the moment. You can dream up lots of use cases here, e.g. a documentation-like view that lists a struct at the top, and functions taking a pointer to that struct after that, with only the functions folded by default. An AST-query language, so you can do arbitrary searches without having to code them up and restart the editor. A browsing history that treats queries like URLs.
Obviously, this wouldn't really work for 4coder - except you could simply replace top-level AST nodes with partial views into a buffer and multiple views concatenated in each window (hopefully with some sort of separator to make this obvious).
I realize this is a pretty involved feature request, as it probably touches a lot of existing code in 4coder, but I believe there previously was talk about code folding, as well as "zooming in" on a scope, only leaving multiple snippets per view. I also realize that this probably isn't quite as useful as I imagine it, as long as 4coder lacks the language-awareness to easily make context sensitive key-bindings and intelligent search possible.
Any thoughts?
On a related note...
With 4coder becoming more and more language-aware (and generally awesome!) these past releases, I dread the day Jonathan Blow's JAI is released, because I will almost certainly switch immediately. 4coder is awesome, and I would love utilizing all of its power when working with a better language.
Have you ever considered splitting the language-specific code into its own dll, so that we can have a separate one for JAI? To me, that seems like the easiest way to allow support for another language.