IntelliJ and Android Studio icons for Kotlin files

I tried to understand what IntelliJ (and Android Studio) is doing with my Kotlin icons. In the picture you can see that Kotlin files come with two different icons - either a rectangle with a small "K" or a circle C with a small "K" (red in the picture). The rectangle version also contains a useful .kt suffix.

After some tinkering with this black box of the problem - it seems that if a kotlin file just declares a class that matches the filename, it gets a "round C" icon. But if it does something kind of non-Java-like - for example, declaring a variable outside of the class (for example val foo = 42

), then the icon is shifted into the rectangle with "K". The icon documentation here assumes that IntelliJ thinks that the rectangle with "K" is a "Kotlin file" whereas the round C is a Kotlin class ".

Does anyone know if there is a deeper implication for this? I think I'll include an val

out-of-class declaration so that all the icon symbols in the Kotlin file match. They will then also have a handy ".kt" extension to clearly indicate that they are Kotlin files.

For example - here's the code that will change your icon to a rectangle from "K" in the Foo.kt file:

val bar = 42;
class Foo {}

      

enter image description here

+3


source to share


1 answer


Your analysis is correct. If a file only defines one class, the Project node view shows that class and not the file as a whole. If there are multiple declarations in the file, the file icon is displayed in the Project node view.



The class icon looks like it does for consistency with Java class icons in mixed language projects.

+6


source







All Articles