Skip to content

Commit c3fcf46

Browse files
committed
Merge branch '2025.1' into 2025.2
2 parents 338eef2 + f42c39c commit c3fcf46

24 files changed

+343
-129
lines changed

changelog.md

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

3+
## [1.8.11]
4+
5+
### Added
6+
7+
- Using Minecraft version to recognize unobfuscated Minecraft
8+
9+
### Fixed
10+
11+
- Downgraded non-void WrapWithCondition to warning if there is a pop instruction afterwards
12+
- Fixed local templates freezing
13+
- Avoided a crash for unknown MC versions
14+
- Don't suggest that locals can use names with argsOnly = true
15+
316
## [1.8.10]
417

518
### Fixed

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.2
2525

26-
coreVersion = 1.8.10
26+
coreVersion = 1.8.11
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.10-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.11-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/JdkComboBoxWithPreference.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package com.demonwav.mcdev.creator
2222

23-
import com.demonwav.mcdev.util.invokeLater
2423
import com.intellij.ide.util.PropertiesComponent
2524
import com.intellij.ide.util.projectWizard.ProjectWizardUtil
2625
import com.intellij.ide.util.projectWizard.WizardContext
@@ -43,7 +42,6 @@ import com.intellij.openapi.util.Disposer
4342
import com.intellij.ui.dsl.builder.Cell
4443
import com.intellij.ui.dsl.builder.Row
4544
import javax.swing.JComponent
46-
import org.jetbrains.concurrency.runAsync
4745

4846
internal class JdkPreferenceData(
4947
var jdk: JavaSdkVersion,
@@ -91,17 +89,15 @@ class JdkComboBoxWithPreference internal constructor(
9189
preferenceData.jdk = version
9290
reloadModel()
9391

94-
for (jdkVersion in version.ordinal until JavaSdkVersion.entries.size) {
95-
val jdk = JavaSdkVersion.entries[jdkVersion]
92+
for (jdkVersion in version.ordinal until JavaSdkVersion.values().size) {
93+
val jdk = JavaSdkVersion.values()[jdkVersion]
9694

9795
val preferredSdkPath = preferenceData.sdkPathByJdk[jdk]
9896
if (preferredSdkPath != null) {
9997
val sdk = model.sdks.firstOrNull { it.homePath == preferredSdkPath }
10098
?: suggestions.firstOrNull { it.homePath == preferredSdkPath }
10199
if (sdk != null) {
102-
runAsync {
103-
setSelectedItem(sdk)
104-
}
100+
setSelectedItem(sdk)
105101
return
106102
}
107103
}
@@ -149,7 +145,7 @@ fun Row.jdkComboBoxWithPreference(
149145
for (preferenceDataStr in preferenceDataStrs) {
150146
val parts = preferenceDataStr.split('=', limit = 2)
151147
val featureVersion = parts.firstOrNull()?.toIntOrNull() ?: continue
152-
val knownJdkVersions = JavaSdkVersion.entries
148+
val knownJdkVersions = JavaSdkVersion.values()
153149
if (featureVersion !in knownJdkVersions.indices) {
154150
continue
155151
}
@@ -180,9 +176,7 @@ fun Row.jdkComboBoxWithPreference(
180176
}
181177

182178
val lastUsedSdk = stateComponent.getValue(selectedJdkProperty)
183-
runAsync {
184-
ProjectWizardUtil.preselectJdkForNewModule(project, lastUsedSdk, comboBox) { true }
185-
}
179+
ProjectWizardUtil.preselectJdkForNewModule(project, lastUsedSdk, comboBox) { true }
186180

187181
val windowChild = context.getUserData(AbstractWizard.KEY)!!.contentPanel
188182
comboBox.loadSuggestions(windowChild, context.disposable)

src/main/kotlin/creator/custom/CreatorTemplateProcessor.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import com.intellij.codeInsight.actions.ReformatCodeProcessor
3434
import com.intellij.ide.projectView.ProjectView
3535
import com.intellij.ide.util.projectWizard.WizardContext
3636
import com.intellij.openapi.application.WriteAction
37-
import com.intellij.openapi.concurrency.awaitPromise
3837
import com.intellij.openapi.diagnostic.Attachment
3938
import com.intellij.openapi.diagnostic.ControlFlowException
4039
import com.intellij.openapi.diagnostic.thisLogger
@@ -54,15 +53,11 @@ import com.intellij.ui.dsl.builder.Panel
5453
import com.intellij.ui.dsl.builder.panel
5554
import com.intellij.util.application
5655
import java.nio.file.Path
57-
import java.time.Duration
58-
import java.util.concurrent.TimeUnit
5956
import java.util.function.Consumer
6057
import kotlin.io.path.createDirectories
6158
import kotlin.io.path.writeText
6259
import kotlinx.coroutines.CoroutineScope
6360
import kotlinx.coroutines.launch
64-
import org.jetbrains.concurrency.await
65-
import org.jetbrains.concurrency.runAsync
6661

6762
interface ExternalTemplatePropertyProvider {
6863

@@ -273,11 +268,7 @@ class CreatorTemplateProcessor(
273268
destPath.parent.createDirectories()
274269
destPath.writeText(processedContent)
275270

276-
val virtualFile = runCatching {
277-
runAsync {
278-
destPath.refreshAndFindVirtualFile()
279-
}.blockingGet(20, TimeUnit.MILLISECONDS)
280-
}.getOrNull()
271+
val virtualFile = destPath.refreshAndFindVirtualFile()
281272
if (virtualFile != null) {
282273
generatedFiles.add(file to virtualFile)
283274
} else {

src/main/kotlin/creator/custom/CustomPlatformStep.kt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ import com.demonwav.mcdev.creator.custom.providers.LoadedTemplate
2727
import com.demonwav.mcdev.creator.custom.providers.TemplateProvider
2828
import com.demonwav.mcdev.creator.modalityState
2929
import com.demonwav.mcdev.util.getOrLogException
30-
import com.demonwav.mcdev.util.invokeAndWait
31-
import com.demonwav.mcdev.util.runWriteTask
32-
import com.demonwav.mcdev.util.tryWriteSafeContext
3330
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
3431
import com.intellij.ide.wizard.GitNewProjectWizardData
3532
import com.intellij.ide.wizard.NewProjectWizardBaseData
3633
import com.intellij.ide.wizard.NewProjectWizardStep
3734
import com.intellij.openapi.application.EDT
38-
import com.intellij.openapi.application.ModalityState
39-
import com.intellij.openapi.application.TransactionGuard
4035
import com.intellij.openapi.application.asContextElement
41-
import com.intellij.openapi.application.impl.ModalityStateEx
4236
import com.intellij.openapi.application.runWriteAction
4337
import com.intellij.openapi.diagnostic.logger
4438
import com.intellij.openapi.observable.properties.GraphProperty
@@ -57,12 +51,10 @@ import com.intellij.ui.dsl.builder.bindText
5751
import com.intellij.util.application
5852
import com.intellij.util.ui.AsyncProcessIcon
5953
import javax.swing.JLabel
60-
import javax.swing.SwingUtilities
6154
import kotlinx.coroutines.Dispatchers
6255
import kotlinx.coroutines.Job
6356
import kotlinx.coroutines.cancel
6457
import kotlinx.coroutines.launch
65-
import org.jetbrains.kotlin.descriptors.Modality
6658

6759
/**
6860
* The step to select a custom template repo.
@@ -75,7 +67,7 @@ class CustomPlatformStep(
7567
val creatorUiScope = TemplateService.instance.scope("MinecraftDev Creator UI")
7668
val templateRepos = MinecraftSettings.instance.creatorTemplateRepos
7769

78-
val templateRepoProperty = propertyGraph.property(
70+
val templateRepoProperty = propertyGraph.property<MinecraftSettings.TemplateRepo>(
7971
templateRepos.firstOrNull() ?: MinecraftSettings.TemplateRepo.makeBuiltinRepo()
8072
)
8173
var templateRepo by templateRepoProperty
@@ -87,19 +79,19 @@ class CustomPlatformStep(
8779
lateinit var availableGroupsSegmentedButton: SegmentedButton<String>
8880
lateinit var availableTemplatesSegmentedButton: SegmentedButton<LoadedTemplate>
8981

90-
val selectedGroupProperty = propertyGraph.property("")
82+
val selectedGroupProperty = propertyGraph.property<String>("")
9183
var selectedGroup by selectedGroupProperty
9284
val selectedTemplateProperty = propertyGraph.property<LoadedTemplate>(EmptyLoadedTemplate)
9385
var selectedTemplate by selectedTemplateProperty
9486

95-
val templateProvidersLoadingProperty = propertyGraph.property(true)
87+
val templateProvidersLoadingProperty = propertyGraph.property<Boolean>(true)
9688
val templateProvidersTextProperty = propertyGraph.property("")
9789
val templateProvidersText2Property = propertyGraph.property("")
9890
lateinit var templateProvidersProcessIcon: Cell<AsyncProcessIcon>
9991

100-
val templateLoadingProperty = propertyGraph.property(false)
101-
val templateLoadingTextProperty = propertyGraph.property("")
102-
val templateLoadingText2Property = propertyGraph.property("")
92+
val templateLoadingProperty = propertyGraph.property<Boolean>(false)
93+
val templateLoadingTextProperty = propertyGraph.property<String>("")
94+
val templateLoadingText2Property = propertyGraph.property<String>("")
10395
lateinit var templatePropertiesProcessIcon: Cell<AsyncProcessIcon>
10496
lateinit var noTemplatesAvailable: Cell<JLabel>
10597
var templateLoadingJob: Job? = null
@@ -256,9 +248,11 @@ class CustomPlatformStep(
256248
templateLoadingTextProperty.set(MCDevBundle("creator.step.generic.load_template.message"))
257249
templateLoadingProperty.set(true)
258250

259-
tryWriteSafeContext(context.modalityState) {
260-
VirtualFileManager.getInstance().syncRefresh()
261-
}
251+
// For some reason syncRefresh doesn't play nice with writeAction() coroutines so we do it beforehand
252+
application.invokeAndWait(
253+
{ runWriteAction { VirtualFileManager.getInstance().syncRefresh() } },
254+
context.modalityState
255+
)
262256

263257
val dialogCoroutineContext = context.modalityState.asContextElement()
264258
val uiContext = dialogCoroutineContext + Dispatchers.EDT

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ import javax.swing.ListCellRenderer
6767
import kotlin.io.path.absolutePathString
6868
import kotlin.io.path.exists
6969
import kotlin.io.path.writeBytes
70-
import kotlinx.coroutines.Dispatchers
71-
import kotlinx.coroutines.withContext
7270

7371
open class RemoteTemplateProvider : TemplateProvider {
7472

@@ -150,20 +148,18 @@ open class RemoteTemplateProvider : TemplateProvider {
150148
context: WizardContext,
151149
repo: MinecraftSettings.TemplateRepo,
152150
rawInnerPath: String
153-
): List<LoadedTemplate> = withContext(Dispatchers.IO) { // don't run on EDT
151+
): List<LoadedTemplate> {
154152
val remoteRootPath = RemoteTemplateRepo.getDestinationZip(repo.name)
155153
if (!remoteRootPath.exists()) {
156-
return@withContext emptyList()
154+
return emptyList()
157155
}
158156

159157
val archiveRoot = remoteRootPath.absolutePathString() + JarFileSystem.JAR_SEPARATOR
160158

161159
val fs = JarFileSystem.getInstance()
162-
163160
val rootFile = fs.refreshAndFindFileByPath(archiveRoot)
164-
?: return@withContext emptyList()
161+
?: return emptyList()
165162
val modalityState = context.modalityState
166-
167163
rootFile.refreshSync(modalityState)
168164

169165
val innerPath = replaceVariables(rawInnerPath)
@@ -174,10 +170,10 @@ open class RemoteTemplateProvider : TemplateProvider {
174170
}
175171

176172
if (repoRoot == null) {
177-
return@withContext emptyList()
173+
return emptyList()
178174
}
179175

180-
return@withContext TemplateProvider.findTemplates(modalityState, repoRoot)
176+
return TemplateProvider.findTemplates(modalityState, repoRoot)
181177
}
182178

183179
private fun replaceVariables(originalRepoUrl: String): String =
@@ -271,7 +267,7 @@ open class RemoteTemplateProvider : TemplateProvider {
271267
index: Int,
272268
isSelected: Boolean,
273269
cellHasFocus: Boolean
274-
): Component {
270+
): Component? {
275271
text = value?.displayname?.let(MCDevBundle::invoke) ?: value?.name?.capitalize().toString()
276272
return this
277273
}

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import com.intellij.serviceContainer.BaseKeyedLazyInstance
4545
import com.intellij.util.KeyedLazyInstance
4646
import com.intellij.util.xmlb.annotations.Attribute
4747
import java.util.ResourceBundle
48-
import java.util.concurrent.TimeUnit
4948
import javax.swing.JComponent
50-
import org.jetbrains.concurrency.runAsync
49+
import kotlinx.coroutines.Dispatchers
50+
import kotlinx.coroutines.runBlocking
5151

5252
/**
5353
* Extensions responsible for creating a [TemplateDescriptor] based on whatever data it is provided in its configuration
@@ -75,12 +75,13 @@ interface TemplateProvider {
7575

7676
fun getAllKeys() = EP_NAME.extensionList.mapNotNull { it.key }
7777

78-
fun findTemplates(
78+
suspend fun findTemplates(
7979
modalityState: ModalityState,
8080
repoRoot: VirtualFile,
8181
templates: MutableList<VfsLoadedTemplate> = mutableListOf(),
82-
bundle: ResourceBundle? = loadMessagesBundle(modalityState, repoRoot)
82+
bundle: ResourceBundle? = null
8383
): List<VfsLoadedTemplate> {
84+
val bundle = bundle ?: loadMessagesBundle(modalityState, repoRoot)
8485
val templatesToLoad = mutableListOf<VirtualFile>()
8586
val visitor = object : VirtualFileVisitor<Unit>() {
8687
override fun visitFile(file: VirtualFile): Boolean {
@@ -116,7 +117,7 @@ interface TemplateProvider {
116117
return templates
117118
}
118119

119-
fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try {
120+
suspend fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try {
120121
val locale = DynamicBundle.getLocale()
121122
// Simplified bundle resolution, but covers all the most common cases
122123
val baseBundle = doLoadMessageBundle(
@@ -143,7 +144,7 @@ interface TemplateProvider {
143144
null
144145
}
145146

146-
private fun doLoadMessageBundle(
147+
private suspend fun doLoadMessageBundle(
147148
file: VirtualFile?,
148149
modalityState: ModalityState,
149150
parent: ResourceBundle?
@@ -153,9 +154,8 @@ interface TemplateProvider {
153154
}
154155

155156
try {
156-
return runAsync {
157-
file.inputStream.reader().use { TemplateResourceBundle(it, parent) }
158-
}.blockingGet(20, TimeUnit.MILLISECONDS)
157+
return file.refreshSync(modalityState)
158+
?.inputStream?.reader()?.use { TemplateResourceBundle(it, parent) }
159159
} catch (t: Throwable) {
160160
if (t is ControlFlowException) {
161161
return parent
@@ -167,19 +167,15 @@ interface TemplateProvider {
167167
return parent
168168
}
169169

170-
fun createVfsLoadedTemplate(
170+
suspend fun createVfsLoadedTemplate(
171171
modalityState: ModalityState,
172172
templateRoot: VirtualFile,
173173
descriptorFile: VirtualFile,
174174
tooltip: String? = null,
175175
bundle: ResourceBundle? = null
176176
): VfsLoadedTemplate? {
177-
var descriptor = runCatching {
178-
runAsync {
179-
descriptorFile.refreshSync(modalityState)
180-
Gson().fromJson<TemplateDescriptor>(descriptorFile.readText())
181-
}.blockingGet(100, TimeUnit.MILLISECONDS)
182-
}.getOrNull() ?: return null
177+
descriptorFile.refreshSync(modalityState)
178+
var descriptor = Gson().fromJson<TemplateDescriptor>(descriptorFile.readText())
183179
if (descriptor.version != TemplateDescriptor.FORMAT_VERSION) {
184180
thisLogger().warn("Cannot handle template ${descriptorFile.path} of version ${descriptor.version}")
185181
return null
@@ -198,7 +194,7 @@ interface TemplateProvider {
198194
descriptor.translateOrNull("platform.${labelKey.lowercase()}.label") ?: descriptor.translate(labelKey)
199195

200196
if (descriptor.inherit != null) {
201-
val parent = templateRoot.findFileByRelativePath(descriptor.inherit)
197+
val parent = templateRoot.findFileByRelativePath(descriptor.inherit!!)
202198
if (parent != null) {
203199
parent.refresh(false, false)
204200
val parentDescriptor = Gson().fromJson<TemplateDescriptor>(parent.readText())
@@ -235,5 +231,5 @@ class TemplateProviderBean : BaseKeyedLazyInstance<TemplateProvider>(), KeyedLaz
235231

236232
override fun getKey(): String = name
237233

238-
override fun getImplementationClassName(): String = implementation
234+
override fun getImplementationClassName(): String? = implementation
239235
}

src/main/kotlin/platform/mixin/expression/MEExpressionCompletionUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ object MEExpressionCompletionUtil {
992992
val locals = localsHere.filter { it.index == index }
993993

994994
val elementFactory = JavaPsiFacade.getElementFactory(project)
995-
val hasNamedLocalVariables = mixinClass.findModule()?.hasNamedLocalVariables(targetClass.name.replace('/', '.')) != false
995+
val hasNamedLocalVariables = mixinClass.hasNamedLocalVariables(targetClass.name.replace('/', '.'))
996996

997997
return locals.map { localVariable ->
998998
val localPsiType = if (localVariable.signature != null) {

0 commit comments

Comments
 (0)