⁠
kyle wood: Re-work some NBT handling for better performance, and handle big files
This commit includes some default NBT formatting settings which result
in smaller files, and re-implements NbtVirtualFile to be a
LightVirtualFile. Part of that re-implementation is to make NBT files
only write to disk when saved manually, which is the behavior I
originally wanted anyways. This feels much safer and more stable than
whatever was happening originally.
By being a LightVirtualFile it seems the size limits / requirements on
Psi files are relaxed, but I don't fully understand the details. It
seems to handle larger NBT files better now.
Relevant issues: #1894 , #1893
This commit includes some default NBT formatting settings which result
in smaller files, and re-implements NbtVirtualFile to be a
LightVirtualFile. Part of that re-implementation is to make NBT files
only write to disk when saved manually, which is the behavior I
originally wanted anyways. This feels much safer and more stable than
whatever was happening originally.
By being a LightVirtualFile it seems the size limits / requirements on
Psi files are relaxed, but I don't fully understand the details. It
seems to handle larger NBT files better now.
Relevant issues: #1894 , #1893
- /*
- * Minecraft Dev for IntelliJ
- *
- * https://minecraftdev.org
- *
- * Copyright (c) 2022 minecraft-dev
- *
- * MIT License
- */
- package com.demonwav.mcdev.platform.mixin.config
- import com.demonwav.mcdev.asset.PlatformAssets
- import com.intellij.json.JsonLanguage
- import com.intellij.openapi.fileTypes.LanguageFileType
- import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile
- import com.intellij.openapi.vfs.VirtualFile
- object MixinConfigFileType : LanguageFileType(JsonLanguage.INSTANCE), FileTypeIdentifiableByVirtualFile {
- private val filenameRegex = "(^|\\.)mixins?(\\.[^.]+)*\\.json\$".toRegex()
- // Dynamic file type detection is sadly needed as we're overriding the built-in json file type.
- // Simply using an extension pattern is not sufficient as there is no way to bump the version to tell
- // the cache that the pattern has changed, as it now has, without changing the file type name.
- // See https://www.plugin-dev.com/intellij/custom-language/file-type-detection/#guidelines
- override fun isMyFileType(file: VirtualFile) = file.name.contains(filenameRegex)
- override fun getName() = "Mixin Configuration"
- override fun getDescription() = "Mixin Configuration"
- override fun getDefaultExtension() = ""
- override fun getIcon() = PlatformAssets.MIXIN_ICON
- }
- /*
- * Minecraft Dev for IntelliJ
- *
- * https://minecraftdev.org
- *
- * Copyright (c) 2022 minecraft-dev
- *
- * MIT License
- */
- package com.demonwav.mcdev.platform.mixin.config
- import com.demonwav.mcdev.asset.PlatformAssets
- import com.intellij.json.JsonLanguage
- import com.intellij.openapi.fileTypes.LanguageFileType
- import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile
- import com.intellij.openapi.vfs.VirtualFile
- object MixinConfigFileType : LanguageFileType(JsonLanguage.INSTANCE), FileTypeIdentifiableByVirtualFile {
- private val filenameRegex = "(^|\\.)mixins?(\\.[^.]+)*\\.json\$".toRegex()
- // Dynamic file type detection is sadly needed as we're overriding the built-in json file type.
- // Simply using an extension pattern is not sufficient as there is no way to bump the version to tell
- // the cache that the pattern has changed, as it now has, without changing the file type name.
- // See https://www.plugin-dev.com/intellij/custom-language/file-type-detection/#guidelines
- override fun isMyFileType(file: VirtualFile) = file.name.contains(filenameRegex)
- override fun getName() = "Mixin Configuration"
- override fun getDescription() = "Mixin configuration"
- override fun getDefaultExtension() = ""
- override fun getIcon() = PlatformAssets.MIXIN_ICON
- }