AtomMaterialUI / a-file-icon-idea

Atom Material Icons for JetBrains - Replace File and UI Icons for better visual grepping.
http://www.material-theme.com/docs/configuration/icons-settings/#atom-material-icons-plugin
MIT License
220 stars 27 forks source link

Implementing a PSI visualisation in Typescript #318

Closed DexyIce closed 1 year ago

DexyIce commented 1 year ago

Hello πŸ‘‹ This is my first issue on a public project πŸ˜… I hope to do well and that I don't say anything stupid.. haha

Is your feature request related to a problem? Please describe. I've been using Material Icons for about a year now and I'm very happy with it, it's a nice change from the horrible things that are offered by default when you install the IDE.

However, as someone who codes a lot in PHP & Typescript, I'm a bit disappointed with the PSI support for TypeScript. An abstract class is not supported on the TypeScript side while on the PHP side it is... and the visual when you manipulate a lot of files, it's quite important, as much as the name of the files!

Do you think PSI integration is possible for Typescript? πŸ₯Ί

Describe the solution you'd like I don't think there is any need to reinvent the world for this kind of thing, if I take what is done on the PHP side, we should adapt the colour to the TypeScript graphic charter

psiIcons

Describe alternatives you've considered Well, after reading a bit of documentation, the only possible alternative would be to import icons and have the selection done on the file name, but that seems to me to be an overkill solution because there is already a PSI system for PHP and it would be enough to transpose it to other languages.

Additional context Euh.. β€οΈπŸ‡«πŸ‡·

welcome[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the issue template!

Unthrottled commented 1 year ago

I was curious about this, so I looked into it a bit.

Looks like what icon gets dealt is probably dependent on what the language plugin parses/recognizes.

I created a Kotlin file and added a single abstract class into it, and also added a empty Kotlin file. When the IDE first starts up both files are recognized as a plain Kotlin file (PsiFile). However, later on, the file with the abstract class gets recognized as a class (KtClass).

I did the same thing with typescript, and both of the files remain recognized as JSFileImpl (which is a PsiFile). Looks like the Typescript support (atleast for the bundled intellij ultimate) doesn't treat them the differently, so they all get the same file icon. So I guess without having special names for the file & creating an association, we'd need the typescript language plugin to recognize the file with an abstract class as another type of PsiElement.

That being said, I'm just an outsider looking in at a black box and assuming things work the way they do, so take it with a grain of salt.

mallowigi commented 1 year ago

This is something I wanted from day one, but alas it's not something available out of the box, and if some implementation is needed, it's definitely not something that should be done within the scope of this plugin.

In my opinion, it wouldn't make sense in JavaScript as files can be represented in many ways:

Also, it depends on the framework/libraries. The contents of a file can vary a lot, it could be eslint.js, gulpfile.js, app.js, server.js... and don't get me started on the index.js which can serve many purposes.

Truly, to bother parsing the files in order to detect what kind of psi elements are in there are most of the time completely useless. It could make sense in well-defined frameworks such as Angular or Nest, but it's an exception to the rule. Relying on the extension is usually the rule of thumb here, the aforementioned frameworks advise on that, and other frameworks recommend to do the same (Redux, RxJS, etc). But its' seldom enforced and still not enough reason to do so.

BTW, next time please open a Discussion for this, not a bug. Thanks