Intellij IDEA 9.0.4

Hi!

I'm trying out Intellij IDEA 9.0.4, as our dev team is searching for Eclipse alternatives. I ran into few issues while setting up the IDEA environment:

1) Colors and fonts, Java editor

Changing the default theme to a black one was easy, but there was one issue I couldn't figure out:

For some reason, a String which has regexp data in it is drawn differently. See idea_code.JPG and compare it to eclipse_code.JPG. Is this is a bug or am I missing something from the color/font configuration?

2) Ant support

We use several external files to enhance to Ant build process, such as ant-contrib-1.0b3.jar, jsch-0.1.42.jar and yui-compressor-ant-task-0.5.jar. The build process itself works fine in IntelliJ IDEA, but the Ant editor is complaining about the <var> tag, <scp> and <sshexec> tasks etc. Is there a way to "add" these files to the IDE, so that it won't mark these tags as errors?

Best regards,

Tuomas Hynninen
Software Engineer
Sonecta Ltd.



Attachment(s):
eclipse_code.JPG
idea_code.JPG
5 comments
Comment actions Permalink

> Is there a way to "add" these files to the IDE, so that it won't mark these tags as errors?

it's simple
just add needed jars to ant in ant properties dialog

0
Comment actions Permalink

tuomash wrote:



1) Colors and fonts, Java editor

Changing the default theme to a black one was easy, but there was one issue I couldn't figure out:

For some reason, a String which has regexp data in it is drawn differently. See idea_code.JPG and compare it to eclipse_code.JPG. Is this is a bug or am I missing something from the color/font configuration?

This is not a bug. It is a feature called Language Injection. IDEA is aware of other languages that are injected  into files that are primarily of another language. For example, it can be aware of HTML, XML, CSS, SQL, JavaScript, etc. in a Java file. JavaScript  or CSS syntax in an XML or HTML file. Etc. It then provides full editing capabilities, including syntax highlighting, code completion and error highlighting, for the appropriate language.

In some case you have to "tell" idea to do such via an annotation (see below). In other cases, IDEA is intelligent enough to auto detect these occurrences.  In the case of the String.replaceAll() method, IDEA knows (via a configuration) that the first method parameter must be a valid regular expression and automatically provides the appropriate syntax and error highlighting for a regex String. If you had a syntax error in your regex, you would see a red underline squiggle. As such, the style settings for a regex apply rather than for a Java file, or more specifically a Java String. There isn't any auto completion for the regex language, so that feature can not be demonstrated using the replaceAll() method. But in the case of something like the methods in the Spring JdbcTemplate classes, IDEA knows the String parameter is an SQL statement and provides SQL syntax highlighting and code completions (including table and column names if you have a Datasource configured for your project via Tools | Datasources...). You can configure any method you like to have such automatic language injection via the "Language Injection" page in the settings dialog (ctrl+alt+S).

If for some reason, you do not like this feature, you can disable it for a particular language type or a file. But I would recommend giving it a try first. To me, it it one of IDEA's top features.

A plug-in, called IntelliLang, let's you take advantage of language injection for String literals and XML fragements. You can annotate a String, a method, or method parameter with a "Language" annotation. IDEA than provides full syntax highlighting and code completion. You can place your cursor on the String, type alt+Enter and select "Edit ${language-name} Fragment" to get a small popup editor window to allow for more robust editing, including line breaks. You will of course need the "Language" annotation in your classpath. If you type the language annotation, then hit alt+enter, a quick fix option will be to add it to you classpath. The com.intellij:annotations jar is also available in maven. Even for non IDEA users, the annotation has value as it documents that a String (or return type) is expected to be a particular language. So it helps document the code. (Note that IntelliLang has additional features besides just language injection.)

For more information, see http://www.jetbrains.com/idea/webhelp/language-injections.html and http://www.jetbrains.com/idea/webhelp/intellilang.html or the corresponding pages in IDEA's Help.

0
Comment actions Permalink

Another optionis to place the necessary jars in

${user.home}/.ant/lib
as detailed at http://ant.apache.org/manual/install.html#optionalTasks You then need to restart IDEA.They will then be there for all Ant files. The downside of this approach is that differnet projects cannot use different versions of the jars.
0
Comment actions Permalink

Hi!

Sorry for the late reply.

Ah, now I understand. The Language Injection feature is actually really good, since I have to build JPQL queries and IDEA recognizes them automatically. Saves a lot of time on those little syntax errors...

0
Comment actions Permalink

Hi!

Sorry for the late reply...

I couldn't get the .jar file adding working. I selected the build.xml file's properties, selected "Additional Classpath" and input the .jar files, but to no effect.

Am I in the right properties dialog? :)

0

Please sign in to leave a comment.