Skip to content

Commit 80ecf22

Browse files
committed
Merge branch '2024.2' into 2024.3
2 parents 4fd58b4 + 2fa7cb6 commit 80ecf22

File tree

70 files changed

+2039
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2039
-52
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[*.{kt,kts}]
22
max_line_length=120
33
ij_kotlin_imports_layout=*
4+
ij_kotlin_name_count_to_use_star_import = 2147483647
5+
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
6+
insert_final_newline = true

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ dependencies {
9090
exclude(group = "org.ow2.asm", module = "asm-debug-all")
9191
}
9292
testLibs(libs.mixinExtras.common)
93+
implementation(libs.jgraphx)
9394

9495
implementation(libs.mappingIo)
9596
implementation(libs.bundles.asm)

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ changelog-plugin = { module = "org.jetbrains.changelog:org.jetbrains.changelog.g
3434
coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
3535

3636
mappingIo = "net.fabricmc:mapping-io:0.2.1"
37-
mixinExtras-expressions = "io.github.llamalad7:mixinextras-expressions:0.0.4"
37+
mixinExtras-expressions = "io.github.llamalad7:mixinextras-expressions:0.0.6"
38+
jgraphx = "com.github.vlsi.mxgraph:jgraphx:4.2.2"
3839

3940
# GrammarKit
4041
jflex-lib = "org.jetbrains.idea:jflex:1.7.0-b7f882a"

src/main/kotlin/platform/mixin/MixinModule.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121
package com.demonwav.mcdev.platform.mixin
2222

2323
import com.demonwav.mcdev.facet.MinecraftFacet
24-
import com.demonwav.mcdev.facet.MinecraftFacetDetector
2524
import com.demonwav.mcdev.platform.AbstractModule
2625
import com.demonwav.mcdev.platform.PlatformType
2726
import com.demonwav.mcdev.platform.mixin.config.MixinConfig
2827
import com.demonwav.mcdev.platform.mixin.config.MixinConfigFileType
29-
import com.demonwav.mcdev.platform.mixin.framework.MIXIN_LIBRARY_KIND
30-
import com.demonwav.mcdev.util.SemanticVersion
31-
import com.demonwav.mcdev.util.nullable
3228
import com.intellij.json.psi.JsonFile
3329
import com.intellij.json.psi.JsonObject
3430
import com.intellij.openapi.project.Project
@@ -40,14 +36,6 @@ import com.intellij.psi.search.GlobalSearchScope
4036
import javax.swing.Icon
4137

4238
class MixinModule(facet: MinecraftFacet) : AbstractModule(facet) {
43-
val mixinVersion by nullable {
44-
var version = MinecraftFacetDetector.getLibraryVersions(facet.module)[MIXIN_LIBRARY_KIND]
45-
?: return@nullable null
46-
// fabric mixin uses the format "0.10.4+mixin.0.8.4", return the original string otherwise.
47-
version = version.substringAfter("+mixin.")
48-
SemanticVersion.parse(version)
49-
}
50-
5139
override val moduleType = MixinModuleType
5240
override val type = PlatformType.MIXIN
5341
override val icon: Icon? = null

src/main/kotlin/platform/mixin/action/GenerateAccessorAction.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package com.demonwav.mcdev.platform.mixin.action
2323
import com.demonwav.mcdev.platform.mixin.MixinModuleType
2424
import com.intellij.codeInsight.FileModificationService
2525
import com.intellij.codeInsight.generation.actions.BaseGenerateAction
26+
import com.intellij.openapi.actionSystem.AnActionEvent
2627
import com.intellij.openapi.application.ApplicationManager
2728
import com.intellij.openapi.command.CommandProcessor
2829
import com.intellij.openapi.editor.Editor
@@ -34,11 +35,21 @@ import com.intellij.psi.PsiJavaFile
3435
import com.intellij.psi.util.PsiUtilBase
3536

3637
class GenerateAccessorAction : BaseGenerateAction(GenerateAccessorHandler()) {
38+
override fun actionPerformed(e: AnActionEvent) {
39+
val project = e.project ?: return
40+
val editor = getEditor(e.dataContext, project, false)
41+
performAction(project, editor)
42+
}
43+
44+
override fun actionPerformedImpl(project: Project, editor: Editor?) {
45+
performAction(project, editor)
46+
}
47+
3748
/**
3849
* Copied from [com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl]
3950
* except that it calls the [GenerateAccessorHandler.customInvoke] method instead of the normal one
4051
*/
41-
override fun actionPerformedImpl(project: Project, editor: Editor?) {
52+
private fun performAction(project: Project, editor: Editor?) {
4253
if (editor == null) {
4354
return
4455
}

src/main/kotlin/platform/mixin/completion/MixinCompletionContributor.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import com.intellij.codeInsight.completion.CompletionType
3232
import com.intellij.codeInsight.completion.JavaCompletionContributor
3333
import com.intellij.codeInsight.completion.JavaCompletionSorting
3434
import com.intellij.codeInsight.completion.LegacyCompletionContributor
35-
import com.intellij.codeInsight.completion.PrioritizedLookupElement
35+
import com.intellij.openapi.progress.ProgressManager
36+
import com.intellij.openapi.util.text.StringUtil
3637
import com.intellij.psi.PsiClassType
3738
import com.intellij.psi.PsiExpression
3839
import com.intellij.psi.PsiJavaReference
@@ -58,6 +59,9 @@ class MixinCompletionContributor : CompletionContributor() {
5859
return
5960
}
6061

62+
// Run all the other contributors first
63+
result.runRemainingContributors(parameters, result::passResult)
64+
6165
val superMixin = psiClass.superClass?.takeIf { it.isWritable && it.isMixin }
6266

6367
val javaResult = JavaCompletionSorting.addJavaSorting(parameters, result)
@@ -107,8 +111,12 @@ class MixinCompletionContributor : CompletionContributor() {
107111

108112
// Process methods and fields from target class
109113
val elements = findShadowTargets(psiClass, start, superMixin != null)
114+
.filter {
115+
val name = it.name
116+
StringUtil.isJavaIdentifier(name) && prefixMatcher.prefixMatches(name)
117+
}
118+
.onEach { ProgressManager.checkCanceled() }
110119
.map { it.createLookupElement(psiClass.project) }
111-
.filter { prefixMatcher.prefixMatches(it) }
112120
.filter(filter, position)
113121
.toList()
114122

src/main/kotlin/platform/mixin/expression/MEExpressionAnnotator.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ class MEExpressionAnnotator : Annotator {
326326
}
327327

328328
private fun AnnotationBuilder.withDefinitionFix(name: MEName) =
329-
withFix(AddDefinitionInspection(name))
329+
withFix(AddDefinitionFix(name))
330330

331-
private class AddDefinitionInspection(name: MEName) : LocalQuickFixAndIntentionActionOnPsiElement(name) {
331+
private class AddDefinitionFix(name: MEName) : LocalQuickFixAndIntentionActionOnPsiElement(name) {
332332
private val id = name.text
333333

334334
override fun getFamilyName(): String = "Add @Definition"
@@ -355,9 +355,9 @@ class MEExpressionAnnotator : Annotator {
355355
project,
356356
startElement,
357357
id,
358-
"dummy"
358+
"dummy = \"\""
359359
) ?: return
360-
val dummy = annotation.findAttribute("dummy") as? PsiElement ?: return
360+
val dummy = annotation.parameterList.attributes.firstOrNull { it.name == "dummy" } ?: return
361361
val hostEditor = InjectedLanguageEditorUtil.getTopLevelEditor(editor)
362362
hostEditor.caretModel.moveToOffset(dummy.textOffset)
363363
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(hostEditor.document)

src/main/kotlin/platform/mixin/expression/MEExpressionMatchUtil.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ object MEExpressionMatchUtil {
263263
insns: Iterable<VirtualInsn>,
264264
contextType: ExpressionContext.Type,
265265
forCompletion: Boolean,
266+
crossinline reportMatchStatus: (FlowValue, Expression, Boolean) -> Unit = { _, _, _ -> },
267+
crossinline reportPartialMatch: (FlowValue, Expression) -> Unit = { _, _ -> },
266268
callback: (ExpressionMatch) -> Unit
267269
) {
268270
for (insn in insns) {
@@ -283,6 +285,14 @@ object MEExpressionMatchUtil {
283285
// Our maps are per-injector anyway, so this is just a normal decoration.
284286
decorations.getOrPut(VirtualInsn(insn), ::mutableMapOf)[key] = value
285287
}
288+
289+
override fun reportMatchStatus(node: FlowValue, expr: Expression, matched: Boolean) {
290+
reportMatchStatus.invoke(node, expr, matched)
291+
}
292+
293+
override fun reportPartialMatch(node: FlowValue, expr: Expression) {
294+
reportPartialMatch.invoke(node, expr)
295+
}
286296
}
287297

288298
val flow = flows[insn] ?: continue
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Minecraft Development for IntelliJ
3+
*
4+
* https://mcdev.io/
5+
*
6+
* Copyright (C) 2025 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+
package com.demonwav.mcdev.platform.mixin.expression.gui
22+
23+
import com.intellij.openapi.editor.colors.EditorColorsManager
24+
import com.intellij.openapi.editor.colors.EditorFontType
25+
import com.intellij.ui.JBColor
26+
import com.intellij.util.ui.JBUI
27+
import com.intellij.util.ui.UIUtil
28+
import com.mxgraph.util.mxConstants
29+
import java.awt.Color
30+
31+
object DiagramStyles {
32+
val DEFAULT_NODE
33+
get() = mapOf(
34+
mxConstants.STYLE_FONTFAMILY to CURRENT_EDITOR_FONT.family,
35+
mxConstants.STYLE_ROUNDED to true,
36+
mxConstants.STYLE_FILLCOLOR to JBUI.CurrentTheme.Button.buttonColorStart().hexString,
37+
mxConstants.STYLE_FONTCOLOR to UIUtil.getLabelForeground().hexString,
38+
mxConstants.STYLE_STROKECOLOR to JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).hexString,
39+
mxConstants.STYLE_ALIGN to mxConstants.ALIGN_CENTER,
40+
mxConstants.STYLE_VERTICAL_ALIGN to mxConstants.ALIGN_TOP,
41+
mxConstants.STYLE_SHAPE to mxConstants.SHAPE_LABEL,
42+
mxConstants.STYLE_SPACING to 5,
43+
mxConstants.STYLE_SPACING_TOP to 3,
44+
)
45+
val DEFAULT_EDGE
46+
get() = mapOf(
47+
mxConstants.STYLE_STROKECOLOR to UIUtil.getFocusedBorderColor().hexString,
48+
)
49+
val LINE_NUMBER = mapOf(
50+
mxConstants.STYLE_FONTSIZE to "16",
51+
mxConstants.STYLE_STROKECOLOR to "none",
52+
mxConstants.STYLE_FILLCOLOR to "none",
53+
)
54+
val SEARCH_HIGHLIGHT
55+
get() = mapOf(
56+
mxConstants.STYLE_STROKECOLOR to UIUtil.getFocusedBorderColor().hexString,
57+
mxConstants.STYLE_STROKEWIDTH to "2",
58+
)
59+
val IGNORED = mapOf(
60+
mxConstants.STYLE_OPACITY to 20,
61+
mxConstants.STYLE_TEXT_OPACITY to 20,
62+
mxConstants.STYLE_STROKE_OPACITY to 20,
63+
mxConstants.STYLE_FILL_OPACITY to 20,
64+
)
65+
val FAILED
66+
get() = mapOf(
67+
mxConstants.STYLE_STROKECOLOR to JBColor.red.hexString,
68+
mxConstants.STYLE_STROKEWIDTH to "3.5",
69+
)
70+
val PARTIAL_MATCH
71+
get() = mapOf(
72+
mxConstants.STYLE_STROKECOLOR to JBColor.orange.hexString,
73+
mxConstants.STYLE_STROKEWIDTH to "2.5",
74+
)
75+
val SUCCESS
76+
get() = mapOf(
77+
mxConstants.STYLE_STROKECOLOR to JBColor.green.hexString,
78+
mxConstants.STYLE_STROKEWIDTH to "1.5",
79+
)
80+
val CURRENT_EDITOR_FONT
81+
get() = EditorColorsManager.getInstance().globalScheme.getFont(EditorFontType.PLAIN)
82+
}
83+
84+
private val Color.hexString get() = "#%06X".format(rgb)

0 commit comments

Comments
 (0)