Skip to content

Commit

Permalink
Merge branch '2024.1' into 2024.2
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Oct 6, 2024
2 parents 69a1bdd + 9c27b29 commit 017a3e9
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 50 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Minecraft Development for IntelliJ

## [Unreleased]
## [1.8.2]

### Added

Expand All @@ -13,6 +13,7 @@
- Mixin injection signature fix preview
- Loom 1.8 support
- K2 mode compatibility
- [#2385](https://github.com/minecraft-dev/MinecraftDev/issues/2385) ModDevGradle Vanilla-Mode support

### Changed

Expand All @@ -28,6 +29,7 @@
- [#2376](https://github.com/minecraft-dev/MinecraftDev/issues/2376) Error when generating event listeners in read only file
- [#2308](https://github.com/minecraft-dev/MinecraftDev/issues/2308) Mixin Inject signature fix adds last parameter as first local
- [#1813](https://github.com/minecraft-dev/MinecraftDev/issues/1813) Single character Accessor targets aren't inferred correctly
- [#1886](https://github.com/minecraft-dev/MinecraftDev/issues/1886) Sync error in ForgeGradle composite builds

## [1.8.1] - 2024-08-10

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# suppress inspection "UnusedProperty" for whole file
ideaVersionName = 2024.2

coreVersion = 1.8.1
coreVersion = 1.8.2

# Silences a build-time warning because we are bundling our own kotlin library
kotlin.stdlib.default.dependency = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService {
return null
}

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

def accessTransformersRaw = extension.accessTransformers
List<File> accessTransformers
Expand All @@ -74,7 +72,7 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService {
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@

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


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

@CompileStatic
@Immutable(knownImmutableClasses = [File])
final class NeoModDevGradleModelImpl implements McpModelNMD, Serializable {

final String neoForgeVersion
final String neoFormVersion
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
Expand Up @@ -20,11 +20,14 @@

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

import org.jetbrains.annotations.Nullable;

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

public interface McpModelNMD {
String getNeoForgeVersion();
@Nullable String getNeoForgeVersion();
@Nullable String getNeoFormVersion();
File getMappingsFile();
List<File> getAccessTransformers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() {

val projectDirPath = Paths.get(projectDataNode.data.linkedExternalProjectPath)
runGradleTask(project, projectDirPath) { settings ->
settings.taskNames = allTaskNames
settings.taskNames = allTaskNames.distinct()
}

super.resolveFinished(projectDataNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.LocalFileSystem
import org.gradle.tooling.model.idea.IdeaModule
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext
import org.jetbrains.plugins.gradle.util.gradleIdentityPath

object McpModelFG3Handler : McpModelDataHandler {

Expand Down Expand Up @@ -68,9 +69,10 @@ object McpModelFG3Handler : McpModelDataHandler {
forgeVersion,
)

val gradleProjectPath = gradleModule.gradleProject.projectIdentifier.projectPath
val suffix = if (gradleProjectPath.endsWith(':')) "" else ":"
val taskName = gradleProjectPath + suffix + data.taskName
// gradleIdentityPath makes it work with composite builds
val identityPath = node.data.gradleIdentityPath
// But ignore it if it is the root project, as taskName already starts with a colon
val taskName = if (identityPath == ":") data.taskName else identityPath + ':' + data.taskName

val ats = data.accessTransformers
if (ats != null && ats.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ object McpModelNMDHandler : McpModelDataHandler {
) {
val data = resolverCtx.getExtraProject(gradleModule, McpModelNMD::class.java) ?: return

val minecraftVersion = when {
data.neoForgeVersion != null -> "1." + data.neoForgeVersion!!.substringBeforeLast('.').removeSuffix(".0")
data.neoFormVersion != null -> data.neoFormVersion!!.substringBeforeLast('-').removeSuffix(".0")
else -> null
}

val state = McpModuleSettings.State(
"1." + data.neoForgeVersion.substringBeforeLast('.').removeSuffix(".0"),
minecraftVersion,
null,
data.mappingsFile?.absolutePath,
SrgType.TSRG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,17 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() {
}
val method = startElement as PsiMethod
fixParameters(project, method.parameterList, false)
fixReturnType(method)
fixIntLikeTypes(method, editor ?: return)
fixReturnType(method, editor ?: return, file, false)
fixIntLikeTypes(method, editor, false)
}

override fun generatePreview(project: Project, editor: Editor, file: PsiFile): IntentionPreviewInfo {
val method = PsiTreeUtil.findSameElementInCopy(startElement, file) as? PsiMethod
?: return IntentionPreviewInfo.EMPTY
fixParameters(project, method.parameterList, true)
fixReturnType(method)
fixIntLikeTypes(method, editor)
// Pass the original startElement because the underlying fix gets the preview element itself
fixReturnType(startElement as PsiMethod, editor, file, true)
fixIntLikeTypes(method, editor, true)
return IntentionPreviewInfo.DIFF
}

Expand Down Expand Up @@ -386,34 +387,43 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() {
}
}

private fun fixReturnType(method: PsiMethod) {
private fun fixReturnType(method: PsiMethod, editor: Editor, file: PsiFile, preview: Boolean) {
if (expectedReturnType == null) {
return
}
QuickFixFactory.getInstance()
.createMethodReturnFix(method, expectedReturnType, false)
.applyFix()
val fix = QuickFixFactory.getInstance().createMethodReturnFix(method, expectedReturnType, false)
if (preview) {
fix.generatePreview(file.project, editor, file)
} else {
fix.applyFix()
}
}

private fun fixIntLikeTypes(method: PsiMethod, editor: Editor) {
private fun fixIntLikeTypes(method: PsiMethod, editor: Editor, preview: Boolean) {
if (intLikeTypePositions.isEmpty()) {
return
}
invokeLater {
WriteCommandAction.runWriteCommandAction(
method.project,
"Choose Int-Like Type",
null,
{
val template = makeIntLikeTypeTemplate(method, intLikeTypePositions)
if (template != null) {
editor.caretModel.moveToOffset(method.startOffset)
TemplateManager.getInstance(method.project)
.startTemplate(editor, template)
}
},
method.parentOfType<PsiFile>()!!
)
val runnable = {
val template = makeIntLikeTypeTemplate(method, intLikeTypePositions)
if (template != null) {
editor.caretModel.moveToOffset(method.startOffset)
TemplateManager.getInstance(method.project)
.startTemplate(editor, template)
}
}

if (preview) {
runnable()
} else {
invokeLater {
WriteCommandAction.runWriteCommandAction(
method.project,
"Choose Int-Like Type",
null,
runnable,
method.parentOfType<PsiFile>()!!
)
}
}
}

Expand Down

0 comments on commit 017a3e9

Please sign in to comment.