Skip to content

Commit

Permalink
Merge branch 'dev' into 2024.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Sep 28, 2024
2 parents 7093a23 + dcf7e99 commit f8d87fb
Show file tree
Hide file tree
Showing 34 changed files with 133 additions and 68 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
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ plugins {
`mcdev-publishing`
}

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

val gradleToolingExtension: Configuration by configurations.creating
Expand All @@ -43,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
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(17))
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 = "2024.1"
idea-ext = "1.1.8"
psiPlugin = "241.14494.158-EAP-SNAPSHOT"
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
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
25 changes: 19 additions & 6 deletions src/main/kotlin/platform/mixin/config/MixinConfigFileType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,35 @@ package com.demonwav.mcdev.platform.mixin.config

import com.demonwav.mcdev.asset.PlatformAssets
import com.intellij.json.JsonLanguage
import com.intellij.json.json5.Json5Language
import com.intellij.openapi.fileTypes.LanguageFileType
import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile
import com.intellij.openapi.vfs.VirtualFile

object MixinConfigFileType : LanguageFileType(JsonLanguage.INSTANCE), FileTypeIdentifiableByVirtualFile {

private val filenameRegex = "(^|\\.)mixins?(\\.[^.]+)*\\.json\$".toRegex()
interface MixinConfigFileType : FileTypeIdentifiableByVirtualFile {
fun getFilenameRegex() : Regex

// Dynamic file type detection is sadly needed as we're overriding the built-in json file type.
// Simply using an extension pattern is not sufficient as there is no way to bump the version to tell
// the cache that the pattern has changed, as it now has, without changing the file type name.
// See https://www.plugin-dev.com/intellij/custom-language/file-type-detection/#guidelines
override fun isMyFileType(file: VirtualFile) = file.name.contains(filenameRegex)
override fun isMyFileType(file: VirtualFile) = file.name.contains(getFilenameRegex())

override fun getName() = "Mixin Configuration"
override fun getDescription() = "Mixin configuration"
override fun getDefaultExtension() = ""
override fun getIcon() = PlatformAssets.MIXIN_ICON
}

object Json : LanguageFileType(JsonLanguage.INSTANCE), MixinConfigFileType {
private val filenameRegex = "(^|\\.)mixins?(\\.[^.]+)*\\.json\$".toRegex()

override fun getFilenameRegex() : Regex = filenameRegex
override fun getName() = "Mixin Json Configuration"
}

object Json5 : LanguageFileType(Json5Language.INSTANCE), MixinConfigFileType {
private var filenameRegex = "(^|\\.)mixins?(\\.[^.]+)*\\.json5\$".toRegex()

override fun getFilenameRegex() : Regex = filenameRegex
override fun getName() = "Mixin Json5 Configuration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MixinConfigImportOptimizer : ImportOptimizer {
}
}

override fun supports(file: PsiFile) = file is JsonFile && file.fileType == MixinConfigFileType
override fun supports(file: PsiFile) = file is JsonFile && file.fileType is MixinConfigFileType

override fun processFile(file: PsiFile): Runnable {
if (file !is JsonFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class MixinConfigInspection : LocalInspectionTool() {
protected abstract fun buildVisitor(holder: ProblemsHolder): PsiElementVisitor

private fun checkFile(file: PsiFile): Boolean {
return file.fileType === MixinConfigFileType && MixinModuleType.isInModule(file)
return file.fileType is MixinConfigFileType && MixinModuleType.isInModule(file)
}

final override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ import com.intellij.psi.PsiReferenceContributor
import com.intellij.psi.PsiReferenceRegistrar

class MixinConfigReferenceContributor : PsiReferenceContributor() {

override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
val anyMixinConfigFileType = StandardPatterns.or(
StandardPatterns.`object`(MixinConfigFileType.Json),
StandardPatterns.`object`(MixinConfigFileType.Json5)
)

val pattern = PlatformPatterns.psiElement(JsonStringLiteral::class.java)
.inFile(PlatformPatterns.psiFile().withFileType(StandardPatterns.`object`(MixinConfigFileType)))
.inFile(PlatformPatterns.psiFile().withFileType(anyMixinConfigFileType))

registrar.registerReferenceProvider(pattern.isPropertyKey(), ConfigProperty)
registrar.registerReferenceProvider(pattern.isPropertyValue("package"), MixinPackage)
Expand All @@ -47,3 +51,4 @@ class MixinConfigReferenceContributor : PsiReferenceContributor() {
registrar.registerReferenceProvider(pattern.withParent(mixinList.isPropertyValue("client")), MixinClass)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ package com.demonwav.mcdev.platform.mixin.framework
import com.demonwav.mcdev.util.libraryKind
import com.intellij.openapi.roots.libraries.LibraryKind

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

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

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

val VELOCITY_LIBRARY_KIND: LibraryKind = libraryKind("velocity-api")
val VELOCITY_LIBRARY_KIND: LibraryKind by libraryKind("velocity-api")
Loading

0 comments on commit f8d87fb

Please sign in to comment.