Annoying Notification From Intellij about this plugin.
Opened this issue · 13 comments
Basically, the plugin doesn't check if its already registered the file type before trying to register again. While it doesn't seem to break the plugin, but it does have an annoying notification in Intellij.
com.intellij.diagnostic.PluginException: Trying to override already registered file type NBT [Plugin: com.github.tth05.minecraft-nbt-intellij-plugin]
at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.loadFileTypeBeans(FileTypeManagerImpl.java:423)
at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.initStandardFileTypes(FileTypeManagerImpl.java:311)
at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.<init>(FileTypeManagerImpl.java:228)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:44)
at com.intellij.serviceContainer.PlatformComponentManagerImpl.instantiateClassWithConstructorInjection(PlatformComponentManagerImpl.kt:505)
at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:52)
at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:39)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:110)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:72)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:65)
at com.intellij.serviceContainer.PlatformComponentManagerImpl$preloadServices$future$1.run(PlatformComponentManagerImpl.kt:622)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:222)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:30)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:201)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:193)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
I'm really not sure how to fix this. The file type is registered in an xml file, where I can't just write an if statement to see if the file type is already registered.
It is weird that you get a notification for this. I can only see it in the console in my dev environment, but I don't get a notification. You can try to just disable the notification if that's possible.
You could also disable the other plugin that registers the file type (probably "Minecraft Development") if that's an option for you.
I actually think this should be reported to Jetbrains, because Intellij should have an option for the user to choose which plugin should have control over a given file type.
Internal file type names must be unique in IntelliJ or this error will happen. You can declare multiple file types for the same file, but the name for the file type can't be the same. Because both plugins are using NBT
for the file type name, that causes the conflict:
https://github.com/minecraft-dev/MinecraftDev/blob/dev/src/main/resources/META-INF/plugin.xml#L85
The easiest fix is to rename your file type to something else (that name is just an internal identifier for the file type, won't change anything else). I'm going to temporarily push out a version of mcdev which uses the deprecated FileTypeFactory
and not register my file type if yours is already registered in the mean time, but that's a temporary solution which will break eventually considering it's deprecated.
I will also add a check for your file type name (assuming you choose a new one) and disable my file type detection if that one is present so they don't conflict.
I tried to use the FileTypeFactory
but it turns out I can't access FileTypeManager
from a FileTypeFactory
because it hasn't been created yet. So I can't do my temporary fix.
Oh well, didn't realize it's that easy to fix. I'll change the name.
I fixed it now. The only weird thing that still happens is that, while my plugin provides the file editor, your plugin provides the file icon. It's not really a problem but still a weird behavior.
The next version of mcdev will take your new name into account and disable those features if present, so that should help.
Also if you implement FileTypeOverrider
that should fix that issue as well on your side.
Ok, thanks.
Registering a FileTypeOverrider
does indeed fix the icon issue, but it causes my custom editor not to be shown anymore when opening any NBT file. It is instead openend as a normal text file which is unreadable.
Sadly, I'm not familiar enough with the Intellij platform to know if this is fixable.
If you push what you have to a branch I can take a look at it and see if I can figure it out.
I pushed it to a separate branch.
Also, thanks a lot for helping me out here!