I have been tinkering trying to understand what IntelliJ (and Android Studio) are doing to my Kotlin file icons. In the picture you can see that Kotlin files come with two different icons - either a rectangle with a small "K" or a circled C with a small "K" (circled in red in the picture). The rectangle version also includes a useful ".kt" suffix.
After some tinkering with this black box of a problem - it appears that if the kotlin file just declares a class matching the file name then it gets a "circled C" icon. But if it does anything that is un-Java-like - such as declaring a variable outside the class (e.g. val foo = 42
) - then the icon is shifted to the rectangle with the "K". The icon documentation here suggests that IntelliJ thinks the rectangle with the "K" is a "Kotlin file" whereas the circled C is a "Kotlin class".
Does anybody know if there is a deeper meaning to this? I think I will include a val
declaration outside the class just to get my Kotlin file icon symbols all to match. Then they will also have the handy ".kt" extension to clearly indicate that they are Kotlin files.
For example - here is code that will change your icon to a rectangle with a "K" in file Foo.kt:
val bar = 42;
class Foo {}
IntelliJ IDEA provides first-class support for Kotlin. It includes Kotlin-specific project templates, coding assistance, refactorings, debugging, analysis tools, and so on.
Chose Android Studio. Android application development can also be done using the IntelliJ IDE. It is a very good IDE but it is paid for professional and commercial product development. However, IntelliJ IDE is available with a student license for limited application development features.
A symbol is a semantic element in some model, e.g., language or framework model. The IntelliJ Platform uses Symbol to represent symbols, and Symbol serves as a link between Platform APIs, such as navigation, finding usages, or renaming.
Your analysis is correct. If a file defines only a single class, then the Project view node shows that class, instead of the file as a whole. If there are multiple declarations in the file, then the Project view node shows a file icon.
The class icon looks the way it does for consistency with Java class icons in mixed-language projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With