Eclipse Quick Fix != Quick Assist

August 13th, 2006

If there’s an error in your java code, Eclipse sticks a marker in the gutter with a light-bulb icon. Clicking on the marker or pressing Ctl+1 with the cursor in the offending line brings up a helpful pop-up of suggested fixes for the problem.

I’ve always assumed that this was called Quick Fix. If you right click on the marker, the option is labelled Quick Fix. However, after struggling for a long while to understand why some Quick Fix code I wrote wasn’t showing up in this menu, I’ve come to the conclusion that this is actually Quick Assist and that the label is wrong (I’ve flagged this as a bug).

To launch Quick Fix you need instead to right click on a Warning/Error in the Problems View. Quick Fix and Quick Assist are in fact two different things with confusingly similar names and functionality.

Internally appropriate Quick Fixes are calculated by a class implementing IMarkerResolutionGenerator that extends org.eclipse.ui.ide.markerResolution. The fixes themselves are contained in classes implementing either IMarkerResolution or IMarkerResolution2. By contrast, Quick Assists are calculated by a class extending org.eclipse.jdt.ui.quickAssistProcessors and implement IQuickAssistProcessor. The classes containing the assists implement IJavaCompletionProposal.

So, if you’re developing a plug-in and cannot work out why your Quick Fixes are not showing up, take a closer look. Maybe like me you’re checking in the wrong place and what you meant to write was actually a Quick Assist.

The Compiler is Your Friend

August 3rd, 2006

I’ve been coding exclusively in Java for the last few weeks. However, when I needed to write a quick program to crunch some numbers the other day, I decided to write it in C++ for the change. Since I’ve also been working exclusively within Eclipse, I decided to use a simple text editor for this and gcc from the command line.

The experience made me reflect a little on the importance of good tools.

In Contributing to Eclipse, Kent Beck and Erich Gamma speak of the compiler moving from being a separate tool to “air - something vital that’s always around”. While using the JDT, the compiler is constantly running in the background, warning you of potential errors as you type each line of code. The IDE also makes suggestions for fixes that save much typing. In this collaborative model, the compiler/editor is like a helpful colleague looking over your shoulder and making gentle suggestions from time to time. By contrast, the model of finishing the code, trying to compile it and working through the often opaque error warnings thrown by a c++ compiler is more like facing a difficult interview. The rhythm of work is completely different.

Doug Schaefer, project lead for the Eclipse CDT, explains in this Callisto podcast (direct link to mp3) that the simplicity of Java makes the JDT experience possible but that it would be prohibitively expensive to do the same with CDT.

Another thing I missed was JUnit. At the moment, I frequently work outside my comfort zone, learning through discovery and error and unit testing gives me the confidence to do this and to refactor. The task at hand was so brief it wasn’t worth investing the time to explore the xUnit variants for C++ but I intend to do so the moment I need to write more substantial code in that language.

Borderline Comment Spam

August 2nd, 2006

I’ve just deleted a relatively innocuous comment on a recent post because, although it was not in itself spam, the poster gave his url as a site that stinks like a link-farm.

The IP address of the poster was from an Indian ISP which makes me wonder if some comment spammers frustrated with the efficiency of blocking tools are now abandoning automated scripts and outsourcing their work to low-waged workers. Of course, once a comment has been approved from a certain IP, it increases the chances that further comments will be approved so perhaps they are merely using people to get a foot in the door before launching an automated assault.

Either way, if your comment was genuine and I deleted it over-zealously I apologise. Somehow however, I doubt this was the case.

Wet Neural Nets

August 1st, 2006

Scientists at the Georgia Institute of Technology figured they could learn more from neuron clumps that acted more like real brains, so they’ve developed “neurally controlled animats” — a few thousand rat neurons grown atop a grid of electrodes and connected to a robot body or computer-simulated virtual environment.

It’s Alive (ish) | Wired

A fascinating - but frustratingly brief - look at a something that blurs the boundary between animate life and machines. I, for one, welcome our animat overlords.

Google Down

July 27th, 2006

Google seems to have gone down. I’ve never known this happen. I wonder how long it will take before it comes back up.

Edit: about 20 minutes. Not that long in the scheme of things but long enough to start wondering how very different my experience of the web would be without the ever-useful search engine.

Patching Eclipse 3.2 for Debian 3.1

July 1st, 2006

Eclipse 3.2 is out but I haven’t had much of a chance to look at it yet because I’ve spent the afternoon trying to get it to install.

The GTK focus bug from 3.1 is still present (the problem lies with Debian’s use of version numbers) so you need to download the source, patch it and compile it for your own platform. (Instructions here.)

Compilation proved a little trickier than it was for 3.1. As before you need to edit plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java - feel free to use my patch from the root of your unzipped source:

$ patch -p0 < debGTKBugPatch

I couldn’t get the default build to work but finally got things compiling (ignoring literally hundreds of warnings about non-type safe generic code) by editing the build.xml file and changing javacSource and javacTarget to 1.5 (I only have Java 1.5 on my machine: it should be possible to compile at least some of the source using Java 1.4 but I haven’t tried it)

<property name="javacSource" value="1.5" />
<property name="javacTarget" value="1.5" />

Finally start the build process and go and do something else for a while (on my ageing P4 1.8 it takes close to 50 minutes to build).

$ export ANT_HOME=/usr/bin/ant
$ export JAVA_HOME=/usr/
$ chmod +x build
$ ./build -os linux -ws gtk -arch x86 -java5home /usr/bin/

The custom built version will be in result/linux-gtk-x86-sdk.tar.gz. Extract it into another directory and run eclipse from there.

These notes explain how I got it to work on my machine. Your setup may differ.

Python for Series 60

June 11th, 2006

To give myself a break from my studies, I’ve been exploring writing code for my mobile phone. I bought a Series 60 phone at Christmas from a high-street store planning to learn how to program it. Instead I ended up wasting most of the holidays dealing with Carphone Warehouse’s appalling customer service.

(It’s a long story. In brief, the salesman lied to me and sold me the phone on a tariff that was unusable with the handset meaning I couldn’t get network access on it. His manager, an unhelpful thug, refused to accept the return of the phone. It took close to 40 hours of phone calls, letters, emails and visits to stores to cancel the contract and get my money back. The experience left a very bitter taste in my mouth. I will never use Carphone Warehouse again.)

I’ve only scratched the surface of developing C++ apps for Symbian so far but while searching for a way to read GSM cell info (according to the forum posts it looks as if the API is restricted to registered developers who pay) I found that it was simplicity itself to get this data using Python for Series 60.

Learning Python is (yet another) thing on my todo list and after installing it on the phone and trying out a few sample scripts from the web I’m eager to do so.

Although it’s easy to code on your pc and send the finished script to your phone via bluetooth, there is also a way to code directly on the phone from your machine by using the bluetooth console that is included with Nokia’s python installer.

Assuming you have bluetooth up and running already on your Debian box:

$ sdptool add --channel=2 SP
Serial Port service registered
$ rfcomm listen /dev/rfcomm0 2
Waiting for connection on channel 2

Now start python on the phone and select bluetooth console from the options.

Connection from 00:16:4E:CD:09:06 to /dev/rfcomm0
Press CTRL-C for hangup

In a new terminal on the machine start minicom with the following flags

$minicom -s -m

then choose “Serial Port Setup” and set the Serial Device to “/dev/rfcomm0″ and you’re ready to run.

Test with:

import appuifw
appuifw.note(u'Hello world!', 'info')

You should get a “Hello world!” info box popping up on your phone screen.

Now for something more interesting, print the gsm location details of your nearest cell (see how simple this is):

import location
print(location.gsm_location())

Finally to send a text message (replacing 0000000000 below with the real destination number) :

import messaging
messaging.sms_send("0000000000", u"Hello there")

I can see Python coming in very handy for creating rapid prototypes of applications and/or simple applications for private use only. Although I find the low level details you need to know for C++ development fascinating, there’s something undeniably satisfying about being able to write an application that does something powerful in only two or three lines of code.

Brother HL-2030 Printer on Debian

June 6th, 2006

Just bought a new mono laser printer, the Brother HL-2030 and setting it up on Debian was simplicity itself thanks to excellent driver support.

Hop over to the Brother Linux Driver Homepage and follow the appropriate links to download the LPR and CUPS wrapper drivers.

As the FAQ warns, you’ll need a temporary symlink to get the CUPS wrapper to install:

$ dpkg -i brhl2030lpr_1.1.2-3_i386.deb
$ ln -s /etc/init.d/cupsys /etc/init.d/cups
$ dpkg -i cupswrapperhl2030_1.0.0-1_i386.deb
$ rm /etc/init.d/cups

and you’re done.

The drivers are GPL too. No closed source binaries here. Well done Brother! It’s a great printer too and very reasonably priced.

Inform 7 Released

June 4th, 2006

Inform 7 has been released, a new version of the langugage used to write Infocom-style text-based adventure games (am I showing my age?). Whereas Inform 6 resembled an OO language, version 7 resembles structured English.

In place of traditional computer programming, the design is built by writing natural English-language sentences:

  1. Martha is a woman in the Vineyard.
  2. The cask is either customs sealed, liable to tax or stolen goods.
  3. The prevailing wind is a direction that varies.
  4. The Old Ice House overlooks the Garden.
  5. A container is bursting if the total weight of things in it is greater than its breaking strain.

Although the exams are over, I still have my project to complete so I probably won’t touch this for a few months but I’m looking forward to exploring it.

The Finals Countdown

May 18th, 2006

One week before the exams are due and the university has finally confirmed that, following a meeting with the local branch of the AUT, the exams will be going ahead as scheduled.

My revision has suffered from the uncertainty. Let’s see how much I can catch up in seven days.