Skip to content

Commit ed21b03

Browse files
committed
Merge branch '2023.1' into 2023.2
2 parents 7cf5114 + ef3663e commit ed21b03

21 files changed

+203
-54
lines changed

externalAnnotations/net/minecraft/client/annotations.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<item name="net.minecraft.client.KeyMapping KeyMapping(java.lang.String, com.mojang.blaze3d.platform.InputConstants.Type, int, java.lang.String) 3">
3232
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
3333
</item>
34+
35+
<!--region Forge -->
3436
<item name="net.minecraft.client.KeyMapping KeyMapping(java.lang.String, net.minecraftforge.client.settings.IKeyConflictContext, com.mojang.blaze3d.platform.InputConstants.Type, int, java.lang.String) 0">
3537
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
3638
</item>
@@ -55,4 +57,5 @@
5557
<item name="net.minecraft.client.KeyMapping KeyMapping(java.lang.String, net.minecraftforge.client.settings.IKeyConflictContext, net.minecraftforge.client.settings.KeyModifier, com.mojang.blaze3d.platform.InputConstants.Key, java.lang.String) 4">
5658
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
5759
</item>
60+
<!--endregion-->
5861
</root>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
Minecraft Development for IntelliJ
3+
4+
https://mcdev.io/
5+
6+
Copyright (C) 2023 minecraft-dev
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as published
10+
by the Free Software Foundation, version 3.0 only.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
-->
20+
21+
<!-- Yarn mappings -->
22+
23+
<root>
24+
<item name="net.minecraft.client.option.KeyBinding KeyBinding(java.lang.String, int, java.lang.String) 0">
25+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
26+
</item>
27+
<item name="net.minecraft.client.option.KeyBinding KeyBinding(java.lang.String, int, java.lang.String) 2">
28+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
29+
</item>
30+
<item name="net.minecraft.client.option.KeyBinding KeyBinding(java.lang.String, com.mojang.blaze3d.platform.InputConstants.Type, int, java.lang.String) 0">
31+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
32+
</item>
33+
<item name="net.minecraft.client.option.KeyBinding KeyBinding(java.lang.String, com.mojang.blaze3d.platform.InputConstants.Type, int, java.lang.String) 3">
34+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
35+
</item>
36+
</root>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
Minecraft Development for IntelliJ
3+
4+
https://mcdev.io/
5+
6+
Copyright (C) 2023 minecraft-dev
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as published
10+
by the Free Software Foundation, version 3.0 only.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
-->
20+
21+
<!-- Yarn mappings -->
22+
<root>
23+
<item name="net.minecraft.client.resource.language.I18n java.lang.String translate(java.lang.String, java.lang.Object...) 0">
24+
<annotation name="com.demonwav.mcdev.annotations.Translatable">
25+
<val name="foldMethod" val="true"/>
26+
</annotation>
27+
</item>
28+
<item name="net.minecraft.client.resource.language.I18n boolean hasTranslation(java.lang.String) 0">
29+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
30+
</item>
31+
</root>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--
2+
Minecraft Development for IntelliJ
3+
4+
https://mcdev.io/
5+
6+
Copyright (C) 2023 minecraft-dev
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU Lesser General Public License as published
10+
by the Free Software Foundation, version 3.0 only.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
-->
20+
21+
<!-- Yarn mappings -->
22+
23+
<root>
24+
<item name="net.minecraft.text.TranslatableText TranslatableText(java.lang.String) 0">
25+
<annotation name="com.demonwav.mcdev.annotations.Translatable">
26+
<val name="foldMethod" val="true"/>
27+
</annotation>
28+
</item>
29+
<item name="net.minecraft.text.TranslatableText TranslatableText(java.lang.String, java.lang.Object...) 0">
30+
<annotation name="com.demonwav.mcdev.annotations.Translatable">
31+
<val name="foldMethod" val="true"/>
32+
</annotation>
33+
</item>
34+
<item name="net.minecraft.text.Text net.minecraft.text.MutableText translatable(java.lang.String) 0">
35+
<annotation name="com.demonwav.mcdev.annotations.Translatable">
36+
<val name="foldMethod" val="true"/>
37+
</annotation>
38+
</item>
39+
<item name="net.minecraft.text.Text net.minecraft.text.MutableText translatable(java.lang.String, java.lang.Object...) 0">
40+
<annotation name="com.demonwav.mcdev.annotations.Translatable">
41+
<val name="foldMethod" val="true"/>
42+
</annotation>
43+
</item>
44+
<item name="net.minecraft.text.Text net.minecraft.text.MutableText translatableWithFallback(java.lang.String, java.lang.String) 0">
45+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
46+
</item>
47+
<item name="net.minecraft.text.Text net.minecraft.text.MutableText translatableWithFallback(java.lang.String, java.lang.String, java.lang.Object...) 0">
48+
<annotation name="com.demonwav.mcdev.annotations.Translatable"/>
49+
</item>
50+
</root>

src/main/kotlin/platform/bukkit/BukkitModule.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class BukkitModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, type: T
9292
chosenClass: PsiClass,
9393
chosenName: String,
9494
data: GenerationData?,
95-
): PsiMethod {
95+
): PsiMethod? {
9696
val bukkitData = data as BukkitGenerationData
9797

9898
val method = generateBukkitStyleEventListenerMethod(
@@ -101,7 +101,7 @@ class BukkitModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, type: T
101101
project,
102102
BukkitConstants.HANDLER_ANNOTATION,
103103
bukkitData.isIgnoreCanceled,
104-
)
104+
) ?: return null
105105

106106
if (bukkitData.eventPriority != "NORMAL") {
107107
val list = method.modifierList
@@ -217,8 +217,8 @@ class BukkitModule<out T : AbstractModuleType<*>>(facet: MinecraftFacet, type: T
217217
project: Project,
218218
annotationName: String,
219219
setIgnoreCancelled: Boolean,
220-
): PsiMethod {
221-
val newMethod = createVoidMethodWithParameterType(project, chosenName, chosenClass)
220+
): PsiMethod? {
221+
val newMethod = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null
222222
val modifierList = newMethod.modifierList
223223
val annotation = modifierList.addAnnotation(annotationName)
224224

src/main/kotlin/platform/forge/ForgeModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ class ForgeModule internal constructor(facet: MinecraftFacet) : AbstractModule(f
163163
chosenClass: PsiClass,
164164
chosenName: String,
165165
data: GenerationData?,
166-
): PsiMethod {
166+
): PsiMethod? {
167167
val isFmlEvent = chosenClass.extendsOrImplements(ForgeConstants.FML_EVENT)
168168

169-
val method = createVoidMethodWithParameterType(project, chosenName, chosenClass)
169+
val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null
170170
val modifierList = method.modifierList
171171

172172
if (isFmlEvent) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import com.intellij.openapi.project.Project
3232
import com.intellij.psi.JavaPsiFacade
3333
import com.intellij.psi.JavaTokenType
3434
import com.intellij.psi.PsiBinaryExpression
35+
import com.intellij.psi.PsiClassType
3536
import com.intellij.psi.PsiExpression
3637
import com.intellij.psi.PsiField
3738
import com.intellij.psi.PsiReferenceExpression
@@ -117,7 +118,7 @@ class StackEmptyInspection : BaseInspection() {
117118
}
118119

119120
private fun isExpressionStack(expression: PsiExpression?): Boolean {
120-
return expression?.type?.equalsToText(STACK_FQ_NAME) == true
121+
return (expression?.type as? PsiClassType)?.resolve()?.fullQualifiedName == STACK_FQ_NAME
121122
}
122123

123124
private fun isExpressionEmptyConstant(expression: PsiExpression?): Boolean {

src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.intellij.psi.CommonClassNames.JAVA_LANG_INTEGER
4040
import com.intellij.psi.CommonClassNames.JAVA_LANG_LONG
4141
import com.intellij.psi.CommonClassNames.JAVA_LANG_SHORT
4242
import com.intellij.psi.CommonClassNames.JAVA_LANG_STRING
43+
import com.intellij.psi.CommonClassNames.JAVA_LANG_STRING_SHORT
4344
import com.intellij.psi.PsiArrayType
4445
import com.intellij.psi.PsiClassType
4546
import com.intellij.psi.PsiElementVisitor
@@ -96,23 +97,27 @@ class ConfigValueInspection : MixinConfigInspection() {
9697
return true // Idk, it's fine I guess
9798
}
9899

99-
if (type.equalsToText(JAVA_LANG_STRING)) {
100+
if (type.className == JAVA_LANG_STRING_SHORT && type.resolve()?.qualifiedName == JAVA_LANG_STRING) {
100101
return value is JsonStringLiteral
101102
}
102103

103-
if (type.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) {
104+
if (type.className == "Boolean" && type.resolve()?.qualifiedName == CommonClassNames.JAVA_LANG_BOOLEAN) {
104105
return value is JsonBooleanLiteral || value is JsonNullLiteral
105106
}
106107

107-
if (qualifiedNumberNames.any(type::equalsToText)) {
108+
if (
109+
shortNumberNames.contains(type.className) &&
110+
qualifiedNumberNames.contains(type.resolve()?.qualifiedName)
111+
) {
108112
return value is JsonNumberLiteral || value is JsonNullLiteral
109113
}
110114

111115
PsiUtil.extractIterableTypeParameter(type, true)?.let { return checkArray(it, value) }
112116
return value is JsonObject
113117
}
114118

115-
private val qualifiedNumberNames = listOf(
119+
private val shortNumberNames = setOf("Byte", "Character", "Double", "Float", "Integer", "Long", "Short")
120+
private val qualifiedNumberNames = setOf(
116121
JAVA_LANG_BYTE,
117122
JAVA_LANG_CHARACTER,
118123
JAVA_LANG_DOUBLE,

src/main/kotlin/platform/mixin/folding/MixinObjectCastFoldingBuilder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.intellij.openapi.editor.Document
2828
import com.intellij.openapi.util.TextRange
2929
import com.intellij.psi.CommonClassNames
3030
import com.intellij.psi.JavaRecursiveElementWalkingVisitor
31+
import com.intellij.psi.PsiClassType
3132
import com.intellij.psi.PsiElement
3233
import com.intellij.psi.PsiJavaFile
3334
import com.intellij.psi.PsiTypeCastExpression
@@ -73,7 +74,7 @@ class MixinObjectCastFoldingBuilder : CustomFoldingBuilder() {
7374
}
7475

7576
val innerCast = expression.operand as? PsiTypeCastExpression ?: return
76-
if (innerCast.type?.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) == true) {
77+
if ((innerCast.type as? PsiClassType)?.resolve()?.qualifiedName == CommonClassNames.JAVA_LANG_OBJECT) {
7778
// Fold the two casts
7879

7980
val start = (expression as? CompositeElement)?.findChildByRole(ChildRole.LPARENTH) ?: return

src/main/kotlin/platform/mixin/handlers/InvokerHandler.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ import com.demonwav.mcdev.util.constantStringValue
3030
import com.demonwav.mcdev.util.decapitalize
3131
import com.demonwav.mcdev.util.descriptor
3232
import com.demonwav.mcdev.util.findAnnotation
33+
import com.demonwav.mcdev.util.fullQualifiedName
3334
import com.intellij.psi.PsiAnnotation
35+
import com.intellij.psi.PsiClassType
3436
import com.intellij.psi.PsiMember
3537
import com.intellij.psi.PsiMethod
3638
import com.intellij.psi.SmartPsiElementPointer
@@ -53,7 +55,7 @@ class InvokerHandler : MixinMemberAnnotationHandler {
5355
val name = getInvokerTargetName(annotation, member) ?: return emptyList()
5456
val constructor = name == "<init>"
5557
if (constructor &&
56-
member.returnType?.equalsToText(targetClass.name.replace('/', '.').replace('$', '.')) != true
58+
(member.returnType as? PsiClassType)?.resolve()?.fullQualifiedName?.replace('.', '/') != targetClass.name
5759
) {
5860
return emptyList()
5961
}

0 commit comments

Comments
 (0)