Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ and Android Studio icons for Kotlin files

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 {}

enter image description here

like image 698
Jim Andreas Avatar asked Apr 05 '17 14:04

Jim Andreas


People also ask

Can you use IntelliJ for Kotlin?

IntelliJ IDEA provides first-class support for Kotlin. It includes Kotlin-specific project templates, coding assistance, refactorings, debugging, analysis tools, and so on.

Can I use IntelliJ instead of Android Studio?

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.

What are symbols in IntelliJ?

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.


1 Answers

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.

like image 113
yole Avatar answered Oct 20 '22 16:10

yole