Query and inspect your Java, Smalltalk, C and Cobol programs.
Applications of SOUL » Barista: an Eclipse plugin for SOUL » Extending Barista Plugins
Barista offers collaborating plugins two ways of interacting with the Soul evaluator. First, on demand querying is available by means of a number of interfaces. With this plugins can query the code of projects in the workspace, having as results actual ASTNodes of the code in the projects. Second, plugins can schedule queries to be run whenever a given project is compiled. This allows plugins to keep up to date information about properties of the source code.
Plugins are able to query code in a given project by using the IBarista interface. The interface is accessed from the Barista plugin by means of the BaristaPlugin.getIBarista() static method. From this interface, collaborating plugins can access the evaluators and repositories of predicates available in Soul.
Queries are launched using the IBarista.query(..) method. The method takes as parameters the query, the project in which to run it, the evaluator to use and the repository of predicates. As a result, an IEvaluator is returned. Using it, the collaborating plugin can control the way in which the query is run by selecting how many results must be obtained. Results are encapsulated in an object accessible through the IResults interface, which provides whether the query succeded, the number of results, the time it took to produce the results and a map from the variables in the query to their bindings.
Queries can be scheduled by implementing the Barista.scheduleQueries extension point. A class implementing the IQueryManager interface must be provided by the collaborating plugin. The interface defines two methods: getQueries() and resultsDone(IResults). The Barista plugin will then gather all of the queries from contributing plugins and run them everytime their correspoinding projects are built. Once the build is performed, the Barista plugin will run the scheduled queries, and hand over the results to the collaborating plugin by means of the resultsDone(IResults) method. This extension point is used in the implementation of the SmartAnnotations tool.