User: joe
Date: 07 Nov 25 01:44
Revision: 1d2656d86540f383c768ff5c06b3a15e9a4dc158
Summary:
Make hasNamedLocalVariableNames extensible via extension points
TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=10241&personal=false
Index: src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt
===================================================================
--- src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
+++ src/main/kotlin/platform/mixin/util/MinecraftMissingLVTChecker.kt (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
@@ -0,0 +1,35 @@
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 minecraft-dev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, version 3.0 only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.demonwav.mcdev.platform.mixin.util
+
+import com.intellij.openapi.module.Module
+import com.intellij.openapi.util.registry.Registry
+
+class MinecraftMissingLVTChecker : MissingLVTChecker {
+ override fun hasMissingLVT(module: Module, className: String): Boolean {
+ return if (className.startsWith("net.minecraft.") || className.startsWith("com.mojang.blaze3d.")) {
+ // TODO: we'll be able to handle this better when we know which Minecraft version will be unobfuscated
+ !Registry.`is`("mcdev.unobfuscated.minecraft")
+ } else {
+ false
+ }
+ }
+}
Index: src/main/kotlin/platform/mixin/util/MissingLVTChecker.kt
===================================================================
--- src/main/kotlin/platform/mixin/util/MissingLVTChecker.kt (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
+++ src/main/kotlin/platform/mixin/util/MissingLVTChecker.kt (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
@@ -0,0 +1,32 @@
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 minecraft-dev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, version 3.0 only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+
+package com.demonwav.mcdev.platform.mixin.util
+
+import com.intellij.openapi.extensions.ExtensionPointName
+import com.intellij.openapi.module.Module
+
+interface MissingLVTChecker {
+ companion object {
+ val EP_NAME = ExtensionPointName.create("com.demonwav.minecraft-dev.missingLVTChecker")
+ }
+
+ fun hasMissingLVT(module: Module, className: String): Boolean
+}
Index: src/main/kotlin/platform/mixin/util/Mixin.kt
===================================================================
--- src/main/kotlin/platform/mixin/util/Mixin.kt (revision 2b9801dd834a9244df58c6b7e66d95316434dc69)
+++ src/main/kotlin/platform/mixin/util/Mixin.kt (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
@@ -35,7 +35,6 @@
import com.demonwav.mcdev.util.resolveClassArray
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
-import com.intellij.openapi.util.registry.Registry
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiArrayType
@@ -302,10 +301,11 @@
}
fun Module.hasNamedLocalVariables(className: String): Boolean {
- if (className.startsWith("net.minecraft.") || className.startsWith("com.mojang.blaze3d.")) {
- // TODO: we'll be able to handle this better when we know which Minecraft version will be unobfuscated
- return Registry.`is`("mcdev.unobfuscated.minecraft")
- } else {
- return true
+ for (checker in MissingLVTChecker.EP_NAME.extensionList) {
+ if (checker.hasMissingLVT(this, className)) {
+ return false
- }
-}
+ }
+ }
+
+ return true
+}
Index: src/main/resources/META-INF/plugin.xml
===================================================================
--- src/main/resources/META-INF/plugin.xml (revision 2b9801dd834a9244df58c6b7e66d95316434dc69)
+++ src/main/resources/META-INF/plugin.xml (revision 1d2656d86540f383c768ff5c06b3a15e9a4dc158)
@@ -116,6 +116,9 @@
+
@@ -312,6 +315,8 @@
+
+