Skip to content

Commit

Permalink
Merge branch '2024.2' into 2024.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle/libs.versions.toml
  • Loading branch information
RedNesto committed Sep 28, 2024
2 parents c141268 + 00b9a23 commit 18c612f
Show file tree
Hide file tree
Showing 41 changed files with 160 additions and 103 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ body:
- Sponge
- Architectury
- Minecraft Forge
- NeoForge
- Fabric
- Velocity
- Mixins
Expand All @@ -46,4 +47,4 @@ body:
id: description
attributes:
label: Description of the bug
description: Always include a stack trace if there is one. Otherwise, the more information you can provide in terms of how to reproduce the problem, the more likely it'll be fixed. If there is something specific about your project, a link to the GitHub project can be very helpful.
description: Always include a stack trace if there is one. Otherwise, the more information you can provide in terms of how to reproduce the problem, the more likely it'll be fixed. If there is something specific about your project, a link to the GitHub project can be very helpful.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/project_wizard_outdated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ body:
- Sponge
- Architectury
- Minecraft Forge
- NeoForge
- Fabric
- Velocity
- BungeeCord
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
echo "GRADLE_USER_HOME=$HOME/.gradle" >> "$GITHUB_ENV"
echo "mcdev.deploy.token=${JETBRAINS_TOKEN}" > ~/.gradle/gradle.properties
- name: Publish plugin
run: ./gradlew clean publishPlugin --no-daemon --stacktrace
run: ./gradlew clean :publishPlugin --no-daemon --stacktrace
- name: Get tag name
id: get_tag
shell: bash
Expand Down
22 changes: 0 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ plugins {
`mcdev-publishing`
}

val ideaVersionProvider: Provider<String> = providers.gradleProperty("ideaVersion")
val ideaVersionName: String by project
val coreVersion: String by project

val gradleToolingExtension: Configuration by configurations.creating
Expand All @@ -44,7 +42,6 @@ val testLibs: Configuration by configurations.creating {
}

group = "com.demonwav.mcdev"
version = "$ideaVersionName-$coreVersion"

val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
configurations.named(compileOnlyConfigurationName) {
Expand Down Expand Up @@ -121,25 +118,6 @@ dependencies {
pluginVerifier()
}

intellijPlatform {
intellijIdeaCommunity(ideaVersionProvider, useInstaller = false)
bundledPlugin("com.intellij.java")
bundledPlugin("org.jetbrains.idea.maven")
bundledPlugin("com.intellij.gradle")
bundledPlugin("org.intellij.groovy")
// For some reason the Kotlin plugin can't be resolved...
bundledPlugin("org.jetbrains.kotlin")
bundledPlugin("ByteCodeViewer")
bundledPlugin("org.intellij.intelliLang")
bundledPlugin("com.intellij.properties")
bundledPlugin("org.toml.lang")

testFramework(TestFrameworkType.JUnit5)
testFramework(TestFrameworkType.Plugin.Java)

pluginVerifier()
}

testLibs(libs.test.mockJdk)
testLibs(libs.test.mixin)
testLibs(libs.test.spigotapi)
Expand Down
13 changes: 12 additions & 1 deletion buildSrc/src/main/kotlin/mcdev-core.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ plugins {
id("org.cadixdev.licenser")
}

val ideaVersionName: String by project
val coreVersion: String by project
val buildNumber: String? by project

version = "$ideaVersionName-$coreVersion"

// Build numbers are used for nightlies
if (buildNumber != null) {
version = "$version-$buildNumber"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
Expand Down Expand Up @@ -99,7 +110,7 @@ dependencies {
}

testImplementation(libs.junit.api)
testCompileOnly(libs.junit.vintage) // Hack to get tests to compile and run
testImplementation(libs.junit.vintage) // Hack to get tests to compile and run
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.platform.launcher)
}
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ plugins {
}

tasks.publishPlugin {
// Build numbers are used for nightlies
properties["buildNumber"]?.let { buildNumber ->
project.version = "${project.version}-$buildNumber"
}
properties["mcdev.deploy.token"]?.let { deployToken ->
token.set(deployToken.toString())
}
Expand Down
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
### Added

- `plugin.yml`, `paper-plugin.yml` and `bungee.yml` main class reference and validity inspection
- `mods.toml` and `neoforge.mods.toml` documentation for lookup elements
- Support for split strings within inspections and method target references in Mixins ([#2358](https://github.com/minecraft-dev/MinecraftDev/pull/2358))
- Mouse ungrab on breakpoint hit while running a Gradle task

### Changed

- More reliable ClassFqn creator property suggestions and validation
- Lang spellchecking now works in dumb mode

### Fixed

- [#2362](https://github.com/minecraft-dev/MinecraftDev/issues/2362) CME in fabric.mod.json
- Ignored annotations registrations
- NeoGradle and NeoModDev Minecraft version import
- [#2360](https://github.com/minecraft-dev/MinecraftDev/issues/2360) `Class initialization must not depend on services` error

## [1.8.1] - 2024-08-10

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ asm = "9.6"
fuel = "2.3.1"
licenser = "0.6.1"
changelog = "2.2.0"
intellij-plugin = "2.0.1"
intellij-plugin = "2.1.0"
intellij-ide = "243-EAP-SNAPSHOT"
idea-ext = "1.1.8"
psiPlugin = "243.7768"
Expand Down
4 changes: 0 additions & 4 deletions obfuscation-explorer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ plugins {
`mcdev-publishing`
}

val ideaVersionName: String by project
val coreVersion: String by project

val jflex by configurations
val jflexSkeleton by configurations
val grammarKit by configurations

group = "io.mcdev.obfex"
version = "$ideaVersionName-$coreVersion"

intellijPlatform {
projectName = "Obfuscation Explorer"
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/creator/custom/BuiltinValidations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ package com.demonwav.mcdev.creator.custom
import com.demonwav.mcdev.asset.MCDevBundle
import com.demonwav.mcdev.platform.fabric.util.FabricVersions
import com.demonwav.mcdev.util.SemanticVersion
import com.intellij.lang.java.lexer.JavaLexer
import com.demonwav.mcdev.util.isJavaKeyword
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.ValidationInfo
import com.intellij.openapi.ui.validation.DialogValidation
import com.intellij.openapi.ui.validation.validationErrorIf
import com.intellij.openapi.util.text.StringUtil
import com.intellij.pom.java.LanguageLevel
import javax.swing.JComponent

object BuiltinValidations {
Expand Down Expand Up @@ -61,7 +60,7 @@ object BuiltinValidations {

val validClassFqn = validationErrorIf<String>(MCDevBundle("creator.validation.class_fqn")) {
it.isBlank() || it.split('.').any { part ->
!StringUtil.isJavaIdentifier(part) || JavaLexer.isKeyword(part, LanguageLevel.HIGHEST)
!StringUtil.isJavaIdentifier(part) || part.isJavaKeyword()
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/creator/custom/CustomPlatformStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import com.demonwav.mcdev.creator.custom.providers.EmptyLoadedTemplate
import com.demonwav.mcdev.creator.custom.providers.LoadedTemplate
import com.demonwav.mcdev.creator.custom.providers.TemplateProvider
import com.demonwav.mcdev.creator.modalityState
import com.demonwav.mcdev.util.getOrLogException
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
import com.intellij.ide.wizard.GitNewProjectWizardData
import com.intellij.ide.wizard.NewProjectWizardBaseData
import com.intellij.ide.wizard.NewProjectWizardStep
import com.intellij.openapi.application.EDT
import com.intellij.openapi.application.asContextElement
import com.intellij.openapi.diagnostic.getOrLogException
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.observable.properties.GraphProperty
import com.intellij.openapi.observable.util.transform
Expand All @@ -50,8 +50,6 @@ import com.intellij.ui.dsl.builder.bindText
import com.intellij.util.application
import com.intellij.util.ui.AsyncProcessIcon
import javax.swing.JLabel
import kotlin.collections.component1
import kotlin.collections.component2
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.demonwav.mcdev.creator.custom.PropertyDerivationSelect
import com.demonwav.mcdev.creator.custom.TemplateEvaluator
import com.demonwav.mcdev.creator.custom.TemplateValidationReporter
import com.demonwav.mcdev.creator.custom.types.CreatorProperty
import com.intellij.openapi.diagnostic.getOrLogException
import com.demonwav.mcdev.util.getOrLogException
import com.intellij.openapi.diagnostic.thisLogger

class SelectPropertyDerivation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.demonwav.mcdev.creator.custom.TemplateEvaluator
import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor
import com.demonwav.mcdev.creator.custom.TemplateValidationReporter
import com.demonwav.mcdev.util.SemanticVersion
import com.intellij.openapi.diagnostic.getOrLogException
import com.demonwav.mcdev.util.getOrLogException
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.observable.properties.GraphProperty
import com.intellij.ui.ComboboxSpeedSearch
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/creator/field-validation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package com.demonwav.mcdev.creator

import com.demonwav.mcdev.util.isJavaKeyword
import com.demonwav.mcdev.util.isJavaSoftKeyword

fun isValidClassName(className: String): Boolean {
// default package
Expand All @@ -42,5 +42,5 @@ fun isValidClassName(className: String): Boolean {
return false
}
// keyword identifier
return !fieldNameSplit.any { it.isJavaKeyword() }
return !fieldNameSplit.any { it.isJavaSoftKeyword() }
}
34 changes: 18 additions & 16 deletions src/main/kotlin/facet/MinecraftLibraryKinds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ import com.demonwav.mcdev.platform.neoforge.framework.NEOFORGE_LIBRARY_KIND
import com.demonwav.mcdev.platform.sponge.framework.SPONGE_LIBRARY_KIND
import com.demonwav.mcdev.platform.velocity.framework.VELOCITY_LIBRARY_KIND

val MINECRAFT_LIBRARY_KINDS = setOf(
BUKKIT_LIBRARY_KIND,
SPIGOT_LIBRARY_KIND,
PAPER_LIBRARY_KIND,
SPONGE_LIBRARY_KIND,
FORGE_LIBRARY_KIND,
NEOFORGE_LIBRARY_KIND,
FABRIC_LIBRARY_KIND,
ARCHITECTURY_LIBRARY_KIND,
MCP_LIBRARY_KIND,
MIXIN_LIBRARY_KIND,
BUNGEECORD_LIBRARY_KIND,
WATERFALL_LIBRARY_KIND,
VELOCITY_LIBRARY_KIND,
ADVENTURE_LIBRARY_KIND,
)
val MINECRAFT_LIBRARY_KINDS by lazy {
setOf(
BUKKIT_LIBRARY_KIND,
SPIGOT_LIBRARY_KIND,
PAPER_LIBRARY_KIND,
SPONGE_LIBRARY_KIND,
FORGE_LIBRARY_KIND,
NEOFORGE_LIBRARY_KIND,
FABRIC_LIBRARY_KIND,
ARCHITECTURY_LIBRARY_KIND,
MCP_LIBRARY_KIND,
MIXIN_LIBRARY_KIND,
BUNGEECORD_LIBRARY_KIND,
WATERFALL_LIBRARY_KIND,
VELOCITY_LIBRARY_KIND,
ADVENTURE_LIBRARY_KIND,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.demonwav.mcdev.util.mapFirstNotNull
import com.intellij.codeInsight.CodeInsightActionHandler
import com.intellij.ide.util.TreeClassChooserFactory
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorModificationUtil
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile
Expand All @@ -43,6 +44,10 @@ class GenerateEventListenerHandler : CodeInsightActionHandler {
val caretElement = file.findElementAt(editor.caretModel.offset) ?: return
val context = caretElement.context ?: return

if (!EditorModificationUtil.requestWriting(editor)) {
return
}

val chooser = TreeClassChooserFactory.getInstance(project)
.createWithInnerClassesScopeChooser(
RefactoringBundle.message("choose.destination.class"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.adventure.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val ADVENTURE_LIBRARY_KIND: LibraryKind = libraryKind("adventure-api")
val ADVENTURE_LIBRARY_KIND: LibraryKind by libraryKind("adventure-api")
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.architectury.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val ARCHITECTURY_LIBRARY_KIND: LibraryKind = libraryKind("architectury-api")
val ARCHITECTURY_LIBRARY_KIND: LibraryKind by libraryKind("architectury-api")
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ package com.demonwav.mcdev.platform.bukkit.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val BUKKIT_LIBRARY_KIND: LibraryKind = libraryKind("bukkit-api")
val SPIGOT_LIBRARY_KIND: LibraryKind = libraryKind("spigot-api")
val PAPER_LIBRARY_KIND: LibraryKind = libraryKind("paper-api")
val BUKKIT_LIBRARY_KIND: LibraryKind by libraryKind("bukkit-api")
val SPIGOT_LIBRARY_KIND: LibraryKind by libraryKind("spigot-api")
val PAPER_LIBRARY_KIND: LibraryKind by libraryKind("paper-api")
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ package com.demonwav.mcdev.platform.bungeecord.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val BUNGEECORD_LIBRARY_KIND: LibraryKind = libraryKind("bungeecord-api")
val WATERFALL_LIBRARY_KIND: LibraryKind = libraryKind("waterfall-api")
val BUNGEECORD_LIBRARY_KIND: LibraryKind by libraryKind("bungeecord-api")
val WATERFALL_LIBRARY_KIND: LibraryKind by libraryKind("waterfall-api")
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.fabric.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val FABRIC_LIBRARY_KIND: LibraryKind = libraryKind("fabric-library")
val FABRIC_LIBRARY_KIND: LibraryKind by libraryKind("fabric-library")
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.forge.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val FORGE_LIBRARY_KIND: LibraryKind = libraryKind("forge-library")
val FORGE_LIBRARY_KIND: LibraryKind by libraryKind("forge-library")
2 changes: 1 addition & 1 deletion src/main/kotlin/platform/mcp/framework/McpLibraryKind.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.mcp.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

val MCP_LIBRARY_KIND: LibraryKind = libraryKind("mcp-library")
val MCP_LIBRARY_KIND: LibraryKind by libraryKind("mcp-library")
19 changes: 12 additions & 7 deletions src/main/kotlin/platform/mixin/MixinModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.demonwav.mcdev.util.nullable
import com.intellij.json.psi.JsonFile
import com.intellij.json.psi.JsonObject
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.fileTypes.FileTypes
import com.intellij.openapi.project.Project
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiClass
Expand All @@ -54,19 +53,24 @@ class MixinModule(facet: MinecraftFacet) : AbstractModule(facet) {
override val icon: Icon? = null

companion object {
private val mixinFileType by lazy {
FileTypeManager.getInstance().findFileTypeByName("Mixin Configuration") ?: FileTypes.UNKNOWN
private val mixinFileTypes by lazy {
listOfNotNull(
FileTypeManager.getInstance().findFileTypeByName("Mixin Json Configuration"),
FileTypeManager.getInstance().findFileTypeByName("Mixin Json5 Configuration")
)
}

fun getMixinConfigs(
project: Project,
scope: GlobalSearchScope,
): Collection<MixinConfig> {
return FileTypeIndex.getFiles(mixinFileType, scope)
.mapNotNull {
(PsiManager.getInstance(project).findFile(it) as? JsonFile)?.topLevelValue as? JsonObject
return mixinFileTypes
.flatMap { FileTypeIndex.getFiles(it, scope) }
.mapNotNull { file ->
(PsiManager.getInstance(project).findFile(file) as? JsonFile)?.topLevelValue as? JsonObject
}.map { jsonObject ->
MixinConfig(project, jsonObject)
}
.map { MixinConfig(project, it) }
}

fun getAllMixinClasses(
Expand All @@ -93,3 +97,4 @@ class MixinModule(facet: MinecraftFacet) : AbstractModule(facet) {
}
}
}

2 changes: 2 additions & 0 deletions src/main/kotlin/platform/mixin/config/MixinConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class MixinConfig(private val project: Project, private var json: JsonObject) {
}

private fun reformat() {
if(json.containingFile.name.endsWith(".json5")) return

json = CodeStyleManager.getInstance(project).reformat(json) as JsonObject
file?.let { file ->
val psiFile = PsiManager.getInstance(project).findFile(file) as? JsonFile ?: return
Expand Down
Loading

0 comments on commit 18c612f

Please sign in to comment.