Skip to main content

JQuery - Logic Programming, Source code and Eclipse Plugins

Posted by jonmountjoy on October 27, 2004 at 7:48 AM PDT

These days, I use Eclipse a lot, and I've just stumbled across a great little plugin, JQuery that combines logic programming and Eclipse to produce a tool that provides a way to build interesting views of your source code. For example, you can build queries that view only those classes which have tasks, or only those packages that have classes that inherit from interface IFoo, etc.

So, first of all it uses a small logic programming language called TyRuBa. Next, It populates a fact database that is used by said language, from the structure of your Java classes, packages, errors and warning messages etc. Finally, it provides an Eclipse View where you can use these tools to build a query that resolves to whatever elements of the source code that you want to view.

For example, instead of the standard package view, I wanted one that showed me all classes that had associated tasks (AFAIK, this is not available as standard in Eclipse. You can show all tasks, and then find the classes, but I wanted something different). To do this, I created the following query:

type(?T),
task(?Task),child+(?T,?Task)

(and specified an additional view variable view of ?T, ?Task). What this does is resolve ?T to all types which have tasks as children. (Note that I want child+ here and not child as I want to find types that have tasks associated with their methods too, which are child elements of the type). The result is a hierarchy, with all the roots being classes that have tasks. Expanding a class shows me the task. Of course, I can click on the class/task and it will take me to the relevant source code. Nifty.

The predicates I've used here are pretty basic - JQuery supports a very rich predicate set allowing you to build queries on everything from subtypes to constructors.

It's a great idea.

Related Topics >>