Skip to content

Commit b0c7c8c

Browse files
committed
Merge branch '2022.3' into 2023.1
# Conflicts: # src/main/kotlin/creator/step/AbstractLatentStep.kt
2 parents 7d4ba10 + b95677e commit b0c7c8c

File tree

13 files changed

+45
-64
lines changed

13 files changed

+45
-64
lines changed

src/main/kotlin/creator/step/AbstractLatentStep.kt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ abstract class AbstractLatentStep<T>(parent: NewProjectWizardStep) : AbstractNew
8484
return@launch
8585
}
8686

87-
val result = asyncIO {
87+
val (result: T?, errorMessage: String?) = asyncIO {
8888
try {
89-
computeData()
89+
computeData() to null
9090
} catch (e: Throwable) {
91-
LOGGER.error(e)
92-
null
91+
LOGGER.warn("computeData failed", e)
92+
null to e.message
9393
}
9494
}.await()
9595

@@ -105,17 +105,11 @@ abstract class AbstractLatentStep<T>(parent: NewProjectWizardStep) : AbstractNew
105105
if (result == null) {
106106
placeholder.component = panel {
107107
row {
108-
val label = label(MCDevBundle("creator.ui.generic_validation_failure.message", description))
108+
val labelValidationText =
109+
MCDevBundle("creator.ui.generic_validation_failure.message", description, errorMessage)
110+
val label = label(labelValidationText)
109111
.validationRequestor(WHEN_GRAPH_PROPAGATION_FINISHED(propertyGraph))
110-
.validation(
111-
DialogValidation {
112-
val labelValidationText = MCDevBundle(
113-
"creator.ui.generic_validation_failure.message",
114-
description
115-
)
116-
ValidationInfo(labelValidationText)
117-
}
118-
)
112+
.validation(DialogValidation { ValidationInfo(labelValidationText) })
119113
label.component.foreground = JBColor.RED
120114
}
121115
}

src/main/kotlin/errorreporter/ErrorReporter.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class ErrorReporter : ErrorReportSubmitter() {
4444
private val ignoredErrorMessages = listOf(
4545
"Key com.demonwav.mcdev.translations.TranslationFoldingSettings duplicated",
4646
"Inspection #EntityConstructor has no description",
47+
"VFS name enumerator corrupted",
48+
"PersistentEnumerator storage corrupted",
4749
)
4850
override fun getReportActionText() = MCDevBundle("error_reporter.submit.action")
4951

src/main/kotlin/platform/bukkit/creator/ui-steps.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ abstract class AbstractBukkitPlatformStep(
7878
override val description = "download versions"
7979

8080
override suspend fun computeData() = coroutineScope {
81-
try {
82-
asyncIO { getVersionSelector(platform) }.await()
83-
} catch (e: Throwable) {
84-
null
85-
}
81+
asyncIO { getVersionSelector(platform) }.await()
8682
}
8783

8884
override fun createStep(data: PlatformVersion) =

src/main/kotlin/platform/bukkit/inspection/BukkitListenerImplementedInspection.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.siyeh.ig.BaseInspection
3030
import com.siyeh.ig.BaseInspectionVisitor
3131
import com.siyeh.ig.InspectionGadgetsFix
3232
import org.jetbrains.annotations.Nls
33+
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
3334

3435
class BukkitListenerImplementedInspection : BaseInspection() {
3536

@@ -44,10 +45,10 @@ class BukkitListenerImplementedInspection : BaseInspection() {
4445
"All Bukkit @EventHandler methods must reside in a class that implements Listener."
4546

4647
override fun buildFix(vararg infos: Any): InspectionGadgetsFix {
48+
val classPointer = (infos[0] as PsiClass).createSmartPointer()
4749
return object : InspectionGadgetsFix() {
4850
override fun doFix(project: Project, descriptor: ProblemDescriptor) {
49-
val psiClass = infos[0] as PsiClass
50-
psiClass.addImplements(BukkitConstants.LISTENER_CLASS)
51+
classPointer.element?.addImplements(BukkitConstants.LISTENER_CLASS)
5152
}
5253

5354
@Nls
@@ -61,11 +62,7 @@ class BukkitListenerImplementedInspection : BaseInspection() {
6162
override fun buildVisitor(): BaseInspectionVisitor {
6263
return object : BaseInspectionVisitor() {
6364
override fun visitClass(aClass: PsiClass) {
64-
if (
65-
aClass.methods.none {
66-
it.modifierList.findAnnotation(BukkitConstants.HANDLER_ANNOTATION) != null
67-
}
68-
) {
65+
if (aClass.methods.none { it.hasAnnotation(BukkitConstants.HANDLER_ANNOTATION) }) {
6966
return
7067
}
7168

src/main/kotlin/platform/bungeecord/creator/ui-steps.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ abstract class AbstractBungeePlatformStep(
7272
override val description = "download versions"
7373

7474
override suspend fun computeData() = coroutineScope {
75-
try {
76-
asyncIO { getVersionSelector(platform) }.await()
77-
} catch (e: Throwable) {
78-
null
79-
}
75+
asyncIO { getVersionSelector(platform) }.await()
8076
}
8177

8278
override fun createStep(data: PlatformVersion) =

src/main/kotlin/platform/bungeecord/inspection/BungeeCordListenerImplementedInspection.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.siyeh.ig.BaseInspection
3030
import com.siyeh.ig.BaseInspectionVisitor
3131
import com.siyeh.ig.InspectionGadgetsFix
3232
import org.jetbrains.annotations.Nls
33+
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
3334

3435
class BungeeCordListenerImplementedInspection : BaseInspection() {
3536

@@ -43,10 +44,10 @@ class BungeeCordListenerImplementedInspection : BaseInspection() {
4344
"All BungeeCord @EventHandler methods must reside in a class that implements Listener."
4445

4546
override fun buildFix(vararg infos: Any): InspectionGadgetsFix {
47+
val classPointer = (infos[0] as PsiClass).createSmartPointer()
4648
return object : InspectionGadgetsFix() {
4749
override fun doFix(project: Project, descriptor: ProblemDescriptor) {
48-
val psiClass = infos[0] as PsiClass
49-
psiClass.addImplements(BungeeCordConstants.LISTENER_CLASS)
50+
classPointer.element?.addImplements(BungeeCordConstants.LISTENER_CLASS)
5051
}
5152

5253
@Nls

src/main/kotlin/platform/mcp/inspections/StackEmptyInspection.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.siyeh.ig.BaseInspection
4040
import com.siyeh.ig.BaseInspectionVisitor
4141
import com.siyeh.ig.InspectionGadgetsFix
4242
import org.jetbrains.annotations.Nls
43+
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
4344

4445
class StackEmptyInspection : BaseInspection() {
4546
companion object {
@@ -63,14 +64,17 @@ class StackEmptyInspection : BaseInspection() {
6364
" the stack should still be considered empty. Instead, isEmpty() should be called."
6465

6566
override fun buildFix(vararg infos: Any): InspectionGadgetsFix {
67+
val compareExpressionPointer = (infos[0] as PsiExpression).createSmartPointer()
68+
val binaryExpressionPointer = (infos[2] as PsiBinaryExpression).createSmartPointer()
6669
return object : InspectionGadgetsFix() {
6770
override fun getFamilyName() = "Replace with .isEmpty()"
6871

6972
override fun doFix(project: Project, descriptor: ProblemDescriptor) {
70-
val compareExpression = infos[0] as PsiExpression
71-
val binaryExpression = infos[2] as PsiBinaryExpression
7273
val elementFactory = JavaPsiFacade.getElementFactory(project)
7374

75+
val compareExpression = compareExpressionPointer.element ?: return
76+
val binaryExpression = binaryExpressionPointer.element ?: return
77+
7478
val mappedIsEmpty = compareExpression.findModule()?.getMappedMethod(IS_EMPTY_SRG)?.name ?: "isEmpty"
7579

7680
var expressionText = "${compareExpression.text}.$mappedIsEmpty()"

src/main/kotlin/platform/mixin/inspection/suppress/MixinClassCastInspectionSuppressor.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,25 @@ import com.intellij.psi.PsiExpression
3939
import com.intellij.psi.PsiInstanceOfExpression
4040
import com.intellij.psi.PsiType
4141
import com.intellij.psi.PsiTypeCastExpression
42+
import com.intellij.psi.PsiTypeTestPattern
4243
import com.intellij.psi.util.PsiUtil
4344

4445
/**
45-
* Looks for `ConstantConditions` warnings on type casts and checks if they are casts to interfaces introduced by mixins
46+
* Looks for `ConstantConditions`, `ConstantValue` and `DataFlowIssue` warnings on type casts and checks if they are
47+
* casts to interfaces introduced by mixins
4648
*/
4749
class MixinClassCastInspectionSuppressor : InspectionSuppressor {
4850

4951
override fun isSuppressedFor(element: PsiElement, toolId: String): Boolean {
50-
if (toolId != INSPECTION) {
52+
if (toolId !in INSPECTIONS) {
5153
return false
5254
}
5355

5456
// check instanceof
5557
if (element is PsiInstanceOfExpression) {
56-
val castType = element.checkType?.type ?: return false
58+
val castType = element.checkType?.type
59+
?: (element.pattern as? PsiTypeTestPattern)?.checkType?.type
60+
?: return false
5761
var operand = PsiUtil.skipParenthesizedExprDown(element.operand) ?: return false
5862
while (operand is PsiTypeCastExpression) {
5963
operand = PsiUtil.skipParenthesizedExprDown(operand.operand) ?: return false
@@ -126,6 +130,6 @@ class MixinClassCastInspectionSuppressor : InspectionSuppressor {
126130
SuppressQuickFix.EMPTY_ARRAY
127131

128132
companion object {
129-
private const val INSPECTION = "ConstantConditions"
133+
private val INSPECTIONS = setOf("ConstantConditions", "ConstantValue", "DataFlowIssue")
130134
}
131135
}

src/main/kotlin/platform/mixin/util/Mixin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fun isAssignable(left: PsiType, right: PsiType): Boolean {
201201
private fun isClassAssignable(leftClass: PsiClass, rightClass: PsiClass): Boolean {
202202
var result = false
203203
InheritanceUtil.processSupers(rightClass, true) {
204-
if (it == leftClass) {
204+
if (it.qualifiedName == leftClass.qualifiedName) {
205205
result = true
206206
false
207207
} else {

src/main/kotlin/platform/sponge/SpongeVersion.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,12 @@
2020

2121
package com.demonwav.mcdev.platform.sponge
2222

23-
import com.demonwav.mcdev.creator.getText
24-
import com.demonwav.mcdev.util.fromJson
25-
import com.google.gson.Gson
26-
import com.intellij.openapi.diagnostic.logger
23+
import com.demonwav.mcdev.creator.getVersionJson
2724

2825
data class SpongeVersion(var versions: LinkedHashMap<String, String>, var selectedIndex: Int) {
2926
companion object {
30-
private val LOGGER = logger<SpongeVersion>()
31-
3227
suspend fun downloadData(): SpongeVersion? {
33-
return try {
34-
val text = getText("sponge_v2.json")
35-
Gson().fromJson(text, SpongeVersion::class)
36-
} catch (e: Exception) {
37-
LOGGER.error("Failed to download Sponge version json", e)
38-
null
39-
}
28+
return getVersionJson<SpongeVersion>("sponge_v2.json")
4029
}
4130
}
4231
}

0 commit comments

Comments
 (0)