From 5530d6aa6b2ac1df8f851198cc4f9ab13289a644 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 17 Aug 2022 18:12:42 -0500 Subject: [PATCH 1/7] Switch to new alpha K2 compiler --- build.gradle.kts | 3 ++- .../platform/mcp/at/completion/AtCompletionContributor.kt | 2 +- src/main/kotlin/translations/TranslationFiles.kt | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a31318625..aa5f264fc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -193,7 +193,8 @@ tasks.withType().configureEach { tasks.withType().configureEach { kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() - freeCompilerArgs = listOf("-Xjvm-default=all") + freeCompilerArgs = listOf("-Xuse-k2", "-Xjvm-default=all", "-Xjdk-release=11") + kotlinDaemonJvmArguments.add("-Xmx1G") } } diff --git a/src/main/kotlin/platform/mcp/at/completion/AtCompletionContributor.kt b/src/main/kotlin/platform/mcp/at/completion/AtCompletionContributor.kt index de7a078bc..eea8a59dd 100644 --- a/src/main/kotlin/platform/mcp/at/completion/AtCompletionContributor.kt +++ b/src/main/kotlin/platform/mcp/at/completion/AtCompletionContributor.kt @@ -204,7 +204,7 @@ class AtCompletionContributor : CompletionContributor() { val entry = memberName.parent as? AtEntry ?: return - val entryClass = entry.className.classNameValue ?: return + val entryClass = entry.className?.classNameValue ?: return val module = ModuleUtilCore.findModuleForPsiElement(memberName) ?: return val project = module.project diff --git a/src/main/kotlin/translations/TranslationFiles.kt b/src/main/kotlin/translations/TranslationFiles.kt index 5ab5c8e40..977d51d8c 100644 --- a/src/main/kotlin/translations/TranslationFiles.kt +++ b/src/main/kotlin/translations/TranslationFiles.kt @@ -59,8 +59,12 @@ object TranslationFiles { file?.nameWithoutExtension?.lowercase(Locale.ENGLISH) tailrec fun seekTranslation(element: PsiElement): PsiNamedElement? { - return toTranslation(element)?.let { element as? PsiNamedElement } - ?: seekTranslation(element.parent ?: return null) + // don't use elvis here, K2 doesn't think it's a tail recursive call if you do + val res = toTranslation(element)?.let { element as? PsiNamedElement } + if (res != null) { + return res + } + return seekTranslation(element.parent ?: return null) } fun toTranslation(element: PsiElement): Translation? = From 58e6b4d7ae5c1c5f87d8482b3fc5e015151913dc Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 17 Aug 2022 18:42:55 -0500 Subject: [PATCH 2/7] Use sentence capitalization in NBTT annotation types --- src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt b/src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt index 7f495244e..2acafa2bc 100644 --- a/src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt +++ b/src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt @@ -13,7 +13,6 @@ package com.demonwav.mcdev.nbt.lang.colors import com.demonwav.mcdev.nbt.lang.gen.psi.NbttByte import com.demonwav.mcdev.nbt.lang.gen.psi.NbttDouble import com.demonwav.mcdev.nbt.lang.gen.psi.NbttFloat -import com.demonwav.mcdev.nbt.lang.gen.psi.NbttInt import com.demonwav.mcdev.nbt.lang.gen.psi.NbttLong import com.demonwav.mcdev.nbt.lang.gen.psi.NbttShort import com.demonwav.mcdev.nbt.lang.gen.psi.NbttString @@ -70,12 +69,11 @@ class NbttAnnotator : Annotator { private fun annotateTypes(element: PsiElement, holder: AnnotationHolder) { when (element) { - is NbttByte -> holder.newAnnotation(HighlightSeverity.INFORMATION, "byte").range(element).create() - is NbttShort -> holder.newAnnotation(HighlightSeverity.INFORMATION, "short").range(element).create() - is NbttInt -> holder.newAnnotation(HighlightSeverity.INFORMATION, "int").range(element).create() - is NbttLong -> holder.newAnnotation(HighlightSeverity.INFORMATION, "long").range(element).create() - is NbttFloat -> holder.newAnnotation(HighlightSeverity.INFORMATION, "float").range(element).create() - is NbttDouble -> holder.newAnnotation(HighlightSeverity.INFORMATION, "double").range(element).create() + is NbttByte -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: byte").range(element).create() + is NbttShort -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: short").range(element).create() + is NbttLong -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: long").range(element).create() + is NbttFloat -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: float").range(element).create() + is NbttDouble -> holder.newAnnotation(HighlightSeverity.INFORMATION, "Type: double").range(element).create() } } } From 53a0fd1771158e85867783c44dbb6c5e5b080923 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 17 Aug 2022 18:52:31 -0500 Subject: [PATCH 3/7] Workaround bug in IntelliJ error highlighting --- src/main/kotlin/translations/TranslationFiles.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/translations/TranslationFiles.kt b/src/main/kotlin/translations/TranslationFiles.kt index 977d51d8c..def757b41 100644 --- a/src/main/kotlin/translations/TranslationFiles.kt +++ b/src/main/kotlin/translations/TranslationFiles.kt @@ -192,6 +192,9 @@ object TranslationFiles { is FileEntry.Comment -> result.append("# ${entry.text}\n") is FileEntry.Translation -> result.append("${entry.key}=${entry.text}\n") FileEntry.EmptyLine -> result.append('\n') + // TODO: IntelliJ shows a false error here without the `else`. The compiler doesn't care because + // FileEntry is a sealed class. When this bug in IntelliJ is fixed, remove this `else`. + else -> {} } } @@ -226,6 +229,9 @@ object TranslationFiles { result.append("\"${StringUtil.escapeStringCharacters(entry.text)}\",\n") } FileEntry.EmptyLine -> result.append('\n') + // TODO: IntelliJ shows a false error here without the `else`. The compiler doesn't care because + // FileEntry is a sealed class. When this bug in IntelliJ is fixed, remove this `else`. + else -> {} } } From fe75ec4fcca11966c31f47e24dac4100a63206a1 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 17 Aug 2022 19:56:04 -0500 Subject: [PATCH 4/7] Don't use EDT coroutine scope --- src/main/kotlin/util/utils.kt | 7 ++----- src/test/kotlin/framework/EdtInterceptor.kt | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/util/utils.kt b/src/main/kotlin/util/utils.kt index 2a8640783..cb47bd5dd 100644 --- a/src/main/kotlin/util/utils.kt +++ b/src/main/kotlin/util/utils.kt @@ -16,7 +16,6 @@ import com.intellij.lang.java.lexer.JavaLexer import com.intellij.openapi.application.AppUIExecutor import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.impl.coroutineDispatchingContext import com.intellij.openapi.application.runReadAction import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.module.Module @@ -33,8 +32,6 @@ import com.intellij.pom.java.LanguageLevel import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFile import java.util.Locale -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking inline fun runWriteTask(crossinline func: () -> T): T { return invokeAndWait { @@ -92,8 +89,8 @@ fun invokeLaterAny(func: () -> Unit) { ApplicationManager.getApplication().invokeLater(func, ModalityState.any()) } -fun edtCoroutineScope(block: suspend CoroutineScope.() -> T): T { - return runBlocking(AppUIExecutor.onUiThread().coroutineDispatchingContext(), block) +fun invokeEdt(block: () -> T): T { + return AppUIExecutor.onUiThread().submit(block).get() } inline fun PsiFile.runWriteAction(crossinline func: () -> T) = diff --git a/src/test/kotlin/framework/EdtInterceptor.kt b/src/test/kotlin/framework/EdtInterceptor.kt index 8ae91d6f8..1d41d0192 100644 --- a/src/test/kotlin/framework/EdtInterceptor.kt +++ b/src/test/kotlin/framework/EdtInterceptor.kt @@ -10,7 +10,7 @@ package com.demonwav.mcdev.framework -import com.demonwav.mcdev.util.edtCoroutineScope +import com.demonwav.mcdev.util.invokeEdt import java.lang.reflect.Method import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.api.extension.InvocationInterceptor @@ -50,7 +50,7 @@ class EdtInterceptor : InvocationInterceptor { return } - val thrown = edtCoroutineScope { + val thrown = invokeEdt { runCatching { invocation.proceed() }.exceptionOrNull() From 42b8792e158fcc98a6b3c3ee545284e888fecfec Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 17 Aug 2022 20:14:04 -0500 Subject: [PATCH 5/7] Don't always show stacktrace I think this is breaking TeamCity's ability to find tests on failure since it will still print a stacktrace on test failure. --- settings.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 6863e28a0..258412994 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,8 +10,6 @@ rootProject.name = "MinecraftDev" -gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL - enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include("mixin-test-data") From bb1e1d6fca14deb0756c02b656065bbd6cdccee4 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 25 Sep 2022 11:48:10 +0200 Subject: [PATCH 6/7] Add 2022.3 nightly builds --- readme.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ef2d691d9..1b79908ee 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ Minecraft Development for IntelliJ Teamcity Build Status - Nightly Builds + Nightly Builds 2021.2 2021.2 Nightly Status @@ -28,6 +28,10 @@ Minecraft Development for IntelliJ 2022.2 2022.2 Nightly Status + + 2022.3 + 2022.3 Nightly Status + OS Tests @@ -36,7 +40,7 @@ Minecraft Development for IntelliJ -Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.19-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327) +Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.20-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327) ---------------------- From b1c99b4b0060310ef09ee8cd1b3ac44434370b57 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sun, 25 Sep 2022 12:28:12 +0200 Subject: [PATCH 7/7] Update intellij-gradle-plugin to 1.9.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index aa5f264fc..d08825dcf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ plugins { mcdev groovy idea - id("org.jetbrains.intellij") version "1.8.0" + id("org.jetbrains.intellij") version "1.9.0" id("org.cadixdev.licenser") id("org.jlleitschuh.gradle.ktlint") version "10.3.0" }