Sunday, April 29, 2007

Cohatoe extension wizardry

I have started to add some helpful tools to the Plugin Development Environment (PDE) in Eclipse to facilitate working with Cohatoe. One of the things that still take some time (in my experience when implementing the examples) is creating the source files and manifest entries that are needed for a new Haskell contribution via Cohatoe. It's not much (and mostly boilerplate that is always almost the same stuff), and it can actually be generated from very little input by the user.

So I have first added a wizard for creating a new Cohatoe extension. Suppose that you already have a plugin project. Then you can now just go to the Extensions Tab on the Plugin Manifest editor, click Add > Extension Wizards > Cohatoe Development Tools > Haskell Contribution, and you get a wizard that generates all the files and manifest entries that you need, namely:

  • It adds the dependency to the Cohatoe Core plugin to the META-INF/ file (if it is not already there).
  • It adds an extension in the plugin.xml file and declares the Haskell source file along with the Java implementation and interface types.
  • It generates the Java interface and implementation types, together with the code necessary to call the server (i.e. what happens inside the implementation class) and with a usage example that can be copied to where you want to call the function from your Java code.
  • It generates the skeleton source file for the Haskell module that is called.
The only things you have to specify are some workspace locations, in particular the source folder (there is usually only one, so that's probably trivial), a Java package name, and a name for your contribution, from which the name of the Haskell module and the Java types are derived.

For the time being, this supports only contributing source files, if you want to change this into an object file contribution, you have to enter the path to the object files manually in the plugin.xml, in the codeFile attribute (where originally the source file is specified in what the wizard has generated).

I think this should considerably ease and speed up the process of creating the plumbing for a new Haskell contribution, and help you to focus on the actually more interesting bits, namely the Haskell code itself, and the places where it is eventually called in the Eclipse plugin :-)

(NB: this is not yet in the downloadable preview, but in the Darcs repo. But I think I'll do another preview build soon.)

No comments: