Languages Tools Factorization
Contents
Goal
Eclipse is the host of various programming languages tools (JDT, CDT, JSDT/VJET, AJDT, PDT... at Eclipse.org; Ceylon-IDE, Groovy-Eclipse, Scala-IDE, Counterclockwise... outside of Eclipse.org). Most of these tools have been sharing the same features but not necessary the same code because of the lack of factorization on this topic.
The goal is to find out which pieces are implemented by most Language Development Tool, and to implement them in a generic/universal way as part of a LTK-like project or component (or LTK itself). Then, it would be easier to write Tools for new languages by re-using the available bundles, and more mature projects could move towards this new bundles in order to benefit from factorization.
Useful Links/Discussions
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=36939
- http://www.eclipse.org/org/langsymp/ (?)
- http://dev.eclipse.org/mhonarc/lists/ide-dev/msg00023.html (2013)
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=415563 (2013)
- https://dev.eclipse.org/mhonarc/lists/ide-dev/msg00772.html (2015)
Existing Language Development Tools Frameworks
- Xtext ("full stack" framework, from parser and semantic analysis to IDE UI)
- DLTK (JDT-clone, development has stagnated since 2013)
- MelnormeEclipse (similar scope to a JDT-like IDE framework, but focus on using external tools for semantic analysis)
- Handly (focus on a subset of IDE-generic functionality: the handle model)
Existing Language Development Tools
This is not meant to be an exhaustive list of all LDTs. It is meant to identify which LDTs are under active development and can serve as examples of the kinds of languages and features we want to support:
- JDT (JVM)
- JSDT
- AJDT (JVM)
- CDT
- PDT
- Koneki LDT
- Xtend IDE (JVM)
- Groovy-Eclipse (JVM)
- CeylonIDE (JVM)
- Scala-IDE (JVM)
- Counterclockwise (JVM)
- Object Teams (JVM)
- Goclipse, RustDT, DDT (MelnormeEclipse)
Common features
Indexing
Indexing the code structure to make it efficient to search for types/members. There are two components of this feature:
- Creating indexes: This operation visits a document (or all documents in a project) and extracts relevant keys from inside of them, placing them in a datastore.
- Searching indexes: This operation searches the datastore for documents containing a given key. The result of this operation is a set of documents known to contain the given key. These documents are now suitable for a fine-grained search.
- The datastore itself should be language agnostic. Although, some of the keys placed in the datastore may not be relevant to all languages.
Known implementations
JDT implements a datastore. AJDT and Groovy-Eclipse (and potentially others) implement source code visitors that populate the datastore with language-specific keys. To be more precise, the keys added to the datastore have Java semantics even when they do not represent Java artifacts (eg- pointcuts in AspectJ are stored as method declaration keys). This is problematic.
Xtext has a language agnostic index.
CDT has a binary index format using B-Trees to speed up searches and inserts. It stores ASTName locations (where the symbols are defined and used) as well as the Bindings that connect references to declarations. In theory it's multi-language supporting C and C++. I think there's Fortran out there too. What it doesn't handle well is dynamic bindings such as when JavaScript is used and C++ objects are dynamically registered with the JS engine.
Fine-grained search
Searches a single document to find a precise location of a semantically rich search pattern. The document is typically a file, archive entry, or a module written in any programming language supported by the current Eclipse IDE.
Known implementations
JDT, AJDT, Groovy-Eclipse (and potentially others).
Refactoring
Idea is to provide cross-language refactoring support. For example, being able to rename semantically identical references and declarations in both C and JavaScript.
Idea is to provide a seamless way to navigate to the declaration of a reference across language boundaries. For example, in http://eclipseblog.ostroukhovs.com/2013/11/14/source-editor-worth-70/ , user would like the Open Type dialog to be homogeneous across languages.
Model
Describes an abstract structure of a project so that individual elements can be identified, located, and manipulated. Possibly a prerequisite for refactoring and navigation.
Editor
Provide more common features to the code editor. One example is a standard way of providing hover help so that we can show documentation when a user hovers over a symbol. Linux Tools has libHover which does that and may be a good starting point.
Potential new features
Cross-languages search
- Purpose Polyglot development is becoming mainstream, it would be interesting to develop the tools to handle it easily. For example, developing with Qt can mix JavaScript and C++