forked from minecraft-dev/MinecraftDev
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/platform/mixin/inspection/NonJavaMixinInspection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Minecraft Dev for IntelliJ | ||
* | ||
* https://minecraftdev.org | ||
* | ||
* Copyright (c) 2023 minecraft-dev | ||
* | ||
* MIT License | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mixin.inspection | ||
|
||
import com.demonwav.mcdev.platform.mixin.util.MixinConstants | ||
import com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool | ||
import com.intellij.codeInspection.InspectionManager | ||
import com.intellij.codeInspection.ProblemDescriptor | ||
import com.intellij.codeInspection.ProblemHighlightType | ||
import com.intellij.lang.java.JavaLanguage | ||
import org.jetbrains.uast.UClass | ||
|
||
class NonJavaMixinInspection : AbstractBaseUastLocalInspectionTool(UClass::class.java) { | ||
override fun getDisplayName() = "Mixin is not written in Java" | ||
override fun getStaticDescription() = | ||
"<html>Mixins should be written in Java. See <a href=\"$RELEVANT_ISSUE\">this Mixin issue</a></html>" | ||
|
||
override fun checkClass( | ||
aClass: UClass, | ||
manager: InspectionManager, | ||
isOnTheFly: Boolean | ||
): Array<ProblemDescriptor>? { | ||
val sourcePsi = aClass.sourcePsi ?: return null | ||
if (sourcePsi.language == JavaLanguage.INSTANCE) { | ||
return null | ||
} | ||
val isMixin = aClass.uAnnotations.any { ann -> ann.qualifiedName == MixinConstants.Annotations.MIXIN } | ||
if (!isMixin) { | ||
return null | ||
} | ||
val problem = manager.createProblemDescriptor( | ||
aClass.uastAnchor?.sourcePsi ?: sourcePsi, | ||
this.staticDescription, | ||
isOnTheFly, | ||
null, | ||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING | ||
) | ||
return arrayOf(problem) | ||
} | ||
|
||
companion object { | ||
private const val RELEVANT_ISSUE = "https://github.com/SpongePowered/Mixin/issues/245" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricStatusEffect.java.ft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | ||
#parse("File Header.java") | ||
|
||
import net.minecraft.entity.effect.StatusEffect; | ||
import net.minecraft.entity.effect.StatusEffectCategory; | ||
|
||
public class ${NAME} extends StatusEffect { | ||
public ${NAME}(StatusEffectCategory statusEffectCategory, int color) { | ||
super(statusEffectCategory, color); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/fileTemplates/j2ee/skeleton/fabric/FabricStatusEffect.java.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
Minecraft Dev for IntelliJ | ||
https://minecraftdev.org | ||
Copyright (c) 2023 minecraft-dev | ||
MIT License | ||
--> | ||
|
||
<html> | ||
<body> | ||
An empty Fabric status effect class. | ||
</body> | ||
</html> |