Guidance on creating custom ArchiveFileSystem

Answered

What would be the steps to create a custom FileSystem (similar to JarFileSystem)?

For example, I might have an archive of binary files added as a library to the project (similar to JAR). And I want to have support for that archive type similar to jar type: correct class resolution based on path to binaries, archive is expandable in a file tree window, etc.

Tbh, I have no idea where to start. I've read the docs about VirtualSystem, it's a high-level overview, so I still not sure if I need to implement a number of classes, use some extension points, or invoke any IJ API.

Could someone explain to me the steps needed to create a custom FileSystem? Any help is appreciated!

2 comments
Comment actions Permalink

Implement your custom FileSystem by extending base class com.intellij.openapi.vfs.newvfs.ArchiveFileSystem and register it in extension point com.intellij.virtualFileSystem.

You can find a number of VFS System implementations in IJ Community sources or in 3rd party plugins: https://plugins.jetbrains.com/intellij-platform-explorer?extensions=com.intellij.virtualFileSystem

Resolving classes really depends on how these files are setup in project model/roots. It's possible to provide custom com.intellij.psi.NonClasspathClassFinder extension.

1
Comment actions Permalink

Posting an update for anyone looking into implementing FileSystem. Extending ArchiveFileSystem is not enough. I asked a follow-up question here, and the answer was to also implement new FileType: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010870600-Intellij-does-not-trigger-custom-ArchiveFileSystem

0

Please sign in to leave a comment.