Camork / file-expander-plugin

A IntelliJ plugin that can explore archive-based file in project view
GNU General Public License v3.0
44 stars 7 forks source link

Resolve all File Types missing from Settings #8

Closed theY4Kman closed 5 years ago

theY4Kman commented 5 years ago

Description

This PR alters the ArchiveBasedFileType base class to ensure getDescription() returns a non-null string.

getDescription() is used to sort the various FileTypes for display in the Editor > File Types settings window; when a null is returned, the sorting throws a NullPointerException and all file types fail to display.

The Hunt

A while back, I noticed the list of File Types in the Settings were missing. I'm not sure which version it started with, but I'm primarily using PyCharm 2019.2.1 (PY-192.6262.12) right now. This is what the File Types settings window looked like (mind, this image was taken while running under DevKit) missing-file-types

In the IDEA log, I found this stacktrace idea-exception

I traced back to the FileTypeConfigurable.updateFileTypeList method, and found this source updateFileTypeList-source

Figuring some FileType was returning null for getDescription(), I whipped up a little Groovy script using LivePlugin (super handy) to list all the FileTypes and their descriptions

import static liveplugin.PluginUtil.*
import com.intellij.openapi.fileTypes.FileTypeRegistry
import com.intellij.openapi.fileTypes.FileType

fileTypeRegistry = FileTypeRegistry.getInstance()
registeredFileTypes = fileTypeRegistry.getRegisteredFileTypes()

for (FileType fileType : registeredFileTypes) {
    log(String.format("%s — %s", fileType.class, fileType.getDescription()))
}

The culprits were found ;) liveplugin-dump-of-filetypes

I added a basic little getDescription() based on getName(), and all is well in the world fixed-filetypes

Camork commented 5 years ago

Good catch, Thank you for the contribution!