Skip to content

Commit

Permalink
Merge branch '2021.2' into 2021.3
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Sep 25, 2022
2 parents 472b4e0 + b1c99b4 commit 9931589
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 23 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -194,7 +194,8 @@ tasks.withType<JavaCompile>().configureEach {
tasks.withType<KotlinCompile>().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")
}
}

Expand Down
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Minecraft Development for IntelliJ
<td colspan="2"><a href="https://ci.demonwav.com/viewType.html?buildTypeId=MinecraftDev_Build"><img src="https://tc.demonwav.com/app/rest/builds/buildType:(id:MinecraftDev_Build)/statusIcon.svg" alt="Teamcity Build Status" /></a></td>
</tr>
<tr>
<td align="right" rowspan="4"><b>Nightly Builds</b></td>
<td align="right" rowspan="5"><b>Nightly Builds</b></td>
<td align="left">2021.2</td>
<td align="left"><a href="https://ci.denwav.dev/viewType.html?buildTypeId=MinecraftDev_Nightly_20212"><img src="https://ci.denwav.dev/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20212)/statusIcon.svg" alt="2021.2 Nightly Status" /></a></td>
</tr>
Expand All @@ -28,6 +28,10 @@ Minecraft Development for IntelliJ
<td align="left">2022.2</td>
<td align="left"><a href="https://ci.denwav.dev/viewType.html?buildTypeId=MinecraftDev_Nightly_20222"><img src="https://ci.denwav.dev/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20222)/statusIcon.svg" alt="2022.2 Nightly Status" /></a></td>
</tr>
<tr>
<td align="left">2022.3</td>
<td align="left"><a href="https://ci.denwav.dev/viewType.html?buildTypeId=MinecraftDev_Nightly_20223"><img src="https://ci.denwav.dev/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20223)/statusIcon.svg" alt="2022.3 Nightly Status" /></a></td>
</tr>
<tr>
<td align="right"><b>OS Tests</b></td>
<td align="left" colspan="2">
Expand All @@ -36,7 +40,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

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)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

rootProject.name = "MinecraftDev"

gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include("mixin-test-data")
12 changes: 5 additions & 7 deletions src/main/kotlin/nbt/lang/colors/NbttAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/main/kotlin/translations/TranslationFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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? =
Expand Down Expand Up @@ -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 -> {}
}
}

Expand Down Expand Up @@ -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 -> {}
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/main/kotlin/util/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <T : Any?> runWriteTask(crossinline func: () -> T): T {
return invokeAndWait {
Expand Down Expand Up @@ -92,8 +89,8 @@ fun invokeLaterAny(func: () -> Unit) {
ApplicationManager.getApplication().invokeLater(func, ModalityState.any())
}

fun <T> edtCoroutineScope(block: suspend CoroutineScope.() -> T): T {
return runBlocking(AppUIExecutor.onUiThread().coroutineDispatchingContext(), block)
fun <T> invokeEdt(block: () -> T): T {
return AppUIExecutor.onUiThread().submit(block).get()
}

inline fun <T : Any?> PsiFile.runWriteAction(crossinline func: () -> T) =
Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/framework/EdtInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +50,7 @@ class EdtInterceptor : InvocationInterceptor {
return
}

val thrown = edtCoroutineScope {
val thrown = invokeEdt {
runCatching {
invocation.proceed()
}.exceptionOrNull()
Expand Down

0 comments on commit 9931589

Please sign in to comment.