Take the 2-minute tour ×

I'm trying to use Eclipse templates (in Juno) to generate statements for both regular and static imports and ran into something odd.

After consulting the docs my first attempt was this

${:import(org.junit.Test)}                //ok
${:importStatic('org.junit.Assert.*')}    //gives error

:import works fine, but :importStatic gives this error

Template variable '' has incompatible types

But the syntax above is exactly how it's presented in the docs, where :importStatic is identical to :import in the left-hand column.

I noticed the example in the right-hand column, which uses a namespace is in front of :importStatic


So I added that namespace, the error went away, and the template works

However I'm a little bugged by this magical unexplained is namespace - I can't find any explanation in the docs of where it comes from. In fact, playing around a little it seems there's nothing special about is at all - turns out any namespace in front of :importStatic will work.

${donkey:importStatic(...     //works fine...

So, does anyone know why a namespace is necessary for :importStatic but not :import?

Is the error and the fact it won't save without a namespace just a bug in the template editor or am I missing something?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This is not a namespace, it is an id for the variable used in the template - except that import and importStatic should not need a variable.

I believe what you are see is Eclipse bug 336989 where leaving out the id on two statements causes this problem. As you have found the workaround is to specify an id even though it is not required.

share|improve this answer
Thanks, indeed that looks like the problem - I tried something:import and now :staticImport works. Just one question (I'm completely new to this templating stuff) why would a variable need an id anyway? Is it so you can reuse it elsewhere in the template without having to retype the whole statement? –  davnicwil Dec 31 '13 at 15:36
The id is shown in the initial code generated and should indicate what sort of value is required (iterable_value for example). You then tab through these ids providing actual value. –  greg-449 Dec 31 '13 at 16:04
add comment

Your Answer


