diff --git a/build.gradle.kts b/build.gradle.kts index 982616d5b..9c432d265 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" } @@ -194,7 +194,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/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) ---------------------- 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") 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() } } } 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..def757b41 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? = @@ -188,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 -> {} } } @@ -222,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 -> {} } } 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()