Kotlin文件的IntelliJ和Android Studio图标 [英] IntelliJ and Android Studio icons for Kotlin files

查看:198
本文介绍了Kotlin文件的IntelliJ和Android Studio图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试理解IntelliJ(和Android Studio)对我的Kotlin文件图标所做的事情.在图片中,您可以看到Kotlin文件带有两个不同的图标-带有小"K"的矩形或带有小"K"的圆圈C(图片中以红色圆圈).矩形版本还包含一个有用的".kt"后缀.

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.

在对这个问题的黑匣子进行了一些修改之后-如果kotlin文件 just 声明了一个与文件名匹配的类,那么它将得到一个带圆圈的C"图标.但是,如果它执行的操作类似于Java,例如在类外声明变量(例如val foo = 42),则图标将移动到带有"K"的矩形.图标文档此处建议IntelliJ认为带有"K"的矩形是"Kotlin文件",而带圆圈的C是"Kotlin类".

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".

有人知道这是否有更深层的含义吗?我想我将在类外包含val声明,只是为了使我的Kotlin文件图标符号全部匹配.然后,它们还将具有方便的".kt"扩展名,以清楚表明它们是Kotlin文件.

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.

例如-这里的代码会将Foo.kt文件中的图标更改为带有"K"的矩形:

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

推荐答案

您的分析是正确的.如果文件仅定义一个类,则项目"视图节点将显示该类,而不是整个文件.如果文件中有多个声明,则项目"视图节点将显示一个文件图标.

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.

在混合语言项目中,类图标看起来与Java类图标保持一致.

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

这篇关于Kotlin文件的IntelliJ和Android Studio图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆