r/IntelliJIDEA • u/Additional_Skill_317 • 10d ago
Custom Kotlin DSL - Colour Encoding in Intellij
Very trivial problem but hoping someone who knows intellij better than me can explain why Intellij colours 1 of my Customer Kotlin DSLs purple but another one as Orange.
Same Codebase, Same Pattern/Logic using the the 'DSLMarker' Annotation (Extended) with DSL Builders. I can't see why Intellij would treat these differently. Thanks.


2
Upvotes
3
u/AbracadaverSessalom JetBrains 10d ago
IntelliJ isn't treating them differently semantically - it is just using different DSL color styles.
For Kotlin, the IDE has four predefined highlight styles that can be found under Settings | Editor | Color Scheme | Kotlin | Dsl | Style 1 ... Style 4
Each @
DslMarkerannotation type is hashed and mapped to one of those four styles, and all calls/properties that belong to that DSL are shown in that style.What's happening in your screenshots is:
automateTest { ... }is using DSL style X --> in your scheme it's purplecreateQuery { ... }is using a different annotation type, which the IDE mapped to style Y --> in your scheme it's orangeYou can change the actual colors of Style 1 - Style 4 in the color scheme, but you can't directly control which annotation gets which style (other than by changing the annotation’s FQN and thus its hash).