News for hackers. Stuff that matters.
Re:Why Don't We Have a General-Purpose Tree Editor? (2014) by chriswarbo on Monday February 06, 2017 @06:19PM (#13585276)
Keep in mind that it's pretty trivial (if laborious) to make parsers/pretty-printers between your language of choice and s-expressions, which would allow a generic tree editor to work on your language.

Note that you don't need a fleshed-out, implementation-friendly abstract syntax tree (e.g. "(definition (name foo) (type (function int int)) (arguments ((name x) (type int))) (body ...))"); you just need a parse tree of the tokens (e.g. (def foo ((int x)) ...)).

I agree that the existing silos of VisualStudio, Eclipse, Netbeans, jEdit, Emacs, Vi, etc. is a bad thing, and initiatives like LSP are is a step in the right direction.

Another nice approach that I came across recently is https://github.com/CarlOlson/structured-editing . This also uses a separate process to get information about code, but uses "spans" (start position, end position, label, extra info) which seem to be in between strings and syntax trees. For example a span might encompass a class definition; another span covers a method inside that class; another covers a statement in that method; another covers a function call in that statement; another covers the function name in that call, and it's extra info includes the location where that function is defined, its type, etc.

There are no comments on this comment yet.