Intellij IDEA, Cucumber and German Spell Checking

Now that Intellij IDEA (12.1.3 in my case) supports auto completion & syntax highlighting for cucumber features not only in english but also in any other language that is available for gherkin it would be nice to have native spell checking as well.

To use your native language with cucumber you just have to place a language comment at the first line of your feature file. For example see this super useful feature description:

# language: de

Funktionalität: deutsche Feature-Beschreibungen
  Um cucumber in unserer Muttersprache zu benutzten
  möchte ich als Szenario-Schreiber
  die deutschen Schlüsselwörter benutzen

  Szenario: deutsche Schlüsselwörter & Steps
    Angenommen ich schreibe eine Feature-Beschreibung
    Wenn ich die deutschen Gherkin-Schlüsselwörter benutze
    Dann werden die deutschen Steps aufgerufen

To get spell checking for an additional language in IntelliJ we need to add a dictionary for that language. This is done in a few simple steps:

  • first, we need a dictionary for our language. This is a plain text file with a lot of words, each on a single line. I found a german dictionary on sourceforge.
  • second, we need to make sure it is encoded in utf–8. The german.dic file was encoded in latin–1. If it is not encode in utf–8 use your text editor of choice (e.g. Notepadd++ or TextWrangler or …) and convert it to utf–8 (no BOM).
  • third, create a folder (e.g. dictionaries) where you want to save the dic file
  • fourth, tell IntelliJ about the dictionary folder following the documentation, which is in short:
    1. open the Settings dialog
    2. type ‘spell’ into the search box and select Spelling
    3. switch to the Dictionaries tab
    4. and add the folder to the Custom Dictionaries Folder list

You should see now the dictionary under Dictionaries as a user dictionary and the checkbox enabled.

That’s it, no more typos in the features :-)

IntelliJ IDEA & Spock: Groovy Pointless Arithmetic

Maybe this is just plain stupid but there is a simple workaround for the warning 0 * report.addError can be replaced by 0 in the following test (in IDEA):

def "does not report step error or failure when it succeeds" () {
  Result result = Mock (Result)
  result.error >> null

    uat.step (stepStub ())
    uat.result (result)

    0 * report.addError (_)
    0 * report.addFailure (_)

My solution so far was to add an @SuppressWarnings(["GroovyPointlessArithmetic"]) to the test class. But there is a simpler solution without disabling the warning. I can simply write

def "does not report step error or failure when it succeeds" () {
  Result result = Mock (Result)
  result.error >> null

    uat.step (stepStub ())
    uat.result (result)

    (0) * report.addError (_)
    (0) * report.addFailure (_)

to remove the warning. See the difference? I have replaced the 0 with (0) and the warning goes away. :-)

First Impression of appCode, JetBrains Objective-C IDE

JetBrains just released their first EAP version of a new IDE for Objective-C.

Objective-C ???? Yes, no joke. :-)

The JetBrains page says:

appCode is a new IDE based on IntelliJ platform, for developers building apps for Apple devices such as Macs, iPhones & iPads.”

I don’t do daily programming in Java but If I do java programming I use IntelliJ IDEA. At work with the commercial version and at home with the community edition.

My free time interest right know is iOS development and I have written a couple of articles about iOS stuff on my blog. So I was quite curious to take look at appCode.

I downloaded the archive and started to play around with it.

Here are a couple of things I tried:

Loading an Xcode project did work without problem.

Building and running my app did work out of the box. The only thing was that I had to specifically set the device to iPad. It didn’t pick that up by itself.

Using the typical IDEA run/debug configuration dialog I was also able to configure and run my GTM unit tests. appCode recognizes all the targets from the Xcode project and you can modify the SDK, device and so on.

appCode doesn’t seem handle the test results so far. It complained about 65 errors although only 2 failed. Not sure where it got that number from. The failing tests are not appCodes fault. Double clicking the error also didn’t jump to the source.

Debugging works too. I was able to set breakpoints and step through the code. [Update: 11.04.] A bit strange is that it didn’t honor breakpoints in all methods. I’m unable to reproduce the breakpoints that did not work. I retried multiple times and now it just works. I don’t know what made me believe it did not stop on all breakpoints.

The editor itself works great. You are directly at home if you know IntelliJ IDEA. It offers a similar feature set:

IDEAs common navigation shortcuts, auto completion, inspections, live templates and so on.

At the left of the editor you have small icons that tell you that a method overwrites a base class method and clicking it will jump to its declaration. appCode also marks methods with a small pair of arrows icon to jump from declaration to definition and the other way.

Auto completion works really good. I’ve just used it a short time but it looks like it provides better suggestions (less noise) than Xcode.

Inspections. It’s recognizing unused #imports and variables and creates the IDEA typical yellow lines in the editor scroll bar.

Live Templates work too. For example typing alloc<tab> will result in [[ alloc] init] with the cursor before the alloc.

It also comes with a number of refactorings. I tried rename and extract method without problems.

appCode did open a xib file as xml. It didn’t run Interface Builder. Not sure if it is even possible to run Interface Builder now that it is built into Xcode 4.

It also had some problem to find all the #imported files and complained about undefined symbols (in the editor, building works, I guess it simply runs xcodebuild).

I have created a couple of different source folders in my project to organize the sources. In Xcode I have set a couple of additional #import folders and #import header files relative to them.

appCode didn’t pick up the additional #import folders. You can tell appCode about the source root folder and test source root folder but that did not completely fix this issue. I have three parallel source folders: “Source”, “Source Test” and “Source External” and the external folder contains the GTM, OCMock and OCHamcrest code which appCode did not find.

My first impression (after maybe an hour and a half) is quite good. I think I will spend some more time working with it and see how it feels when doing some real work.

What’s your opinion on appCode?