Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/mixinextras expressions #2322

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a62cd60
Fix #2278 1.20.5 requires Java 21
RedNesto Apr 17, 2024
b2c6e44
Suppress `ReferenceToMixin` for `@Dynamic` (#2280)
senseiwells Apr 17, 2024
1e828e1
Update NeoForge MDK
RedNesto Apr 17, 2024
7c0ec12
Small adjustment to fabric's build.gradle template
RedNesto Apr 25, 2024
0a29cf0
Version 1.7.5
RedNesto Apr 25, 2024
5992a6a
change error requirements from public to non-private (#2289)
O7410 Apr 27, 2024
3d61c67
Add NeoGradle version dropdown
RedNesto Apr 27, 2024
50002d7
NeoForge 1.20.5 template
RedNesto Apr 27, 2024
2e4ae91
Only show the 50 most recent NeoGradle versions
RedNesto Apr 27, 2024
8f2bb55
Allow dynamic selectors to choose the class to perform member lookups…
Bawnorton May 9, 2024
7127a3c
Add 2024.2 to readme
RedNesto May 16, 2024
1af46a4
Fix typo
RedNesto May 16, 2024
10bd8d7
New: Add support for `@WrapMethod` in MixinExtras. (#2300)
LlamaLad7 May 28, 2024
efcfd5d
New: Support `WrongOperationParametersInspection` in `@WrapMethod`s. …
LlamaLad7 Jun 1, 2024
b7276ac
Minecraft 1.21 templates
RedNesto Jun 14, 2024
4bb6087
Version 1.7.6
RedNesto Jun 14, 2024
41240ca
fix: #2316 (#2317)
nelind3 Jun 20, 2024
6de3376
Initial support for NeoForge's ModDevGradle
RedNesto Jun 21, 2024
9da3841
Improve fabric.mod.json entrypoints insight
RedNesto Jul 2, 2024
7b07722
Merge remote-tracking branch 'refs/remotes/original/dev' into mixinex…
LlamaLad7 Jul 2, 2024
3ecde2d
MixinExtras Expressions: Migrate to Expressions library.
LlamaLad7 Jul 2, 2024
d8a9f83
Fix: Resolve being unable to get the descriptor for some complex types.
LlamaLad7 Jul 2, 2024
c88fd70
MixinExtras Expressions: Recreate `ClassInfo#getCommonSuperClassOrInt…
LlamaLad7 Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ repositories {
maven("https://maven.fabricmc.net/") {
content {
includeModule("net.fabricmc", "mapping-io")
includeModule("net.fabricmc", "fabric-loader")
}
}
mavenCentral()

// TODO: temporary waiting for MixinExtras expression library
maven("https://repo.spongepowered.org/")
maven("https://repo.spongepowered.org/maven/")
maven("https://jitpack.io/") {
content {
includeGroupByRegex("com\\.github\\..+")
Expand All @@ -100,9 +101,11 @@ dependencies {
// Add tools.jar for the JDI API
implementation(files(Jvm.current().toolsJar))

// TODO: temporary waiting for MixinExtras expression library
testLibs(implementation("com.github.LlamaLad7.MixinExtras:mixinextras-common:86c9835")!!)
implementation("org.spongepowered:mixin:0.8.4")
// TODO: temporary waiting for a release
fun mixinExtras(variant: String) = "com.github.LlamaLad7.MixinExtras:mixinextras-$variant:4d2e01e"

implementation(mixinExtras("expressions"))
testLibs(mixinExtras("common"))
implementation("org.ow2.asm:asm-util:9.3")

// Kotlin
Expand Down Expand Up @@ -132,6 +135,7 @@ dependencies {
classifier = "shaded"
}
}
testLibs(libs.test.fabricloader)
testLibs(libs.test.nbt) {
artifact {
extension = "nbt"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kotlin.code.style=official
ideaVersion = 2023.2.2
ideaVersionName = 2023.2.2

coreVersion = 1.7.4
coreVersion = 1.7.6
downloadIdeaSources = true

pluginTomlVersion = 232.8660.88
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fuel-coroutines = { module = "com.github.kittinunf.fuel:fuel-coroutines", versio
test-mockJdk = "org.jetbrains.idea:mock-jdk:1.7-4d76c50"
test-mixin = "org.spongepowered:mixin:0.8.5"
test-spongeapi = "org.spongepowered:spongeapi:7.4.0"
test-fabricloader = "net.fabricmc:fabric-loader:0.15.11"
test-nbt = "com.demonwav.mcdev:all-types-nbt:1.0"

junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Minecraft Development for IntelliJ
<td align="left">2024.1</td>
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20241"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20241)/statusIcon.svg" alt="2024.1 Nightly Status" /></a></td>
</tr>
<tr>
<td align="left">2024.2</td>
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20242"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20242)/statusIcon.svg" alt="2024.2 Nightly Status" /></a></td>
</tr>
<tr>
<td align="right"><b>OS Tests</b></td>
<td align="left" colspan="2">
Expand All @@ -31,7 +35,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.7.4-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.7.6-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev

import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD
import org.gradle.api.Project
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService

import java.nio.file.Files

final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService {

@Override
boolean canBuild(String modelName) {
return McpModelNMD.name == modelName
}

@Override
Object buildAll(String modelName, Project project) {
def extension = project.extensions.findByName('neoForge')
if (extension == null) {
return null
}

if (!project.plugins.findPlugin("net.neoforged.moddev")) {
return null
}

def neoforgeVersion = extension.version.get()
if (neoforgeVersion == null) {
return null
}

def accessTransformers = extension.accessTransformers.get().collect { project.file(it) }

// Hacky way to guess where the mappings file is, but I could not find a proper way to find it
def neoformDir = project.buildDir.toPath().resolve("neoForm")
def mappingsFile = Files.list(neoformDir)
.map { it.resolve("config/joined.tsrg") }
.filter { Files.exists(it) }
.findFirst()
.orElse(null)
?.toFile()

//noinspection GroovyAssignabilityCheck
return new NeoModDevGradleModelImpl(neoforgeVersion, mappingsFile, accessTransformers)
}

@Override
ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) {
return ErrorMessageBuilder.create(
project, e, "MinecraftDev import errors"
).withDescription("Unable to build MinecraftDev MCP project configuration")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev


import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD
import groovy.transform.CompileStatic

@CompileStatic
final class NeoModDevGradleModelImpl implements McpModelNMD, Serializable {

final String neoForgeVersion
final File mappingsFile
final List<File> accessTransformers

NeoModDevGradleModelImpl(
final String neoForgeVersion,
final File mappingsFile,
final List<File> accessTransformers
) {
this.neoForgeVersion = neoForgeVersion
this.mappingsFile = mappingsFile
this.accessTransformers = accessTransformers
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

package com.demonwav.mcdev.platform.mcp.gradle.tooling;

import java.io.File;
import java.util.List;

public interface McpModelNMD {
String getNeoForgeVersion();
File getMappingsFile();
List<File> getAccessTransformers();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
com.demonwav.mcdev.platform.mcp.gradle.tooling.archloom.ArchitecturyModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.fabricloom.FabricLoomModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.neogradle.NeoGradle7ModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev.NeoModDevGradleModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.vanillagradle.VanillaGradleModelBuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG2BuilderImpl
com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelFG3BuilderImpl
2 changes: 1 addition & 1 deletion src/main/kotlin/creator/buildsystem/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
import org.jetbrains.plugins.gradle.service.project.open.canLinkAndRefreshGradleProject
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject

val DEFAULT_GRADLE_VERSION = SemanticVersion.release(8, 5)
val DEFAULT_GRADLE_VERSION = SemanticVersion.release(8, 7)
val GRADLE_VERSION_KEY = Key.create<SemanticVersion>("mcdev.gradleVersion")

fun FixedAssetsNewProjectWizardStep.addGradleWrapperProperties(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.demonwav.mcdev.util.SemanticVersion
class BungeeMainPlatformStep(parent: BungeePlatformStep) : AbstractBungeePlatformStep(parent, PlatformType.BUNGEECORD) {
override fun getRepositories(mcVersion: SemanticVersion) = listOf(
BuildRepository("sonatype", "https://oss.sonatype.org/content/groups/public/"),
// Seems to be required since 1.21
BuildRepository("Minecraft Libraries", "https://libraries.minecraft.net/"),
)

override fun getDependencies(mcVersion: SemanticVersion) = listOf(
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/platform/fabric/creator/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FabricGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningA
val mcVersion = data.getUserData(FabricVersionChainStep.MC_VERSION_KEY) ?: return
val yarnVersion = data.getUserData(FabricVersionChainStep.YARN_VERSION_KEY) ?: return
val loaderVersion = data.getUserData(FabricVersionChainStep.LOADER_VERSION_KEY) ?: return
val loomVersion = "1.5-SNAPSHOT"
val loomVersion = "1.6-SNAPSHOT"
val javaVersion = findStep<JdkProjectSetupFinalizer>().preferredJdk.ordinal
val apiVersion = data.getUserData(FabricVersionChainStep.API_VERSION_KEY)
val officialMappings = data.getUserData(FabricVersionChainStep.OFFICIAL_MAPPINGS_KEY) ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ package com.demonwav.mcdev.platform.fabric.inspection

import com.demonwav.mcdev.platform.fabric.reference.EntryPointReference
import com.demonwav.mcdev.platform.fabric.util.FabricConstants
import com.demonwav.mcdev.util.equivalentTo
import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.json.psi.JsonArray
import com.intellij.json.psi.JsonElementVisitor
import com.intellij.json.psi.JsonLiteral
import com.intellij.json.psi.JsonProperty
import com.intellij.json.psi.JsonStringLiteral
import com.intellij.psi.JavaPsiFacade
Expand Down Expand Up @@ -79,8 +82,7 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
val element = resolved.singleOrNull()?.element
when {
element is PsiClass && !literal.text.contains("::") -> {
val propertyKey = literal.parentOfType<JsonProperty>()?.name
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
val (propertyKey, expectedType) = findEntrypointKeyAndType(literal)
if (propertyKey != null && expectedType != null &&
!isEntrypointOfCorrectType(element, propertyKey)
) {
Expand Down Expand Up @@ -111,21 +113,43 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
reference.rangeInElement,
)
}

if (!element.hasModifierProperty(PsiModifier.PUBLIC)) {
holder.registerProblem(
literal,
"Entrypoint method must be public",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}

if (!element.hasModifierProperty(PsiModifier.STATIC)) {
val clazz = element.containingClass
if (clazz != null && clazz.constructors.isNotEmpty() &&
clazz.constructors.find { !it.hasParameters() } == null
) {
holder.registerProblem(
literal,
"Entrypoint instance method class must have an empty constructor",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}
}
}

element is PsiField -> {
if (!element.hasModifierProperty(PsiModifier.STATIC)) {
if (!element.hasModifierProperty(PsiModifier.PUBLIC)) {
holder.registerProblem(
literal,
"Entrypoint field must be static",
"Entrypoint field must be public",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
reference.rangeInElement,
)
}

val propertyKey = literal.parentOfType<JsonProperty>()?.name
val (propertyKey, expectedType) = findEntrypointKeyAndType(literal)
val fieldTypeClass = (element.type as? PsiClassType)?.resolve()
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
if (propertyKey != null && fieldTypeClass != null && expectedType != null &&
!isEntrypointOfCorrectType(fieldTypeClass, propertyKey)
) {
Expand All @@ -141,11 +165,21 @@ class FabricEntrypointsInspection : LocalInspectionTool() {
}
}

private fun findEntrypointKeyAndType(literal: JsonLiteral): Pair<String?, String?> {
val propertyKey = when (val parent = literal.parent) {
is JsonArray -> (parent.parent as? JsonProperty)?.name
is JsonProperty -> parent.parentOfType<JsonProperty>()?.name
else -> null
}
val expectedType = propertyKey?.let { FabricConstants.ENTRYPOINT_BY_TYPE[it] }
return propertyKey to expectedType
}

private fun isEntrypointOfCorrectType(element: PsiClass, type: String): Boolean {
val entrypointClass = FabricConstants.ENTRYPOINT_BY_TYPE[type]
?: return false
val clazz = JavaPsiFacade.getInstance(element.project).findClass(entrypointClass, element.resolveScope)
return clazz != null && element.isInheritor(clazz, true)
return clazz != null && (element.equivalentTo(clazz) || element.isInheritor(clazz, true))
}
}
}
Loading
Loading