Software artifacts, once available as instances of Ecore-based model, can be queried with OCL. Some useful links for this task:
- an Ecore-based metamodel of Java (without OCL well-formedness rules) has been contributed by Mikael Barbero (INRIA) and can be found here (for a tree-based visualization follow this link)
- the MM above can be used in conjunction with this plugin, which instantiates such metamodel for a compilation unit of choice (using the JDT infrastructure)
- more sample code for querying the “raw” AST offered by the JDT can be found in ASTView. In order to understand in detail the type information of a given Java file, these tutorial slides prove extremely useful.
Querying a Java AST is usually cumbersome given its detailed nature. As in databases, having a stock of parameterized queries (to filter only those items useful for the task at hand) goes a long way towards improving usability.
It looks to me that until the following critical mass is necessary:
- libraries of metamodels (with WFRs)
- plugins to parse software artifacts into those metamodels
- pre-defined queries for repetitive tasks on those metamodels
- efficient mechanisms to evaluate queries, author them, and to visualize their results
"Watch this space!" :)
Keine Kommentare:
Kommentar veröffentlichen