Skip to content

Commit e2365e6

Browse files
committed
Merge branch '2025.2' into 2025.3
2 parents a9ba25a + 78fa6fb commit e2365e6

File tree

8 files changed

+56
-29
lines changed

8 files changed

+56
-29
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Minecraft Development for IntelliJ
22

3+
## [1.8.8]
4+
5+
### Fixed
6+
7+
- `@At` targets inside `@Slice` are no longer checked for invalid instructions according to the injector type.
8+
39
## [1.8.7]
410

511
### Added

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx1g
2323

2424
ideaVersionName = 2025.3
2525

26-
coreVersion = 1.8.7
26+
coreVersion = 1.8.8
2727

2828
# Silences a build-time warning because we are bundling our own kotlin library
2929
kotlin.stdlib.default.dependency = false

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Minecraft Development for IntelliJ
3131
</tr>
3232
</table>
3333

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

3737
<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>

src/main/kotlin/creator/custom/providers/RemoteTemplateProvider.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import com.github.kittinunf.result.getOrNull
3636
import com.github.kittinunf.result.onError
3737
import com.intellij.ide.util.projectWizard.WizardContext
3838
import com.intellij.openapi.application.PathManager
39-
import com.intellij.openapi.application.writeAction
4039
import com.intellij.openapi.diagnostic.ControlFlowException
4140
import com.intellij.openapi.diagnostic.thisLogger
4241
import com.intellij.openapi.observable.properties.PropertyGraph
@@ -161,7 +160,7 @@ open class RemoteTemplateProvider : TemplateProvider {
161160
val rootFile = fs.refreshAndFindFileByPath(archiveRoot)
162161
?: return emptyList()
163162
val modalityState = context.modalityState
164-
writeAction { rootFile.refreshSync(modalityState) }
163+
rootFile.refreshSync(modalityState)
165164

166165
val innerPath = replaceVariables(rawInnerPath)
167166
val repoRoot = if (innerPath.isNotBlank()) {

src/main/kotlin/creator/custom/providers/TemplateProvider.kt

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import com.intellij.util.KeyedLazyInstance
4646
import com.intellij.util.xmlb.annotations.Attribute
4747
import java.util.ResourceBundle
4848
import javax.swing.JComponent
49+
import kotlinx.coroutines.Dispatchers
50+
import kotlinx.coroutines.runBlocking
4951

5052
/**
5153
* Extensions responsible for creating a [TemplateDescriptor] based on whatever data it is provided in its configuration
@@ -73,31 +75,34 @@ interface TemplateProvider {
7375

7476
fun getAllKeys() = EP_NAME.extensionList.mapNotNull { it.key }
7577

76-
fun findTemplates(
78+
suspend fun findTemplates(
7779
modalityState: ModalityState,
7880
repoRoot: VirtualFile,
7981
templates: MutableList<VfsLoadedTemplate> = mutableListOf(),
80-
bundle: ResourceBundle? = loadMessagesBundle(modalityState, repoRoot)
82+
bundle: ResourceBundle? = null
8183
): List<VfsLoadedTemplate> {
84+
val bundle = bundle ?: loadMessagesBundle(modalityState, repoRoot)
8285
val visitor = object : VirtualFileVisitor<Unit>() {
8386
override fun visitFile(file: VirtualFile): Boolean {
8487
if (!file.isFile || !file.name.endsWith(".mcdev.template.json")) {
8588
return true
8689
}
8790

88-
try {
89-
createVfsLoadedTemplate(modalityState, file.parent, file, bundle = bundle)
90-
?.let(templates::add)
91-
} catch (t: Throwable) {
92-
if (t is ControlFlowException) {
93-
throw t
94-
}
95-
96-
val attachment = runCatching { Attachment(file.name, file.readText()) }.getOrNull()
97-
if (attachment != null) {
98-
thisLogger().error("Failed to load template ${file.path}", t, attachment)
99-
} else {
100-
thisLogger().error("Failed to load template ${file.path}", t)
91+
runBlocking(Dispatchers.Unconfined) {
92+
try {
93+
createVfsLoadedTemplate(modalityState, file.parent, file, bundle = bundle)
94+
?.let(templates::add)
95+
} catch (t: Throwable) {
96+
if (t is ControlFlowException) {
97+
throw t
98+
}
99+
100+
val attachment = runCatching { Attachment(file.name, file.readText()) }.getOrNull()
101+
if (attachment != null) {
102+
thisLogger().error("Failed to load template ${file.path}", t, attachment)
103+
} else {
104+
thisLogger().error("Failed to load template ${file.path}", t)
105+
}
101106
}
102107
}
103108

@@ -108,7 +113,7 @@ interface TemplateProvider {
108113
return templates
109114
}
110115

111-
fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try {
116+
suspend fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try {
112117
val locale = DynamicBundle.getLocale()
113118
// Simplified bundle resolution, but covers all the most common cases
114119
val baseBundle = doLoadMessageBundle(
@@ -135,7 +140,7 @@ interface TemplateProvider {
135140
null
136141
}
137142

138-
private fun doLoadMessageBundle(
143+
private suspend fun doLoadMessageBundle(
139144
file: VirtualFile?,
140145
modalityState: ModalityState,
141146
parent: ResourceBundle?
@@ -158,7 +163,7 @@ interface TemplateProvider {
158163
return parent
159164
}
160165

161-
fun createVfsLoadedTemplate(
166+
suspend fun createVfsLoadedTemplate(
162167
modalityState: ModalityState,
163168
templateRoot: VirtualFile,
164169
descriptorFile: VirtualFile,

src/main/kotlin/platform/mixin/handlers/injectionPoint/AtResolver.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import com.demonwav.mcdev.platform.mixin.reference.isMiscDynamicSelector
2929
import com.demonwav.mcdev.platform.mixin.reference.parseMixinSelector
3030
import com.demonwav.mcdev.platform.mixin.reference.target.TargetReference
3131
import com.demonwav.mcdev.platform.mixin.util.InjectionPointSpecifier
32+
import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.AT
33+
import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.SLICE
3234
import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Classes.SHIFT
3335
import com.demonwav.mcdev.platform.mixin.util.findSourceClass
3436
import com.demonwav.mcdev.platform.mixin.util.findSourceElement
@@ -152,11 +154,13 @@ class AtResolver(
152154
}
153155
}
154156

155-
fun findInjectorAnnotation(at: PsiAnnotation): PsiAnnotation? {
157+
fun findInjectorAnnotation(at: PsiAnnotation, skipThroughSlice: Boolean = true): PsiAnnotation? {
156158
return at.parents(false)
157159
.takeWhile { it !is PsiClass }
158160
.filterIsInstance<PsiAnnotation>()
159-
.firstOrNull { it.parent is PsiModifierList }
161+
.firstOrNull {
162+
!skipThroughSlice || (!it.hasQualifiedName(SLICE) && !it.hasQualifiedName(AT))
163+
}
160164
}
161165

162166
fun getShift(at: PsiAnnotation): Int {
@@ -281,7 +285,7 @@ class AtResolver(
281285
val injectionPoint = getInjectionPoint(at) ?: return emptyList()
282286
val targetAttr = at.findAttributeValue("target")
283287
val target = targetAttr?.let { parseMixinSelector(it) }
284-
val injector = findInjectorAnnotation(at)?.let(MixinAnnotationHandler::forMixinAnnotation)
288+
val injector = findInjectorAnnotation(at, skipThroughSlice = false)?.let(MixinAnnotationHandler::forMixinAnnotation)
285289
as? InjectorAnnotationHandler
286290

287291
// Collect all possible targets

src/main/kotlin/platform/mixin/inspection/injector/DisallowedTargetInsnInspection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DisallowedTargetInsnInspection : MixinInspection() {
4141
return
4242
}
4343

44-
val injectorAnnotation = AtResolver.findInjectorAnnotation(annotation) ?: return
44+
val injectorAnnotation = AtResolver.findInjectorAnnotation(annotation, skipThroughSlice = false) ?: return
4545
val injector = MixinAnnotationHandler.forMixinAnnotation(injectorAnnotation, annotation.project)
4646
as? InjectorAnnotationHandler ?: return
4747
val containingClass = injectorAnnotation.findContainingClass() ?: return

src/main/kotlin/util/files.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
package com.demonwav.mcdev.util
2222

23+
import com.intellij.openapi.application.ApplicationManager
2324
import com.intellij.openapi.application.ModalityState
25+
import com.intellij.openapi.application.writeAction
2426
import com.intellij.openapi.vfs.LocalFileSystem
2527
import com.intellij.openapi.vfs.VfsUtilCore
2628
import com.intellij.openapi.vfs.VirtualFile
@@ -44,7 +46,7 @@ val Path.virtualFileOrError: VirtualFile
4446
val VirtualFile.manifest: Manifest?
4547
get() = try {
4648
JarFile(localFile).use { it.manifest }
47-
} catch (e: IOException) {
49+
} catch (_: IOException) {
4850
null
4951
}
5052

@@ -77,7 +79,18 @@ val VirtualFile.mcDomainAndPath: Pair<String, String>?
7779
operator fun Manifest.get(attribute: String): String? = mainAttributes.getValue(attribute)
7880
operator fun Manifest.get(attribute: Attributes.Name): String? = mainAttributes.getValue(attribute)
7981

80-
fun VirtualFile.refreshSync(modalityState: ModalityState): VirtualFile? {
81-
RefreshQueue.getInstance().refresh(false, this.isDirectory, null, modalityState, this)
82+
suspend fun VirtualFile.refreshSync(modalityState: ModalityState): VirtualFile? {
83+
fun refresh() {
84+
RefreshQueue.getInstance().refresh(false, this.isDirectory, null, modalityState, this)
85+
}
86+
87+
if (ApplicationManager.getApplication().isWriteAccessAllowed) {
88+
refresh()
89+
} else {
90+
writeAction {
91+
refresh()
92+
}
93+
}
94+
8295
return this.parent?.findOrCreateChildData(this, this.name)
8396
}

0 commit comments

Comments
 (0)