From a0e4482c23bb9be3b963d5cdf3b8a4acf38e5ef5 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Fri, 20 Jan 2023 18:25:41 +0100 Subject: [PATCH 01/14] 2023.1 EAP --- gradle.properties | 6 ++--- gradle/libs.versions.toml | 2 +- ...AddEmptyConstructorInspectionGadgetsFix.kt | 2 +- .../platform/mcp/actions/GotoAtEntryAction.kt | 18 +------------ .../platform/mcp/actions/SrgActionBase.kt | 27 +++++++++++++++---- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/gradle.properties b/gradle.properties index e9700123c..13cc0affe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,13 +11,13 @@ # suppress inspection "UnusedProperty" for whole file kotlin.code.style=official -ideaVersion = 223-EAP-SNAPSHOT -ideaVersionName = 2022.3 +ideaVersion = 231-EAP-SNAPSHOT +ideaVersionName = 2023.1 coreVersion = 1.5.21 downloadIdeaSources = true -pluginTomlVersion = 223.4884.72 +pluginTomlVersion = 231.4840.388 # Silences a build-time warning because we are bundling our own kotlin library kotlin.stdlib.default.dependency = true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 163239ede..64b857d5b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ jflex-skeleton = "org.jetbrains.idea:jflex:1.7.0-c1fdf11" grammarKit = "org.jetbrains.idea:grammar-kit:1.5.1" # Gradle Tooling -gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension:223-EAP-SNAPSHOT" +gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension:231-EAP-SNAPSHOT" annotations = "org.jetbrains:annotations:23.0.0" groovy = "org.codehaus.groovy:groovy-all:2.5.18" diff --git a/src/main/kotlin/platform/forge/inspections/simpleimpl/AddEmptyConstructorInspectionGadgetsFix.kt b/src/main/kotlin/platform/forge/inspections/simpleimpl/AddEmptyConstructorInspectionGadgetsFix.kt index 8599c06db..847621dc7 100644 --- a/src/main/kotlin/platform/forge/inspections/simpleimpl/AddEmptyConstructorInspectionGadgetsFix.kt +++ b/src/main/kotlin/platform/forge/inspections/simpleimpl/AddEmptyConstructorInspectionGadgetsFix.kt @@ -22,7 +22,7 @@ class AddEmptyConstructorInspectionGadgetsFix(element: PsiClass, private val nam private val pointer: SmartPsiElementPointer = element.createSmartPointer() - override fun doFix(project: Project, descriptor: ProblemDescriptor?) { + override fun doFix(project: Project, descriptor: ProblemDescriptor) { val clazz = pointer.element ?: return clazz.addBefore(JavaPsiFacade.getElementFactory(project).createConstructor(), clazz.methods[0]) } diff --git a/src/main/kotlin/platform/mcp/actions/GotoAtEntryAction.kt b/src/main/kotlin/platform/mcp/actions/GotoAtEntryAction.kt index a919645f0..52bac56ef 100644 --- a/src/main/kotlin/platform/mcp/actions/GotoAtEntryAction.kt +++ b/src/main/kotlin/platform/mcp/actions/GotoAtEntryAction.kt @@ -17,15 +17,11 @@ import com.demonwav.mcdev.platform.mixin.handlers.ShadowHandler import com.demonwav.mcdev.util.ActionData import com.demonwav.mcdev.util.getDataFromActionEvent import com.demonwav.mcdev.util.gotoTargetElement -import com.demonwav.mcdev.util.invokeLater import com.demonwav.mcdev.util.qualifiedMemberReference import com.demonwav.mcdev.util.simpleQualifiedMemberReference import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.ui.popup.Balloon -import com.intellij.openapi.ui.popup.JBPopupFactory -import com.intellij.openapi.wm.WindowManager import com.intellij.psi.PsiField import com.intellij.psi.PsiIdentifier import com.intellij.psi.PsiManager @@ -34,8 +30,6 @@ import com.intellij.psi.PsiMethod import com.intellij.psi.search.LocalSearchScope import com.intellij.psi.search.PsiSearchHelper import com.intellij.psi.search.UsageSearchContext -import com.intellij.ui.LightColors -import com.intellij.ui.awt.RelativePoint class GotoAtEntryAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { @@ -107,16 +101,6 @@ class GotoAtEntryAction : AnAction() { } private fun showBalloon(e: AnActionEvent) { - val balloon = JBPopupFactory.getInstance() - .createHtmlTextBalloonBuilder("No access transformer entry found", null, LightColors.YELLOW, null) - .setHideOnAction(true) - .setHideOnClickOutside(true) - .setHideOnKeyOutside(true) - .createBalloon() - - val project = e.project ?: return - val statusBar = WindowManager.getInstance().getStatusBar(project) - - invokeLater { balloon.show(RelativePoint.getCenterOf(statusBar.component), Balloon.Position.atRight) } + SrgActionBase.showBalloon("No access transformer entry found", e) } } diff --git a/src/main/kotlin/platform/mcp/actions/SrgActionBase.kt b/src/main/kotlin/platform/mcp/actions/SrgActionBase.kt index 6a76687ac..64e0dd8b1 100644 --- a/src/main/kotlin/platform/mcp/actions/SrgActionBase.kt +++ b/src/main/kotlin/platform/mcp/actions/SrgActionBase.kt @@ -29,6 +29,8 @@ import com.intellij.psi.PsiMember import com.intellij.psi.PsiReference import com.intellij.ui.LightColors import com.intellij.ui.awt.RelativePoint +import java.awt.Point +import javax.swing.JComponent abstract class SrgActionBase : AnAction() { @@ -74,19 +76,34 @@ abstract class SrgActionBase : AnAction() { .createBalloon() val project = e.project ?: return - val statusBar = WindowManager.getInstance().getStatusBar(project) invokeLater { val element = getDataFromActionEvent(e)?.element val editor = getDataFromActionEvent(e)?.editor - val at = if (element != null && editor != null) { + if (element != null && editor != null) { val pos = editor.offsetToVisualPosition(element.textRange.endOffset - element.textLength / 2) - RelativePoint( + val at = RelativePoint( editor.contentComponent, editor.visualPositionToXY(VisualPosition(pos.line + 1, pos.column)) ) - } else RelativePoint.getCenterOf(statusBar.component) - balloon.show(at, Balloon.Position.below) + balloon.show(at, Balloon.Position.below) + return@invokeLater + } + + val statusBar = WindowManager.getInstance().getStatusBar(project) + val statusBarComponent = statusBar.component + if (statusBarComponent != null) { + balloon.show(RelativePoint.getCenterOf(statusBarComponent), Balloon.Position.below) + return@invokeLater + } + + val focused = WindowManager.getInstance().getFocusedComponent(project) + if (focused is JComponent) { + balloon.show(RelativePoint.getCenterOf(focused), Balloon.Position.below) + return@invokeLater + } + + balloon.show(RelativePoint.fromScreen(Point()), Balloon.Position.below) } } From 9c080d24dce94a88e85bdb0df64512b31eb777b5 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Fri, 20 Jan 2023 19:03:53 +0100 Subject: [PATCH 02/14] Bump IJ Gradle to 1.12.0 Let's see if it helps with the macos test errors --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 372c2d23b..2d867741a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ plugins { mcdev groovy idea - id("org.jetbrains.intellij") version "1.9.0" + id("org.jetbrains.intellij") version "1.12.0" id("org.cadixdev.licenser") id("org.jlleitschuh.gradle.ktlint") version "10.3.0" } From e670cb9ca3c13d78b223cf9b9cb31eeca93ad8fc Mon Sep 17 00:00:00 2001 From: RedNesto Date: Fri, 20 Jan 2023 20:18:46 +0100 Subject: [PATCH 03/14] Revert "Bump IJ Gradle to 1.12.0" This reverts commit 9c080d24dce94a88e85bdb0df64512b31eb777b5. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2d867741a..372c2d23b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ plugins { mcdev groovy idea - id("org.jetbrains.intellij") version "1.12.0" + id("org.jetbrains.intellij") version "1.9.0" id("org.cadixdev.licenser") id("org.jlleitschuh.gradle.ktlint") version "10.3.0" } From 1a7c78f399122fa0e969fffa8cf4449f200e61d1 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sat, 21 Jan 2023 12:57:50 +0100 Subject: [PATCH 04/14] Fix some new internal symbol usage warnings --- src/main/kotlin/facet/MinecraftFacetDetector.kt | 4 ++-- src/main/kotlin/util/utils.kt | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/facet/MinecraftFacetDetector.kt b/src/main/kotlin/facet/MinecraftFacetDetector.kt index a7b5eac17..db52a8772 100644 --- a/src/main/kotlin/facet/MinecraftFacetDetector.kt +++ b/src/main/kotlin/facet/MinecraftFacetDetector.kt @@ -163,8 +163,8 @@ class MinecraftFacetDetector : StartupActivity { if (m.name.startsWith("SpongeAPI", ignoreCase = true)) { // We don't want want to add parent modules in module groups val moduleManager = ModuleManager.getInstance(m.project) - val groupPath = moduleManager.getModuleGroupPath(m) - if (groupPath == null) { + val groupPath = moduleManager.getModuleGrouper(null).getGroupPath(m) + if (groupPath.isEmpty()) { platformKinds.add(SPONGE_LIBRARY_KIND) return@forEach true } diff --git a/src/main/kotlin/util/utils.kt b/src/main/kotlin/util/utils.kt index d5c67037f..7c8b929d3 100644 --- a/src/main/kotlin/util/utils.kt +++ b/src/main/kotlin/util/utils.kt @@ -226,7 +226,11 @@ fun Module.findChildren(): Set { continue } - val path = manager.getModuleGroupPath(m) ?: continue + val path = manager.getModuleGrouper(null).getGroupPath(m) + if (path.isEmpty()) { + continue + } + val namedModule = manager.findModuleByName(path.last()) ?: continue if (namedModule != this) { From 4e860a8ec2abd02230c5a2fb57eb824910e1ecad Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Sat, 28 Jan 2023 20:10:47 -0600 Subject: [PATCH 05/14] Fix build and address deprecation warnings --- build.gradle.kts | 37 +------------- src/main/kotlin/creator/PlatformVersion.kt | 2 +- .../version/ArchitecturyVersion.kt | 49 ++++++++++--------- .../injectionPoint/LoadInjectionPoint.kt | 4 +- .../platform/mixin/util/LocalVariables.kt | 6 ++- 5 files changed, 37 insertions(+), 61 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 372c2d23b..d513172ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,6 @@ import org.cadixdev.gradle.licenser.header.HeaderStyle import org.gradle.internal.jvm.Jvm -import org.gradle.internal.os.OperatingSystem import org.jetbrains.gradle.ext.settings import org.jetbrains.gradle.ext.taskTriggers import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -22,7 +21,7 @@ plugins { mcdev groovy idea - id("org.jetbrains.intellij") version "1.9.0" + id("org.jetbrains.intellij") version "1.12.0" id("org.cadixdev.licenser") id("org.jlleitschuh.gradle.ktlint") version "10.3.0" } @@ -247,22 +246,6 @@ tasks.test { jvmArgs( "-Dsun.io.useCanonCaches=false", "-Dsun.io.useCanonPrefixCache=false", - "--add-opens", "java.base/java.io=ALL-UNNAMED", - "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", - "--add-opens", "java.base/java.lang.ref=ALL-UNNAMED", - "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", - "--add-opens", "java.base/java.lang=ALL-UNNAMED", - "--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED", - "--add-opens", "java.base/java.util.concurrent.locks=ALL-UNNAMED", - "--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED", - "--add-opens", "java.base/sun.nio.fs=ALL-UNNAMED", - "--add-opens", "java.desktop/java.awt.event=ALL-UNNAMED", - "--add-opens", "java.desktop/java.awt=ALL-UNNAMED", - "--add-opens", "java.desktop/javax.swing.plaf.basic=ALL-UNNAMED", - "--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", - "--add-opens", "java.desktop/sun.awt=ALL-UNNAMED", - "--add-opens", "java.desktop/sun.font=ALL-UNNAMED", - "--add-opens", "java.desktop/sun.swing=ALL-UNNAMED", ) } @@ -379,22 +362,4 @@ tasks.runIde { tasks.buildSearchableOptions { // not working atm enabled = false - // https://youtrack.jetbrains.com/issue/IDEA-210683 - jvmArgs( - "--illegal-access=deny", - "--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED", - "--add-opens=java.base/java.lang=ALL-UNNAMED", - "--add-opens=java.base/java.util=ALL-UNNAMED", - "--add-opens=java.desktop/java.awt.event=ALL-UNNAMED", - "--add-opens=java.desktop/java.awt=ALL-UNNAMED", - "--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED", - "--add-opens=java.desktop/javax.swing=ALL-UNNAMED", - "--add-opens=java.desktop/sun.awt=ALL-UNNAMED", - "--add-opens=java.desktop/sun.font=ALL-UNNAMED", - "--add-opens=java.desktop/sun.swing=ALL-UNNAMED" - ) - - if (OperatingSystem.current().isMacOsX) { - jvmArgs("--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED") - } } diff --git a/src/main/kotlin/creator/PlatformVersion.kt b/src/main/kotlin/creator/PlatformVersion.kt index 22a172f50..7bf385aa1 100644 --- a/src/main/kotlin/creator/PlatformVersion.kt +++ b/src/main/kotlin/creator/PlatformVersion.kt @@ -29,7 +29,7 @@ import kotlin.reflect.KClass private const val CLOUDFLARE_BASE_URL = "https://minecraftdev.org/versions/" private const val GITHUB_BASE_URL = "https://raw.githubusercontent.com/minecraft-dev/minecraftdev.org/master/versions/" -val PLATFORM_VERSION_LOGGER = Logger.getInstance("MDev.PlatformVersion") +val PLATFORM_VERSION_LOGGER = Logger.getInstance("com.demonwav.mcdev.creator.PlatformVersion") suspend fun getVersionSelector(type: PlatformType): PlatformVersion { val versionJson = type.versionJson ?: throw UnsupportedOperationException("Incorrect platform type: $type") diff --git a/src/main/kotlin/platform/architectury/version/ArchitecturyVersion.kt b/src/main/kotlin/platform/architectury/version/ArchitecturyVersion.kt index 49f878ddb..b262f6fe8 100644 --- a/src/main/kotlin/platform/architectury/version/ArchitecturyVersion.kt +++ b/src/main/kotlin/platform/architectury/version/ArchitecturyVersion.kt @@ -45,36 +45,41 @@ class ArchitecturyVersion private constructor( companion object { - suspend fun downloadData(): ArchitecturyVersion { - val url = "https://api.modrinth.com/v2/project/architectury-api/version" - val manager = FuelManager() - manager.proxy = selectProxy(url) + suspend fun downloadData(): ArchitecturyVersion? { + try { + val url = "https://api.modrinth.com/v2/project/architectury-api/version" + val manager = FuelManager() + manager.proxy = selectProxy(url) - val response = manager.get(url) - .header("User-Agent", PluginUtil.useragent) - .suspendable() - .awaitString() + val response = manager.get(url) + .header("User-Agent", PluginUtil.useragent) + .suspendable() + .awaitString() - val data = Gson().fromJson>(response) + val data = Gson().fromJson>(response) - val apiVersionMap = HashMap>() + val apiVersionMap = HashMap>() - for (version in data) { - val apiVersion = SemanticVersion.parse(version.versionNumber.substringBeforeLast('+')) + for (version in data) { + val apiVersion = SemanticVersion.parse(version.versionNumber.substringBeforeLast('+')) - for (gameVersion in version.gameVersions) { - val parsed = SemanticVersion.parse(gameVersion) - val set = apiVersionMap.computeIfAbsent(parsed) { HashSet() } - set += apiVersion + for (gameVersion in version.gameVersions) { + val parsed = SemanticVersion.parse(gameVersion) + val set = apiVersionMap.computeIfAbsent(parsed) { HashSet() } + set += apiVersion + } } - } - val apiVersionMapList = HashMap>() - for ((mcVersion, archList) in apiVersionMap.entries) { - apiVersionMapList[mcVersion] = archList.sortedDescending() - } + val apiVersionMapList = HashMap>() + for ((mcVersion, archList) in apiVersionMap.entries) { + apiVersionMapList[mcVersion] = archList.sortedDescending() + } - return ArchitecturyVersion(apiVersionMapList) + return ArchitecturyVersion(apiVersionMapList) + } catch (e: IOException) { + e.printStackTrace() + } + return null } } } diff --git a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt index 1228ac3db..1d0746a36 100644 --- a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt +++ b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt @@ -180,7 +180,9 @@ abstract class AbstractLoadInjectionPoint(private val store: Boolean) : Injectio override fun visitForeachStatement(statement: PsiForeachStatement) { checkImplicitLocalsPre(statement) if (store) { - addLocalUsage(statement.iterationParameter, statement.iterationParameter.name) + (statement.iterationDeclaration as? PsiParameter)?.let { param -> + addLocalUsage(param, param.name) + } } super.visitForeachStatement(statement) checkImplicitLocalsPost(statement) diff --git a/src/main/kotlin/platform/mixin/util/LocalVariables.kt b/src/main/kotlin/platform/mixin/util/LocalVariables.kt index 9db991723..e7c621b55 100644 --- a/src/main/kotlin/platform/mixin/util/LocalVariables.kt +++ b/src/main/kotlin/platform/mixin/util/LocalVariables.kt @@ -55,6 +55,7 @@ import com.intellij.psi.PsiForeachStatement import com.intellij.psi.PsiLambdaExpression import com.intellij.psi.PsiMethod import com.intellij.psi.PsiModifier +import com.intellij.psi.PsiParameter import com.intellij.psi.PsiStatement import com.intellij.psi.PsiType import com.intellij.psi.PsiVariable @@ -299,7 +300,10 @@ object LocalVariables { // longs and doubles take two slots is PsiVariable -> if (element.isDoubleSlot) 2 else 1 // arrays have copy of array, length and index variables, iterables have the iterator variable - is PsiForeachStatement -> if (element.iterationParameter.type is PsiArrayType) 3 else 1 + is PsiForeachStatement -> { + val param = element.iterationDeclaration as? PsiParameter + if (param?.type is PsiArrayType) 3 else 1 + } else -> 0 } } From c67a0e85d9aec533290c7ae87927bf0630be0b86 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 26 Feb 2023 11:58:28 +0000 Subject: [PATCH 06/14] Fixup new project wizard for 2023.1 --- .../kotlin/creator/ProjectSetupFinalizerWizardStep.kt | 4 ++-- .../creator/buildsystem/BuildSystemPropertiesStep.kt | 8 ++++---- src/main/kotlin/creator/step/AbstractLatentStep.kt | 6 +++--- src/main/kotlin/creator/step/ModNameStep.kt | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt b/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt index a995e9539..f4aeaa9ed 100644 --- a/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt +++ b/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt @@ -22,8 +22,8 @@ import com.intellij.openapi.projectRoots.JavaSdk import com.intellij.openapi.projectRoots.JavaSdkVersion import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.ui.ValidationInfo -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.DialogValidation +import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.ui.JBColor import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.Placeholder @@ -57,7 +57,7 @@ class ProjectSetupFinalizerWizardStep(parent: NewProjectWizardStep) : AbstractNe if (finalizers.isNotEmpty()) { builder.row { cell(JPanel()) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .validation( DialogValidation { finalizers.mapFirstNotNull(ProjectSetupFinalizer::validate)?.let(::ValidationInfo) diff --git a/src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt b/src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt index a7a4c7dcd..4ac0bc9dd 100644 --- a/src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt +++ b/src/main/kotlin/creator/buildsystem/BuildSystemPropertiesStep.kt @@ -16,10 +16,10 @@ import com.intellij.ide.wizard.AbstractNewProjectWizardStep import com.intellij.ide.wizard.NewProjectWizardBaseData import com.intellij.ide.wizard.NewProjectWizardStep import com.intellij.openapi.observable.util.bindStorage -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.CHECK_ARTIFACT_ID import com.intellij.openapi.ui.validation.CHECK_GROUP_ID import com.intellij.openapi.ui.validation.CHECK_NON_EMPTY +import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.openapi.ui.validation.validationErrorIf import com.intellij.ui.dsl.builder.COLUMNS_MEDIUM import com.intellij.ui.dsl.builder.Panel @@ -61,21 +61,21 @@ class BuildSystemPropertiesStep(private val parent: ParentStep) : Ab textField() .bindText(groupIdProperty) .columns(COLUMNS_MEDIUM) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .textValidation(CHECK_NON_EMPTY, CHECK_GROUP_ID, nonExampleValidation) } row("Artifact ID:") { textField() .bindText(artifactIdProperty) .columns(COLUMNS_MEDIUM) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .textValidation(CHECK_NON_EMPTY, CHECK_ARTIFACT_ID) } row("Version:") { textField() .bindText(versionProperty) .columns(COLUMNS_MEDIUM) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .textValidation(versionValidation) } }.expanded = true diff --git a/src/main/kotlin/creator/step/AbstractLatentStep.kt b/src/main/kotlin/creator/step/AbstractLatentStep.kt index de677faf2..2d2a08dc1 100644 --- a/src/main/kotlin/creator/step/AbstractLatentStep.kt +++ b/src/main/kotlin/creator/step/AbstractLatentStep.kt @@ -21,8 +21,8 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.project.Project import com.intellij.openapi.ui.ValidationInfo -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.DialogValidation +import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.openapi.util.Disposer import com.intellij.ui.JBColor import com.intellij.ui.dsl.builder.Panel @@ -95,7 +95,7 @@ abstract class AbstractLatentStep(parent: NewProjectWizardStep) : AbstractNew placeholder.component = panel { row { val label = label("Unable to $description") - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .validation(DialogValidation { ValidationInfo("Unable to $description") }) label.component.foreground = JBColor.RED } @@ -141,7 +141,7 @@ abstract class AbstractLatentStep(parent: NewProjectWizardStep) : AbstractNew } } ) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .validation(DialogValidation { ValidationInfo("Haven't finished $description") }) } } diff --git a/src/main/kotlin/creator/step/ModNameStep.kt b/src/main/kotlin/creator/step/ModNameStep.kt index 6181b524f..98a947736 100644 --- a/src/main/kotlin/creator/step/ModNameStep.kt +++ b/src/main/kotlin/creator/step/ModNameStep.kt @@ -15,8 +15,8 @@ import com.intellij.ide.wizard.AbstractNewProjectWizardStep import com.intellij.ide.wizard.NewProjectWizardBaseData import com.intellij.ide.wizard.NewProjectWizardStep import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.CHECK_NON_EMPTY +import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.openapi.util.Key import com.intellij.ui.dsl.builder.COLUMNS_MEDIUM import com.intellij.ui.dsl.builder.Panel @@ -42,7 +42,7 @@ abstract class AbstractModNameStep(parent: NewProjectWizardStep) : AbstractNewPr textField() .bindText(nameProperty) .columns(COLUMNS_MEDIUM) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .textValidation(CHECK_NON_EMPTY) } } From 4cd8f589d16998df2cd0c3dcf9d0e6266b0b5839 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 1 Mar 2023 21:01:02 +0000 Subject: [PATCH 07/14] Update readme for 1.6.1 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 7d810b0fd..b49b2c120 100644 --- a/readme.md +++ b/readme.md @@ -35,7 +35,7 @@ Minecraft Development for IntelliJ -Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.6.0-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327) +Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.6.1-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327) ---------------------- From 705c9ee8b95c7255cdcc467d30e85dcae4909182 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 19 Mar 2023 15:28:17 +0100 Subject: [PATCH 08/14] Build against 231.8109 to fix some new errors --- gradle.properties | 4 ++-- .../ProjectSetupFinalizerWizardStep.kt | 17 ++++++---------- .../step/FixedAssetsNewProjectWizardStep.kt | 8 ++++---- src/main/kotlin/creator/step/OptionalSteps.kt | 10 +++++----- .../bungeecord/creator/gradle-steps.kt | 2 +- .../injectionPoint/LoadInjectionPoint.kt | 4 +--- .../platform/mixin/util/LocalVariables.kt | 2 +- .../inspection/SpongeInjectionInspection.kt | 20 +++++++++++++------ .../platform/velocity/creator/gradle-steps.kt | 2 +- src/main/kotlin/util/utils.kt | 2 +- 10 files changed, 36 insertions(+), 35 deletions(-) diff --git a/gradle.properties b/gradle.properties index 958a3412e..fa6a1d298 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,13 +11,13 @@ # suppress inspection "UnusedProperty" for whole file kotlin.code.style=official -ideaVersion = 231-EAP-SNAPSHOT +ideaVersion = 231.8109-EAP-CANDIDATE-SNAPSHOT ideaVersionName = 2023.1 coreVersion = 1.6.1 downloadIdeaSources = true -pluginTomlVersion = 231.4840.388 +pluginTomlVersion = 231.8109.1 # Silences a build-time warning because we are bundling our own kotlin library kotlin.stdlib.default.dependency = false diff --git a/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt b/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt index 71ddf6db5..f8a33a905 100644 --- a/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt +++ b/src/main/kotlin/creator/ProjectSetupFinalizerWizardStep.kt @@ -12,10 +12,8 @@ package com.demonwav.mcdev.creator import com.demonwav.mcdev.creator.ProjectSetupFinalizer.Factory import com.demonwav.mcdev.util.mapFirstNotNull -import com.demonwav.mcdev.util.toTypedArray import com.intellij.ide.wizard.AbstractNewProjectWizardStep import com.intellij.ide.wizard.NewProjectWizardStep -import com.intellij.ide.wizard.stepSequence import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.observable.properties.GraphProperty import com.intellij.openapi.project.Project @@ -45,16 +43,11 @@ class ProjectSetupFinalizerWizardStep(parent: NewProjectWizardStep) : AbstractNe } result } - private val step by lazy { - if (finalizers.isEmpty()) { - null - } else { - stepSequence(finalizers[0], *finalizers.asSequence().drop(1).toTypedArray()) - } - } override fun setupUI(builder: Panel) { - step?.setupUI(builder) + for (step in finalizers) { + step.setupUI(builder) + } if (finalizers.isNotEmpty()) { builder.row { cell(JPanel()) @@ -69,7 +62,9 @@ class ProjectSetupFinalizerWizardStep(parent: NewProjectWizardStep) : AbstractNe } override fun setupProject(project: Project) { - step?.setupProject(project) + for (step in finalizers) { + step.setupProject(project) + } } } diff --git a/src/main/kotlin/creator/step/FixedAssetsNewProjectWizardStep.kt b/src/main/kotlin/creator/step/FixedAssetsNewProjectWizardStep.kt index ca8fc6231..b5b7a002e 100644 --- a/src/main/kotlin/creator/step/FixedAssetsNewProjectWizardStep.kt +++ b/src/main/kotlin/creator/step/FixedAssetsNewProjectWizardStep.kt @@ -111,7 +111,7 @@ abstract class FixedAssetsNewProjectWizardStep(parent: NewProjectWizardStep) : A throw IOException("Unable to process template", e) } - val pathStr = "$outputDirectory/${asset.targetFileName}" + val pathStr = "$outputDirectory/${asset.relativePath}" val path = Path.of(pathStr) path.parent?.let(NioFiles::createDirectories) Files.writeString(path, code) @@ -122,7 +122,7 @@ abstract class FixedAssetsNewProjectWizardStep(parent: NewProjectWizardStep) : A private fun generateFile(asset: GeneratorResourceFile): VirtualFile? { val content = asset.resource.openStream().use { it.readAllBytes() } - val pathStr = "$outputDirectory/${asset.targetFileName}" + val pathStr = "$outputDirectory/${asset.relativePath}" val path = Path.of(pathStr) path.parent?.let(NioFiles::createDirectories) Files.write(path, content) @@ -131,7 +131,7 @@ abstract class FixedAssetsNewProjectWizardStep(parent: NewProjectWizardStep) : A } private fun generateFile(asset: GeneratorEmptyDirectory): VirtualFile? { - val pathStr = "$outputDirectory/${asset.targetFileName}" + val pathStr = "$outputDirectory/${asset.relativePath}" val path = Path.of(pathStr) NioFiles.createDirectories(path) return VfsUtil.findFile(path, true) @@ -169,7 +169,7 @@ sealed class FixedGeneratorAsset { } data class GeneratorAssetDelegate(val delegate: GeneratorAsset) : FixedGeneratorAsset() { - override val targetFileName get() = delegate.targetFileName + override val targetFileName get() = delegate.relativePath } class GeneratorFile( diff --git a/src/main/kotlin/creator/step/OptionalSteps.kt b/src/main/kotlin/creator/step/OptionalSteps.kt index b9d75e9a8..91398b1d2 100644 --- a/src/main/kotlin/creator/step/OptionalSteps.kt +++ b/src/main/kotlin/creator/step/OptionalSteps.kt @@ -56,22 +56,22 @@ abstract class AbstractOptionalStringBasedOnProjectNameStep( value = suggestValue() } valueProperty.updateWhenChanged(formatProperty, ::suggestValue) - valueProperty.updateWhenChanged(baseData.nameProperty, ::suggestValue) + valueProperty.updateWhenChanged(baseData!!.nameProperty, ::suggestValue) formatProperty.updateWhenChanged(valueProperty, ::suggestFormat) } - private fun suggestValue() = format.replace(PROJECT_NAME_PLACEHOLDER, baseData.name) + private fun suggestValue() = format.replace(PROJECT_NAME_PLACEHOLDER, baseData!!.name) private fun suggestFormat(): String { - val index = value.indexOf(baseData.name) + val index = value.indexOf(baseData!!.name) if (index == -1) { return value } - if (value.indexOf(baseData.name, startIndex = index + baseData.name.length) != -1) { + if (value.indexOf(baseData!!.name, startIndex = index + baseData!!.name.length) != -1) { // don't change format if there are multiple instances of the project name return format } - return value.replace(baseData.name, PROJECT_NAME_PLACEHOLDER) + return value.replace(baseData!!.name, PROJECT_NAME_PLACEHOLDER) } companion object { diff --git a/src/main/kotlin/platform/bungeecord/creator/gradle-steps.kt b/src/main/kotlin/platform/bungeecord/creator/gradle-steps.kt index e63ea760a..4161e9d44 100644 --- a/src/main/kotlin/platform/bungeecord/creator/gradle-steps.kt +++ b/src/main/kotlin/platform/bungeecord/creator/gradle-steps.kt @@ -46,7 +46,7 @@ class BungeeGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningA override val description = "Creating Gradle files" override fun setupAssets(project: Project) { - val projectName = baseData.name + val projectName = baseData!!.name val buildSystemProps = findStep>() assets.addTemplateProperties( "PROJECT_NAME" to projectName, diff --git a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt index 8f5850ae8..b1194e0b5 100644 --- a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt +++ b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt @@ -180,9 +180,7 @@ abstract class AbstractLoadInjectionPoint(private val store: Boolean) : Injectio override fun visitForeachStatement(statement: PsiForeachStatement) { checkImplicitLocalsPre(statement) if (store) { - (statement.iterationDeclaration as? PsiParameter)?.let { param -> - addLocalUsage(param, param.name) - } + addLocalUsage(statement.iterationParameter, statement.iterationParameter.name) } super.visitForeachStatement(statement) checkImplicitLocalsPost(statement) diff --git a/src/main/kotlin/platform/mixin/util/LocalVariables.kt b/src/main/kotlin/platform/mixin/util/LocalVariables.kt index c641b340e..7b3a05687 100644 --- a/src/main/kotlin/platform/mixin/util/LocalVariables.kt +++ b/src/main/kotlin/platform/mixin/util/LocalVariables.kt @@ -303,7 +303,7 @@ object LocalVariables { is PsiVariable -> if (element.isDoubleSlot) 2 else 1 // arrays have copy of array, length and index variables, iterables have the iterator variable is PsiForeachStatement -> { - val param = element.iterationDeclaration as? PsiParameter + val param = element.iterationParameter as? PsiParameter if (param?.type is PsiArrayType) 3 else 1 } else -> 0 diff --git a/src/main/kotlin/platform/sponge/inspection/SpongeInjectionInspection.kt b/src/main/kotlin/platform/sponge/inspection/SpongeInjectionInspection.kt index 16d327785..0c1ebd745 100644 --- a/src/main/kotlin/platform/sponge/inspection/SpongeInjectionInspection.kt +++ b/src/main/kotlin/platform/sponge/inspection/SpongeInjectionInspection.kt @@ -185,12 +185,20 @@ class SpongeInjectionInspection : AbstractBaseJavaLocalInspectionTool() { } } - holder.registerProblem( - assetPathAttributeValue, - "Asset '$assetPath' does not exist.", - ProblemHighlightType.GENERIC_ERROR, - fix, - ) + if (fix == null) { + holder.registerProblem( + assetPathAttributeValue, + "Asset '$assetPath' does not exist.", + ProblemHighlightType.GENERIC_ERROR, + ) + } else { + holder.registerProblem( + assetPathAttributeValue, + "Asset '$assetPath' does not exist.", + ProblemHighlightType.GENERIC_ERROR, + fix, + ) + } } } } diff --git a/src/main/kotlin/platform/velocity/creator/gradle-steps.kt b/src/main/kotlin/platform/velocity/creator/gradle-steps.kt index 02ce8cab8..75eb9baed 100644 --- a/src/main/kotlin/platform/velocity/creator/gradle-steps.kt +++ b/src/main/kotlin/platform/velocity/creator/gradle-steps.kt @@ -53,7 +53,7 @@ class VelocityGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunnin override val description = "Creating Gradle files" override fun setupAssets(project: Project) { - val projectName = baseData.name + val projectName = baseData!!.name val buildSystemProps = findStep>() val javaVersion = findStep().preferredJdk.ordinal val mainClass = data.getUserData(MainClassStep.KEY) ?: return diff --git a/src/main/kotlin/util/utils.kt b/src/main/kotlin/util/utils.kt index 4175668cc..ca69c30bc 100644 --- a/src/main/kotlin/util/utils.kt +++ b/src/main/kotlin/util/utils.kt @@ -107,7 +107,7 @@ inline fun PsiFile.applyWriteAction(crossinline func: PsiFile.() -> T return result } -inline fun runReadActionAsync(crossinline runnable: () -> T): Promise { +fun runReadActionAsync(runnable: () -> T): Promise { return runAsync { runReadAction(runnable) } From 44661fb8f7b5efc438f462d3be2eb016aa1c3c7f Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 19 Mar 2023 16:02:14 +0100 Subject: [PATCH 09/14] Replace deprecated PsiType constants usages --- settings.gradle.kts | 2 + src/main/kotlin/insight/ColorUtil.kt | 5 ++- .../mixin/action/GenerateAccessorHandler.kt | 4 +- .../inspection/ConfigValueInspection.kt | 6 ++- .../folding/AccessorMixinFoldingBuilder.kt | 4 +- .../mixin/handlers/AccessorHandler.kt | 4 +- .../mixin/handlers/InjectAnnotationHandler.kt | 6 +-- .../mixin/handlers/ModifyArgsHandler.kt | 4 +- .../mixin/handlers/ModifyConstantHandler.kt | 9 +++-- .../mixin/handlers/RedirectInjectorHandler.kt | 13 ++++--- .../ConstantStringMethodInjectionPoint.kt | 3 +- .../injectionPoint/LoadInjectionPoint.kt | 16 ++++---- .../injectionPoint/ReturnInjectionPoint.kt | 6 +-- .../inspection/injector/ParameterGroup.kt | 9 ++++- .../mixin/reference/MixinSelectors.kt | 4 +- .../platform/mixin/util/LocalVariables.kt | 9 +++-- .../reference/SpongeReferenceContributor.kt | 4 +- src/main/kotlin/util/bytecode-utils.kt | 39 ++++++++++--------- src/main/kotlin/util/code-gen.kt | 4 +- 19 files changed, 84 insertions(+), 67 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 49f2bb99d..cc3249995 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,3 +13,5 @@ rootProject.name = "MinecraftDev" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include("mixin-test-data") + +startParameter.warningMode = WarningMode.All diff --git a/src/main/kotlin/insight/ColorUtil.kt b/src/main/kotlin/insight/ColorUtil.kt index f598d6e84..8cd3cbbff 100644 --- a/src/main/kotlin/insight/ColorUtil.kt +++ b/src/main/kotlin/insight/ColorUtil.kt @@ -18,6 +18,7 @@ import com.demonwav.mcdev.util.runWriteAction import com.intellij.openapi.module.ModuleUtilCore import com.intellij.psi.JVMElementFactories import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import java.awt.Color import java.util.Locale @@ -142,10 +143,10 @@ private fun findColorFromCallExpression( return when { // Single Integer Argument - types.size == 1 && types[0] == PsiType.INT -> + types.size == 1 && types[0] == PsiTypes.intType() -> colorFromSingleArgument(arguments[0])?.let { it to arguments[0] } // Triple Integer Argument - types.size == 3 && types.all { it == PsiType.INT } -> + types.size == 3 && types.all { it == PsiTypes.intType() } -> colorFromThreeArguments(arguments)?.let { it to methodExpression } vectorClasses != null && types.size == 1 -> { val scope = GlobalSearchScope.allScope(project) diff --git a/src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt b/src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt index 885cc8367..caf7d04d6 100644 --- a/src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt +++ b/src/main/kotlin/platform/mixin/action/GenerateAccessorHandler.kt @@ -56,7 +56,7 @@ import com.intellij.psi.PsiField import com.intellij.psi.PsiFile import com.intellij.psi.PsiMethod import com.intellij.psi.PsiModifier -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import com.intellij.ui.components.JBCheckBox import com.intellij.uiDesigner.core.GridConstraints @@ -397,7 +397,7 @@ class GenerateAccessorHandler : GenerateMembersHandlerBase("Generate Accessor/In val accessors = arrayListOf() if (generateGetter) { - val prefix = if (target.type == PsiType.BOOLEAN) "is" else "get" + val prefix = if (target.type == PsiTypes.booleanType()) "is" else "get" val method = factory.createMethodFromText( """ @${MixinConstants.Annotations.ACCESSOR} diff --git a/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt b/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt index 0f49c25d3..95f1fd379 100644 --- a/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt +++ b/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt @@ -36,6 +36,7 @@ import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiField import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.util.PsiUtil class ConfigValueInspection : MixinConfigInspection() { @@ -56,8 +57,9 @@ class ConfigValueInspection : MixinConfigInspection() { private fun checkValue(type: PsiType, value: JsonValue) { val valid = when (type) { - PsiType.BOOLEAN -> value is JsonBooleanLiteral - PsiType.BYTE, PsiType.DOUBLE, PsiType.FLOAT, PsiType.INT, PsiType.LONG, PsiType.SHORT -> + PsiTypes.booleanType() -> value is JsonBooleanLiteral + PsiTypes.byteType(), PsiTypes.doubleType(), PsiTypes.floatType(), PsiTypes.intType(), + PsiTypes.longType(), PsiTypes.shortType() -> value is JsonNumberLiteral is PsiArrayType -> checkArray(type.componentType, value) else -> checkObject(type, value) diff --git a/src/main/kotlin/platform/mixin/folding/AccessorMixinFoldingBuilder.kt b/src/main/kotlin/platform/mixin/folding/AccessorMixinFoldingBuilder.kt index 7f0bc531e..3cf427fd3 100644 --- a/src/main/kotlin/platform/mixin/folding/AccessorMixinFoldingBuilder.kt +++ b/src/main/kotlin/platform/mixin/folding/AccessorMixinFoldingBuilder.kt @@ -29,8 +29,8 @@ import com.intellij.psi.PsiIdentifier import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiMethodCallExpression import com.intellij.psi.PsiParenthesizedExpression -import com.intellij.psi.PsiType import com.intellij.psi.PsiTypeCastExpression +import com.intellij.psi.PsiTypes import com.intellij.psi.util.elementType import com.intellij.psi.util.parentOfType @@ -83,7 +83,7 @@ class AccessorMixinFoldingBuilder : CustomFoldingBuilder() { if (method.hasAnnotation(ACCESSOR)) { val name = AccessorHandler.getInstance()?.findAccessorTargetForReference(method)?.element?.name ?: return null - return if (method.returnType == PsiType.VOID) { + return if (method.returnType == PsiTypes.voidType()) { "$name = " } else { name diff --git a/src/main/kotlin/platform/mixin/handlers/AccessorHandler.kt b/src/main/kotlin/platform/mixin/handlers/AccessorHandler.kt index 4a7c1dc14..ae4a4442d 100644 --- a/src/main/kotlin/platform/mixin/handlers/AccessorHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/AccessorHandler.kt @@ -23,7 +23,7 @@ import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiField import com.intellij.psi.PsiMember import com.intellij.psi.PsiMethod -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.SmartPsiElementPointer import com.intellij.psi.util.createSmartPointer import com.intellij.psi.util.parentOfType @@ -47,7 +47,7 @@ class AccessorHandler : MixinMemberAnnotationHandler { if (!method.hasParameters() && accessorInfo.type.allowGetters) { it.desc == method.returnType?.descriptor } else if ( - PsiType.VOID == method.returnType && method.parameterList.parametersCount == 1 && + PsiTypes.voidType() == method.returnType && method.parameterList.parametersCount == 1 && accessorInfo.type.allowSetters ) { it.desc == method.parameterList.parameters[0].type.descriptor diff --git a/src/main/kotlin/platform/mixin/handlers/InjectAnnotationHandler.kt b/src/main/kotlin/platform/mixin/handlers/InjectAnnotationHandler.kt index 11b5e7904..41f6f2ea6 100644 --- a/src/main/kotlin/platform/mixin/handlers/InjectAnnotationHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/InjectAnnotationHandler.kt @@ -25,7 +25,7 @@ import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiMethod import com.intellij.psi.PsiQualifiedReference -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.util.parentOfType import org.objectweb.asm.Opcodes import org.objectweb.asm.Type @@ -55,7 +55,7 @@ class InjectAnnotationHandler : InjectorAnnotationHandler() { result.add( ParameterGroup( listOf( - if (returnType == PsiType.VOID) { + if (returnType == PsiTypes.voidType()) { Parameter("ci", callbackInfoType(annotation.project)) } else { Parameter( @@ -117,7 +117,7 @@ class InjectAnnotationHandler : InjectorAnnotationHandler() { } } - return listOf(MethodSignature(result, PsiType.VOID)) + return listOf(MethodSignature(result, PsiTypes.voidType())) } override val allowCoerce = true diff --git a/src/main/kotlin/platform/mixin/handlers/ModifyArgsHandler.kt b/src/main/kotlin/platform/mixin/handlers/ModifyArgsHandler.kt index 8f814c93f..8fbb20eb8 100644 --- a/src/main/kotlin/platform/mixin/handlers/ModifyArgsHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/ModifyArgsHandler.kt @@ -16,7 +16,7 @@ import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Classes.ARGS import com.demonwav.mcdev.util.Parameter import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiAnnotation -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodInsnNode @@ -44,7 +44,7 @@ class ModifyArgsHandler : InjectorAnnotationHandler() { isVarargs = true, ), ), - PsiType.VOID, + PsiTypes.voidType(), ), ) } diff --git a/src/main/kotlin/platform/mixin/handlers/ModifyConstantHandler.kt b/src/main/kotlin/platform/mixin/handlers/ModifyConstantHandler.kt index d3be8a35f..33b947311 100644 --- a/src/main/kotlin/platform/mixin/handlers/ModifyConstantHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/ModifyConstantHandler.kt @@ -30,6 +30,7 @@ import com.intellij.psi.PsiEnumConstant import com.intellij.psi.PsiManager import com.intellij.psi.PsiReferenceExpression import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import org.objectweb.asm.Opcodes import org.objectweb.asm.Type @@ -136,10 +137,10 @@ class ModifyConstantHandler : InjectorAnnotationHandler() { return constantInfos.asSequence().map { when (it.constantInfo.constant) { null -> PsiType.getJavaLangObject(psiManager, annotation.resolveScope) - is Int -> PsiType.INT - is Float -> PsiType.FLOAT - is Long -> PsiType.LONG - is Double -> PsiType.DOUBLE + is Int -> PsiTypes.intType() + is Float -> PsiTypes.floatType() + is Long -> PsiTypes.longType() + is Double -> PsiTypes.doubleType() is String -> PsiType.getJavaLangString(psiManager, annotation.resolveScope) is Type -> PsiType.getJavaLangClass(psiManager, annotation.resolveScope) else -> throw IllegalStateException("Unknown constant type: ${it.constantInfo.constant.javaClass.name}") diff --git a/src/main/kotlin/platform/mixin/handlers/RedirectInjectorHandler.kt b/src/main/kotlin/platform/mixin/handlers/RedirectInjectorHandler.kt index d43c06905..0d88d45fe 100644 --- a/src/main/kotlin/platform/mixin/handlers/RedirectInjectorHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/RedirectInjectorHandler.kt @@ -28,6 +28,7 @@ import com.intellij.psi.PsiArrayType import com.intellij.psi.PsiElementFactory import com.intellij.psi.PsiManager import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import org.objectweb.asm.Opcodes import org.objectweb.asm.Type import org.objectweb.asm.tree.AbstractInsnNode @@ -186,7 +187,7 @@ class RedirectInjectorHandler : InjectorAnnotationHandler() { return listOf( MethodSignature( listOf(ParameterGroup(parameters)), - PsiType.VOID, + PsiTypes.voidType(), ), ) } @@ -280,7 +281,7 @@ class RedirectInjectorHandler : InjectorAnnotationHandler() { ), ), ), - PsiType.INT, + PsiTypes.intType(), ), ) } @@ -312,7 +313,7 @@ class RedirectInjectorHandler : InjectorAnnotationHandler() { ParameterGroup( listOf( Parameter("array", psiArrayType), - Parameter("index", PsiType.INT), + Parameter("index", PsiTypes.intType()), ), ), ), @@ -348,12 +349,12 @@ class RedirectInjectorHandler : InjectorAnnotationHandler() { ParameterGroup( listOf( Parameter("array", psiArrayType), - Parameter("index", PsiType.INT), + Parameter("index", PsiTypes.intType()), Parameter("value", psiArrayType.componentType), ), ), ), - PsiType.VOID, + PsiTypes.voidType(), ), ) } @@ -418,7 +419,7 @@ class RedirectInjectorHandler : InjectorAnnotationHandler() { ), ) return listOf( - MethodSignature(listOf(parameters), PsiType.BOOLEAN), + MethodSignature(listOf(parameters), PsiTypes.booleanType()), MethodSignature(listOf(parameters), classType), ) } diff --git a/src/main/kotlin/platform/mixin/handlers/injectionPoint/ConstantStringMethodInjectionPoint.kt b/src/main/kotlin/platform/mixin/handlers/injectionPoint/ConstantStringMethodInjectionPoint.kt index 6314dee48..48a9a5046 100644 --- a/src/main/kotlin/platform/mixin/handlers/injectionPoint/ConstantStringMethodInjectionPoint.kt +++ b/src/main/kotlin/platform/mixin/handlers/injectionPoint/ConstantStringMethodInjectionPoint.kt @@ -21,6 +21,7 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiMethod import com.intellij.psi.PsiMethodCallExpression import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode @@ -54,7 +55,7 @@ class ConstantStringMethodInjectionPoint : AbstractMethodInjectionPoint() { ) : NavigationVisitor() { private fun isConstantStringMethodCall(expression: PsiMethodCallExpression): Boolean { // Must return void - if (expression.type != PsiType.VOID) { + if (expression.type != PsiTypes.voidType()) { return false } diff --git a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt index b1194e0b5..d6d15e6ae 100644 --- a/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt +++ b/src/main/kotlin/platform/mixin/handlers/injectionPoint/LoadInjectionPoint.kt @@ -32,7 +32,7 @@ import com.intellij.psi.PsiParameter import com.intellij.psi.PsiPrimitiveType import com.intellij.psi.PsiReferenceExpression import com.intellij.psi.PsiThisExpression -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.PsiUnaryExpression import com.intellij.psi.PsiVariable import com.intellij.psi.util.PsiUtil @@ -140,10 +140,10 @@ abstract class AbstractLoadInjectionPoint(private val store: Boolean) : Injectio val resolved = expression.resolve() as? PsiVariable ?: return val type = resolved.type if (type is PsiPrimitiveType && - type != PsiType.FLOAT && - type != PsiType.DOUBLE && - type != PsiType.LONG && - type != PsiType.BOOLEAN + type != PsiTypes.floatType() && + type != PsiTypes.doubleType() && + type != PsiTypes.longType() && + type != PsiTypes.booleanType() ) { // ModifyVariable currently cannot handle iinc val parentExpr = PsiUtil.skipParenthesizedExprUp(expression.parent) @@ -273,9 +273,9 @@ abstract class AbstractLoadInjectionPoint(private val store: Boolean) : Injectio var opcode = when (info.type) { null -> null !is PsiPrimitiveType -> Opcodes.ALOAD - PsiType.LONG -> Opcodes.LLOAD - PsiType.FLOAT -> Opcodes.FLOAD - PsiType.DOUBLE -> Opcodes.DLOAD + PsiTypes.longType() -> Opcodes.LLOAD + PsiTypes.floatType() -> Opcodes.FLOAD + PsiTypes.doubleType() -> Opcodes.DLOAD else -> Opcodes.ILOAD } if (store && opcode != null) { diff --git a/src/main/kotlin/platform/mixin/handlers/injectionPoint/ReturnInjectionPoint.kt b/src/main/kotlin/platform/mixin/handlers/injectionPoint/ReturnInjectionPoint.kt index a39df9b3a..9869560ca 100644 --- a/src/main/kotlin/platform/mixin/handlers/injectionPoint/ReturnInjectionPoint.kt +++ b/src/main/kotlin/platform/mixin/handlers/injectionPoint/ReturnInjectionPoint.kt @@ -25,7 +25,7 @@ import com.intellij.psi.PsiLambdaExpression import com.intellij.psi.PsiMethod import com.intellij.psi.PsiMethodReferenceExpression import com.intellij.psi.PsiReturnStatement -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.controlFlow.ControlFlowUtil import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.AbstractInsnNode @@ -85,13 +85,13 @@ abstract class AbstractReturnInjectionPoint(private val tailOnly: Boolean) : Inj return } val returnType = LambdaUtil.getFunctionalInterfaceReturnType(executableElement) ?: return - if (returnType != PsiType.VOID) { + if (returnType != PsiTypes.voidType()) { return } body } is PsiMethod -> { - if (executableElement.returnType != PsiType.VOID && !executableElement.isConstructor) { + if (executableElement.returnType != PsiTypes.voidType() && !executableElement.isConstructor) { return } executableElement.body ?: return diff --git a/src/main/kotlin/platform/mixin/inspection/injector/ParameterGroup.kt b/src/main/kotlin/platform/mixin/inspection/injector/ParameterGroup.kt index 3eb295aa0..a0032411e 100644 --- a/src/main/kotlin/platform/mixin/inspection/injector/ParameterGroup.kt +++ b/src/main/kotlin/platform/mixin/inspection/injector/ParameterGroup.kt @@ -17,6 +17,7 @@ import com.demonwav.mcdev.util.normalize import com.intellij.psi.PsiParameter import com.intellij.psi.PsiPrimitiveType import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes data class ParameterGroup( val parameters: List, @@ -55,7 +56,13 @@ data class ParameterGroup( } companion object { - private val INT_TYPES = setOf(PsiType.INT, PsiType.SHORT, PsiType.CHAR, PsiType.BYTE, PsiType.BOOLEAN) + private val INT_TYPES = setOf( + PsiTypes.intType(), + PsiTypes.shortType(), + PsiTypes.charType(), + PsiTypes.byteType(), + PsiTypes.booleanType() + ) private fun matchParameter(expectedType: PsiType, parameter: PsiParameter, allowCoerce: Boolean): Boolean { val normalizedExpected = expectedType.normalize() diff --git a/src/main/kotlin/platform/mixin/reference/MixinSelectors.kt b/src/main/kotlin/platform/mixin/reference/MixinSelectors.kt index 67dc30bfd..92d6f2e43 100644 --- a/src/main/kotlin/platform/mixin/reference/MixinSelectors.kt +++ b/src/main/kotlin/platform/mixin/reference/MixinSelectors.kt @@ -48,7 +48,7 @@ import com.intellij.psi.PsiField import com.intellij.psi.PsiMember import com.intellij.psi.PsiMethod import com.intellij.psi.PsiNameValuePair -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.searches.AnnotatedMembersSearch import com.intellij.psi.util.InheritanceUtil @@ -563,7 +563,7 @@ class DescSelectorParser : DynamicSelectorParser("Desc", "mixin:Desc") { val name = descAnnotation.findAttributeValue("value")?.constantStringValue ?: return null val argTypes = descAnnotation.findAttributeValue("args")?.resolveTypeArray() ?: emptyList() - val ret = descAnnotation.findAttributeValue("ret")?.resolveType() ?: PsiType.VOID + val ret = descAnnotation.findAttributeValue("ret")?.resolveType() ?: PsiTypes.voidType() val desc = Type.getMethodDescriptor( Type.getType(ret.descriptor), *argTypes.mapToArray { Type.getType(it.descriptor) }, diff --git a/src/main/kotlin/platform/mixin/util/LocalVariables.kt b/src/main/kotlin/platform/mixin/util/LocalVariables.kt index 7b3a05687..ccc2ab507 100644 --- a/src/main/kotlin/platform/mixin/util/LocalVariables.kt +++ b/src/main/kotlin/platform/mixin/util/LocalVariables.kt @@ -58,6 +58,7 @@ import com.intellij.psi.PsiModifier import com.intellij.psi.PsiParameter import com.intellij.psi.PsiStatement import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.PsiVariable import com.intellij.psi.controlFlow.ControlFlow import com.intellij.psi.controlFlow.ControlFlowFactory @@ -212,7 +213,7 @@ object LocalVariables { val localsHere = this.locals[offset] ?: arrayOfNulls(variable.index + 1).also { this.locals[offset] = it } localsHere[variable.index] = variable - if (variable.type == PsiType.LONG || variable.type == PsiType.DOUBLE) { + if (variable.type == PsiTypes.longType() || variable.type == PsiTypes.doubleType()) { if (variable.index + 1 < localsHere.size) { localsHere[variable.index + 1] = null } @@ -311,7 +312,7 @@ object LocalVariables { } private val PsiVariable.isDoubleSlot: Boolean - get() = type == PsiType.DOUBLE || type == PsiType.LONG + get() = type == PsiTypes.doubleType() || type == PsiTypes.longType() private fun PsiForeachStatement.getExtraLocals(): List { val localIndex = getUserData(LOCAL_INDEX_KEY)!! @@ -330,7 +331,7 @@ object LocalVariables { // length SourceLocalVariable( "var${localIndex + 1}", - PsiType.INT, + PsiTypes.intType(), localIndex + 1, implicitStoreCountBefore = 1, implicitLoadCountAfter = 1, @@ -338,7 +339,7 @@ object LocalVariables { // index SourceLocalVariable( "var${localIndex + 2}", - PsiType.INT, + PsiTypes.intType(), localIndex + 2, implicitStoreCountBefore = 1, implicitLoadCountBefore = 1, diff --git a/src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt b/src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt index 032cc4b31..d3921b859 100644 --- a/src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt +++ b/src/main/kotlin/platform/sponge/reference/SpongeReferenceContributor.kt @@ -26,7 +26,7 @@ import com.intellij.psi.PsiReferenceContributor import com.intellij.psi.PsiReferenceProvider import com.intellij.psi.PsiReferenceRegistrar import com.intellij.psi.PsiSubstitutor -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.filters.ElementFilter import com.intellij.psi.filters.position.FilterPattern import com.intellij.util.ArrayUtil @@ -96,6 +96,6 @@ private object GetterAnnotationFilter : ElementFilter { PsiLanguageInjectionHost::class.java.isAssignableFrom(hintClass) } -private fun isValidCandidate(method: PsiMethod): Boolean = method.returnType != PsiType.VOID && +private fun isValidCandidate(method: PsiMethod): Boolean = method.returnType != PsiTypes.voidType() && !method.isConstructor && method.hasModifierProperty(PsiModifier.PUBLIC) && !method.hasParameters() && method.containingClass?.qualifiedName != CommonClassNames.JAVA_LANG_OBJECT diff --git a/src/main/kotlin/util/bytecode-utils.kt b/src/main/kotlin/util/bytecode-utils.kt index 5f9f0c214..911fc8f7d 100644 --- a/src/main/kotlin/util/bytecode-utils.kt +++ b/src/main/kotlin/util/bytecode-utils.kt @@ -20,6 +20,7 @@ import com.intellij.psi.PsiMethod import com.intellij.psi.PsiModifier import com.intellij.psi.PsiPrimitiveType import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.util.TypeConversionUtil import org.jetbrains.plugins.groovy.lang.resolve.processors.inference.type @@ -30,29 +31,29 @@ private const val INTERNAL_CONSTRUCTOR_NAME = "" val PsiPrimitiveType.internalName: Char get() = when (this) { - PsiType.BYTE -> 'B' - PsiType.CHAR -> 'C' - PsiType.DOUBLE -> 'D' - PsiType.FLOAT -> 'F' - PsiType.INT -> 'I' - PsiType.LONG -> 'J' - PsiType.SHORT -> 'S' - PsiType.BOOLEAN -> 'Z' - PsiType.VOID -> 'V' + PsiTypes.byteType() -> 'B' + PsiTypes.charType() -> 'C' + PsiTypes.doubleType() -> 'D' + PsiTypes.floatType() -> 'F' + PsiTypes.intType() -> 'I' + PsiTypes.longType() -> 'J' + PsiTypes.shortType() -> 'S' + PsiTypes.booleanType() -> 'Z' + PsiTypes.voidType() -> 'V' else -> throw IllegalArgumentException("Unsupported primitive type: $this") } fun getPrimitiveType(internalName: Char): PsiPrimitiveType? { return when (internalName) { - 'B' -> PsiType.BYTE - 'C' -> PsiType.CHAR - 'D' -> PsiType.DOUBLE - 'F' -> PsiType.FLOAT - 'I' -> PsiType.INT - 'J' -> PsiType.LONG - 'S' -> PsiType.SHORT - 'Z' -> PsiType.BOOLEAN - 'V' -> PsiType.VOID + 'B' -> PsiTypes.byteType() + 'C' -> PsiTypes.charType() + 'D' -> PsiTypes.doubleType() + 'F' -> PsiTypes.floatType() + 'I' -> PsiTypes.intType() + 'J' -> PsiTypes.longType() + 'S' -> PsiTypes.shortType() + 'Z' -> PsiTypes.booleanType() + 'V' -> PsiTypes.voidType() else -> null } } @@ -162,7 +163,7 @@ private fun PsiMethod.appendDescriptor(builder: StringBuilder): StringBuilder { parameter.type.appendDescriptor(builder) } builder.append(')') - return (returnType ?: PsiType.VOID).appendDescriptor(builder) + return (returnType ?: PsiTypes.voidType()).appendDescriptor(builder) } // Field diff --git a/src/main/kotlin/util/code-gen.kt b/src/main/kotlin/util/code-gen.kt index 87d04ff5e..41c035853 100644 --- a/src/main/kotlin/util/code-gen.kt +++ b/src/main/kotlin/util/code-gen.kt @@ -19,11 +19,11 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiClassType import com.intellij.psi.PsiMember import com.intellij.psi.PsiMethod -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope fun createVoidMethodWithParameterType(project: Project, name: String, paramType: PsiClass): PsiMethod? { - val newMethod = JavaPsiFacade.getElementFactory(project).createMethod(name, PsiType.VOID) + val newMethod = JavaPsiFacade.getElementFactory(project).createMethod(name, PsiTypes.voidType()) val list = newMethod.parameterList val qName = paramType.qualifiedName ?: return null From fcb98cd7ef3fd09ef111f96bf394cda4d39bc27d Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 28 Mar 2023 21:54:21 +0100 Subject: [PATCH 10/14] Update to 2023.1 release --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 469919561..0e04f09c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ # suppress inspection "UnusedProperty" for whole file kotlin.code.style=official -ideaVersion = 231.8109-EAP-CANDIDATE-SNAPSHOT +ideaVersion = 2023.1 ideaVersionName = 2023.1 coreVersion = 1.6.2 From cc89308a11e50e40eca09bbc427ec4152231dd45 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sat, 29 Apr 2023 22:21:57 +0200 Subject: [PATCH 11/14] Remove unused import --- src/main/kotlin/platform/bukkit/creator/bukkit-platforms.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/platform/bukkit/creator/bukkit-platforms.kt b/src/main/kotlin/platform/bukkit/creator/bukkit-platforms.kt index 53fc29c57..cd1ff63a8 100644 --- a/src/main/kotlin/platform/bukkit/creator/bukkit-platforms.kt +++ b/src/main/kotlin/platform/bukkit/creator/bukkit-platforms.kt @@ -17,7 +17,6 @@ import com.demonwav.mcdev.util.MinecraftTemplates import com.demonwav.mcdev.util.MinecraftVersions import com.demonwav.mcdev.util.SemanticVersion import com.intellij.openapi.observable.util.bindBooleanStorage -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindSelected From 8e505c8cad9dfbf3a460ae2d27cffb1d38733fe9 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 16 Jul 2023 23:35:45 +0200 Subject: [PATCH 12/14] Fix deprecated symbol usage --- src/main/kotlin/creator/step/ModIdStep.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/creator/step/ModIdStep.kt b/src/main/kotlin/creator/step/ModIdStep.kt index d40819de1..31bdedc7d 100644 --- a/src/main/kotlin/creator/step/ModIdStep.kt +++ b/src/main/kotlin/creator/step/ModIdStep.kt @@ -25,8 +25,8 @@ import com.intellij.ide.wizard.AbstractNewProjectWizardStep import com.intellij.ide.wizard.NewProjectWizardBaseData import com.intellij.ide.wizard.NewProjectWizardStep import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.validation.AFTER_GRAPH_PROPAGATION import com.intellij.openapi.ui.validation.CHECK_NON_EMPTY +import com.intellij.openapi.ui.validation.WHEN_GRAPH_PROPAGATION_FINISHED import com.intellij.openapi.ui.validation.and import com.intellij.openapi.ui.validation.validationErrorIf import com.intellij.openapi.util.Key @@ -75,7 +75,7 @@ abstract class AbstractModIdStep( textField() .bindText(idProperty) .columns(COLUMNS_MEDIUM) - .validationRequestor(AFTER_GRAPH_PROPAGATION(propertyGraph)) + .validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph)) .textValidation(CHECK_NON_EMPTY and idValidation) } } From 5ce632492d722745ef3e94c87bca9d80c6fd7035 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 13 Aug 2023 20:45:44 +0200 Subject: [PATCH 13/14] Revert "Fix Find Mixins TW not showing up" This reverts commit 14b015e45adcd1297e341cb9d3e15a379265db97. For some reason Jetbrains hasn't backported a fix that's plaguing facet-dependent TWs on 2023.1 yet, so let's revert this commit for 2023.1 only --- src/main/kotlin/platform/mixin/action/FindMixinsAction.kt | 4 ++++ src/main/resources/META-INF/plugin.xml | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/platform/mixin/action/FindMixinsAction.kt b/src/main/kotlin/platform/mixin/action/FindMixinsAction.kt index a36e708d5..ecbf4026e 100644 --- a/src/main/kotlin/platform/mixin/action/FindMixinsAction.kt +++ b/src/main/kotlin/platform/mixin/action/FindMixinsAction.kt @@ -52,6 +52,10 @@ class FindMixinsAction : AnAction() { class TWFactory : ToolWindowFactory { override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { } + + override fun shouldBeAvailable(project: Project): Boolean { + return false + } } companion object { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 1891bd0b0..ae426d301 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -426,10 +426,8 @@ order="before javaSkipAutopopupInStrings"/> - + From b29af869bf0aad4270f80f00b53731a9f2756942 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sat, 14 Oct 2023 14:03:28 +0200 Subject: [PATCH 14/14] Replace deprecated constants with PsiTypes methods --- .../mixin/handlers/mixinextras/WrapWithConditionHandler.kt | 3 ++- .../inspection/injector/InjectCouldBeOverwriteInspection.kt | 4 ++-- src/main/kotlin/platform/mixin/util/Mixin.kt | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/platform/mixin/handlers/mixinextras/WrapWithConditionHandler.kt b/src/main/kotlin/platform/mixin/handlers/mixinextras/WrapWithConditionHandler.kt index 408fd7448..cb54352df 100644 --- a/src/main/kotlin/platform/mixin/handlers/mixinextras/WrapWithConditionHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/mixinextras/WrapWithConditionHandler.kt @@ -23,6 +23,7 @@ package com.demonwav.mcdev.platform.mixin.handlers.mixinextras import com.demonwav.mcdev.platform.mixin.inspection.injector.ParameterGroup import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import org.objectweb.asm.Type import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.ClassNode @@ -44,6 +45,6 @@ class WrapWithConditionHandler : MixinExtrasInjectorAnnotationHandler() { insn: AbstractInsnNode ): Pair? { val params = getPsiParameters(insn, targetClass, annotation) ?: return null - return ParameterGroup(params) to PsiType.BOOLEAN + return ParameterGroup(params) to PsiTypes.booleanType() } } diff --git a/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt b/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt index 9d96a33dc..e0ff25791 100644 --- a/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt @@ -72,7 +72,7 @@ import com.intellij.psi.PsiMethodCallExpression import com.intellij.psi.PsiParameter import com.intellij.psi.PsiParameterList import com.intellij.psi.PsiReturnStatement -import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.codeStyle.VariableKind import com.intellij.psi.impl.light.LightParameter import com.intellij.psi.search.LocalSearchScope @@ -149,7 +149,7 @@ class InjectCouldBeOverwriteInspection : MixinInspection() { memState.applyCondition(ciVar.eq(stableCiVar)) val isCancelledVar = PlainDescriptor.createVariableValue( factory, - LightParameter("isCancelled", PsiType.BOOLEAN, methodBody) + LightParameter("isCancelled", PsiTypes.booleanType(), methodBody) ) memState.setVarValue(isCancelledVar, falseValue) diff --git a/src/main/kotlin/platform/mixin/util/Mixin.kt b/src/main/kotlin/platform/mixin/util/Mixin.kt index fab55e079..2b522a7b5 100644 --- a/src/main/kotlin/platform/mixin/util/Mixin.kt +++ b/src/main/kotlin/platform/mixin/util/Mixin.kt @@ -44,6 +44,7 @@ import com.intellij.psi.PsiMethod import com.intellij.psi.PsiParameter import com.intellij.psi.PsiPrimitiveType import com.intellij.psi.PsiType +import com.intellij.psi.PsiTypes import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.util.InheritanceUtil import com.intellij.psi.util.PsiModificationTracker @@ -165,7 +166,7 @@ fun isAssignable(left: PsiType, right: PsiType, allowPrimitiveConversion: Boolea left is PsiArrayType -> right is PsiArrayType && isAssignable(left.componentType, right.componentType) else -> { if (left !is PsiClassType || right !is PsiClassType) { - if (right == PsiType.NULL && left !is PsiPrimitiveType) { + if (right == PsiTypes.nullType() && left !is PsiPrimitiveType) { return true } if (!allowPrimitiveConversion && (left is PsiPrimitiveType || right is PsiPrimitiveType)) {