Categories
Development Tech

Better syntax highlighting in Intellij IDEA

Free code on a MacBook

Quick tip if you’re using Intellij IDEA and not every framework is supported: Add the annotations dependency.

This enables IDEA to get information about certain things in your code and apply the correct validation, information and/or formatting.

We only use it for one thing so far: Marking strings as SQL. That enables IDEA to recognize it and apply the correct highlighting.

The below example shows a wrapper method we have for JDBI, and because of the @Language annotation IDEA knows that it should apply SQL syntax highlighting.

fun createQuery(@Language("sql") sql: String): Query
Kotlin

Dependency:

implementation("org.jetbrains:annotations:24.0.0")
Kotlin

Try it out! 🙂


Subscribe for more 🙂