Archive for eclipse

My Last Week’s Eclipse Usage

I found a cool plugin couple of weeks ago, Ergo by Channing Walton. It monitors the shortcut and menu invocations usage of Eclipse.

I soon discovered that I’d like to know what shortcuts other users use. I whipped up a patch that would let the plugin users specify a reporting URL. Channing liked the idea, open-sourced the plugin and gave me access.

Last week I had the plugin enabled and now I produced a page of the statistics. The stats show that I was pasting all last week :) .

I was also introduced to the EPP’s Usage Data Collector. I have not checked if it also monitors actions’ invocations. If it does not we’ll try to propose a patch of some sort.

I’ll be uploading my stats for another couple of weeks and compare to my colleagues and see if I can find anything interesting.

If anybody is interested in seeing their stats they can download the plugin from the project’s page and use “http://tom.jabber.ee/reporting/” as the URL. Every installation is generated a UUID and if you specify the reporting URL your workspace/.metadata/.plugins/com.stateofflow.ergo/commands.properties will be reported to the specified url every 1 hour. The stats can be seen from http://tom.jabber.ee/reporting/result.php?uuid=YOUR-UUID

Comments (9)

Boosting Eclipse Plugin Development With JavaRebel

The latest development snapshots of JavaRebel include support for the Eclipse platform. This means that plugin developers can launch an Eclipse Application to test their plugins and make changes to the source code and see the results in the already opened Eclipse instance. No need to relaunch Eclipse instances to see changes happen.

More information at the ZeroTurnaround blogpost that has a screencast showing off the new integration.

Comments (3)

Java Development Is Up For a Change

Disclaimer: I’m affiliated with the product and this might be taken as a commercial but nevertheless things will start to change.

Before moving to Java (mostly JEE) I did couple of years PHP development. The thousand levels of abstraction, tons of third party libraries and most importantly the ever taking change-check cycle were something difficult to accept. I was so used to getting feedback automatically and could not even imagine that one day I will even have to re-traverse some application just to store some state.

For the past months I have been working on team battling the change->compile->redeploy cycle. Today there is a release. It is called JavaRebel and the product brings the cycle down to change->compile->check. Classes loaded by the container can be changed and JavaRebel inbetween will load these changes (adding/removing/changing fields, methods etc.).

When I was working on my Google Summer Of Code project I had to buy extra RAM just to be able to run couple of instances of Eclipse. I was not willing to buy a new CPU to make the restarting these instances of Eclipse faster. JavaRebel does not have Eclipse support but it is in the roadmap.

There is a screencast up that will demo some features of it. Java development will change.

Comments (1)

Scripting Bridge Core – Samples

Finally I’ve found a PHP and JS library which work and are useful to show off how to use them through the Scripting Bridge (my GSoC project). This post is about the core part of my work.

A week before the deadline we separated all Eclipse stuff from the Scripting Bridge to provide something more general which we call core now. The core lets you incorporate scripts into your Java code and treat them as regular Java objects.

The libraries I found are:

The samples use these libraries to package a small JavaScript and show the output. Basically I have a Java-PHP mapping interface:

@ScriptableClass (fileName="etc/phpPacker.php,
etc/myWrapper.php",
extension="php")
public interface PhpPacker {
 @ScriptableMethod(functionName="packJs",output="true")
 public String packJs(String jsContents);
}

This defines which PHP files to use and which function to invoke. Then I use this interface as:

PhpPacker phpPacker = (PhpPacker)
 ScriptableFactory.newInstance(PhpPacker.class);
result = phpPacker.packJs(toPack);

This actually invokes the bundled PHP function packJs($str). The same example is also for JavaScript using the other library.

I made a separate page for the core & samples which include

Next post will be about the UI or Eclipse part of the deliverables. I hope I’ll find some sexy PHP & JS scripts.

Comments off

Pencils down

Its pencils down for the Google Summer Of Code. I’ve tagged my source in the repo and made another release. The update URL is the same. More info during the following days.

Comments off

Listing PHP functions using PDT

One of the features that my GSoC project will have is generating Java-To-Php interfaces from PHP files. To accomplish that task I have two options:

Both have their pros and cons. Today I’ll talk about the second option because I was contacted by one of the PDT guys to offer help and now I had time to go into their code.

You can see a list of PDT module names in the viewcvs of the Tools Project. The CVS root is dev.eclipse.org/cvsroot/tools.

How to hook into the PDT to find the function names? There is a handler ParserClient. It has all the necessary callbacks when parsing PHP source files. I’m interested in handleFunctionDeclarationStarts. So I have to implement the interface and I will be called when the parser finds a function. Easy :)

It was not that easy to get it running in a simple main(String args[]) as PDT’s PHPLanguageModel does a lookup of the file using PHPCorePlugin.getDefault().getBundle() which results in a NPE as Eclipse is not running. After overriding couple of classes (+methods) and changing 2 modifiers to public I was able to get it working. Generally to get a list of functions in a PHP file the code looks like this:

ParserClient parserClient = new MyPhpHandler();
PHPLanguageManager langManager = new MyLanguageManager();
PHPParserManager manager = langManager.createPHPParserManager();
final Reader reader = new FileReader(new File("pathToPhpFile"));
manager.parse(reader, "path", 0l, parserClient, new Pattern[]{}, false);

The prefix “My” constitutes to overridden version. So its easy. I’ll contact PDT and see if I can get a cleaner interface from them or maybe provide it myself.

Once I get reflection working I’ll let you know which is easier. Then again who would ever want to parse PHP files from Java and care about the source code more than the output :)

PS. I’m slowly getting back to developing Aranea Web Framework. The final deadline of SoC is 31. August.

Comments (1)

SoC – Next Release Is Out

After three weeks we have the next release of Eclipse Plugins in Php ready. The update site is the same. The main changes include:

Reworked API
Class level annotation to define the PHP file. Method level annotation to define the PHP function. To map Java to PHP only an interface is needed. Sample:

@ScriptableClass(fileName="helloWorld.php")
public interface HelloWorld {
 @ScriptableMethod(functionName="helloWorld")
 String getHelloWorld(String name);
}

And to instantiate a simple call to a factory is needed:

PhpScriptableFactory.newInstance(HelloWorld.class);

Quercus GPL issue
We depended on Quercus to provide out-of-the-box PHP support. Quercus in under GPL, my plugin EPL. Although we had no code level access to the quercus.jar (discovering ScriptEngine is the J2SE’s work) we separated the two by packaging the GPL part of the libraries in a separate fragment. The fragments host plugin is this our plugin and we offer it on the same update site. This means when you install both of them you can run PHP code just after the install :)

I battled with different problems during this time and I’ll try to give an overview in the following blog posts. Some issues I had trouble with include:

  • Generating proxies with ASM
  • Generating interceptors with CGLIB
  • Unit-testing Eclipse plugins
  • Making an Eclipse Fragment

During this time I also managed to finish last in a Go tournament and get accepted to Tartu University to study CS at the masters level.

Comments (4)

SoC – First Release – Eclipse Plugins in PHP

After six weeks I have a release to show, this is something I can really call alpha quality :( . Keep on reading to get the details. Firstly how to get the plugin :)

  • You must have Java 6 installed for the scripting support (I need to verify it works with < Eclipse 3.3)
  • Update site url http://tom.jabber.ee/phpengine/update-site/
  • SVN url http://eclipse-incub.svn.sourceforge.net/viewvc/eclipse-incub/plugins_in_php/
  • Module org.eclipse.soc2007.phpscriptengine
  • Module update-site
  • The info is more up-to-date on my wikipage.

What can you do with the plugin?
Firstly map PHP functions to Java methods. The approach is to create an interface.

public interface HelloWorld extends Scriptable {
@ScriptableAnnotation(
 fileName="helloWorld.php",
 output="true")
String getHelloWorld(String rtrn);
}

Implement the interface with method stubs that return the argument (I’m invoking the methods with return values as arguments). Get a proxy for the object implementing the interface

HelloWorld helloWorld = (HelloWorld)ScriptUtil.registerProxy(
     objectImplementingTheInterface,
     HelloWorld.class,
     classLoaderThatFindsThePath);

And using the interface as you would. Right now you have to read the source code for more comments. I’ve actually documented it to some extent. To get a quick and dirty example see the “Mapping PHP Functions to Java Methods” (step-by-step tutorial) wiki page.

Secondly using some simple PHP developing aids. See the “Facilities Provided by the Plugin” again on the wiki.

The plugin comes with the Quercus ScriptEngine jar inside the plugin. It is compiled from trunk and has the support for MySql (you still have to download the MySql JDBC connector yourself). I’ve proposed a solution/patch to the issue I was ranting about in the last post. No GD support yet but I’ll get around to that soon.

Hopefully next releases will come quicker. I’ve automated the building of the update-site. So it is easy to even produce pseudo releases :) .

Where to now? Oh boy, there is so much more work to do:). Here is a list of ideas/problems that I will be dealing with to produce an actual integration plugin:

  • Provide a cleaner API for users.
  • Implement invoking PHP functions/methods/multiple arguments etc.
  • As PHP is somewhat different (also thanks to Quercus) than other scripting languages also provide support for JavaScript
  • Development aids (when writing interfaces autocomplete for PHP functions/methods/objects etc.)
  • Work on Quercus source code to solve issues that are bugging me (GD, logging exception when certain J2EE classes missing, etc.)
  • Sample plugin mostly in PHP
  • See if and how much I duplicate with PDT Project
  • Bugfixes, bugfixes & bugfixes

Any feedback is appreciated. Go download the plugin, update your J2SE instance and go wild :)

Comments off

GSoC Project Update

There has not been any news for more than a week now. I have not been idleing the whole time :) . Mostly I’ve been battling with Quercus, trying once more the PHP/Java Bridge and waiting for my mentor to get back from a week of vacation which he deserved and is back from :) . One of the main tasks for last week (that i failed) was making an initial release but I was able to run into showstopper bugs. I wanted the release to have at least one feature/example that I find sexy. No luck :( . I’ll give you an idea what I have been trying.

First up is using MySQL or PostgreSQL through the JSR223 PHP ScriptEngine.

mysql_connect("host", "username", "password");
mysql_select_db("databasename");
$result = mysql_query("select * from test");
while($arr=mysql_fetch_assoc($result)) {
 print_r($arr);
}

Currently this produces an error (com.caucho.quercus.QuercusModuleException: Can’t find database for driver). I’ve documented the issue in the bug report. I tried different Quercus versions (currently running trunk). I even tried PostgreSQL. No luck. Although Quercus is a JSR223 ScriptEngine it is developed to run in a web container. The Servlet initializing the QuercusScriptEngine takes care of some configurations that don’t come out-of-the-box when using it as a ScriptEngine.

Secondly I thought it would be nice to do some image manipulation.

$im = @imagecreate(110, 20)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);

This should produce the following image: . Sample is taken from PHP Manual. But I get a java.io.CharConversionException: illegal utf8 encoding. The underlying OutputStream, in this case com.caucho.vfs.ReaderWriterStream insists on checking the bytes of the image for being UTF8. I’ve filed a bug report.

Thirdly I thought of incorporating some PHP into my plugin. I’ve been working on using PHP through annotations and reflection. So that the user would have something along the lines:

@ScriptableAnnotation(
 fileName="org/eclipse/soc2007/php/ScriptablePlugin.php",
 functionName="getVersion()")
public String getVersion(String rtrn) {
 return rtrn;
}

Currently I’m registering a dynamic proxy for the interface of this class. The proxy will invoke the method and the give for the argument the return value of calling getVersion() from ScriptablePlugin.php. Cumbersome :/. I was not able to get this sample to work either. During the initialization I started getting org.osgi.framework.BundleException. Supposedly it is avoiding deadlock and has set time limits on the loading process. ScriptEngine creation takes some time. I’ve been initing the ScriptEngine in a popup menu and this has not happened before so I don’t have a clear answer why this is happening. But still as all plugins are lazily loaded then it is imporant where I put it.

I’m sure I won’t be able to find solutions to all of these problems this week, I’ll still make a release in couple of days. I’ve imported my project to eclipse-incub@sourceforge.net and working on getting the first version out. Stay tuned :)

Comments off

Developing the Mylyn/Eclipse way

About a week ago as I was hacking on my SoC project I was pointed out that I was getting the current selection in the workspace not the right way. I referred that this is how this was done in Mylyn (I guess I was grepping for ISelection in Mylyn sources). I was asked to file a bug and so I did, Bugzilla Bug 195052.

Today I got an answer that the reason was legacy and if I would be interested in contributing a patch. Then there was a another comment with a zip attachment mylyn/context/zip. I already was disappointed that somebody else had made a patch but I only found an XML file. I thought, well I’ve accidently uploaded gibberish too, happens. I did use Mylar about a year ago but I had no idea what a Mylyn context is.

Hours later I took the patch up. Thought I’ll activate the Mylyn task management (I tried it once before but did not understand squeak about it). And woah was I surprised. I was able to retrieve the whole issue to my IDE (screenshot 1st down below). I was amazed. I noticed a menu item Attach contex, it accepted a zip file. Bingo!, I used the weird “accidental” XML file. Boom, only the affected file was visible in my IDE (screenshot 2nd down below).

Taskinfo page in Mylyn Eclipse looks like this when context applied

What this means for developers?

  • Tasks have resource context (subset of the whole project).
  • Tasks & contexts are shareable.
  • Your tasks are where your code is.
  • Don’t have to bookmark the issue to make changes to it.
  • Don’t have to use emails/feedreaders to keep an eye on tasks you’re interested in (Mylyn reqularly updates the task items).

No wonder Eclipse was again on-time with a major release :)

On a side note, I wish Changelogic (used for Aranea Web App Platform development) would have integration with Mylyn. I’ll see, maybe there’s something I can do about it.

Comments (3)

« Previous entries Next Page » Next Page »