User: kyle wood Date: 27 Mar 26 02:22 Revision: f793d783978567f982ddf90810ca5b746e262e9f Summary: Remove Obfuscation Explorer TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=10437&personal=false Index: obfuscation-explorer/.gitignore =================================================================== --- obfuscation-explorer/.gitignore (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/.gitignore (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,3 +0,0 @@ -.sandbox/ -build/ -gen/ Index: obfuscation-explorer/build.gradle.kts =================================================================== --- obfuscation-explorer/build.gradle.kts (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/build.gradle.kts (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,122 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -import org.jetbrains.intellij.platform.gradle.TestFrameworkType - -plugins { - `mcdev-core` - `mcdev-parsing` - `mcdev-publishing` -} - -val jflex by configurations -val jflexSkeleton by configurations -val grammarKit by configurations - -group = "io.mcdev.obfex" - -intellijPlatform { - projectName = "Obfuscation Explorer" -} - -dependencies { - intellijPlatform { - intellijIdeaCommunity(libs.versions.intellij.ide, useInstaller = false) - - plugin(libs.versions.psiPlugin.map { "PsiViewer:$it" }) - - testFramework(TestFrameworkType.JUnit5) - testFramework(TestFrameworkType.Platform) - } -} - -val generateSrgLexer by lexer("SrgLexer", "io/mcdev/obfex/formats/srg/gen") -val generateSrgParser by parser("SrgParser", "io/mcdev/obfex/formats/srg/gen") - -val generateCSrgLexer by lexer("CSrgLexer", "io/mcdev/obfex/formats/csrg/gen") -val generateCSrgParser by parser("CSrgParser", "io/mcdev/obfex/formats/csrg/gen") - -val generateTSrgLexer by lexer("TSrgLexer", "io/mcdev/obfex/formats/tsrg/gen") -val generateTSrgParser by parser("TSrgParser", "io/mcdev/obfex/formats/tsrg/gen") - -val generateTSrg2Lexer by lexer("TSrg2Lexer", "io/mcdev/obfex/formats/tsrg2/gen") -val generateTSrg2Parser by parser("TSrg2Parser", "io/mcdev/obfex/formats/tsrg2/gen") - -val generateJamLexer by lexer("JamLexer", "io/mcdev/obfex/formats/jam/gen") -val generateJamParser by parser("JamParser", "io/mcdev/obfex/formats/jam/gen") - -val generateEnigmaLexer by lexer("EnigmaLexer", "io/mcdev/obfex/formats/enigma/gen") -val generateEnigmaParser by parser("EnigmaParser", "io/mcdev/obfex/formats/enigma/gen") - -val generateTinyV1Lexer by lexer("TinyV1Lexer", "io/mcdev/obfex/formats/tinyv1/gen") -val generateTinyV1Parser by parser("TinyV1Parser", "io/mcdev/obfex/formats/tinyv1/gen") - -val generateTinyV2Lexer by lexer("TinyV2Lexer", "io/mcdev/obfex/formats/tinyv2/gen") -val generateTinyV2Parser by parser("TinyV2Parser", "io/mcdev/obfex/formats/tinyv2/gen") - -val generateProGuardLexer by lexer("ProGuardLexer", "io/mcdev/obfex/formats/proguard/gen") -val generateProGuardParser by parser("ProGuardParser", "io/mcdev/obfex/formats/proguard/gen") - -val generate by tasks.registering { - group = "minecraft" - description = "Generates sources needed to compile the plugin." - outputs.dir(layout.buildDirectory.dir("gen")) - dependsOn( - generateSrgLexer, - generateSrgParser, - generateCSrgLexer, - generateCSrgParser, - generateTSrgLexer, - generateTSrgParser, - generateTSrg2Lexer, - generateTSrg2Parser, - generateJamLexer, - generateJamParser, - generateEnigmaLexer, - generateEnigmaParser, - generateTinyV1Lexer, - generateTinyV1Parser, - generateTinyV2Lexer, - generateTinyV2Parser, - generateProGuardLexer, - generateProGuardParser, - ) -} - -sourceSets.main { java.srcDir(generate) } - -// Remove gen directory on clean -tasks.clean { delete(generate) } - -license { - tasks { - register("gradle") { - files.from( - fileTree(project.projectDir) { - include("*.gradle.kts", "gradle.properties") - exclude("**/buildSrc/**", "**/build/**") - } - ) - } - register("grammars") { - files.from(project.fileTree("src/main/grammars")) - } - } -} Index: obfuscation-explorer/changelog.md =================================================================== --- obfuscation-explorer/changelog.md (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/changelog.md (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,0 +0,0 @@ Index: obfuscation-explorer/gradle.properties =================================================================== --- obfuscation-explorer/gradle.properties (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/gradle.properties (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,22 +0,0 @@ -# -# Minecraft Development for IntelliJ -# -# https://mcdev.io/ -# -# Copyright (C) 2025 minecraft-dev -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, version 3.0 only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . -# - -# suppress inspection "UnusedProperty" for whole file -coreVersion = 0.0.1 Index: obfuscation-explorer/icons/csrg.svg =================================================================== --- obfuscation-explorer/icons/csrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/csrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - CSG - Index: obfuscation-explorer/icons/enigma.svg =================================================================== --- obfuscation-explorer/icons/enigma.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/enigma.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - ENG - Index: obfuscation-explorer/icons/jam.svg =================================================================== --- obfuscation-explorer/icons/jam.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/jam.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - JAM - Index: obfuscation-explorer/icons/pluginIcon.svg =================================================================== --- obfuscation-explorer/icons/pluginIcon.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/pluginIcon.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,138 +0,0 @@ - - - Obfuscation Mapper Icon - - - - - - image/svg+xml - - Obfuscation Mapper Icon - - - - Kyle Wood - - - - - - - - - - - - - - - - - - - - - - - - - Index: obfuscation-explorer/icons/proguard.svg =================================================================== --- obfuscation-explorer/icons/proguard.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/proguard.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - PRO - Index: obfuscation-explorer/icons/srg.svg =================================================================== --- obfuscation-explorer/icons/srg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/srg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - SRG - Index: obfuscation-explorer/icons/tinyv1.svg =================================================================== --- obfuscation-explorer/icons/tinyv1.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/tinyv1.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - Tv1 - Index: obfuscation-explorer/icons/tinyv2.svg =================================================================== --- obfuscation-explorer/icons/tinyv2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/tinyv2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - Tv2 - Index: obfuscation-explorer/icons/tsrg.svg =================================================================== --- obfuscation-explorer/icons/tsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/tsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - TSG - Index: obfuscation-explorer/icons/tsrg2.svg =================================================================== --- obfuscation-explorer/icons/tsrg2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/tsrg2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,81 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - TG2 - Index: obfuscation-explorer/icons/xsrg.svg =================================================================== --- obfuscation-explorer/icons/xsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/icons/xsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - XSG - Index: obfuscation-explorer/src/main/grammars/CSrgLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/CSrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/CSrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,80 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.csrg.gen.psi.CSrgTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public CSrgLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class CSrgLexer -%implements FlexLexer -%function advance -%type IElementType - -%s SIGNATURE - -%unicode - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -COMMENT=\s*#.* -WHITE_SPACE=\s -CRLF=\r\n|\n|\r - -%% - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(YYINITIAL); return CRLF; } - {WHITE_SPACE} { yybegin(YYINITIAL); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(YYINITIAL); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/CSrgParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/CSrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/CSrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,79 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.csrg.gen.parser.CSrgParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="CSrg" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.csrg.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.csrg.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.csrg.gen.psi.CSrgTypes" - elementTypeClass="io.mcdev.obfex.formats.csrg.lang.psi.CSrgElementType" - tokenTypeClass="io.mcdev.obfex.formats.csrg.lang.psi.CSrgTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - - // do not record error reporting information in recover rules - consumeTokenMethod(".*_recover")="consumeTokenFast" -} - -csrg_file ::= line* - -private line ::= !<> mapping? line_end {pin=2 recoverWhile=line_recover} -private line_end ::= <> | CRLF -private line_recover ::= !(mapping | line_end) - -mapping ::= method_mapping | field_mapping | class_mapping - -method_mapping ::= mapping_part mapping_part method_signature mapping_part { - methods=[ - obfClassName="/mapping_part[0]" - obfMethodName="/mapping_part[1]" - obfSignature="/method_signature" - deobfMethodName="/mapping_part[2]" - ] -} -field_mapping ::= mapping_part mapping_part mapping_part { - methods=[ - obfClassName="/mapping_part[0]" - obfFieldName="/mapping_part[1]" - deobfName="/mapping_part[2]" - ] -} -class_mapping ::= mapping_part mapping_part { - methods=[ - obfName="/mapping_part[0]" - deobfName="/mapping_part[1]" - ] -} - -mapping_part ::= PRIMITIVE | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/EnigmaLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/EnigmaLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/EnigmaLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,97 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public EnigmaLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class EnigmaLexer -%implements FlexLexer -%function advance -%type IElementType - -%s DOC_LINE -%s SIGNATURE - -%unicode - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) -INDEX=\d+ - -COMMENT=\s*#.* -DOC_TEXT=[^\r\n]+ - -TAB=\t -WHITE_SPACE=\s -CRLF=\r\n|\n|\r - -%% - - { - "CLASS" { return CLASS_KEY; } - "FIELD" { return FIELD_KEY; } - "METHOD" { return METHOD_KEY; } - "ARG" { return ARG_KEY; } - "COMMENT" { yybegin(DOC_LINE); return COMMENT_KEY; } - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - "" { return CONSTRUCTOR; } - {INDEX} { return INDEX; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } - {TAB} { return TAB; } -} - - { - {DOC_TEXT} { return DOC_TEXT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(YYINITIAL); return CRLF; } - {WHITE_SPACE} { yybegin(YYINITIAL); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(YYINITIAL); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/EnigmaParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/EnigmaParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/EnigmaParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.enigma.gen.parser.EnigmaParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - parserUtilClass='io.mcdev.obfex.formats.enigma.lang.psi.EnigmaParserUtil' - - psiClassPrefix="Enigma" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.enigma.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.enigma.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes" - elementTypeClass="io.mcdev.obfex.formats.enigma.lang.psi.EnigmaElementType" - tokenTypeClass="io.mcdev.obfex.formats.enigma.lang.psi.EnigmaTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - TAB="regexp:\t" - ] - - consumeTokenMethod="consumeTokenFast" -} - -enigma_file ::= entry* - -private entry ::= !<> class_mapping* -private line_end ::= <> | CRLF+ - -external indent ::= indent0 VIRTUAL_OPEN VIRTUAL_CLOSE <> - -class_mapping ::= CLASS_KEY class_mapping_part+ line_end <>? {pin=1} -class_mapping_part ::= mapping_part | INDEX - -private class_children ::= doc_line* member_mapping* - -member_mapping ::= field_mapping | method_mapping | class_mapping {recoverWhile=member_recover} -private member_recover ::= !(FIELD_KEY | METHOD_KEY | (VIRTUAL_CLOSE* CLASS_KEY)) - -doc_line ::= COMMENT_KEY DOC_TEXT? line_end {pin=1} - -field_mapping ::= FIELD_KEY (<> mapping_part)+ type_desc line_end nested_docs? {pin=1} - -method_mapping ::= METHOD_KEY mapping_part+ method_signature line_end <>? {pin=1} - -private method_children ::= doc_line* arg_mapping* - -arg_mapping ::= ARG_KEY arg_index mapping_part line_end nested_docs? {pin=1} -arg_index ::= INDEX - -private nested_docs ::= <> - -mapping_part ::= PRIMITIVE | CONSTRUCTOR | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/JamLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/JamLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/JamLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,90 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.jam.gen.psi.JamTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public JamLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class JamLexer -%implements FlexLexer -%function advance -%type IElementType - -%s ENTRY -%s SIGNATURE - -%unicode - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) -INDEX=\d - -COMMENT=\s*#.* -WHITE_SPACE=\s+ -CRLF=\r\n|\n|\r - -%% - - { - "CL" { yybegin(ENTRY); return CLASS_KEY; } - "FD" { yybegin(ENTRY); return FIELD_KEY; } - "MD" { yybegin(ENTRY); return METHOD_KEY; } - "MP" { yybegin(ENTRY); return PARAM_KEY; } -} - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {INDEX} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return INDEX; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(YYINITIAL); return CRLF; } - {WHITE_SPACE} { yybegin(ENTRY); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(YYINITIAL); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/JamParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/JamParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/JamParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,93 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.jam.gen.parser.JamParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="Jam" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.jam.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.jam.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.jam.gen.psi.JamTypes" - elementTypeClass="io.mcdev.obfex.formats.jam.lang.psi.JamElementType" - tokenTypeClass="io.mcdev.obfex.formats.jam.lang.psi.JamTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - - // do not record error reporting information in recover rules - consumeTokenMethod(".*_recover")="consumeTokenFast" -} - -srg_file ::= line* - -private line ::= !<> mapping? line_end {pin=2 recoverWhile=line_recover} -private line_end ::= <> | CRLF -private line_recover ::= !(mapping | line_end) - -mapping ::= class_mapping | field_mapping | method_mapping | param_mapping - -class_mapping ::= CLASS_KEY mapping_part mapping_part { - pin=1 - methods=[ - obfName="/mapping_part[0]" - deobfName="/mapping_part[1]" - ] -} -field_mapping ::= FIELD_KEY mapping_part mapping_part type_desc mapping_part { - pin=1 - methods=[ - obfClassName="/mapping_part[0]" - obfFieldName="/mapping_part[1]" - obfType="/type_desc" - deobfName="/mapping_part[2]" - ] -} -method_mapping ::= METHOD_KEY mapping_part mapping_part method_signature mapping_part { - pin=1 - methods=[ - obfClassName="/mapping_part[0]" - obfMethodName="/mapping_part[1]" - obfSignature="/method_signature" - deobfName="/mapping_part[2]" - ] -} -param_mapping ::= PARAM_KEY mapping_part mapping_part method_signature mapping_part mapping_part { - pin=1 - methods=[ - obfClassName="/mapping_part[0]" - obfMethodName="/mapping_part[1]" - obfSignature="/method_signature" - parameterIndex="/mapping_part[2]" - deobfName="/mapping_part[3]" - ] -} - -mapping_part ::= PRIMITIVE | identifier | INDEX -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type {pin=1} -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/ProGuardLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/ProGuardLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/ProGuardLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.proguard.gen.psi.ProGuardTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public ProGuardLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class ProGuardLexer -%implements FlexLexer -%function advance -%type IElementType - -%s CORE - -%unicode - -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=void|boolean|char|byte|short|int|long|float|double - -NUMBER=\d -POINTER=\s*->\s* - -COMMENT=\s*#.* - -WHITE_SPACE=\s -CRLF=\r\n|\n|\r - -%% - - { - ":" { return COLON; } - "." { return DOT; } - "," { return COMMA; } - "(" { return OPEN_PAREN; } - ")" { return CLOSE_PAREN; } - "" { return INIT; } - "" { return INIT; } - "[]" { return ARRAY_BRACKETS; } - "package-info" { return PACKAGE_INFO; } - {NUMBER}+ { return NUMBER; } - {POINTER} { return POINTER; } - {PRIMITIVE} { return PRIMITIVE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - -{COMMENT} { return COMMENT; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/ProGuardParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/ProGuardParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/ProGuardParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,69 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.proguard.gen.parser.ProGuardParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="ProGuard" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.proguard.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.proguard.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.proguard.gen.psi.ProGuardTypes" - elementTypeClass="io.mcdev.obfex.formats.proguard.lang.psi.ProGuardElementType" - tokenTypeClass="io.mcdev.obfex.formats.proguard.lang.psi.ProGuardTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] -} - -proguard_file ::= entry* - -private entry ::= !<> class_mapping? - -class_mapping ::= identifier POINTER identifier COLON member_mapping* { - methods=[ - fromName="/class_name[0]" - toName="/class_name[1]" - ] -} - -member_mapping ::= method_mapping | field_mapping - -field_mapping ::= type_desc field_name POINTER field_name { - methods=[ - fromName="/field_name[0]" - toName="/field_name[1]" - ] -} -field_name ::= identifier | NUMBER - -method_mapping ::= (NUMBER COLON NUMBER COLON)? return_type method_name method_signature POINTER method_name -return_type ::= type_desc -method_name ::= identifier | INIT | CLINIT - -method_signature ::= OPEN_PAREN (param_type (COMMA param_type)*)? CLOSE_PAREN {pin=1} -param_type ::= type_desc - -identifier ::= NAME_ELEMENT (DOT (NAME_ELEMENT | PACKAGE_INFO))* {pin(".*")=1} -type_desc ::= (identifier | PRIMITIVE) ARRAY_BRACKETS* Index: obfuscation-explorer/src/main/grammars/SrgLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/SrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/SrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,96 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.srg.gen.psi.SrgTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public SrgLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class SrgLexer -%implements FlexLexer -%function advance -%type IElementType - -%s PACKAGE_ENTRY -%s ENTRY -%s SIGNATURE - -%unicode - -// Package name entries just match until whitespace is hit -PACKAGE_NAME=[^\s\r\n]+ - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -COMMENT=\s*#.* -WHITE_SPACE=\s+ -CRLF=\r\n|\n|\r - -%% - - { - "PK:" { yybegin(PACKAGE_ENTRY); return PACKAGE_KEY; } - "CL:" { yybegin(ENTRY); return CLASS_KEY; } - "FD:" { yybegin(ENTRY); return FIELD_KEY; } - "MD:" { yybegin(ENTRY); return METHOD_KEY; } -} - - { - {PACKAGE_NAME} { return PACKAGE_NAME; } -} - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(YYINITIAL); return CRLF; } - {WHITE_SPACE} { yybegin(ENTRY); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(YYINITIAL); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/SrgParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/SrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/SrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,111 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.srg.gen.parser.SrgParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="Srg" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.srg.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.srg.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.srg.gen.psi.SrgTypes" - elementTypeClass="io.mcdev.obfex.formats.srg.lang.psi.SrgElementType" - tokenTypeClass="io.mcdev.obfex.formats.srg.lang.psi.SrgTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - - // do not record error reporting information in recover rules - consumeTokenMethod(".*_recover")="consumeTokenFast" -} - -srg_file ::= line* - -private line ::= !<> mapping? line_end {pin=2 recoverWhile=line_recover} -private line_end ::= <> | CRLF -private line_recover ::= !(mapping | line_end) - -mapping ::= package_mapping | class_mapping | field_mapping | method_mapping - -package_mapping ::= PACKAGE_KEY package_mapping_part package_mapping_part { - pin=1 - methods=[ - obfName="/package_mapping_part[0]" - deobfName="/package_mapping_part[1]" - ] -} -class_mapping ::= CLASS_KEY mapping_part mapping_part { - pin=1 - methods=[ - obfName="/mapping_part[0]" - deobfName="/mapping_part[1]" - ] -} -field_mapping ::= FIELD_KEY (extended_field_mapping | standard_field_mapping) { - pin=1 - methods=[ - obfName - obfSignature - deobfName - deobfSignature - ] - mixin="io.mcdev.obfex.formats.srg.lang.psi.mixins.impl.SrgFieldMappingImplMixin" - implements="io.mcdev.obfex.formats.srg.lang.psi.mixins.SrgFieldMappingMixin" -} -method_mapping ::= METHOD_KEY mapping_part method_signature mapping_part method_signature { - pin=1 - methods=[ - obfName="/mapping_part[0]" - obfSignature="/method_signature[0]" - deobfName="/mapping_part[1]" - deobfSignature="/method_signature[1]" - ] -} - -package_mapping_part ::= PACKAGE_NAME - -standard_field_mapping ::= mapping_part mapping_part { - methods=[ - obfName="/mapping_part[0]" - deobfName="/mapping_part[1]" - ] -} -extended_field_mapping ::= mapping_part type_desc mapping_part type_desc { - pin=3 - methods=[ - obfName="/mapping_part[0]" - obfType="/type_desc[0]" - deobfName="/mapping_part[1]" - deobfType="/type_desc[1]" - ] -} - -mapping_part ::= PRIMITIVE | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= name_part (SLASH name_part)* {pin(".*")=1} -name_part ::= NAME_ELEMENT - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type {pin=1} -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/TSrg2Lexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/TSrg2Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TSrg2Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,101 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Types.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public TSrg2Lexer() { - this((java.io.Reader)null); - } -%} - -%public -%class TSrg2Lexer -%implements FlexLexer -%function advance -%type IElementType - -%s HEADER -%s CORE -%s SIGNATURE - -%unicode - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -COMMENT=\s*#.* - -TAB=\t -WHITE_SPACE=\s -CRLF=\r\n|\n|\r -NAMESPACE=\w -DIGIT=\d - -%% - - { - "tsrg2" { yybegin(HEADER); return TSRG2_KEY; } -} - -
{ - {NAMESPACE}+ { return NAMESPACE_KEY; } - {CRLF} { yybegin(CORE); return CRLF; } -} - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - "" { return INIT; } - "" { return CLINIT; } - "static" { return STATIC; } - "package-info" { return NAME_ELEMENT; } - {DIGIT}+ { return DIGIT; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } - {TAB} { return TAB; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(CORE); return CRLF; } - {WHITE_SPACE} { yybegin(CORE); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(CORE); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/TSrg2Parser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/TSrg2Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TSrg2Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,81 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.tsrg2.gen.parser.TSrg2Parser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - parserUtilClass='io.mcdev.obfex.formats.util.sigws.SignificantWhitespaceParserUtil' - - psiClassPrefix="TSrg2" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.tsrg2.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.tsrg2.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Types" - elementTypeClass="io.mcdev.obfex.formats.tsrg2.lang.psi.TSrg2ElementType" - tokenTypeClass="io.mcdev.obfex.formats.tsrg2.lang.psi.TSrg2TokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - TAB="regexp:\t" - ] - - consumeTokenMethod="consumeTokenFast" -} - -tsrg_file ::= file_element? -file_element ::= header entry* - -private line_end ::= <> | CRLF+ - -header ::= TSRG2_KEY namespace* line_end {pin=1} - -namespace ::= NAMESPACE_KEY - -private entry ::= !<> class_mapping? - -external indent ::= indent0 VIRTUAL_OPEN VIRTUAL_CLOSE <> - -class_mapping ::= mapping_part+ line_end <>? {pin=1 recoverWhile=mapping_recover} -private mapping_recover ::= !(mapping_part | VIRTUAL_CLOSE) - -private class_children ::= member_mapping* -member_mapping ::= method_mapping | field_mapping {recoverWhile=mapping_recover} - -method_mapping ::= mapping_part method_signature mapping_part+ line_end <>? {pin=2} -private method_members ::= static_decl? param_mapping* - -field_mapping ::= mapping_part+ line_end <>? {pin=1} - -private static_decl ::= STATIC line_end {pin=1 recoverWhile=static_recover} -private static_recover ::= !(VIRTUAL_CLOSE | DIGIT) - -mapping_part ::= PRIMITIVE | INIT | CLINIT | DIGIT | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type {pin=1} -param_types ::= type_desc* -return_type ::= type_desc - -param_mapping ::= param_index mapping_part* line_end {pin=1 recoverWhile=param_recover} -param_index ::= DIGIT -private param_recover ::= !(VIRTUAL_CLOSE | DIGIT) Index: obfuscation-explorer/src/main/grammars/TSrgLexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/TSrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TSrgLexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,83 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.tsrg.gen.psi.TSrgTypes.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public TSrgLexer() { - this((java.io.Reader)null); - } -%} - -%public -%class TSrgLexer -%implements FlexLexer -%function advance -%type IElementType - -%s SIGNATURE - -%unicode - -// Name element is used for all parts of an identifier name -// 1. The parts of the package -// 2. The class name -// 3. The member name -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -COMMENT=\s*#.* - -TAB=\t -WHITE_SPACE=\s -CRLF=\r\n|\n|\r - -%% - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {TAB} { return TAB; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(YYINITIAL); return CRLF; } - {WHITE_SPACE} { yybegin(YYINITIAL); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(YYINITIAL); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/TSrgParser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/TSrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TSrgParser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,70 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.tsrg.gen.parser.TSrgParser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="TSrg" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.tsrg.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.tsrg.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.tsrg.gen.psi.TSrgTypes" - elementTypeClass="io.mcdev.obfex.formats.tsrg.lang.psi.TSrgElementType" - tokenTypeClass="io.mcdev.obfex.formats.tsrg.lang.psi.TSrgTokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - - // do not record error reporting information in recover rules - consumeTokenMethod(".*_recover")="consumeTokenFast" -} - -tsrg_file ::= entry* - -private entry ::= !<> mapping? line_end {recoverWhile=line_recover} -private line_end ::= <> | CRLF -private line_recover ::= !(mapping | line_end) - -mapping ::= class_mapping (line_end member_mapping)* - -class_mapping ::= obf_class_mapping_part deobf_class_mapping_part -obf_class_mapping_part ::= mapping_part -deobf_class_mapping_part ::= mapping_part - -member_mapping ::= TAB (method_mapping | field_mapping) -method_mapping ::= obf_method_mapping_part method_signature deobf_method_mapping_part -obf_method_mapping_part ::= mapping_part -deobf_method_mapping_part ::= mapping_part - -field_mapping ::= obf_field_mapping_part deobf_field_mapping_part -obf_field_mapping_part ::= mapping_part -deobf_field_mapping_part ::= mapping_part - -mapping_part ::= PRIMITIVE | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/TinyV1Lexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/TinyV1Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TinyV1Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,93 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1Types.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - public TinyV1Lexer() { - this((java.io.Reader)null); - } -%} - -%public -%class TinyV1Lexer -%implements FlexLexer -%function advance -%type IElementType - -%s NAMESPACES -%s CORE -%s ENTRY -%s SIGNATURE - -%unicode - -NAMESPACE=[^\s] - -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -COMMENT=\s*#.* -WHITE_SPACE=\s+ -CRLF=\r\n|\n|\r - -%% - - { - "v1" { yybegin(NAMESPACES); return V1_KEY; } -} - - { - {NAMESPACE}+ { return NAMESPACE_KEY; } -} - - { - "CLASS" { yybegin(ENTRY); return CLASS_KEY; } - "FIELD" { yybegin(ENTRY); return FIELD_KEY; } - "METHOD" { yybegin(ENTRY); return METHOD_KEY; } -} - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {WHITE_SPACE} { yybegin(ENTRY); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(CORE); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/TinyV1Parser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/TinyV1Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TinyV1Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,67 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.tinyv1.gen.parser.TinyV1Parser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="TinyV1" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.tinyv1.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.tinyv1.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1Types" - elementTypeClass="io.mcdev.obfex.formats.tinyv1.lang.psi.TinyV1ElementType" - tokenTypeClass="io.mcdev.obfex.formats.tinyv1.lang.psi.TinyV1TokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - - // do not record error reporting information in recover rules - consumeTokenMethod(".*_recover")="consumeTokenFast" -} - -tinyv1_file ::= file_element? -file_element ::= header line_end line* - -header ::= V1_KEY namespace* {pin=1} -namespace ::= NAMESPACE_KEY - -private line_end ::= <> | CRLF -private line_recover ::= !(mapping | line_end) - -private line ::= !<> mapping? line_end {pin=2 recoverWhile=line_recover} - -mapping ::= class_mapping | field_mapping | method_mapping - -class_mapping ::= CLASS_KEY mapping_part* {pin=1} -field_mapping ::= FIELD_KEY mapping_part type_desc mapping_part* {pin=1} -method_mapping ::= METHOD_KEY mapping_part method_signature mapping_part* {pin=1} - -mapping_part ::= PRIMITIVE | identifier -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= name_part (SLASH name_part)* {pin(".*")=1} -name_part ::= NAME_ELEMENT - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type {pin=1} -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/grammars/TinyV2Lexer.flex =================================================================== --- obfuscation-explorer/src/main/grammars/TinyV2Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TinyV2Lexer.flex (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,154 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.gen.lexer; - -import com.intellij.lexer.*; -import com.intellij.psi.tree.IElementType; -import static io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2Types.*; -import static com.intellij.psi.TokenType.*; - -%% - -%{ - private int versionNumCounter = 0; - - public TinyV2Lexer() { - this((java.io.Reader)null); - } -%} - -%public -%class TinyV2Lexer -%implements FlexLexer -%function advance -%type IElementType - -%s HEADER -%s MAYBE_PROPERTIES -%s PROPERTIES -%s PROP_VALUE -%s DOC_LINE -%s CORE -%s CORE2 -%s MAPPING -%s PARAM_MAPPING -%s LOCAL_VAR_MAPPING -%s SIGNATURE - -%unicode - -SAFE_STRING=[^\\\n\r\t\0\s] -PROP_VALUE=[^\s] - -DOC_TEXT=[^\r\n]+ - -NAME_ELEMENT=[\p{L}_\p{Sc}][\p{L}\p{N}_\p{Sc}]* - -PRIMITIVE=[ZBCSIFDJV] -CLASS_TYPE=(\[+[ZBCSIFDJ]|\[*L[^;\s]+;) - -DIGIT=\d - -COMMENT=\s*#.* - -WHITE_SPACE=\s -CRLF=\r\n|\n|\r - -%% - - { - "tiny" { yybegin(HEADER); return TINY_KEY; } -} - -
{ - {DIGIT}+ { if (versionNumCounter++ <= 2) return VERSION_NUM; else return NAMESPACE_KEY; } - {SAFE_STRING}+ { return NAMESPACE_KEY; } - {CRLF} { yybegin(MAYBE_PROPERTIES); return CRLF; } -} - - { - "c" { yybegin(MAPPING); return CLASS_KEY; } - {CRLF} { yybegin(CORE); return CRLF; } - {WHITE_SPACE} { yybegin(PROPERTIES); return WHITE_SPACE; } -} - - { - {SAFE_STRING}+ { return PROPERTY_KEY; } - {CRLF} { yybegin(MAYBE_PROPERTIES); return CRLF; } - {WHITE_SPACE} { yybegin(PROP_VALUE); return WHITE_SPACE; } -} - - { - {CRLF} { yybegin(MAYBE_PROPERTIES); return CRLF; } - {PROP_VALUE}+ { return PROPERTY_VALUE; } -} - - { - "c" { yybegin(MAPPING); return CLASS_KEY; } - {CRLF} { yybegin(CORE); return CRLF; } - {WHITE_SPACE} { yybegin(CORE2); return WHITE_SPACE; } -} - - { - "m" { yybegin(MAPPING); return METHOD_KEY; } - "f" { yybegin(MAPPING); return FIELD_KEY; } - "p" { yybegin(PARAM_MAPPING); return PARAM_KEY; } - "v" { yybegin(LOCAL_VAR_MAPPING); return VAR_KEY; } - "c" { yybegin(DOC_LINE); return COMMENT_KEY; } -} - - { - {DOC_TEXT} { return DOC_TEXT; } - {CRLF} { yybegin(CORE); return CRLF; } -} - - { - "(" { yybegin(SIGNATURE); return OPEN_PAREN; } - "/" { return SLASH; } - {PRIMITIVE} {WHITE_SPACE}? { zzMarkedPos = zzStartRead + 1; return PRIMITIVE; } - "" { return INIT; } - "" { return CLINIT; } - "package-info" { return NAME_ELEMENT; } - {CLASS_TYPE} { return CLASS_TYPE; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - {DIGIT}+ { yybegin(MAPPING); return DIGIT; } -} - - { - {DIGIT}+ { return DIGIT; } - {NAME_ELEMENT} { return NAME_ELEMENT; } -} - - { - ")" { return CLOSE_PAREN; } - {PRIMITIVE} { return PRIMITIVE; } - {CLASS_TYPE} { return CLASS_TYPE; } - {CRLF} { yybegin(CORE); return CRLF; } - {WHITE_SPACE} { yybegin(MAPPING); return WHITE_SPACE; } -} - -{COMMENT} { return COMMENT; } -{CRLF} { yybegin(CORE); return CRLF; } -{WHITE_SPACE} { return WHITE_SPACE; } -[^] { return BAD_CHARACTER; } Index: obfuscation-explorer/src/main/grammars/TinyV2Parser.bnf =================================================================== --- obfuscation-explorer/src/main/grammars/TinyV2Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/grammars/TinyV2Parser.bnf (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,94 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -{ - parserClass="io.mcdev.obfex.formats.tinyv2.gen.parser.TinyV2Parser" - - extends="com.intellij.extapi.psi.ASTWrapperPsiElement" - - psiClassPrefix="TinyV2" - psiImplClassSuffix="Impl" - psiPackage="io.mcdev.obfex.formats.tinyv2.gen.psi" - psiImplPackage="io.mcdev.obfex.formats.tinyv2.gen.psi.impl" - - elementTypeHolderClass="io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2Types" - elementTypeClass="io.mcdev.obfex.formats.tinyv2.lang.psi.TinyV2ElementType" - tokenTypeClass="io.mcdev.obfex.formats.tinyv2.lang.psi.TinyV2TokenType" - - tokens=[ - COMMENT="regexp:\s*#.*" - ] - -// consumeTokenMethod="consumeTokenFast" -} - -tinyv2_file ::= file_element? -file_element ::= header (line_end property*)? class_mapping* - -header ::= TINY_KEY VERSION_NUM VERSION_NUM namespace* {pin=1 recoverWhile=header_recover} { - methods=[ - majorVersionNum="/VERSION_NUM[0]" - minorVersionNum="/VERSION_NUM[1]" - ] -} -private header_recover ::= !line_end - -namespace ::= NAMESPACE_KEY - -property ::= PROPERTY_KEY PROPERTY_VALUE? line_end { - methods=[ - propertyKey="/PROPERTY_KEY" - propergyValue="/PROPERTY_VALUE" - ] -} - -private line_end ::= <> | CRLF+ - -class_mapping ::= CLASS_KEY mapping_part* line_end class_member* {pin=1 recoverWhile=class_recover} -private class_recover ::= !CLASS_KEY - -doc_line ::= COMMENT_KEY DOC_TEXT? line_end {pin=1} - -class_member ::= doc_line | method_mapping | field_mapping {recoverWhile=member_recover} -private member_recover ::= !(METHOD_KEY | FIELD_KEY | CLASS_KEY) -method_mapping ::= METHOD_KEY method_signature mapping_part* line_end method_member* {pin=1} - -method_member ::= doc_line | param_mapping | local_var_mapping - -param_mapping ::= PARAM_KEY param_index mapping_part* line_end doc_line* {pin=1 recoverWhile=param_recover} -private param_recover ::= !(PARAM_KEY | VAR_KEY | METHOD_KEY | FIELD_KEY | CLASS_KEY) -param_index ::= DIGIT - -local_var_mapping ::= VAR_KEY local_var_index local_var_start lvt_index? mapping_part* line_end doc_line* {pin=1 recoverWhile=local_var_recover} -private local_var_recover ::= !(VAR_KEY | PARAM_KEY | METHOD_KEY | FIELD_KEY | CLASS_KEY) -local_var_index ::= DIGIT -local_var_start ::= DIGIT -lvt_index ::= DIGIT - -field_mapping ::= FIELD_KEY type_desc mapping_part* line_end doc_line* {pin=1} - -mapping_part ::= PRIMITIVE | INIT | CLINIT | identifier - -type_desc ::= PRIMITIVE | CLASS_TYPE -identifier ::= NAME_ELEMENT (SLASH NAME_ELEMENT)* {pin(".*")=1} - -method_signature ::= OPEN_PAREN param_types CLOSE_PAREN return_type {pin=1} -param_types ::= type_desc* -return_type ::= type_desc Index: obfuscation-explorer/src/main/kotlin/ObfIcons.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/ObfIcons.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/ObfIcons.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,44 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex - -import com.intellij.ui.IconManager -import javax.swing.Icon - -object ObfIcons { - - val OBF_EX_ICON = load("/fileTypes/obfex.svg") - - val SRG_ICON = load("/fileTypes/srg.svg") - val TSRG_ICON = load("/fileTypes/tsrg.svg") - val TSRG2_ICON = load("/fileTypes/tsrg2.svg") - val CSRG_ICON = load("/fileTypes/csrg.svg") - val XSRG_ICON = load("/fileTypes/xsrg.svg") - val JAM_ICON = load("/fileTypes/jam.svg") - val ENIGMA_ICON = load("/fileTypes/enigma.svg") - val TINY_V1_ICON = load("/fileTypes/tinyv1.svg") - val TINY_V2_ICON = load("/fileTypes/tinyv2.svg") - val PROGUARD_ICONS = load("/fileTypes/proguard.svg") - - private fun load(path: String): Icon { - return IconManager.getInstance().getIcon(path, ObfIcons::class.java.classLoader) - } -} Index: obfuscation-explorer/src/main/kotlin/facet/ObfExFacet.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/ObfExFacet.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/ObfExFacet.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,44 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet - -import com.intellij.facet.Facet -import com.intellij.facet.FacetTypeId -import com.intellij.facet.FacetTypeRegistry -import com.intellij.openapi.module.Module -import io.mcdev.obfex.facet.ObfExFacetType.Companion.TYPE_ID - -class ObfExFacet( - module: Module, - name: String, - config: ObfExFacetConfiguration, - underlyingFacet: Facet<*>? -) : Facet(facetType, module, name, config, underlyingFacet) { - - companion object { - val ID = FacetTypeId(TYPE_ID) - - val facetType: ObfExFacetType - get() = facetTypeOrNull as ObfExFacetType - val facetTypeOrNull: ObfExFacetType? - get() = FacetTypeRegistry.getInstance().findFacetType(TYPE_ID) as? ObfExFacetType - } -} Index: obfuscation-explorer/src/main/kotlin/facet/ObfExFacetConfiguration.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/ObfExFacetConfiguration.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/ObfExFacetConfiguration.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,66 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet - -import com.intellij.facet.FacetConfiguration -import com.intellij.facet.ui.FacetEditorContext -import com.intellij.facet.ui.FacetEditorTab -import com.intellij.facet.ui.FacetValidatorsManager -import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.State -import com.intellij.util.xmlb.annotations.Attribute -import com.intellij.util.xmlb.annotations.Tag -import com.intellij.util.xmlb.annotations.XCollection -import io.mcdev.obfex.facet.config.ObfExFacetEditorTab -import io.mcdev.obfex.formats.MappingsFormatType - -@State(name = "ObfExFacet") -class ObfExFacetConfiguration : FacetConfiguration, PersistentStateComponent { - - private var state = ObfExFacetConfigurationData() - - override fun createEditorTabs( - editorContext: FacetEditorContext?, - validatorsManager: FacetValidatorsManager? - ): Array { - return arrayOf(ObfExFacetEditorTab(this)) - } - - override fun getState() = state - override fun loadState(state: ObfExFacetConfigurationData) { - this.state = state - } -} - -data class ObfExFacetConfigurationData( - @Tag("mappingTargets") - @XCollection(elementName = "mappingTarget", style = XCollection.Style.v2) - var mappingTargets: List = listOf(), -) - -data class MappingTargetConfig( - - @Attribute("type", converter = MappingsFormatType.Converter::class) - var type: MappingsFormatType? = null, - - @Attribute("uri") - var uri: String? = null, -) Index: obfuscation-explorer/src/main/kotlin/facet/ObfExFacetType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/ObfExFacetType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/ObfExFacetType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,47 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet - -import com.intellij.facet.Facet -import com.intellij.facet.FacetType -import com.intellij.openapi.module.Module -import com.intellij.openapi.module.ModuleType -import io.mcdev.obfex.ObfIcons - -class ObfExFacetType : - FacetType(ObfExFacet.ID, TYPE_ID, "Obfuscation Explorer") { - - override fun createFacet( - module: Module, - name: String, - configuration: ObfExFacetConfiguration, - underlyingFacet: Facet<*>? - ) = ObfExFacet(module, name, configuration, underlyingFacet) - - override fun createDefaultConfiguration() = ObfExFacetConfiguration() - override fun isSuitableModuleType(moduleType: ModuleType<*>?) = true - - override fun getIcon() = ObfIcons.OBF_EX_ICON - - companion object { - const val TYPE_ID = "obfex" - } -} Index: obfuscation-explorer/src/main/kotlin/facet/config/MappingsTable.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/config/MappingsTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/config/MappingsTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,313 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet.config - -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.diagnostic.logger -import com.intellij.openapi.fileChooser.FileChooser -import com.intellij.openapi.fileChooser.FileChooserDescriptor -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.wm.IdeFocusManager -import com.intellij.ui.ToolbarDecorator -import com.intellij.ui.components.JBTextField -import com.intellij.ui.components.textFieldWithBrowseButton -import com.intellij.ui.table.JBTable -import com.intellij.util.IconUtil -import com.intellij.util.ui.AbstractTableCellEditor -import io.mcdev.obfex.facet.MappingTargetConfig -import io.mcdev.obfex.facet.ObfExFacetConfiguration -import io.mcdev.obfex.formats.MappingsFormatType -import io.mcdev.obfex.mappings.MappingsFile -import io.mcdev.obfex.mappings.MappingsFormatParser -import java.awt.Component -import java.net.URI -import java.net.URISyntaxException -import java.nio.file.Paths -import javax.swing.JComponent -import javax.swing.JTable -import javax.swing.ListSelectionModel -import javax.swing.table.AbstractTableModel -import javax.swing.table.DefaultTableCellRenderer - -class MappingsTable(private val config: ObfExFacetConfiguration) { - - private val state: MutableList = configToState(config.state.mappingTargets).toMutableList() - - private val model: MappingsFileTableModel = MappingsFileTableModel(state) - private val table: JBTable = createTable(model) - val panel: JComponent = createPanel(table, model) - - fun stateToConfig(): List { - if (!table.isEditing) { - return state.map { MappingTargetConfig(it.type, it.uri?.toString() ?: "") } - } - - val value = table.cellEditor.cellEditorValue as? URI - val currentRow = table.editingRow - - return state.mapIndexed { i, row -> - if (i == currentRow) { - // TODO file type - MappingTargetConfig(null, value?.toString() ?: "") - } else { - MappingTargetConfig(row.type, row.uri?.toString() ?: "") - } - } - } - - private fun configToState(list: List): List { - return list.map { value -> - val (type, uri) = value - if (type == null && uri.isNullOrBlank()) { - MappingsTableRow.NULL - } else { - MappingsTableRow(type, if (uri.isNullOrBlank()) null else URI.create(uri)) - } - } - } - - fun reset() { - state.clear() - state.addAll(configToState(config.state.mappingTargets)) - - table.clearSelection() - model.fireTableDataChanged() - } - - private class MappingsFileTableModel(val state: MutableList) : AbstractTableModel() { - override fun getRowCount(): Int = state.size - override fun getColumnCount(): Int = 1 - override fun getColumnClass(columnIndex: Int): Class<*> = URI::class.java - override fun getColumnName(column: Int): String = "Mappings Files" - - override fun isCellEditable(rowIndex: Int, columnIndex: Int): Boolean = true - - override fun getValueAt(rowIndex: Int, columnIndex: Int): Any { - return state[rowIndex] - } - override fun setValueAt(aValue: Any?, rowIndex: Int, columnIndex: Int) { - val uri = when (aValue) { - is URI -> aValue - is String -> aValue.toUriFromUserInput() - else -> return - } - val type: MappingsFormatType? = uri?.let { - val path = uri.path - val matchedParsers = MappingsFormatParser.EP_NAME.extensions.filter { parser -> - parser.expectedFileExtensions.any { ext -> path.endsWith(ext) } - } - if (matchedParsers.isEmpty()) { - null - } else if (matchedParsers.size == 1) { - // TODO Provide a separate optional API method for getting file type, for parsers which don't - // need to do a full parse to determine type - // TODO Make a util for this since it's repeated here - (matchedParsers.single().parse(toVirtualFile(uri))?.source as? MappingsFile)?.type - } else { - val file = toVirtualFile(uri) - val allMatching = matchedParsers.filterNot { parser -> - parser.isSupportedFile(file) - } - if (allMatching.isEmpty()) { - null - } else if (allMatching.size == 1) { - (allMatching.single().parse(toVirtualFile(uri))?.source as? MappingsFile)?.type - } else { - logger().warn( - "Multiple support mappings parsers found for URI: " + - "$uri; choosing first registered" - ) - (allMatching.first().parse(toVirtualFile(uri))?.source as? MappingsFile)?.type - } - } - } - state[rowIndex] = MappingsTableRow(type, uri) - } - - private fun toVirtualFile(uri: URI): VirtualFile { - // This needs to handle http uris as well - probably by downloading to the .idea directory or something maybe - // need to have an external file manager for handling that, keep track of etags, redownload on change, etc - TODO() - } - } - - private class Editor( - private val model: MappingsFileTableModel, - private val state: MutableList = model.state, - ) : AbstractTableCellEditor() { - private val textField = textFieldWithBrowseButton(null, fileDesc, null) - private var row: Int = -1 - - override fun getCellEditorValue(): Any? { - return textField.text.toUriFromUserInput() - } - - override fun getTableCellEditorComponent( - table: JTable?, - value: Any?, - isSelected: Boolean, - row: Int, - column: Int - ): Component { - this.row = row - textField.text = when (value) { - is URI -> value.toPresentableText() - else -> "" - } - return textField - } - - override fun stopCellEditing(): Boolean { - if (row != -1 && state.size > row) { - val uri = textField.text.toUriFromUserInput() - state[row] = MappingsTableRow(null, uri) - model.fireTableCellUpdated(row, 0) - } - textField.text = "" - return super.stopCellEditing() - } - } - - private object Renderer : DefaultTableCellRenderer() { - private fun readResolve(): Any = Renderer - - override fun getTableCellRendererComponent( - table: JTable?, - value: Any?, - isSelected: Boolean, - hasFocus: Boolean, - row: Int, - column: Int - ): Component { - val field = JBTextField() - field.text = when (value) { - is URI -> value.toPresentableText() - is String -> value - else -> "" - } - field.isEditable = false - - return field - } - } - - companion object { - private fun createTable(model: MappingsFileTableModel): JBTable { - val table = JBTable(model) - - table.setShowGrid(true) - table.setEnableAntialiasing(true) - - table.emptyText.text = "No mappings files" - - table.visibleRowCount = 8 - - table.setDefaultRenderer(URI::class.java, Renderer) - table.setDefaultEditor(URI::class.java, Editor(model)) - - table.selectionModel.selectionMode = ListSelectionModel.SINGLE_SELECTION - - return table - } - - private fun createPanel(table: JBTable, model: MappingsFileTableModel): JComponent { - val state = model.state - - return ToolbarDecorator.createDecorator(table) - .disableUpDownActions() - .setAddAction { - val initial = state.size - - val chosenFiles = FileChooser.chooseFiles(fileDesc, null, null) - for (chosenFile in chosenFiles) { - state.add(MappingsTableRow(null, chosenFile.toNioPath().toUri())) - } - model.fireTableRowsInserted(initial, state.lastIndex) - } - .setAddIcon(IconUtil.addPackageIcon) - .setAddActionName("Add File") - .addExtraAction(object : AnAction( - "Add Text", - "Create blank entry for manual input", - IconUtil.addBlankLineIcon - ) { - override fun actionPerformed(e: AnActionEvent) { - state.add(MappingsTableRow.NULL) - if (table.isEditing) { - table.cellEditor.stopCellEditing() - } - model.fireTableRowsInserted(state.lastIndex - 1, state.lastIndex) - - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown { - IdeFocusManager.getGlobalInstance().requestFocus(table, true) - - table.changeSelection(state.lastIndex, 0, false, false) - table.editCellAt(state.lastIndex, 0) - } - } - }) - .setRemoveAction { - val selected = table.selectedRow - if (selected == -1) { - return@setRemoveAction - } - if (table.isEditing) { - table.cellEditor?.stopCellEditing() - } - - state.removeAt(selected) - model.fireTableRowsDeleted(selected, selected) - - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown { - IdeFocusManager.getGlobalInstance().requestFocus(table, true) - } - } - .setButtonComparator("Add File", "Add Text", "Remove") - .createPanel() - } - - private fun URI.toPresentableText(): String { - if (scheme == "file") { - return Paths.get(this).toAbsolutePath().toString() - } - return toString() - } - - private fun String.toUriFromUserInput(): URI? { - if (isBlank()) { - return null - } - val uri = try { - URI(this) - } catch (_: URISyntaxException) { - return null - } - if (uri.scheme == null) { - // plain file path - return Paths.get(this).toUri() - } - return uri - } - - private val fileDesc = FileChooserDescriptor(true, false, false, false, false, true).withTitle("Mappings Files") - } -} Index: obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableCell.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableCell.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableCell.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,39 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet.config - -import com.intellij.ui.dsl.builder.panel -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsFile -import java.awt.Component - -object MappingsTableCell { - - fun createComponent(def: MappingsDefinition): Component = panel { - row { - when (val s = def.source) { - is MappingsFile -> { - icon(s.type.icon) - } - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableRow.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableRow.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/config/MappingsTableRow.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet.config - -import io.mcdev.obfex.formats.MappingsFormatType -import java.net.URI - -data class MappingsTableRow( - val type: MappingsFormatType? = null, - val uri: URI? = null, -) { - companion object { - val NULL = MappingsTableRow() - } -} Index: obfuscation-explorer/src/main/kotlin/facet/config/ObfExFacetEditorTab.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/facet/config/ObfExFacetEditorTab.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/facet/config/ObfExFacetEditorTab.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,55 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.facet.config - -import com.intellij.facet.ui.FacetEditorTab -import com.intellij.ui.dsl.builder.AlignX -import com.intellij.ui.dsl.builder.panel -import io.mcdev.obfex.facet.ObfExFacetConfiguration -import javax.swing.JComponent - -class ObfExFacetEditorTab(private val config: ObfExFacetConfiguration) : FacetEditorTab() { - - private val table = MappingsTable(config) - - override fun createComponent(): JComponent { - return panel { - row { - cell(table.panel) - .align(AlignX.FILL) - } - } - } - - override fun isModified(): Boolean { - return config.state.mappingTargets != table.stateToConfig() - } - - override fun getDisplayName(): String = "Obfuscation Explorer Module Settings" - - override fun reset() { - table.reset() - } - - override fun apply() { - config.state.mappingTargets = table.stateToConfig() - } -} Index: obfuscation-explorer/src/main/kotlin/formats/MappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,41 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats - -import com.intellij.util.xmlb.Converter as IConverter -import javax.swing.Icon -import org.jetbrains.annotations.NonNls - -abstract class MappingsFormatType(@param:NonNls val id: String) { - - abstract val icon: Icon - abstract val name: String - - class Converter : IConverter() { - override fun toString(value: MappingsFormatType): String? { - return value.id - } - - override fun fromString(value: String): MappingsFormatType? { - return MappingsFormatTypeManager.get().registeredTypes.firstOrNull { it.id == value } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/MappingsFormatTypeManager.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/MappingsFormatTypeManager.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/MappingsFormatTypeManager.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,43 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats - -import java.util.Collections - -class MappingsFormatTypeManager { - - private val types: HashMap = hashMapOf() - - fun registerType(type: MappingsFormatType) { - if (types.containsKey(type.id)) { - throw IllegalArgumentException("Cannot register mappings format type: ${type.id}; Already registered") - } - types[type.id] = type - } - - val registeredTypes: Collection - get() = Collections.unmodifiableCollection(types.values) - - companion object { - private val instance = MappingsFormatTypeManager() - fun get() = instance - } -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,109 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLines -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.ref.lowPriority - -class CSrgMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("csrg") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(CSrgMappingsFormatType, file) - - file.forLines { lineNum, parts, line -> - when (parts.size) { - 2 -> parseClassLine(builder, lineNum, parts[0], parts[1]) - 3 -> parseFieldLine(builder, lineNum, parts[0], parts[1], parts[2]) - 4 -> parseMethodLine(builder, lineNum, parts[0], parts[1], parts[2], parts[3]) - else -> { - builder.error("Unrecognized line: $line", FileCoords(lineNum)) - } - } - - true - } - - return builder.build() - } - - private fun parseClassLine( - builder: MappingsDefinitionBuilder, - lineNum: Int, - leftClass: MappingPart, - rightClass: MappingPart, - ) { - builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private fun parseFieldLine( - builder: MappingsDefinitionBuilder, - lineNum: Int, - className: MappingPart, - leftField: MappingPart, - rightField: MappingPart, - ) { - builder.clazz(className.asClass().from, lineNum.lowPriority).field(lineNum.highPriority) { - with(leftField.asField().from) - with(rightField.asField().to) - } - } - - private fun parseMethodLine( - builder: MappingsDefinitionBuilder, - lineNum: Int, - className: MappingPart, - leftMethod: MappingPart, - methodDesc: MappingPart, - rightMethod: MappingPart, - ) { - val descParsed = MethodDescriptor.parse(methodDesc) - if (descParsed == null) { - builder.error("Invalid method descriptor: ${methodDesc.value}", FileCoords(lineNum, methodDesc)) - return - } - - builder.clazz(className.asClass().from, lineNum.lowPriority).method(lineNum.highPriority) { - desc = descParsed - - with(leftMethod.asMethod().from) - with(rightMethod.asMethod().to) - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/CSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object CSrgMappingsFormatType : MappingsFormatType("CSRG") { - - override val icon: Icon = ObfIcons.CSRG_ICON - override val name: String = "CSRG" -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class CSrgFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, CSrgLanguage) { - override fun getFileType(): FileType = CSrgFileType - override fun toString(): String = CSrgFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object CSrgFileType : LanguageFileType(CSrgLanguage) { - - override fun getName(): String = "CSRG" - override fun getDescription(): String = "CSRG obfuscation mapping file" - override fun getDefaultExtension(): String = "csrg" - override fun getIcon(): Icon = ObfIcons.CSRG_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang - -import com.intellij.lang.Language - -object CSrgLanguage : Language("CSRG") Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/CSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.csrg.gen.parser.CSrgParser -import io.mcdev.obfex.formats.csrg.gen.psi.CSrgTypes -import io.mcdev.obfex.formats.csrg.lang.psi.CSrgLexerAdapter - -class CSrgParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = CSrgLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = CSrgParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = CSrgFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = CSrgTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(CSrgTypes.COMMENT) -private val FILE = IFileElementType(Language.findInstance(CSrgLanguage::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.csrg.gen.psi.CSrgClassMapping -import io.mcdev.obfex.formats.csrg.gen.psi.CSrgFieldMapping -import io.mcdev.obfex.formats.csrg.gen.psi.CSrgMethodMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class CSrgAnnotator : Annotator { - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - when (element) { - is CSrgClassMapping -> { - registerHighlight(element.obfName, CSrgSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.deobfName, CSrgSyntaxHighlighter.CLASS_NAME, holder, true) - } - is CSrgMethodMapping -> { - registerHighlight(element.obfClassName, CSrgSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.obfMethodName, CSrgSyntaxHighlighter.METHOD, holder) - registerHighlight(element.deobfMethodName, CSrgSyntaxHighlighter.METHOD, holder, true) - } - is CSrgFieldMapping -> { - registerHighlight(element.obfClassName, CSrgSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.obfFieldName, CSrgSyntaxHighlighter.FIELD, holder) - registerHighlight(element.deobfName, CSrgSyntaxHighlighter.FIELD, holder, true) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,71 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.colors - -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.csrg.gen.psi.CSrgTypes -import io.mcdev.obfex.formats.csrg.lang.psi.CSrgLexerAdapter - -class CSrgSyntaxHighlighter : SyntaxHighlighterBase() { - override fun getHighlightingLexer() = CSrgLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array = - when (tokenType) { - CSrgTypes.CLASS_TYPE -> CLASS_TYPE_KEYS - CSrgTypes.PRIMITIVE -> PRIMITIVE_KEYS - CSrgTypes.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - - companion object { - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "CSRG_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "CSRG_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "CSRG_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "CSRG_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "CSRG_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "CSRG_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/colors/CSrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,29 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class CSrgSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = CSrgSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.csrg.lang.CSrgLanguage -import org.jetbrains.annotations.NonNls - -class CSrgElementType(@NonNls debugName: String) : IElementType(debugName, CSrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.csrg.gen.lexer.CSrgLexer - -class CSrgLexerAdapter : FlexAdapter(CSrgLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/csrg/lang/psi/CSrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.csrg.lang.CSrgLanguage -import org.jetbrains.annotations.NonNls - -class CSrgTokenType(@NonNls debugName: String) : IElementType(debugName, CSrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaLanguageCodeStyleSettingsProvider.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaLanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaLanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,46 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma - -import io.mcdev.obfex.formats.enigma.lang.EnigmaLanguage -import io.mcdev.obfex.formats.util.TabCodeStyleSettingsProvider -import org.intellij.lang.annotations.Language - -class EnigmaLanguageCodeStyleSettingsProvider : TabCodeStyleSettingsProvider() { - override fun getLanguage() = EnigmaLanguage - override fun getCodeSample(settingsType: SettingsType) = SAMPLE -} - -@Language("Enigma") -private const val SAMPLE = """ -CLASS net/minecraft/class_6489 net/minecraft/GameVersion - COMMENT The game version interface used by Minecraft, replacing the javabridge - COMMENT one's occurrences in Minecraft code. - METHOD method_37912 getSaveVersion ()Lnet/minecraft/class_6595; - COMMENT {@return the save version information for this game version} - METHOD method_48017 getResourceVersion (Lnet/minecraft/class_3264;)I - ARG 1 type - METHOD method_48018 getId ()Ljava/lang/String; - METHOD method_48019 getName ()Ljava/lang/String; - METHOD method_48020 getProtocolVersion ()I - METHOD method_48021 getBuildTime ()Ljava/util/Date; - METHOD method_48022 isStable ()Z -""" Index: obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,218 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLinesIndent -import io.mcdev.obfex.formats.util.indicesFrom -import io.mcdev.obfex.mappings.ClassMappingBuilder -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingIssuesRegistry -import io.mcdev.obfex.mappings.MappingSetBuilderCore -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.MethodMappingBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.ns -import io.mcdev.obfex.mappings.param -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asParam -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.highPriority - -class EnigmaMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("mapping", "mappings") - - private data class State( - val builder: MappingsDefinitionBuilder, - var baseIndent: Int = 0, - var classNamesStack: ArrayDeque = ArrayDeque(), - var classMapping: ClassMappingBuilder? = null, - var methodMapping: MethodMappingBuilder? = null, - ) : MappingSetBuilderCore by builder, MappingIssuesRegistry by builder - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(EnigmaMappingsFormatType, file) - - val state = State(builder) - file.forLinesIndent { indent, lineNum, parts, _ -> - when { - indent == state.baseIndent -> parseClass(state, lineNum, parts) - indent == state.baseIndent + 1 -> parseMember(state, lineNum, parts) - indent == state.baseIndent + 2 -> parseSubMember(state, lineNum, parts) - indent < state.baseIndent -> { - // new class starting - state.baseIndent = indent - while (state.classNamesStack.size > state.baseIndent) { - state.classNamesStack.removeLastOrNull() - } - parseClass(state, lineNum, parts) - } - } - - return@forLinesIndent true - } - - return builder.build() - } - - private fun parseClass(state: State, lineNum: Int, parts: Array) { - state.classMapping = null - state.methodMapping = null - - if (parts.isEmpty()) { - return - } - - when (parts[0].value) { - "CLASS" -> { - if (parts.size != 3) { - state.error("Unexpected number of entries in class mapping line", FileCoords(lineNum)) - return - } - - val mapping = state.clazz(lineNum.highPriority, parts[0].col) { - for (i in parts.indicesFrom(1)) { - val className = fullClassName(state, i - 1, parts[i].value) - if (className == null) { - state.error( - "All component names for class mapping could not be built as" + - "not all names in the hierarchy are present", - FileCoords(lineNum) - ) - } else { - with(className.asClass().ns(i - 1)) - } - } - } - - state.classMapping = mapping - state.classNamesStack.addLast(mapping) - } - "COMMENT" -> return - else -> state.error("Unexpected mapping file entry", FileCoords(lineNum)) - } - } - - private fun fullClassName(state: State, index: Int, name: String): String? { - if (state.classNamesStack.isEmpty()) { - return name - } - - val last = state.classNamesStack.lastOrNull()?.names?.get(index) ?: return null - @Suppress("ConvertToStringTemplate") - return last + '$' + name - } - - private fun parseMember(state: State, lineNum: Int, parts: Array) { - state.methodMapping = null - - if (parts.isEmpty()) { - return - } - - when (parts[0].value) { - "FIELD" -> parseField(state, lineNum, parts) - "METHOD" -> parseMethod(state, lineNum, parts) - "CLASS" -> { - state.baseIndent++ - parseClass(state, lineNum, parts) - } - "COMMENT" -> return - else -> state.error("Unexpected mapping file entry", FileCoords(lineNum)) - } - } - - private fun parseField(state: State, lineNum: Int, parts: Array) { - val builder = state.classMapping ?: return - - val fieldType = when (parts.size) { - 3 -> null - 4 -> parts[3].value.asTypeDef() - ?: return builder.error("Invalid field type", FileCoords(lineNum, parts[3])) - else -> return state.error("Unexpected number of entries in field mapping line", FileCoords(lineNum)) - } - - builder.field(lineNum.highPriority, parts[0].col) { - type = fieldType - - with(parts[1].asField().from) - with(parts[2].asField().to) - } - } - - private fun parseMethod(state: State, lineNum: Int, parts: Array) { - val builder = state.classMapping ?: return - - val (leftName, rightName, methodDesc) = when (parts.size) { - 3 -> Triple(parts[1], parts[1], parts[2]) - 4 -> Triple(parts[1], parts[2], parts[3]) - else -> return state.error("Unexpected number of entries in method mapping line", FileCoords(lineNum)) - } - - val parsed = methodDesc.value.asMethodDesc() - ?: return state.error("Invalid method descriptor", FileCoords(lineNum, methodDesc)) - - state.methodMapping = builder.method(lineNum.highPriority, parts[0].col) { - desc = parsed - - with(leftName.asMethod().from) - with(rightName.asMethod().to) - } - } - - private fun parseSubMember(state: State, lineNum: Int, parts: Array) { - val builder = state.methodMapping ?: return - - if (parts.isEmpty()) { - return - } - - if (parts[0].value == "COMMENT") { - return - } - if (parts[0].value != "ARG") { - return state.error("Unexpected mapping file entry", FileCoords(lineNum)) - } - - if (parts.size != 3) { - return state.error("Unexpected number of entries in method parameter mapping line", FileCoords(lineNum)) - } - - val index = parts[1].value.toIntOrNull() - ?: return state.error("Method parameter index is not a valid integer", FileCoords(lineNum, parts[1])) - - // TODO enigma actually uses lvt indices, not param. Enigma doesn't include metadata on if the method is static - // or not so we can't reliably work it out here - builder.param(index.asParamIndex(), lineNum.highPriority) { - with(parts[2].asParam().to) - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/EnigmaMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object EnigmaMappingsFormatType : MappingsFormatType("Enigma") { - - override val icon: Icon = ObfIcons.ENIGMA_ICON - override val name: String = "Enigma" -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class EnigmaFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, EnigmaLanguage) { - - override fun getFileType(): FileType = EnigmaFileType - override fun toString(): String = EnigmaFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object EnigmaFileType : LanguageFileType(EnigmaLanguage) { - - override fun getName(): String = "Enigma" - override fun getDescription(): String = "Enigma obfuscation mapping file" - override fun getDefaultExtension(): String = "mapping" - override fun getIcon(): Icon = ObfIcons.ENIGMA_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang - -import com.intellij.lang.Language - -object EnigmaLanguage : Language("Enigma") Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLayoutLexer.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLayoutLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaLayoutLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,35 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang - -import com.intellij.psi.tree.IElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes -import io.mcdev.obfex.formats.enigma.lang.psi.EnigmaLexerAdapter -import io.mcdev.obfex.formats.util.sigws.SignificantWhitespaceLexer - -class EnigmaLayoutLexer : SignificantWhitespaceLexer(EnigmaLexerAdapter()) { - - override val newlineTokens: TokenSet = TokenSet.create(EnigmaTypes.CRLF) - override val tabTokens: TokenSet = TokenSet.create(EnigmaTypes.TAB) - override val virtualOpenToken: IElementType = EnigmaTypes.VIRTUAL_OPEN - override val virtualCloseToken: IElementType = EnigmaTypes.VIRTUAL_CLOSE -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/EnigmaParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,49 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.enigma.gen.parser.EnigmaParser -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes - -class EnigmaParserDefinition : ParserDefinition { - override fun createLexer(project: Project): Lexer = EnigmaLayoutLexer() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = EnigmaParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = EnigmaFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = EnigmaTypes.Factory.createElement(node) - override fun getWhitespaceTokens(): TokenSet = WHITESPACE -} - -private val WHITESPACE = TokenSet.orSet(TokenSet.WHITE_SPACE, TokenSet.create(EnigmaTypes.TAB)) -private val COMMENTS = TokenSet.create(EnigmaTypes.COMMENT) -private val FILE = IFileElementType(EnigmaLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaArgIndex -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaArgMapping -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaClassMappingPart -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaFieldMapping -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaMappingPart -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaMethodMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class EnigmaAnnotator : Annotator { - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - val key = when (element) { - is EnigmaClassMappingPart -> EnigmaSyntaxHighlighter.CLASS_NAME - is EnigmaArgIndex -> EnigmaSyntaxHighlighter.PARAM_INDEX - is EnigmaMappingPart -> when (element.parent) { - is EnigmaMethodMapping -> EnigmaSyntaxHighlighter.METHOD - is EnigmaFieldMapping -> EnigmaSyntaxHighlighter.FIELD - is EnigmaArgMapping -> EnigmaSyntaxHighlighter.PARAM - else -> return - } - else -> return - } - - registerHighlight(element, key, holder) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,95 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.colors - -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes -import io.mcdev.obfex.formats.enigma.lang.psi.EnigmaLexerAdapter - -class EnigmaSyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer() = EnigmaLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array = - when (tokenType) { - EnigmaTypes.CLASS_KEY, EnigmaTypes.FIELD_KEY, EnigmaTypes.METHOD_KEY, - EnigmaTypes.ARG_KEY, EnigmaTypes.COMMENT_KEY -> KEYWORD_KEYS - EnigmaTypes.CLASS_TYPE -> CLASS_TYPE_KEYS - EnigmaTypes.PRIMITIVE -> PRIMITIVE_KEYS - EnigmaTypes.COMMENT -> COMMENT_KEYS - EnigmaTypes.DOC_TEXT -> DOC_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey( - "ENIGMA_KEYWORD", - DefaultLanguageHighlighterColors.KEYWORD - ) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "ENIGMA_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "ENIGMA_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "ENIGMA_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PARAM = TextAttributesKey.createTextAttributesKey( - "ENIGMA_PARAM", - DefaultLanguageHighlighterColors.PARAMETER - ) - val PARAM_INDEX = TextAttributesKey.createTextAttributesKey( - "ENIGMA_PARAM_INDEX", - DefaultLanguageHighlighterColors.INLAY_DEFAULT - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "ENIGMA_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "ENIGMA_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "ENIGMA_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - val DOC = TextAttributesKey.createTextAttributesKey( - "ENIGMA_JAVADOC", - DefaultLanguageHighlighterColors.DOC_COMMENT - ) - - private val KEYWORD_KEYS = arrayOf(KEYWORD) - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - private val DOC_KEYS = arrayOf(DOC) - private val PARAM_INDEX_KEYS = arrayOf(PARAM_INDEX) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/colors/EnigmaSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,29 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class EnigmaSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?) = EnigmaSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.enigma.lang.EnigmaLanguage -import org.jetbrains.annotations.NonNls - -class EnigmaElementType(@NonNls debugName: String) : IElementType(debugName, EnigmaLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.enigma.gen.lexer.EnigmaLexer - -class EnigmaLexerAdapter : FlexAdapter(EnigmaLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaParserUtil.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaParserUtil.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaParserUtil.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,42 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.psi - -import com.intellij.lang.PsiBuilder -import io.mcdev.obfex.formats.enigma.gen.psi.EnigmaTypes -import io.mcdev.obfex.formats.util.sigws.SignificantWhitespaceParserUtil - -@Suppress("UNUSED_PARAMETER") -object EnigmaParserUtil : SignificantWhitespaceParserUtil() { - @JvmStatic - fun fieldMappingPart( - builder: PsiBuilder, - level: Int, - ): Boolean { - if (builder.tokenType !== EnigmaTypes.PRIMITIVE) { - return true - } - val next = builder.lookAhead(1) - return next != null && // eof - next !== EnigmaTypes.CRLF && // end of line - next !== EnigmaTypes.VIRTUAL_CLOSE // automatically inserted at eof - } -} Index: obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/enigma/lang/psi/EnigmaTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.enigma.lang.EnigmaLanguage -import org.jetbrains.annotations.NonNls - -class EnigmaTokenType(@NonNls debugName: String) : IElementType(debugName, EnigmaLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,146 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLines -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.param -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asParam -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asRef -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.ref.lowPriority - -@Suppress("DuplicatedCode") -class JamMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("jam") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(JamMappingsFormatType, file) - - file.forLines { lineNum, parts, _ -> - if (parts.isEmpty()) { - return@forLines true - } - - val key = parts.first() - - when (key.value) { - "CL" -> parseClassLine(builder, lineNum, parts) - "FD" -> parseFieldLine(builder, lineNum, parts) - "MD" -> parseMethodLine(builder, lineNum, parts) - "MP" -> parseMethodParamLine(builder, lineNum, parts) - else -> builder.error("Unrecognized key: ${key.value.substring(0, 2)}", FileCoords(lineNum)) - } - - return@forLines true - } - - return builder.build() - } - - private fun parseClassLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Class line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, rightClass) = parts - builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private fun parseFieldLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 5) { - builder.error("Field line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, leftName, leftDesc, rightName) = parts - - val leftType = leftDesc.value.asTypeDef() - ?: return builder.error("Field descriptor is invalid", FileCoords(lineNum, leftDesc)) - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority).field(lineNum.highPriority) { - type = leftType - - with(leftName.asField().from) - with(rightName.asField().to) - } - } - - private fun parseMethodLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 5) { - builder.error("Method line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, leftMethod, leftDesc, rightName) = parts - - val leftType = leftDesc.value.asMethodDesc() - ?: return builder.error("Method descriptor is invalid", FileCoords(lineNum, leftDesc)) - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority).method(lineNum.highPriority) { - desc = leftType - - with(leftMethod.asMethod().from) - with(rightName.asMethod().to) - } - } - - private fun parseMethodParamLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 6) { - builder.error("Method parameter line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, leftMethod, leftDesc, index) = parts - val rightName = parts[5] - - val leftType = leftDesc.value.asMethodDesc() - ?: return builder.error("Method descriptor is invalid", FileCoords(lineNum, leftDesc)) - - val indexNum = index.value.toIntOrNull() - ?: return builder.error("Method param index is invalid", FileCoords(lineNum, index)) - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) - .method(leftMethod.asMethod().asRef(leftType).from, lineNum.lowPriority) - .param(indexNum.asParamIndex(), lineNum.highPriority) { - with(rightName.asParam().to) - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/JamMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object JamMappingsFormatType : MappingsFormatType("JAM") { - - override val icon: Icon = ObfIcons.JAM_ICON - override val name: String = "JAM" -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class JamFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, JamLanguage) { - override fun getFileType(): FileType = JamFileType - override fun toString(): String = JamFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object JamFileType : LanguageFileType(JamLanguage) { - - override fun getName(): String = "JAM" - override fun getDescription(): String = "JAM obfuscation mapping file" - override fun getDefaultExtension(): String = "jam" - override fun getIcon(): Icon = ObfIcons.JAM_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang - -import com.intellij.lang.Language - -object JamLanguage : Language("JAM") Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/JamParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.jam.gen.parser.JamParser -import io.mcdev.obfex.formats.jam.gen.psi.JamTypes -import io.mcdev.obfex.formats.jam.lang.psi.JamLexerAdapter - -class JamParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = JamLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = JamParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = JamFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = JamTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(JamTypes.COMMENT) -private val FILE = IFileElementType(Language.findInstance(JamLanguage::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,61 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.jam.gen.psi.JamClassMapping -import io.mcdev.obfex.formats.jam.gen.psi.JamFieldMapping -import io.mcdev.obfex.formats.jam.gen.psi.JamMethodMapping -import io.mcdev.obfex.formats.jam.gen.psi.JamParamMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class JamAnnotator : Annotator { - - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - when (element) { - is JamClassMapping -> { - registerHighlight(element.obfName, JamSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.deobfName, JamSyntaxHighlighter.CLASS_NAME, holder, true) - } - - is JamMethodMapping -> { - registerHighlight(element.obfClassName, JamSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.obfMethodName, JamSyntaxHighlighter.METHOD, holder) - registerHighlight(element.deobfName, JamSyntaxHighlighter.METHOD, holder, true) - } - - is JamFieldMapping -> { - registerHighlight(element.obfClassName, JamSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.obfFieldName, JamSyntaxHighlighter.FIELD, holder) - registerHighlight(element.deobfName, JamSyntaxHighlighter.FIELD, holder, true) - } - - is JamParamMapping -> { - registerHighlight(element.obfClassName, JamSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.obfMethodName, JamSyntaxHighlighter.METHOD, holder) - registerHighlight(element.parameterIndex, JamSyntaxHighlighter.PARAM_INDEX, holder) - registerHighlight(element.deobfName, JamSyntaxHighlighter.PARAM, holder, true) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,86 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.colors - -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.jam.gen.psi.JamTypes -import io.mcdev.obfex.formats.jam.lang.psi.JamLexerAdapter -import io.mcdev.obfex.formats.srg.lang.colors.SrgSyntaxHighlighter - -class JamSyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = JamLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array { - return when (tokenType) { - JamTypes.CLASS_KEY, JamTypes.FIELD_KEY, JamTypes.METHOD_KEY, JamTypes.PARAM_KEY -> KEYWORD_KEYS - JamTypes.CLASS_TYPE -> CLASS_TYPE_KEYS - JamTypes.PRIMITIVE -> PRIMITIVE_KEYS - JamTypes.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - } - - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey("JAM_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "JAM_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "JAM_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "JAM_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PARAM = TextAttributesKey.createTextAttributesKey( - "JAM_PARAM", - DefaultLanguageHighlighterColors.PARAMETER - ) - val PARAM_INDEX = TextAttributesKey.createTextAttributesKey( - "JAM_PARAM_INDEX", - DefaultLanguageHighlighterColors.INLAY_DEFAULT - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "JAM_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "JAM_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "JAM_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val KEYWORD_KEYS = arrayOf(SrgSyntaxHighlighter.KEYWORD) - private val PRIMITIVE_KEYS = arrayOf(SrgSyntaxHighlighter.PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(SrgSyntaxHighlighter.CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(SrgSyntaxHighlighter.COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/colors/JamSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class JamSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - JamSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.jam.lang.JamLanguage -import org.jetbrains.annotations.NonNls - -class JamElementType(@NonNls debugName: String) : IElementType(debugName, JamLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.jam.gen.lexer.JamLexer - -class JamLexerAdapter : FlexAdapter(JamLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/jam/lang/psi/JamTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.jam.lang.JamLanguage -import org.jetbrains.annotations.NonNls - -class JamTokenType(@NonNls debugName: String) : IElementType(debugName, JamLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,217 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLinesIndent -import io.mcdev.obfex.mappings.ClassMappingBuilder -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.ref.ArrayTypeDef -import io.mcdev.obfex.ref.ClassTypeDef -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.ReturnTypeDef -import io.mcdev.obfex.ref.TypeDef -import io.mcdev.obfex.ref.VoidTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.highPriority - -@Suppress("DuplicatedCode") -class ProGuardMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("map") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(ProGuardMappingsFormatType, file) - - var classMapping: ClassMappingBuilder? = null - file.forLinesIndent { indent, lineNum, parts, _ -> - if (indent > 0) { - val c = classMapping - if (c == null) { - builder.error("Member mapping line with no associated class", FileCoords(lineNum)) - } else { - parseMember(c, lineNum, parts) - } - } else { - classMapping = parseClass(builder, lineNum, parts) - } - - return@forLinesIndent true - } - - return builder.build() - } - - private fun parseClass( - builder: MappingsDefinitionBuilder, - lineNum: Int, - parts: Array, - ): ClassMappingBuilder? { - if (parts.size != 3) { - builder.error("Invalid class mapping line", FileCoords(lineNum)) - return null - } - - if (parts[1].value != "->") { - builder.error("Unrecognized class mapping separator", FileCoords(lineNum)) - return null - } - - val leftClass = parts[0] - val rightClass = parts[2].value.trimEnd(':') - - return builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private val methodLinesRegex = Regex("\\d+:\\d+:") - - private fun parseMember(builder: ClassMappingBuilder, lineNum: Int, parts: Array) { - if (parts.size != 4) { - builder.error("Unrecognized member mapping line", FileCoords(lineNum)) - return - } - - if (parts[2].value != "->") { - builder.error("Unrecognized member mapping separator", FileCoords(lineNum)) - return - } - - val memberDesc = parts[0] - val leftName = parts[1] - val rightName = parts[3] - - val match = methodLinesRegex.matchAt(memberDesc.value, 0) - if (match != null) { - // method - val returnTypeText = memberDesc.value.substring(match.range.last + 1) - - val paramsIndex = leftName.value.indexOf('(') - if (paramsIndex == -1) { - builder.error("Invalid method descriptor", FileCoords(lineNum, leftName)) - return - } - - val methodName = leftName.value.substring(0, paramsIndex) - val returnType = parseType(returnTypeText) - ?: return builder.error("Invalid return type", FileCoords(lineNum, memberDesc)) - - val methodParams = leftName.value.substring(paramsIndex) - - val params = parseMethodParams(methodParams) - ?: return builder.error("Invalid method descriptor", FileCoords(lineNum, leftName)) - - val methodDesc = MethodDescriptor(params, returnType) - - builder.method(lineNum.highPriority) { - desc = methodDesc - - with(methodName.asMethod().from) - with(rightName.asMethod().to) - } - } else { - val fieldType = parseType(memberDesc.value) - if (fieldType !is TypeDef) { - builder.error("Invalid field type", FileCoords(lineNum, memberDesc)) - return - } - - builder.field(lineNum.highPriority) { - type = fieldType - - with(leftName.asField().from) - with(rightName.asField().to) - } - } - } - - // Proguard doesn't use standard descriptor syntax - private fun parseMethodParams(params: String): List? { - val res = mutableListOf() - - // first index is ( - var index = 1 - while (index < params.length) { - val nextIndex = params.indexOfAny(charArrayOf(',', ')'), index) - if (nextIndex == -1) { - return null - } - - val type = parseType(params.substring(index, nextIndex)) - if (type !is TypeDef) { - return null - } - res += type - - index = nextIndex + 1 - } - - return res - } - - private fun parseType(text: String): ReturnTypeDef? { - return when (text) { - "boolean" -> PrimitiveTypeDef.BOOLEAN - "char" -> PrimitiveTypeDef.CHAR - "byte" -> PrimitiveTypeDef.BYTE - "short" -> PrimitiveTypeDef.SHORT - "int" -> PrimitiveTypeDef.INT - "long" -> PrimitiveTypeDef.LONG - "float" -> PrimitiveTypeDef.FLOAT - "double" -> PrimitiveTypeDef.DOUBLE - "void" -> VoidTypeDef - else -> { - var arrayCount = 0 - while (true) { - if (text.lastIndexOf("[]", text.lastIndex - (arrayCount * 2)) > 0) { - arrayCount++ - continue - } else { - break - } - } - - if (arrayCount > 0) { - val baseType = parseType(text.substring(0, text.lastIndex - arrayCount * 2)) - if (baseType !is TypeDef) { - return null - } - - ArrayTypeDef(baseType, arrayCount) - } else { - ClassTypeDef(text.asClass()) - } - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/ProGuardMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object ProGuardMappingsFormatType : MappingsFormatType("ProGuard") { - - override val icon: Icon = ObfIcons.PROGUARD_ICONS - override val name: String = "ProGuard" -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class ProGuardFile(viewProGuardFile: FileViewProvider) : PsiFileBase(viewProGuardFile, ProGuardLanguage) { - override fun getFileType(): FileType = ProGuardFileType - override fun toString(): String = ProGuardFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object ProGuardFileType : LanguageFileType(ProGuardLanguage) { - - override fun getName(): String = "ProGuard" - override fun getDescription(): String = "ProGuard obfuscation mapping file" - override fun getDefaultExtension(): String = "map" - override fun getIcon(): Icon = ObfIcons.PROGUARD_ICONS -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileTypeDetector.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,73 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang - -import com.intellij.openapi.fileTypes.FileType -import com.intellij.openapi.fileTypes.FileTypeRegistry.FileTypeDetector -import com.intellij.openapi.util.io.ByteSequence -import com.intellij.openapi.vfs.VirtualFile -import org.intellij.lang.annotations.Language - -class ProGuardFileTypeDetector : FileTypeDetector { - - override fun detect(file: VirtualFile, firstBytes: ByteSequence, firstCharsIfText: CharSequence?): FileType? { - if (firstCharsIfText == null) { - return null - } - - val lines = firstCharsIfText.lineSequence() - .filter { !LINE_COMMENT.matches(it) } - .toList() - - if (lines.isEmpty()) { - return null - } - - // first line must be a class mapping line - val firstLine = lines.first() - if (firstLine.matches(CLASS_MAPPING_LINE)) { - return ProGuardFileType - } - - return null - } - - private companion object { - private val LINE_COMMENT = Regex("^\\s*#.*$") - @Language("RegExp") - private const val JAVA_IDENTIFIER_REGEX = - // Initial name (either class or first package identifier) - "\\p{javaJavaIdentifierStart}\\p{javaUnicodeIdentifierPart}*" + - // additional name parts (package and class name) - "(\\.\\p{javaJavaIdentifierStart}\\p{javaUnicodeIdentifierPart}*)*" - - private val CLASS_MAPPING_LINE = Regex( - // starts at beginning of the line - "^" + - JAVA_IDENTIFIER_REGEX + - // Separator - " -> " + - JAVA_IDENTIFIER_REGEX + - // ending can include a trailing comment - ":\\s*(#.*)?$" - ) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang - -import com.intellij.lang.Language - -object ProGuardLanguage : Language("ProGuard") Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/ProGuardParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,48 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.proguard.gen.parser.ProGuardParser -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardTypes -import io.mcdev.obfex.formats.proguard.lang.psi.ProGuardLexerAdapter - -class ProGuardParserDefinition : ParserDefinition { - override fun createLexer(project: Project?): Lexer = ProGuardLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project?): PsiParser = ProGuardParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = ProGuardFile(viewProvider) - override fun createElement(node: ASTNode?): PsiElement = ProGuardTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(ProGuardTypes.COMMENT) -private val FILE = IFileElementType(ProGuardLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,54 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardClassMapping -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardFieldName -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardMethodName -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardTypeDesc -import io.mcdev.obfex.formats.util.registerHighlight - -class ProGuardAnnotator : Annotator { - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - if (element is ProGuardClassMapping) { - for (identifier in element.identifierList) { - registerHighlight(identifier, ProGuardSyntaxHighlighter.CLASS_NAME, holder) - } - return - } - if (element is ProGuardTypeDesc) { - element.identifier?.let { ident -> - registerHighlight(ident, ProGuardSyntaxHighlighter.CLASS_NAME, holder) - } - } - - val key = when (element) { - is ProGuardMethodName -> ProGuardSyntaxHighlighter.METHOD - is ProGuardFieldName -> ProGuardSyntaxHighlighter.FIELD - else -> return - } - - registerHighlight(element, key, holder) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,98 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.colors - -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.proguard.gen.psi.ProGuardTypes -import io.mcdev.obfex.formats.proguard.lang.psi.ProGuardLexerAdapter - -class ProGuardSyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = ProGuardLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array = - when (tokenType) { - ProGuardTypes.PRIMITIVE -> PRIMITIVE_KEYS - ProGuardTypes.NUMBER -> NUMBER_KEYS - ProGuardTypes.DOT -> DOT_KEYS - ProGuardTypes.COMMA -> COMMA_KEYS - ProGuardTypes.COMMENT -> COMMENT_KEYS - ProGuardTypes.COLON -> COLON_KEYS - ProGuardTypes.POINTER -> POINTER_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "PROGUARD_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "PROGUARD_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "PROGUARD_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "PROGUARD_PRIMITIVE", - DefaultLanguageHighlighterColors.KEYWORD - ) - val NUMBER = TextAttributesKey.createTextAttributesKey( - "PROGUARD_NUMBER", - DefaultLanguageHighlighterColors.NUMBER - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "PROGUARD_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - val COMMA = TextAttributesKey.createTextAttributesKey( - "PROGUARD_COMMA", - DefaultLanguageHighlighterColors.DOT - ) - val DOT = TextAttributesKey.createTextAttributesKey( - "PROGUARD_DOT", - COMMA - ) - val COLON = TextAttributesKey.createTextAttributesKey( - "PROGUARD_COLON", - DOT - ) - val POINTER = TextAttributesKey.createTextAttributesKey( - "PROGUARD_POINTER", - DefaultLanguageHighlighterColors.INLAY_TEXT_WITHOUT_BACKGROUND - ) - - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val NUMBER_KEYS = arrayOf(NUMBER) - private val COMMENT_KEYS = arrayOf(COMMENT) - private val COMMA_KEYS = arrayOf(COMMA) - private val DOT_KEYS = arrayOf(DOT) - private val COLON_KEYS = arrayOf(COLON) - private val POINTER_KEYS = arrayOf(POINTER) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/colors/ProGuardSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class ProGuardSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - ProGuardSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.proguard.lang.ProGuardLanguage -import org.jetbrains.annotations.NonNls - -class ProGuardElementType(@NonNls debugName: String) : IElementType(debugName, ProGuardLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.proguard.gen.lexer.ProGuardLexer - -class ProGuardLexerAdapter : FlexAdapter(ProGuardLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/proguard/lang/psi/ProGuardTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.proguard.lang.ProGuardLanguage -import org.jetbrains.annotations.NonNls - -class ProGuardTokenType(@NonNls debugName: String) : IElementType(debugName, ProGuardLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,180 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLines -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.pack -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asPackage -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.ref.lowPriority -import io.mcdev.obfex.splitOnLast - -@Suppress("DuplicatedCode") -class SrgMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("srg") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(SrgMappingsFormatType, file) - - file.forLines { lineNum, parts, _ -> - if (parts.isEmpty()) { - return@forLines true - } - - val key = parts.first() - - when (key.value) { - "PK:" -> parsePackageLine(builder, lineNum, parts) - "CL:" -> parseClassLine(builder, lineNum, parts) - "MD:" -> parseMethodLine(builder, lineNum, parts) - "FD:" -> parseFieldLine(builder, lineNum, parts) - else -> builder.error("Unrecognized key: ${key.value.substring(0, 3)}", FileCoords(lineNum)) - } - - return@forLines true - } - - return builder.build() - } - - private fun parsePackageLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Package line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftPack, rightPack) = parts - builder.pack(lineNum.highPriority) { - with(leftPack.asPackage().from) - with(rightPack.asPackage().to) - } - } - - private fun parseClassLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Class line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, rightClass) = parts - builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private fun parseFieldLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Field line is invalid", FileCoords(lineNum)) - return - } - - val (leftClass, leftField) = parts[1].splitOnLast('/') - if (leftField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[1]) - ) - return - } - - val (rightClass, rightField) = parts[2].splitOnLast('/') - if (rightField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[2]) - ) - return - } - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) { - unlessExists(rightClass.asClass().to) - - field(lineNum.highPriority) { - with(leftField.asField().from) - with(rightField.asField().to) - } - } - } - - private fun parseMethodLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 5) { - builder.error("Method line is invalid", FileCoords(lineNum)) - return - } - - val (leftClass, leftMethod) = parts[1].splitOnLast('/') - if (leftMethod == null) { - builder.error( - "Method mapping is invalid, no method is specified after class", - FileCoords(lineNum, parts[1]) - ) - return - } - - val (rightClass, rightMethod) = parts[3].splitOnLast('/') - if (rightMethod == null) { - builder.error( - "Method mapping is invalid, no method is specified after class", - FileCoords(lineNum, parts[3]) - ) - return - } - - val leftDesc = parts[2].value.asMethodDesc() - if (leftDesc == null) { - builder.error("Method descriptor is invalid", FileCoords(lineNum, parts[2])) - return - } - - // we don't actually store this descriptor, but we verify it for valid syntax - val rightDesc = parts[4].value.asMethodDesc() - if (rightDesc == null) { - builder.error("Method descriptor is invalid", FileCoords(lineNum, parts[4])) - return - } - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) { - unlessExists(rightClass.asClass().to) - - method(lineNum.highPriority) { - desc = leftDesc - - with(leftMethod.asMethod().from) - with(rightMethod.asMethod().to) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/SrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object SrgMappingsFormatType : MappingsFormatType("SRG") { - - override val icon: Icon = ObfIcons.SRG_ICON - override val name: String = "SRG" -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class SrgFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, SrgLanguage) { - override fun getFileType(): FileType = SrgFileType - override fun toString(): String = SrgFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object SrgFileType : LanguageFileType(SrgLanguage) { - - override fun getName(): String = "SRG" - override fun getDescription(): String = "SRG obfuscation mapping file" - override fun getDefaultExtension(): String = "srg" - override fun getIcon(): Icon = ObfIcons.SRG_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang - -import com.intellij.lang.Language - -object SrgLanguage : Language("SRG") Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/SrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.srg.gen.parser.SrgParser -import io.mcdev.obfex.formats.srg.gen.psi.SrgTypes -import io.mcdev.obfex.formats.srg.lang.psi.SrgLexerAdapter - -class SrgParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = SrgLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = SrgParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = SrgFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = SrgTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(SrgTypes.COMMENT) -private val FILE = IFileElementType(Language.findInstance(SrgLanguage::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,72 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.lang.annotation.HighlightSeverity -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.srg.gen.psi.SrgClassMapping -import io.mcdev.obfex.formats.srg.gen.psi.SrgFieldMapping -import io.mcdev.obfex.formats.srg.gen.psi.SrgMethodMapping -import io.mcdev.obfex.formats.srg.lang.SrgLanguage -import io.mcdev.obfex.formats.util.registerHighlight - -class SrgAnnotator : Annotator { - - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - when (element) { - is SrgClassMapping -> { - registerHighlight(element.obfName, SrgSyntaxHighlighter.CLASS_NAME, holder) - registerHighlight(element.deobfName, SrgSyntaxHighlighter.CLASS_NAME, holder, true) - } - - is SrgMethodMapping -> { - registerHighlight(element.obfName, SrgSyntaxHighlighter.CLASS_NAME, holder) - element.obfName?.identifier?.namePartList?.last()?.let { name -> - registerHighlight(name, SrgSyntaxHighlighter.METHOD, holder) - } - registerHighlight(element.deobfName, SrgSyntaxHighlighter.CLASS_NAME, holder, true) - element.deobfName?.identifier?.namePartList?.last()?.let { name -> - registerHighlight(name, SrgSyntaxHighlighter.METHOD, holder, true) - } - } - - is SrgFieldMapping -> { - registerHighlight(element.obfName, SrgSyntaxHighlighter.CLASS_NAME, holder) - element.obfName?.identifier?.namePartList?.last()?.let { name -> - registerHighlight(name, SrgSyntaxHighlighter.FIELD, holder) - } - registerHighlight(element.deobfName, SrgSyntaxHighlighter.CLASS_NAME, holder, true) - element.deobfName?.identifier?.namePartList?.last()?.let { name -> - registerHighlight(name, SrgSyntaxHighlighter.FIELD, holder, true) - } - - if (element.getExtendedFieldMapping() != null && element.containingFile.language == SrgLanguage) { - val msg = "Extended field mappings are not allowed in standard SRG mapping files" - holder.newAnnotation(HighlightSeverity.ERROR, msg) - .range(element) - .create() - } - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.colors - -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.srg.gen.psi.SrgTypes -import io.mcdev.obfex.formats.srg.lang.psi.SrgLexerAdapter - -class SrgSyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = SrgLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array { - return when (tokenType) { - SrgTypes.PACKAGE_KEY, SrgTypes.CLASS_KEY, SrgTypes.FIELD_KEY, SrgTypes.METHOD_KEY -> KEYWORD_KEYS - SrgTypes.CLASS_TYPE -> CLASS_TYPE_KEYS - SrgTypes.PRIMITIVE -> PRIMITIVE_KEYS - SrgTypes.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey("SRG_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "SRG_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "SRG_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "SRG_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "SRG_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "SRG_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "SRG_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val KEYWORD_KEYS = arrayOf(KEYWORD) - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/colors/SrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class SrgSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - SrgSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.srg.lang.SrgLanguage -import org.jetbrains.annotations.NonNls - -class SrgElementType(@NonNls debugName: String) : IElementType(debugName, SrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.srg.gen.lexer.SrgLexer - -class SrgLexerAdapter : FlexAdapter(SrgLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/SrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.srg.lang.SrgLanguage -import org.jetbrains.annotations.NonNls - -class SrgTokenType(@NonNls debugName: String) : IElementType(debugName, SrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/SrgFieldMappingMixin.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/SrgFieldMappingMixin.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/SrgFieldMappingMixin.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,36 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.psi.mixins - -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.srg.gen.psi.SrgExtendedFieldMapping -import io.mcdev.obfex.formats.srg.gen.psi.SrgMappingPart -import io.mcdev.obfex.formats.srg.gen.psi.SrgStandardFieldMapping - -interface SrgFieldMappingMixin : PsiElement { - fun getExtendedFieldMapping(): SrgExtendedFieldMapping? - - fun getStandardFieldMapping(): SrgStandardFieldMapping? - - val mappingPartList: List - val obfName: SrgMappingPart? - val deobfName: SrgMappingPart? -} Index: obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/impl/SrgFieldMappingImplMixin.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/impl/SrgFieldMappingImplMixin.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/srg/lang/psi/mixins/impl/SrgFieldMappingImplMixin.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,38 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg.lang.psi.mixins.impl - -import com.intellij.extapi.psi.ASTWrapperPsiElement -import com.intellij.lang.ASTNode -import io.mcdev.obfex.formats.srg.gen.psi.SrgMappingPart -import io.mcdev.obfex.formats.srg.lang.psi.mixins.SrgFieldMappingMixin - -abstract class SrgFieldMappingImplMixin(node: ASTNode) : ASTWrapperPsiElement(node), SrgFieldMappingMixin { - - override val mappingPartList: List - get() = getStandardFieldMapping()?.mappingPartList ?: getStandardFieldMapping()?.mappingPartList ?: emptyList() - - override val obfName: SrgMappingPart? - get() = getStandardFieldMapping()?.obfName ?: getExtendedFieldMapping()?.obfName - - override val deobfName: SrgMappingPart? - get() = getStandardFieldMapping()?.deobfName ?: getExtendedFieldMapping()?.deobfName -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,193 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1 - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLines -import io.mcdev.obfex.formats.util.indicesFrom -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.ns -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.ref.lowPriority -import io.mcdev.obfex.splitMappingLine - -class TinyV1MappingsFormatParser : MappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("tiny") - - override fun isSupportedFile(file: VirtualFile): Boolean { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - return getNamespaces(firstLine) != null - } - - override fun parse(file: VirtualFile): MappingsDefinition? { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - - val namespaces = getNamespaces(firstLine) ?: return null - - val builder = MappingsDefinitionBuilder(TinyV1MappingsFormatType, file, *namespaces) - - file.forLines(skipLines = 1, preserveBlank = true) { lineNum, parts, _ -> - if (parts.isEmpty()) { - return@forLines true - } - - val key = parts[0].value - when (key) { - "CLASS" -> parseClass(builder, namespaces.size, lineNum, parts) - "FIELD" -> parseField(builder, namespaces.size, lineNum, parts) - "METHOD" -> parseMethod(builder, namespaces.size, lineNum, parts) - } - - return@forLines true - } - - return builder.build() - } - - private fun getNamespaces(line: String?): Array? { - if (line == null) { - return null - } - - val header = line.splitMappingLine() - if (header.size < 3) { - return null - } - - if (header[0].value != "v1") { - return null - } - - val namespaces = arrayOfNulls(header.size - 1) - for (index in 1 until header.size) { - namespaces[index - 1] = header[index].value - } - - @Suppress("UNCHECKED_CAST") - return namespaces as Array - } - - private fun parseClass( - builder: MappingsDefinitionBuilder, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (parts.size - 1 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.size == 1) { - builder.warning("Class mapping line has no names", FileCoords(lineNum)) - return - } - - builder.clazz(lineNum.highPriority) { - for (i in parts.indicesFrom(1)) { - with(parts[i].asClass().ns(i - 1)) - } - } - } - - private fun parseField( - builder: MappingsDefinitionBuilder, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (parts.size - 3 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.size < 3) { - builder.error("Field mapping line does not have all necessary components", FileCoords(lineNum)) - return - } - - if (parts.size == 3) { - builder.warning("Field mapping line has no names", FileCoords(lineNum)) - } - - val owner = parts[1] - val fieldType = parts[2].value.asTypeDef() - ?: return builder.error("Field mapping has an invalid type", FileCoords(lineNum, parts[2])) - - builder.clazz(owner.asClass().ns(0), lineNum.lowPriority).field { - type = fieldType - - for (i in parts.indicesFrom(3)) { - with(parts[i].asField().ns(i - 3)) - } - } - } - - private fun parseMethod( - builder: MappingsDefinitionBuilder, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (parts.size - 3 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.size < 3) { - builder.error("Method mapping line does not have all necessary components", FileCoords(lineNum)) - return - } - - if (parts.size == 3) { - builder.warning("Method mapping line has no names", FileCoords(lineNum)) - } - - val owner = parts[1] - val methodDesc = parts[2].value.asMethodDesc() - ?: return builder.error("Method mapping has an invalid descriptor", FileCoords(lineNum, parts[2])) - - builder.clazz(owner.asClass().ns(0)).method { - desc = methodDesc - - for (i in parts.indicesFrom(3)) { - with(parts[i].asMethod().ns(i - 3)) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/TinyV1MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1 - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object TinyV1MappingsFormatType : MappingsFormatType("tiny-v1") { - - override val icon: Icon = ObfIcons.TINY_V1_ICON - override val name: String = "Tiny v2" -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyFileTypeDetector.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,48 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang - -import com.intellij.openapi.fileTypes.FileType -import com.intellij.openapi.fileTypes.FileTypeRegistry -import com.intellij.openapi.util.io.ByteSequence -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.formats.tinyv2.lang.TinyV2FileType - -class TinyFileTypeDetector : FileTypeRegistry.FileTypeDetector { - - override fun detect(file: VirtualFile, firstBytes: ByteSequence, firstCharsIfText: CharSequence?): FileType? { - if (firstCharsIfText == null) { - return null - } - - if (!file.name.endsWith(".tiny")) { - return null - } - - if (firstCharsIfText.startsWith("v1")) { - return TinyV1FileType - } else if (firstCharsIfText.startsWith("tiny\t2\t0")) { - return TinyV2FileType - } - - return null - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1File.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class TinyV1File(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, TinyV1Language) { - override fun getFileType(): FileType = TinyV1FileType - override fun toString(): String = TinyV1FileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1FileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object TinyV1FileType : LanguageFileType(TinyV1Language) { - - override fun getName(): String = "Tiny v1" - override fun getDescription(): String = "Tiny v1 obfuscation mapping file" - override fun getDefaultExtension(): String = "tiny" - override fun getIcon(): Icon = ObfIcons.TINY_V1_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1Language.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang - -import com.intellij.lang.Language - -object TinyV1Language : Language("TinyV1") Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1ParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/TinyV1ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.tinyv1.gen.parser.TinyV1Parser -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1Types -import io.mcdev.obfex.formats.tinyv1.lang.psi.TinyV1LexerAdapter - -class TinyV1ParserDefinition : ParserDefinition { - - override fun createLexer(project: Project?): Lexer = TinyV1LexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project?): PsiParser = TinyV1Parser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = TinyV1File(viewProvider) - override fun createElement(node: ASTNode): PsiElement = TinyV1Types.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(TinyV1Types.COMMENT) -private val FILE = IFileElementType(Language.findInstance(TinyV1Language::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1Annotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,51 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import com.intellij.psi.util.childrenOfType -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1ClassMapping -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1FieldMapping -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1MappingPart -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1MethodMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class TinyV1Annotator : Annotator { - - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - val key = when (element) { - is TinyV1ClassMapping -> TinyV1SyntaxHighlighter.CLASS_NAME - is TinyV1MethodMapping -> TinyV1SyntaxHighlighter.METHOD - is TinyV1FieldMapping -> TinyV1SyntaxHighlighter.FIELD - else -> return - } - - for ((i, part) in element.childrenOfType().withIndex()) { - if (i == 0) { - registerHighlight(part, TinyV1SyntaxHighlighter.CLASS_NAME, holder) - } else { - registerHighlight(part, key, holder) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1RainbowVisitor.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,94 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.colors - -import com.intellij.codeInsight.daemon.impl.HighlightVisitor -import com.intellij.psi.PsiElement -import com.intellij.psi.util.findParentOfType -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1ClassMapping -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1FieldMapping -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1FileElement -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1MappingPart -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1MethodMapping -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1MethodSignature -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1Namespace -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1TypeDesc -import io.mcdev.obfex.formats.tinyv1.lang.TinyV1Language -import io.mcdev.obfex.formats.util.NamespaceRainbowVisitor - -class TinyV1RainbowVisitor : NamespaceRainbowVisitor(TinyV1Language) { - - override fun visit(element: PsiElement) { - if (element is TinyV1Namespace) { - highlightNamespaceDecl(element) - return - } - - val file = element.findParentOfType() ?: return - val namespaces = file.header.namespaceList - - if (element is TinyV1MappingPart) { - handleMappingPart(element, namespaces) - } else if (element is TinyV1TypeDesc && element.parent is TinyV1FieldMapping) { - handleTypeSignature(element, namespaces) - } else if (element is TinyV1MethodSignature) { - handleTypeSignature(element, namespaces) - } - } - - private fun handleMappingPart(element: TinyV1MappingPart, namespaces: List) { - var index = indexOf(element) - - if (element.parent is TinyV1ClassMapping) { - if (namespaces.size > index) { - highlightElement(element, index, HighlightType.CLASS) - } - return - } - - // fields and methods - // first part is always class name - if (index == 0 && namespaces.isNotEmpty()) { - highlightElement(element, index, HighlightType.CLASS) - return - } - - index-- - if (namespaces.size <= index) { - return - } - - when (element.parent) { - is TinyV1MethodMapping -> highlightElement(element, index, HighlightType.METHOD) - is TinyV1FieldMapping -> highlightElement(element, index, HighlightType.FIELD) - } - } - - private fun handleTypeSignature(element: PsiElement, namespaces: List) { - if (namespaces.isEmpty()) { - return - } - - highlightTypeSignature(element) - } - - override fun clone(): HighlightVisitor = TinyV1RainbowVisitor() -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,87 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.colors - -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv1.gen.psi.TinyV1Types -import io.mcdev.obfex.formats.tinyv1.lang.psi.TinyV1LexerAdapter - -class TinyV1SyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = TinyV1LexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array { - return when (tokenType) { - TinyV1Types.V1_KEY, TinyV1Types.CLASS_KEY, TinyV1Types.FIELD_KEY, TinyV1Types.METHOD_KEY -> KEYWORD_KEYS - TinyV1Types.NAMESPACE_KEY -> NAMESPACE_KEYS - TinyV1Types.CLASS_TYPE -> CLASS_TYPE_KEYS - TinyV1Types.PRIMITIVE -> PRIMITIVE_KEYS - TinyV1Types.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey( - "TINYV1_KEYWORD", - DefaultLanguageHighlighterColors.KEYWORD - ) - val NAMESPACE = TextAttributesKey.createTextAttributesKey( - "TINYV1_NAMESPACE", - DefaultLanguageHighlighterColors.METADATA - ) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "TINYV1_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "TINYV1_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "TINYV1_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "TINYV1_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "TINYV1_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "TINYV1_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val KEYWORD_KEYS = arrayOf(KEYWORD) - private val NAMESPACE_KEYS = arrayOf(NAMESPACE) - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/colors/TinyV1SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class TinyV1SyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - TinyV1SyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1ElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv1.lang.TinyV1Language -import org.jetbrains.annotations.NonNls - -class TinyV1ElementType(@NonNls debugName: String) : IElementType(debugName, TinyV1Language) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1LexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.tinyv1.gen.lexer.TinyV1Lexer - -class TinyV1LexerAdapter : FlexAdapter(TinyV1Lexer()) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1TokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv1/lang/psi/TinyV1TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv1.lang.TinyV1Language -import org.jetbrains.annotations.NonNls - -class TinyV1TokenType(@NonNls debugName: String) : IElementType(debugName, TinyV1Language) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2LanguageCodeStyleSettingsProvider.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2LanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2LanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,43 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2 - -import io.mcdev.obfex.formats.tinyv2.lang.TinyV2Language -import io.mcdev.obfex.formats.util.TabCodeStyleSettingsProvider -import org.intellij.lang.annotations.Language - -class TinyV2LanguageCodeStyleSettingsProvider : TabCodeStyleSettingsProvider() { - override fun getLanguage() = TinyV2Language - override fun getCodeSample(settingsType: SettingsType) = SAMPLE -} - -@Language("TinyV2") -private const val SAMPLE = """ -tiny 2 0 source target target2 -c class_1 class1Ns0Rename class1Ns1Rename - f I field_1 field1Ns0Rename field1Ns1Rename - m ()I method_1 method1Ns0Rename method1Ns1Rename - p 1 param_1 param1Ns0Rename param1Ns1Rename - v 2 2 2 var_1 var1Ns0Rename var1Ns1Rename -c class_1${'$'}class_2 class1Ns0Rename${'$'}class2Ns0Rename class1Ns1Rename${'$'}class2Ns1Rename - f I field_2 field2Ns0Rename field2Ns1Rename -c class_3 class3Ns0Rename class3Ns1Rename -""" Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,325 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2 - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLinesIndent -import io.mcdev.obfex.formats.util.indicesFrom -import io.mcdev.obfex.mappings.ClassMappingBuilder -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.MethodMappingBuilder -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.localVar -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.ns -import io.mcdev.obfex.mappings.param -import io.mcdev.obfex.ref.LvtIndex -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asLocal -import io.mcdev.obfex.ref.asLocalVar -import io.mcdev.obfex.ref.asLvtIndex -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asParam -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.splitMappingLine - -class TinyV2MappingsFormatParser : MappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("tiny") - - override fun isSupportedFile(file: VirtualFile): Boolean { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - return getNamespaces(firstLine) != null - } - - override fun parse(file: VirtualFile): MappingsDefinition? { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - - val namespaces = getNamespaces(firstLine) ?: return null - - val builder = MappingsDefinitionBuilder(TinyV2MappingsFormatType, file, *namespaces) - - var classMapping: ClassMappingBuilder? = null - var methodMapping: MethodMappingBuilder? = null - file.forLinesIndent(skipLines = 1, preserveBlank = true) { indent, lineNum, parts, _ -> - if (parts.isEmpty()) { - return@forLinesIndent true - } - - val key = parts[0].value - when (key) { - "c" -> { - methodMapping = null - classMapping = parseClass(builder, indent, namespaces.size, lineNum, parts) - } - "f" -> { - methodMapping = null - parseField(classMapping, indent, namespaces.size, lineNum, parts) - } - "m" -> methodMapping = parseMethod(classMapping, indent, namespaces.size, lineNum, parts) - "p" -> parseParam(methodMapping, indent, namespaces.size, lineNum, parts) - "v" -> parseLocalVar(methodMapping, indent, namespaces.size, lineNum, parts) - } - - return@forLinesIndent true - } - - return builder.build() - } - - private fun getNamespaces(line: String?): Array? { - if (line == null) { - return null - } - - val header = line.splitMappingLine() - if (header.size < 5) { - return null - } - - if (header[0].value != "tiny" || header[1].value != "2" || header[2].value != "0") { - return null - } - - val namespaces = arrayOfNulls(header.size - 3) - for (index in header.indicesFrom(3)) { - namespaces[index - 3] = header[index].value - } - - @Suppress("UNCHECKED_CAST") - return namespaces as Array - } - - private fun parseClass( - builder: MappingsDefinitionBuilder, - indent: Int, - namespaceCount: Int, - lineNum: Int, - parts: Array - ): ClassMappingBuilder? { - if (indent != 0) { - builder.error("Unexpected indent of class mapping line", FileCoords(lineNum)) - return null - } - - if (parts.size - 1 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return null - } - - if (parts.size == 1) { - builder.warning("Class mapping has no names", FileCoords(lineNum)) - } - - return builder.clazz(lineNum.highPriority) { - for (i in parts.indicesFrom(1)) { - with(parts[i].asClass().ns(i - 1)) - } - } - } - - private fun parseField( - builder: ClassMappingBuilder?, - indent: Int, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (builder == null) { - return - } - - if (indent != 1) { - builder.error("Unexpected indent of field mapping line", FileCoords(lineNum)) - return - } - - if (parts.size - 2 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.size < 2) { - builder.error("Field mapping line does not have all necessary components", FileCoords(lineNum)) - return - } - - if (parts.size == 2) { - builder.warning("Field mapping line has no names", FileCoords(lineNum)) - } - - val fieldType = parts[1].value.asTypeDef() - ?: return builder.error("Field descriptor is invalid", FileCoords(lineNum, parts[1])) - - builder.field(lineNum.highPriority) { - type = fieldType - - for (i in parts.indicesFrom(2)) { - with(parts[i].asField().ns(i - 2)) - } - } - } - - private fun parseMethod( - builder: ClassMappingBuilder?, - indent: Int, - namespaceCount: Int, - lineNum: Int, - parts: Array - ): MethodMappingBuilder? { - if (builder == null) { - return null - } - - if (indent != 1) { - builder.error("Unexpected indent of method mapping line", FileCoords(lineNum)) - return null - } - - if (parts.size - 2 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return null - } - - if (parts.size < 2) { - builder.error("Method mapping line does not have all necessary components", FileCoords(lineNum)) - return null - } - - if (parts.size == 2) { - builder.warning("Method mapping line has no names", FileCoords(lineNum)) - } - - val methodDesc = parts[1].value.asMethodDesc() - ?: run { - builder.error("Method descriptor is invalid", FileCoords(lineNum, parts[1])) - return null - } - - return builder.method(lineNum.highPriority) { - desc = methodDesc - - for (i in parts.indicesFrom(2)) { - with(parts[i].asMethod().ns(i - 2)) - } - } - } - - private fun parseParam( - builder: MethodMappingBuilder?, - indent: Int, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (builder == null) { - return - } - - if (indent != 2) { - builder.error("Unexpected indent of method parameter mapping line", FileCoords(lineNum)) - return - } - - if (parts.size - 2 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.size < 2) { - builder.error("Method parameter mapping line does not have all necessary components", FileCoords(lineNum)) - return - } - - if (parts.size == 2) { - builder.warning("Method parameter mapping line has no names", FileCoords(lineNum)) - } - - val index = parts[1].value.toIntOrNull() - ?: return builder.error("Method parameter index is not an integer", FileCoords(lineNum, parts[1])) - - builder.param(index.asParamIndex(), lineNum.highPriority) { - for (i in parts.indicesFrom(2)) { - with(parts[i].asParam().ns(i - 2)) - } - } - } - - private fun parseLocalVar( - builder: MethodMappingBuilder?, - indent: Int, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (builder == null) { - return - } - - if (indent != 2) { - builder.error("Unexpected indent of method local var mapping line", FileCoords(lineNum)) - return - } - - if (parts.size < 3) { - builder.error("Method local var mapping line does not have all necessary components", FileCoords(lineNum)) - return - } - - val localIndex = parts[1].value.toIntOrNull()?.asLocal() - ?: return builder.error("Method local var index is not an integer", FileCoords(lineNum, parts[1])) - val localStart = parts[2].value.toIntOrNull()?.asLocal() - ?: return builder.error("Method local var start offset is not an integer", FileCoords(lineNum, parts[2])) - - val lvtIndex = if (parts.size >= 4) { - // lvtIndex is optional - parts[3].value.toIntOrNull()?.asLvtIndex() - } else { - null - } ?: LvtIndex.UNKNOWN - - val nameStartIndex = if (lvtIndex.isKnown) 4 else 3 - - if (parts.size - nameStartIndex > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - builder.localVar(localIndex.asLocalVar(startIndex = localStart), lvtIndex, lineNum.highPriority) { - for (i in parts.indicesFrom(nameStartIndex)) { - with(parts[i].asLocal().ns(i - nameStartIndex)) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/TinyV2MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2 - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object TinyV2MappingsFormatType : MappingsFormatType("tiny-v2") { - - override val icon: Icon = ObfIcons.TINY_V2_ICON - override val name: String = "Tiny v2" -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2File.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class TinyV2File(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, TinyV2Language) { - override fun getFileType(): FileType = TinyV2FileType - override fun toString(): String = TinyV2FileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2FileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object TinyV2FileType : LanguageFileType(TinyV2Language) { - - override fun getName(): String = "Tiny v2" - override fun getDescription(): String = "Tiny v2 obfuscation mapping file" - override fun getDefaultExtension(): String = "tiny" - override fun getIcon(): Icon = ObfIcons.TINY_V2_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2Language.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang - -import com.intellij.lang.Language - -object TinyV2Language : Language("TinyV2") Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2ParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/TinyV2ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.tinyv2.gen.parser.TinyV2Parser -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2Types -import io.mcdev.obfex.formats.tinyv2.lang.psi.TinyV2LexerAdapter - -class TinyV2ParserDefinition : ParserDefinition { - - override fun createLexer(project: Project?): Lexer = TinyV2LexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project?): PsiParser = TinyV2Parser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = TinyV2File(viewProvider) - override fun createElement(node: ASTNode?): PsiElement = TinyV2Types.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(TinyV2Types.COMMENT) -private val FILE = IFileElementType(Language.findInstance(TinyV2Language::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2Annotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,66 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import com.intellij.psi.util.childrenOfType -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2ClassMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2FieldMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2LocalVarIndex -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2LocalVarMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2LocalVarStart -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2LvtIndex -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2MappingPart -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2MethodMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2ParamIndex -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2ParamMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class TinyV2Annotator : Annotator { - - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - when (element) { - is TinyV2ParamIndex -> { - registerHighlight(element, TinyV2SyntaxHighlighter.PARAM_INDEX, holder) - return - } - is TinyV2LocalVarIndex, is TinyV2LocalVarStart, is TinyV2LvtIndex -> { - registerHighlight(element, TinyV2SyntaxHighlighter.LOCAL_VAR_INDEX, holder) - return - } - } - - val key = when (element) { - is TinyV2ClassMapping -> TinyV2SyntaxHighlighter.CLASS_NAME - is TinyV2MethodMapping -> TinyV2SyntaxHighlighter.METHOD - is TinyV2FieldMapping -> TinyV2SyntaxHighlighter.FIELD - is TinyV2ParamMapping -> TinyV2SyntaxHighlighter.PARAM - is TinyV2LocalVarMapping -> TinyV2SyntaxHighlighter.LOCAL_VAR - else -> return - } - - for (part in element.childrenOfType()) { - registerHighlight(part, key, holder) - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2RainbowVisitor.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,75 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.colors - -import com.intellij.codeInsight.daemon.impl.HighlightVisitor -import com.intellij.psi.PsiElement -import com.intellij.psi.util.findParentOfType -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2ClassMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2FieldMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2FileElement -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2LocalVarMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2MappingPart -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2MethodMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2MethodSignature -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2Namespace -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2ParamMapping -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2TypeDesc -import io.mcdev.obfex.formats.tinyv2.lang.TinyV2Language -import io.mcdev.obfex.formats.util.NamespaceRainbowVisitor - -class TinyV2RainbowVisitor : NamespaceRainbowVisitor(TinyV2Language) { - - override fun visit(element: PsiElement) { - if (element is TinyV2Namespace) { - highlightNamespaceDecl(element) - return - } - - val file = element.findParentOfType() ?: return - val namespaces = file.header.namespaceList - - if (element is TinyV2MappingPart) { - handleMappingPart(element, namespaces) - } else if (element is TinyV2TypeDesc && element.parent is TinyV2FieldMapping) { - highlightTypeSignature(element) - } else if (element is TinyV2MethodSignature) { - highlightTypeSignature(element) - } - } - - private fun handleMappingPart(element: TinyV2MappingPart, namespaces: List) { - val index = indexOf(element.parent) - if (namespaces.size <= index) { - return - } - - when (element.parent.parent) { - is TinyV2ClassMapping -> highlightElement(element, index, HighlightType.CLASS) - is TinyV2FieldMapping -> highlightElement(element, index, HighlightType.FIELD) - is TinyV2MethodMapping -> highlightElement(element, index, HighlightType.METHOD) - is TinyV2ParamMapping -> highlightElement(element, index, HighlightType.PARAM) - is TinyV2LocalVarMapping -> highlightElement(element, index, HighlightType.LOCAL_VAR) - } - } - - override fun clone(): HighlightVisitor = TinyV2RainbowVisitor() -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,127 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.colors - -import com.intellij.ide.highlighter.custom.CustomHighlighterColors -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv2.gen.psi.TinyV2Types -import io.mcdev.obfex.formats.tinyv2.lang.psi.TinyV2LexerAdapter - -class TinyV2SyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = TinyV2LexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array { - return when (tokenType) { - TinyV2Types.TINY_KEY, TinyV2Types.VERSION_NUM -> KEYWORD_KEYS - - TinyV2Types.CLASS_KEY, TinyV2Types.FIELD_KEY, TinyV2Types.METHOD_KEY, TinyV2Types.PARAM_KEY, - TinyV2Types.VAR_KEY -> KEYWORD_KEYS - - TinyV2Types.COMMENT_KEY -> KEYWORD_KEYS - TinyV2Types.DOC_TEXT -> DOC_COMMENT_KEYS - TinyV2Types.NAMESPACE_KEY -> NAMESPACE_KEYS - TinyV2Types.PROPERTY_KEY -> PROPERTY_KEY_KEYS - TinyV2Types.PROPERTY_VALUE -> PROPERTY_VALUE_KEYS - TinyV2Types.CLASS_TYPE -> CLASS_TYPE_KEYS - TinyV2Types.PRIMITIVE -> PRIMITIVE_KEYS - TinyV2Types.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey( - "TINYV2_KEYWORD", - DefaultLanguageHighlighterColors.KEYWORD - ) - val NAMESPACE = TextAttributesKey.createTextAttributesKey( - "TINYV2_NAMESPACE", - DefaultLanguageHighlighterColors.METADATA - ) - val PROPERTY_KEY = TextAttributesKey.createTextAttributesKey( - "TINYV2_PROPERTY_KEY", - CustomHighlighterColors.CUSTOM_KEYWORD2_ATTRIBUTES - ) - val PROPERTY_VALUE = TextAttributesKey.createTextAttributesKey( - "TINYV2_PROPERTY_VALUE", - CustomHighlighterColors.CUSTOM_KEYWORD3_ATTRIBUTES - ) - val DOC_COMMENT = TextAttributesKey.createTextAttributesKey( - "TINYV2_DOC_COMMENT", - DefaultLanguageHighlighterColors.DOC_COMMENT - ) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "TINYV2_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "TINYV2_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "TINYV2_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PARAM_INDEX = TextAttributesKey.createTextAttributesKey( - "TINYV2_PARAM_INDEX", - DefaultLanguageHighlighterColors.INLAY_DEFAULT - ) - val PARAM = TextAttributesKey.createTextAttributesKey( - "TINYV2_PARAM", - DefaultLanguageHighlighterColors.PARAMETER - ) - val LOCAL_VAR_INDEX = TextAttributesKey.createTextAttributesKey( - "TINYV2_LOCAL_VAR_INDEX", - DefaultLanguageHighlighterColors.INLAY_DEFAULT - ) - val LOCAL_VAR = TextAttributesKey.createTextAttributesKey( - "TINYV2_LOCAL_VAR", - DefaultLanguageHighlighterColors.PARAMETER - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "TINYV2_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "TINYV2_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "TINYV2_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val KEYWORD_KEYS = arrayOf(KEYWORD) - private val DOC_COMMENT_KEYS = arrayOf(DOC_COMMENT) - private val NAMESPACE_KEYS = arrayOf(NAMESPACE) - private val PROPERTY_KEY_KEYS = arrayOf(PROPERTY_KEY) - private val PROPERTY_VALUE_KEYS = arrayOf(PROPERTY_VALUE) - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/colors/TinyV2SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class TinyV2SyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - TinyV2SyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2ElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv2.lang.TinyV2Language -import org.jetbrains.annotations.NonNls - -class TinyV2ElementType(@NonNls debugName: String) : IElementType(debugName, TinyV2Language) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2LexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.tinyv2.gen.lexer.TinyV2Lexer - -class TinyV2LexerAdapter : FlexAdapter(TinyV2Lexer()) Index: obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2TokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tinyv2/lang/psi/TinyV2TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tinyv2.lang.TinyV2Language -import org.jetbrains.annotations.NonNls - -class TinyV2TokenType(@NonNls debugName: String) : IElementType(debugName, TinyV2Language) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgLanguageCodeStyleSettingsProvider.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgLanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgLanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,40 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg - -import io.mcdev.obfex.formats.tsrg.lang.TSrgLanguage -import io.mcdev.obfex.formats.util.TabCodeStyleSettingsProvider -import org.intellij.lang.annotations.Language - -class TSrgLanguageCodeStyleSettingsProvider : TabCodeStyleSettingsProvider() { - override fun getLanguage() = TSrgLanguage - override fun getCodeSample(settingsType: SettingsType) = SAMPLE -} - -@Language("TSRG") -private const val SAMPLE = """ -class_1 class1Ns0Rename - field_1 field1Ns0Rename - method_1 ()I method1Ns0Rename -class_1${'$'}class_2 class1Ns0Rename${'$'}class2Ns0Rename - field_2 field2Ns0Rename -class_3 class3Ns0Rename -""" Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,120 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLinesIndent -import io.mcdev.obfex.mappings.ClassMappingBuilder -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.highPriority - -@Suppress("DuplicatedCode") -class TSrgMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("tsrg") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(TSrgMappingsFormatType, file) - - var classMapping: ClassMappingBuilder? = null - file.forLinesIndent { indent, lineNum, parts, _ -> - if (indent > 0) { - val c = classMapping - if (c == null) { - builder.error("Member mapping line with no associated class", FileCoords(lineNum)) - } else { - parseMember(c, lineNum, parts) - } - } else { - classMapping = parseClass(builder, lineNum, parts) - } - - return@forLinesIndent true - } - - return builder.build() - } - - private fun parseClass( - builder: MappingsDefinitionBuilder, - lineNum: Int, - parts: Array, - ): ClassMappingBuilder? { - if (parts.size != 2) { - builder.error("Invalid class line", FileCoords(lineNum)) - return null - } - - val (leftClass, rightClass) = parts - - return builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private fun parseMember(builder: ClassMappingBuilder, lineNum: Int, parts: Array) { - when (parts.size) { - 2 -> parseField(builder, lineNum, parts[0], parts[1]) - 3 -> parseMethod(builder, lineNum, parts[0], parts[1], parts[2]) - else -> builder.error("Invalid member line", FileCoords(lineNum)) - } - } - - private fun parseField(builder: ClassMappingBuilder, lineNum: Int, leftName: MappingPart, rightName: MappingPart) { - builder.field(lineNum.highPriority) { - with(leftName.asField().from) - with(rightName.asField().to) - } - } - - private fun parseMethod( - builder: ClassMappingBuilder, - lineNum: Int, - leftName: MappingPart, - leftDesc: MappingPart, - rightName: MappingPart, - ) { - val methodDesc = leftDesc.value.asMethodDesc() - if (methodDesc == null) { - builder.error("Invalid method descriptor", FileCoords(lineNum, leftDesc)) - return - } - - builder.method(lineNum.highPriority) { - desc = methodDesc - - with(leftName.asMethod().from) - with(rightName.asMethod().to) - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/TSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object TSrgMappingsFormatType : MappingsFormatType("TSRG") { - - override val icon: Icon = ObfIcons.TSRG_ICON - override val name: String = "TSRG" -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class TSrgFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, TSrgLanguage) { - override fun getFileType(): FileType = TSrgFileType - override fun toString(): String = TSrgFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object TSrgFileType : LanguageFileType(TSrgLanguage) { - - override fun getName(): String = "TSRG" - override fun getDescription(): String = "TSRG obfuscation mapping file" - override fun getDefaultExtension(): String = "tsrg" - override fun getIcon(): Icon = ObfIcons.TSRG_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileTypeDetector.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgFileTypeDetector.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,45 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang - -import com.intellij.openapi.fileTypes.FileType -import com.intellij.openapi.fileTypes.FileTypeRegistry -import com.intellij.openapi.util.io.ByteSequence -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2FileType - -class TSrgFileTypeDetector : FileTypeRegistry.FileTypeDetector { - - override fun detect(file: VirtualFile, firstBytes: ByteSequence, firstCharsIfText: CharSequence?): FileType? { - if (firstCharsIfText == null) { - return null - } - if (!file.name.endsWith(".tsrg")) { - return null - } - - return if (firstCharsIfText.startsWith("tsrg2")) { - TSrg2FileType - } else { - TSrgFileType - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang - -import com.intellij.lang.Language - -object TSrgLanguage : Language("TSRG") Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/TSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.tsrg.gen.parser.TSrgParser -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgTypes -import io.mcdev.obfex.formats.tsrg.lang.psi.TSrgLexerAdapter - -class TSrgParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = TSrgLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = TSrgParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = TSrgFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = TSrgTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(TSrgTypes.COMMENT) -private val FILE = IFileElementType(Language.findInstance(TSrgLanguage::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgAnnotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgAnnotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgDeobfClassMappingPart -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgDeobfFieldMappingPart -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgDeobfMethodMappingPart -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgObfClassMappingPart -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgObfFieldMappingPart -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgObfMethodMappingPart -import io.mcdev.obfex.formats.util.registerHighlight - -class TSrgAnnotator : Annotator { - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - val key = when (element) { - is TSrgObfClassMappingPart, is TSrgDeobfClassMappingPart -> TSrgSyntaxHighlighter.CLASS_NAME - is TSrgObfMethodMappingPart, is TSrgDeobfMethodMappingPart -> TSrgSyntaxHighlighter.METHOD - is TSrgObfFieldMappingPart, is TSrgDeobfFieldMappingPart -> TSrgSyntaxHighlighter.FIELD - else -> return - } - - val highlight = when (element) { - is TSrgDeobfClassMappingPart, is TSrgDeobfMethodMappingPart, is TSrgDeobfFieldMappingPart -> true - else -> false - } - - registerHighlight(element, key, holder, highlight) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,71 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.colors - -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg.gen.psi.TSrgTypes -import io.mcdev.obfex.formats.tsrg.lang.psi.TSrgLexerAdapter - -class TSrgSyntaxHighlighter : SyntaxHighlighterBase() { - override fun getHighlightingLexer() = TSrgLexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array = - when (tokenType) { - TSrgTypes.CLASS_TYPE -> CLASS_TYPE_KEYS - TSrgTypes.PRIMITIVE -> PRIMITIVE_KEYS - TSrgTypes.COMMENT -> COMMENT_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - - companion object { - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "TSRG_CLASS_NAME", - DefaultLanguageHighlighterColors.STRING - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "TSRG_METHOD", - DefaultLanguageHighlighterColors.INSTANCE_METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "TSRG_FIELD", - DefaultLanguageHighlighterColors.INSTANCE_FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "TSRG_PRIMITIVE", - DefaultLanguageHighlighterColors.NUMBER - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "TSRG_CLASS_TYPE", - DefaultLanguageHighlighterColors.CLASS_REFERENCE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "TSRG_COMMENT", - DefaultLanguageHighlighterColors.LINE_COMMENT - ) - - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - private val COMMENT_KEYS = arrayOf(COMMENT) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/colors/TSrgSyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class TSrgSyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - TSrgSyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg.lang.TSrgLanguage -import org.jetbrains.annotations.NonNls - -class TSrgElementType(@NonNls debugName: String) : IElementType(debugName, TSrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgLexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgLexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.tsrg.gen.lexer.TSrgLexer - -class TSrgLexerAdapter : FlexAdapter(TSrgLexer()) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgTokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg/lang/psi/TSrgTokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg.lang.TSrgLanguage -import org.jetbrains.annotations.NonNls - -class TSrgTokenType(@NonNls debugName: String) : IElementType(debugName, TSrgLanguage) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2LanguageCodeStyleSettingsProvider.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2LanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2LanguageCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,44 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2 - -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2Language -import io.mcdev.obfex.formats.util.TabCodeStyleSettingsProvider -import org.intellij.lang.annotations.Language - -class TSrg2LanguageCodeStyleSettingsProvider : TabCodeStyleSettingsProvider() { - override fun getLanguage() = TSrg2Language - override fun getCodeSample(settingsType: SettingsType): String? { - TODO("Not yet implemented") - } -} - -@Language("TSRGv2") -private const val SAMPLE = """ -tsrg2 source target target2 -class_1 class1Ns0Rename class1Ns1Rename - field_1 I field1Ns0Rename field1Ns1Rename - method_1 ()I method1Ns0Rename method1Ns1Rename - 1 param_1 param1Ns0Rename param1Ns1Rename -class_1${'$'}class_2 class1Ns0Rename$${'$'}class2Ns0Rename class1Ns1Rename$${'$'}class2Ns1Rename - field_2 I field2Ns0Rename field2Ns1Rename -class_3 class3Ns0Rename class3Ns1Rename -""" Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,231 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2 - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.Tristate -import io.mcdev.obfex.forLinesIndent -import io.mcdev.obfex.formats.util.indicesFrom -import io.mcdev.obfex.mappings.ClassMappingBuilder -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.MethodMappingBuilder -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.ns -import io.mcdev.obfex.mappings.param -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asParam -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.splitMappingLine - -class TSrg2MappingsFormatParser : MappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("tsrg") - - override fun isSupportedFile(file: VirtualFile): Boolean { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - return getNamespaces(firstLine) != null - } - - override fun parse(file: VirtualFile): MappingsDefinition? { - val firstLine = file.inputStream.bufferedReader(file.charset).use { reader -> - reader.readLine() - } - val namespaces = getNamespaces(firstLine) ?: return null - val namespaceCount = namespaces.size - - val builder = MappingsDefinitionBuilder(TSrg2MappingsFormatType, file, *namespaces) - - var classMapping: ClassMappingBuilder? = null - var methodMapping: MethodMappingBuilder? = null - file.forLinesIndent(skipLines = 1, preserveBlank = true) { indent, lineNum, parts, _ -> - when (indent) { - 0 -> { - methodMapping = null - classMapping = parseClass(builder, namespaceCount, lineNum, parts) - } - 1 -> { - methodMapping = parseClassMember(classMapping, namespaceCount, lineNum, parts) - } - 2 -> parseMethodMember(methodMapping, namespaceCount, lineNum, parts) - } - - return@forLinesIndent true - } - - return builder.build() - } - - private fun parseClass( - builder: MappingsDefinitionBuilder, - namespaceCount: Int, - lineNum: Int, - parts: Array - ): ClassMappingBuilder? { - if (parts.size > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return null - } - - return builder.clazz(lineNum.highPriority) { - for (i in parts.indices) { - with(parts[i].asClass().ns(i)) - } - } - } - - private fun parseClassMember( - builder: ClassMappingBuilder?, - namespaceCount: Int, - lineNum: Int, - parts: Array - ): MethodMappingBuilder? { - val desc = parts.getOrNull(1)?.value?.asMethodDesc() - if (desc != null) { - return parseMethod(builder, namespaceCount, lineNum, parts, desc) - } else { - parseField(builder, namespaceCount, lineNum, parts) - return null - } - } - - private fun parseField( - builder: ClassMappingBuilder?, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (builder == null) { - return - } - - if (parts.size > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - builder.field(lineNum.highPriority) { - for (i in parts.indices) { - with(parts[i].asField().ns(i)) - } - } - } - - private fun parseMethod( - builder: ClassMappingBuilder?, - namespaceCount: Int, - lineNum: Int, - parts: Array, - methodDesc: MethodDescriptor, - ): MethodMappingBuilder? { - if (builder == null) { - return null - } - - if (parts.size - 1 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return null - } - - return builder.method(lineNum.highPriority) { - desc = methodDesc - // We default static to false, it will be set to true later if we see the static keyword - meta = meta.copy(isStatic = Tristate.FALSE) - - with(parts[0].asMethod().ns(0)) - - for (i in parts.indicesFrom(2)) { - with(parts[i].asMethod().ns(i - 1)) - } - } - } - - private fun parseMethodMember( - builder: MethodMappingBuilder?, - namespaceCount: Int, - lineNum: Int, - parts: Array - ) { - if (builder == null) { - return - } - - if (parts.size == 1 && parts[0].value == "static") { - builder.meta = builder.meta.copy(isStatic = Tristate.TRUE) - return - } - - if (parts.size - 1 > namespaceCount) { - builder.error("Unexpected number of names present", FileCoords(lineNum)) - return - } - - if (parts.isEmpty()) { - return - } - val index = parts[0].value.toIntOrNull() - if (index == null) { - builder.error("Method parameter index is not an integer", FileCoords(lineNum, parts[0])) - return - } - - builder.param(index.asParamIndex(), lineNum.highPriority) { - for (i in parts.indicesFrom(1)) { - with(parts[i].asParam().ns(i - 1)) - } - } - } - - private fun getNamespaces(line: String?): Array? { - if (line == null) { - return null - } - - val header = line.splitMappingLine() - if (header.size < 3) { - return null - } - - if (header[0].value != "tsrg2") { - return null - } - - val namespaces = arrayOfNulls(header.size - 1) - for (index in header.indicesFrom(1)) { - namespaces[index - 1] = header[index].value - } - - @Suppress("UNCHECKED_CAST") - return namespaces as Array - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/TSrg2MappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2 - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object TSrg2MappingsFormatType : MappingsFormatType("TSRG2") { - - override val icon: Icon = ObfIcons.TSRG2_ICON - override val name: String = "TSRG v2" -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2File.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2File.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class TSrg2File(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, TSrg2Language) { - override fun getFileType(): FileType = TSrg2FileType - override fun toString(): String = TSrg2FileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2FileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2FileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object TSrg2FileType : LanguageFileType(TSrg2Language) { - - override fun getName(): String = "TSRGv2" - override fun getDescription(): String = "TSRGv2 obfuscation mapping file" - override fun getDefaultExtension(): String = "tsrg" - override fun getIcon(): Icon = ObfIcons.TSRG2_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2Language.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2Language.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang - -import com.intellij.lang.Language - -object TSrg2Language : Language("TSRGv2") Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2LayoutLexer.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2LayoutLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2LayoutLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,35 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang - -import com.intellij.psi.tree.IElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Types -import io.mcdev.obfex.formats.tsrg2.lang.psi.TSrg2LexerAdapter -import io.mcdev.obfex.formats.util.sigws.SignificantWhitespaceLexer - -class TSrg2LayoutLexer : SignificantWhitespaceLexer(TSrg2LexerAdapter()) { - - override val newlineTokens: TokenSet = TokenSet.create(TSrg2Types.CRLF) - override val tabTokens: TokenSet = TokenSet.create(TSrg2Types.TAB) - override val virtualOpenToken: IElementType = TSrg2Types.VIRTUAL_OPEN - override val virtualCloseToken: IElementType = TSrg2Types.VIRTUAL_CLOSE -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2ParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/TSrg2ParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,51 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.tsrg2.gen.parser.TSrg2Parser -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Types - -class TSrg2ParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = TSrg2LayoutLexer() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = TSrg2Parser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = TSrg2File(viewProvider) - override fun createElement(node: ASTNode): PsiElement = TSrg2Types.Factory.createElement(node) - override fun getWhitespaceTokens(): TokenSet = WHITESPACE -} - -private val WHITESPACE = TokenSet.orSet(TokenSet.WHITE_SPACE, TokenSet.create(TSrg2Types.TAB)) -private val COMMENTS = TokenSet.create(TSrg2Types.COMMENT) -private val FILE = IFileElementType(Language.findInstance(TSrg2Language::class.java)) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2Annotator.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2Annotator.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,55 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.colors - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.Annotator -import com.intellij.psi.PsiElement -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2ClassMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2FieldMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2MappingPart -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2MethodMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2ParamIndex -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2ParamMapping -import io.mcdev.obfex.formats.util.registerHighlight - -class TSrg2Annotator : Annotator { - override fun annotate(element: PsiElement, holder: AnnotationHolder) { - if (element is TSrg2ParamIndex) { - registerHighlight(element, TSrg2SyntaxHighlighter.PARAM_INDEX, holder) - return - } - - if (element !is TSrg2MappingPart) { - return - } - - val key = when (element.parent) { - is TSrg2ClassMapping -> TSrg2SyntaxHighlighter.CLASS_NAME - is TSrg2MethodMapping -> TSrg2SyntaxHighlighter.METHOD - is TSrg2FieldMapping -> TSrg2SyntaxHighlighter.FIELD - is TSrg2ParamMapping -> TSrg2SyntaxHighlighter.PARAM - else -> return - } - - registerHighlight(element, key, holder) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2RainbowVisitor.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2RainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,78 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.colors - -import com.intellij.codeInsight.daemon.impl.HighlightVisitor -import com.intellij.psi.PsiElement -import com.intellij.psi.util.findParentOfType -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2ClassMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2FieldMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2FileElement -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2MappingPart -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2MethodMapping -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2MethodSignature -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Namespace -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2ParamMapping -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2Language -import io.mcdev.obfex.formats.util.NamespaceRainbowVisitor - -class TSrg2RainbowVisitor : NamespaceRainbowVisitor(TSrg2Language) { - - override fun visit(element: PsiElement) { - if (element is TSrg2Namespace) { - highlightNamespaceDecl(element) - return - } - - val file = element.findParentOfType() ?: return - val namespaces = file.header.namespaceList - - if (element is TSrg2MappingPart) { - handleMappingPart(element, namespaces) - } else if (element is TSrg2MethodSignature) { - handleMethodSignature(element, namespaces) - } - } - - private fun handleMappingPart(element: TSrg2MappingPart, namespaces: List) { - val index = indexOf(element) - if (namespaces.size <= index) { - return - } - - when (element.parent) { - is TSrg2ClassMapping -> highlightElement(element, index, HighlightType.CLASS) - is TSrg2MethodMapping -> highlightElement(element, index, HighlightType.METHOD) - is TSrg2FieldMapping -> highlightElement(element, index, HighlightType.FIELD) - is TSrg2ParamMapping -> highlightElement(element, index, HighlightType.PARAM) - } - } - - private fun handleMethodSignature(element: TSrg2MethodSignature, namespaces: List) { - if (namespaces.isEmpty()) { - return - } - - highlightTypeSignature(element) - } - - override fun clone(): HighlightVisitor = TSrg2RainbowVisitor() -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,95 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.colors - -import com.intellij.lexer.Lexer -import com.intellij.openapi.editor.DefaultLanguageHighlighterColors -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.fileTypes.SyntaxHighlighterBase -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg.lang.colors.TSrgSyntaxHighlighter -import io.mcdev.obfex.formats.tsrg2.gen.psi.TSrg2Types -import io.mcdev.obfex.formats.tsrg2.lang.psi.TSrg2LexerAdapter - -class TSrg2SyntaxHighlighter : SyntaxHighlighterBase() { - - override fun getHighlightingLexer(): Lexer = TSrg2LexerAdapter() - - override fun getTokenHighlights(tokenType: IElementType?): Array = - when (tokenType) { - TSrg2Types.TSRG2_KEY, TSrg2Types.STATIC -> KEYWORD_KEYS - TSrg2Types.NAMESPACE_KEY -> NAMESPACE_KEYS - TSrg2Types.PRIMITIVE -> PRIMITIVE_KEYS - TSrg2Types.COMMENT -> COMMENT_KEYS - TSrg2Types.CLASS_TYPE -> CLASS_TYPE_KEYS - else -> TextAttributesKey.EMPTY_ARRAY - } - - @Suppress("MemberVisibilityCanBePrivate") - companion object { - val KEYWORD = TextAttributesKey.createTextAttributesKey( - "TSRG2_KEYWORD", - DefaultLanguageHighlighterColors.KEYWORD - ) - val NAMESPACE = TextAttributesKey.createTextAttributesKey( - "TSRG2_NAMESPACE", - DefaultLanguageHighlighterColors.METADATA - ) - val CLASS_NAME = TextAttributesKey.createTextAttributesKey( - "TSRG2_CLASS_NAME", - TSrgSyntaxHighlighter.CLASS_NAME - ) - val METHOD = TextAttributesKey.createTextAttributesKey( - "TSRG2_METHOD", - TSrgSyntaxHighlighter.METHOD - ) - val FIELD = TextAttributesKey.createTextAttributesKey( - "TSRG2_FIELD", - TSrgSyntaxHighlighter.FIELD - ) - val PRIMITIVE = TextAttributesKey.createTextAttributesKey( - "TSRG2_PRIMITIVE", - TSrgSyntaxHighlighter.PRIMITIVE - ) - val CLASS_TYPE = TextAttributesKey.createTextAttributesKey( - "TSRG2_CLASS_TYPE", - TSrgSyntaxHighlighter.CLASS_TYPE - ) - val COMMENT = TextAttributesKey.createTextAttributesKey( - "TSRG2_COMMENT", - TSrgSyntaxHighlighter.COMMENT - ) - val PARAM_INDEX = TextAttributesKey.createTextAttributesKey( - "TSRG2_PARAM_INDEX", - DefaultLanguageHighlighterColors.INLAY_DEFAULT - ) - val PARAM = TextAttributesKey.createTextAttributesKey( - "TSRG2_PARAM", - DefaultLanguageHighlighterColors.PARAMETER - ) - - private val KEYWORD_KEYS = arrayOf(KEYWORD) - private val NAMESPACE_KEYS = arrayOf(NAMESPACE) - private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE) - private val COMMENT_KEYS = arrayOf(COMMENT) - private val CLASS_TYPE_KEYS = arrayOf(CLASS_TYPE) - } -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighterFactory.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/colors/TSrg2SyntaxHighlighterFactory.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.colors - -import com.intellij.openapi.fileTypes.SyntaxHighlighter -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile - -class TSrg2SyntaxHighlighterFactory : SyntaxHighlighterFactory() { - override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter = - TSrg2SyntaxHighlighter() -} Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2ElementType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2ElementType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2Language -import org.jetbrains.annotations.NonNls - -class TSrg2ElementType(@NonNls debugName: String) : IElementType(debugName, TSrg2Language) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2LexerAdapter.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2LexerAdapter.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.psi - -import com.intellij.lexer.FlexAdapter -import io.mcdev.obfex.formats.tsrg2.gen.lexer.TSrg2Lexer - -class TSrg2LexerAdapter : FlexAdapter(TSrg2Lexer()) Index: obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2TokenType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/tsrg2/lang/psi/TSrg2TokenType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,27 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2.lang.psi - -import com.intellij.psi.tree.IElementType -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2Language -import org.jetbrains.annotations.NonNls - -class TSrg2TokenType(@NonNls debugName: String) : IElementType(debugName, TSrg2Language) Index: obfuscation-explorer/src/main/kotlin/formats/util/NamespaceRainbowVisitor.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/util/NamespaceRainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/util/NamespaceRainbowVisitor.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,137 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.util - -import com.intellij.codeHighlighting.ColorGenerator -import com.intellij.codeHighlighting.RainbowHighlighter -import com.intellij.codeInsight.daemon.RainbowVisitor -import com.intellij.codeInsight.daemon.impl.HighlightInfo -import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder -import com.intellij.lang.Language -import com.intellij.openapi.editor.markup.EffectType -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import java.awt.Color -import java.awt.Font - -abstract class NamespaceRainbowVisitor(private val language: Language) : RainbowVisitor() { - - private var rainbowColors: Array? = null - - override fun suitableForFile(file: PsiFile): Boolean = file.language == language - - override fun analyze( - file: PsiFile, - updateWholeFile: Boolean, - holder: HighlightInfoHolder, - action: Runnable, - ): Boolean { - computeColors(holder) - val res = super.analyze(file, updateWholeFile, holder, action) - rainbowColors = null - return res - } - - protected fun highlightNamespaceDecl(element: PsiElement) { - val index = indexOf(element) - val color = getColorFromIndex(index) - - val attribute = TextAttributes(color, null, null, null, Font.PLAIN) - val highlightInfo = HighlightInfo - .newHighlightInfo(RainbowHighlighter.RAINBOW_ELEMENT) - .textAttributes(attribute) - .range(element) - .create() - addInfo(highlightInfo) - } - - protected fun highlightElement( - element: PsiElement, - index: Int, - type: HighlightType - ) { - val color = getColorFromIndex(index) - - val fontType = when (type) { - HighlightType.CLASS -> Font.ITALIC - HighlightType.METHOD -> Font.BOLD - HighlightType.FIELD, HighlightType.PARAM, HighlightType.LOCAL_VAR -> Font.PLAIN - } - - var attr = TextAttributes(color, null, null, null, fontType) - if (type == HighlightType.FIELD) { - attr = attr.highlight() - } - - val info = HighlightInfo - .newHighlightInfo(RainbowHighlighter.RAINBOW_ELEMENT) - .textAttributes(attr) - .range(element) - .create() - addInfo(info) - } - - protected fun highlightTypeSignature(element: PsiElement) { - val color = getColorFromIndex(0) - - val textAttributes = TextAttributes(null, null, color, EffectType.SLIGHTLY_WIDER_BOX, Font.PLAIN) - val highlightInfo = HighlightInfo - .newHighlightInfo(RainbowHighlighter.RAINBOW_ELEMENT) - .textAttributes(textAttributes) - .range(element) - .create() - addInfo(highlightInfo) - } - - protected fun indexOf(element: PsiElement): Int { - return element.parent.childrenOfType(element::class).indexOf(element) - } - - protected enum class HighlightType { - CLASS, METHOD, FIELD, PARAM, LOCAL_VAR - } - - protected fun getColorFromIndex(index: Int): Color { - val colors = rainbowColors ?: error("rainbowColors is not initialized") - return colors[index % colors.size] - } - - private fun computeColors(holder: HighlightInfoHolder) { - val colorScheme = holder.colorsScheme - val stopRainbowColors = RainbowHighlighter.RAINBOW_COLOR_KEYS.map { - colorScheme.getAttributes(it).foregroundColor - } - - val colors = ColorGenerator.generateLinearColorSequence(stopRainbowColors, 4) - - var startingIndex = 0 - var index = 0 - rainbowColors = Array(colors.size) { - val color = colors[index] - index += 5 - if (index >= colors.size) { - index = ++startingIndex - } - color - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/util/TabCodeStyleSettingsProvider.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/util/TabCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/util/TabCodeStyleSettingsProvider.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,36 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.util - -import com.intellij.psi.codeStyle.CommonCodeStyleSettings -import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider - -abstract class TabCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() { - - override fun customizeDefaults( - commonSettings: CommonCodeStyleSettings, - indentOptions: CommonCodeStyleSettings.IndentOptions - ) { - indentOptions.USE_TAB_CHARACTER = true - indentOptions.TAB_SIZE = 4 - indentOptions.INDENT_SIZE = indentOptions.TAB_SIZE - } -} Index: obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceLexer.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceLexer.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,144 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.util.sigws - -import com.intellij.lexer.Lexer -import com.intellij.lexer.LexerBase -import com.intellij.psi.tree.IElementType -import com.intellij.psi.tree.TokenSet - -abstract class SignificantWhitespaceLexer(private val delegate: Lexer) : LexerBase() { - - private var lookingForIndent: Boolean = true - private var lastSeenTabCount = 0 - private var currentToken: Token? = null - - private val tokenStack = ArrayDeque() - - abstract val newlineTokens: TokenSet - abstract val tabTokens: TokenSet - - abstract val virtualOpenToken: IElementType - abstract val virtualCloseToken: IElementType - - override fun getState(): Int = delegate.state - - override fun getTokenType(): IElementType? = currentToken?.tokenType - override fun getTokenStart(): Int = currentToken?.start ?: 0 - override fun getTokenEnd(): Int = currentToken?.end ?: 0 - - override fun getBufferSequence(): CharSequence = delegate.bufferSequence - override fun getBufferEnd(): Int = delegate.bufferEnd - - override fun start(buffer: CharSequence, startOffset: Int, endOffset: Int, initialState: Int) { - delegate.start(buffer, startOffset, endOffset, initialState) - compute(getCurrentToken()) - } - - override fun advance() { - if (tokenStack.isNotEmpty()) { - currentToken = tokenStack.removeFirst() - return - } - - compute() - } - - private fun compute(firstToken: Token? = null) { - var newToken = firstToken ?: getNextToken() ?: return - val firstNewToken = newToken - - if (!lookingForIndent) { - currentToken = newToken - if (newToken.tokenType in newlineTokens) { - lookingForIndent = true - } - return - } - lookingForIndent = false - - tokenStack.addLast(newToken) - - var tabCount = 0 - while (newToken.tokenType in tabTokens) { - tabCount++ - newToken = getNextToken()?.also { tokenStack.addLast(it) } ?: break - } - - if (newToken.tokenType in newlineTokens) { - // this is a blank line, ignore it - currentToken = tokenStack.removeFirstOrNull() - return - } - - when { - tabCount > lastSeenTabCount -> { - val indentToken = virtualOpen(firstNewToken) - repeat(tabCount - lastSeenTabCount) { - tokenStack.addFirst(indentToken) - } - } - tabCount < lastSeenTabCount -> { - val unindentToken = virtualClose(firstNewToken) - repeat(lastSeenTabCount - tabCount) { - tokenStack.addFirst(unindentToken) - } - } - } - lastSeenTabCount = tabCount - - currentToken = tokenStack.removeFirstOrNull() - } - - private fun getNextToken(): Token? { - delegate.advance() - return getCurrentToken() - } - - private fun getCurrentToken(): Token? { - if (delegate.tokenType == null) { - currentToken = null - return null - } - return Token(delegate.tokenType, delegate.tokenStart, delegate.tokenEnd) - } - - private fun virtualOpen(precedesToken: Token) = Token( - tokenType = virtualOpenToken, - start = precedesToken.start, - end = precedesToken.start, - ) - - private fun virtualClose(precedesToken: Token) = Token( - tokenType = virtualCloseToken, - start = precedesToken.start, - end = precedesToken.start, - ) - - private class Token( - val tokenType: IElementType?, - val start: Int, - val end: Int, - ) { - val isEof: Boolean - get() = tokenType == null - } -} Index: obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceParserUtil.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceParserUtil.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/util/sigws/SignificantWhitespaceParserUtil.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,54 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.util.sigws - -import com.intellij.lang.PsiBuilder -import com.intellij.lang.parser.GeneratedParserUtilBase - -open class SignificantWhitespaceParserUtil : GeneratedParserUtilBase() { - companion object { - @JvmStatic - fun indent0( - builder: PsiBuilder, - level: Int, - virtualOpen: Parser, - virtualClose: Parser, - param: Parser, - ): Boolean { - if (!recursion_guard_(builder, level, "indent0")) { - return false - } - - val marker = enter_section_(builder) - - val res = - // VIRTUAL_OPEN - virtualOpen.parse(builder, level + 1) && - // <> - param.parse(builder, level) && - // (VIRTUAL_CLOSE | <>) - (virtualClose.parse(builder, level + 1) || eof(builder, level + 1)) - - exit_section_(builder, marker, null, res) - return res - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/util/util.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/util/util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/util/util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,84 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.util - -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.lang.annotation.HighlightSeverity -import com.intellij.openapi.editor.colors.TextAttributesKey -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.psi.PsiElement -import com.intellij.psi.util.PsiTreeUtil -import com.intellij.ui.JBColor -import java.awt.Color -import java.awt.Font -import kotlin.reflect.KClass - -fun TextAttributesKey.highlight(): TextAttributes = defaultAttributes.highlight() -fun TextAttributes.highlight(): TextAttributes = - TextAttributes.merge( - this, - TextAttributes( - null, - foregroundColor.toBackground(), - foregroundColor, - null, - Font.ITALIC - ) - - ) - -fun registerHighlight( - element: PsiElement?, - key: TextAttributesKey, - holder: AnnotationHolder, - highlight: Boolean = false -) { - if (element == null) { - return - } - val builder = holder.newSilentAnnotation(HighlightSeverity.INFORMATION) - .range(element) - .textAttributes(key) - if (highlight) { - builder.enforcedTextAttributes(key.highlight()) - } - builder.create() -} - -private fun Color.toBackground(): Color { - val darkerBase = darker().darker().darker().darker() - val brighterBase = brighter().brighter().brighter().brighter() - return JBColor( - Color(brighterBase.red, brighterBase.green, brighterBase.blue, 128), - Color(darkerBase.red, darkerBase.green, darkerBase.blue, 128) - ) -} - -fun PsiElement.childrenOfType(type: KClass): List { - return PsiTreeUtil.getChildrenOfTypeAsList(this, type.java) -} - -fun Array<*>.indicesFrom(first: Int): IntRange { - if (first >= size) { - return IntRange.EMPTY - } - return first until size -} Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,224 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.forLines -import io.mcdev.obfex.mappings.FileCoords -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsDefinitionBuilder -import io.mcdev.obfex.mappings.UnnamedMappingsFormatParser -import io.mcdev.obfex.mappings.clazz -import io.mcdev.obfex.mappings.field -import io.mcdev.obfex.mappings.method -import io.mcdev.obfex.mappings.pack -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asField -import io.mcdev.obfex.ref.asMethod -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asPackage -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.highPriority -import io.mcdev.obfex.ref.lowPriority -import io.mcdev.obfex.splitOnLast - -@Suppress("DuplicatedCode") -class XSrgMappingsFormatParser : UnnamedMappingsFormatParser { - - override val expectedFileExtensions: Array = arrayOf("xsrg") - - override fun parse(file: VirtualFile): MappingsDefinition { - val builder = MappingsDefinitionBuilder(XSrgMappingsFormatType, file) - - file.forLines { lineNum, parts, _ -> - if (parts.isEmpty()) { - return@forLines true - } - - val key = parts.first() - - when (key.value) { - "PK:" -> parsePackageLine(builder, lineNum, parts) - "CL:" -> parseClassLine(builder, lineNum, parts) - "MD:" -> parseMethodLine(builder, lineNum, parts) - "FD:" -> parseFieldLine(builder, lineNum, parts) - else -> builder.error("Unrecognized key: ${key.value.substring(0, 3)}", FileCoords(lineNum)) - } - - return@forLines true - } - - return builder.build() - } - - private fun parsePackageLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Package line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftPack, rightPack) = parts - builder.pack(lineNum.highPriority) { - with(leftPack.asPackage().from) - with(rightPack.asPackage().to) - } - } - - private fun parseClassLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 3) { - builder.error("Class line is invalid", FileCoords(lineNum)) - return - } - - val (_, leftClass, rightClass) = parts - builder.clazz(lineNum.highPriority) { - with(leftClass.asClass().from) - with(rightClass.asClass().to) - } - } - - private fun parseFieldLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - when (parts.size) { - 5 -> { - val (leftClass, leftField) = parts[1].splitOnLast('/') - if (leftField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[1]) - ) - return - } - - val (rightClass, rightField) = parts[3].splitOnLast('/') - if (rightField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[2]) - ) - return - } - - val leftDesc = parts[2].value.asTypeDef() - if (leftDesc == null) { - builder.error("Field descriptor is invalid", FileCoords(lineNum, parts[2])) - return - } - - val rightDesc = parts[4].value.asTypeDef() - if (rightDesc == null) { - builder.error("Field descriptor is invalid", FileCoords(lineNum, parts[4])) - return - } - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) { - unlessExists(rightClass.asClass().to) - - field(lineNum.highPriority) { - type = leftDesc - - with(leftField.asField().from) - with(rightField.asField().to) - } - } - } - 3 -> { - val (leftClass, leftField) = parts[1].splitOnLast('/') - if (leftField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[1]) - ) - return - } - - val (rightClass, rightField) = parts[2].splitOnLast('/') - if (rightField == null) { - builder.error( - "Field mapping is invalid, no field is specified after class", - FileCoords(lineNum, parts[2]) - ) - return - } - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) { - unlessExists(rightClass.asClass().to) - - field(lineNum.highPriority) { - with(leftField.asField().from) - with(rightField.asField().to) - } - } - } - else -> { - builder.error("Field line is invalid", FileCoords(lineNum)) - } - } - } - - private fun parseMethodLine(builder: MappingsDefinitionBuilder, lineNum: Int, parts: Array) { - if (parts.size != 5) { - builder.error("Method line is invalid", FileCoords(lineNum)) - return - } - - val (leftClass, leftMethod) = parts[1].splitOnLast('/') - if (leftMethod == null) { - builder.error( - "Method mapping is invalid, no method is specified after class", - FileCoords(lineNum, parts[1]) - ) - return - } - - val (rightClass, rightMethod) = parts[3].splitOnLast('/') - if (rightMethod == null) { - builder.error( - "Method mapping is invalid, no method is specified after class", - FileCoords(lineNum, parts[3]) - ) - return - } - - val leftDesc = parts[2].value.asMethodDesc() - if (leftDesc == null) { - builder.error("Method descriptor is invalid", FileCoords(lineNum, parts[2])) - return - } - - val rightDesc = parts[4].value.asMethodDesc() - if (rightDesc == null) { - builder.error("Method descriptor is invalid", FileCoords(lineNum, parts[4])) - return - } - - builder.clazz(leftClass.asClass().from, lineNum.lowPriority) { - unlessExists(rightClass.asClass().to) - - method(lineNum.highPriority) { - desc = leftDesc - - with(leftMethod.asMethod().from) - with(rightMethod.asMethod().to) - } - } - } -} Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/XSrgMappingsFormatType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,31 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg - -import io.mcdev.obfex.ObfIcons -import io.mcdev.obfex.formats.MappingsFormatType -import javax.swing.Icon - -object XSrgMappingsFormatType : MappingsFormatType("XSRG") { - - override val icon: Icon = ObfIcons.XSRG_ICON - override val name: String = "XSRG" -} Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFile.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFile.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,30 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg.lang - -import com.intellij.extapi.psi.PsiFileBase -import com.intellij.openapi.fileTypes.FileType -import com.intellij.psi.FileViewProvider - -class XSrgFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, XSrgLanguage) { - override fun getFileType(): FileType = XSrgFileType - override fun toString(): String = XSrgFileType.description -} Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFileType.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgFileType.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,33 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg.lang - -import com.intellij.openapi.fileTypes.LanguageFileType -import io.mcdev.obfex.ObfIcons -import javax.swing.Icon - -object XSrgFileType : LanguageFileType(XSrgLanguage) { - - override fun getName(): String = "XSRG" - override fun getDescription(): String = "XSRG obfuscation mapping file" - override fun getDefaultExtension(): String = "xsrg" - override fun getIcon(): Icon = ObfIcons.XSRG_ICON -} Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgLanguage.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgLanguage.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg.lang - -import com.intellij.lang.Language - -object XSrgLanguage : Language("XSRG") Index: obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgParserDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/formats/xsrg/lang/XSrgParserDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,50 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg.lang - -import com.intellij.lang.ASTNode -import com.intellij.lang.Language -import com.intellij.lang.ParserDefinition -import com.intellij.lang.PsiParser -import com.intellij.lexer.Lexer -import com.intellij.openapi.project.Project -import com.intellij.psi.FileViewProvider -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.tree.IFileElementType -import com.intellij.psi.tree.TokenSet -import io.mcdev.obfex.formats.srg.gen.parser.SrgParser -import io.mcdev.obfex.formats.srg.gen.psi.SrgTypes -import io.mcdev.obfex.formats.srg.lang.psi.SrgLexerAdapter - -class XSrgParserDefinition : ParserDefinition { - - override fun createLexer(project: Project): Lexer = SrgLexerAdapter() - override fun getCommentTokens(): TokenSet = COMMENTS - override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY - override fun createParser(project: Project): PsiParser = SrgParser() - override fun getFileNodeType(): IFileElementType = FILE - override fun createFile(viewProvider: FileViewProvider): PsiFile = XSrgFile(viewProvider) - override fun createElement(node: ASTNode): PsiElement = SrgTypes.Factory.createElement(node) -} - -private val COMMENTS = TokenSet.create(SrgTypes.COMMENT) -private val FILE = IFileElementType(Language.findInstance(XSrgLanguage::class.java)) Index: obfuscation-explorer/src/main/kotlin/lookup/HashLookupIndex.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/lookup/HashLookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/lookup/HashLookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,87 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.lookup - -import it.unimi.dsi.fastutil.objects.Object2ObjectFunction -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet -import java.lang.invoke.MethodHandles -import kotlin.reflect.KClass - -class HashLookupIndex( - private val table: HashLookupTable, - private val transformer: LookupIndexTransformer, -) : LookupIndex { - - private var map: Object2ObjectOpenHashMap>? = null - - override fun query(key: K?): MultiLookupTable { - return map?.get(key) ?: MultiLookupTable.empty() - } - - @Suppress("unused") // indirectly accessed by HashLookupTable - private fun rebuild() { - @Suppress("UNCHECKED_CAST") - val store = tableList.get(table.unwrap(HashLookupTable::class)) as ObjectLinkedOpenHashSet - - map = Object2ObjectOpenHashMap(store.size) - - for (t in store) { - add(t) - } - } - - private fun add(value: T) { - val keys = transformer(value) - - for (key in keys) { - map?.computeIfAbsent(key, Object2ObjectFunction { HashLookupTable() })?.add(value) - } - } - - @Suppress("unused") // indirectly accessed by HashLookupTable - private fun remove(value: T) { - val keys = transformer(value) - - for (key in keys) { - val list = map?.get(key) - list?.remove(value) - - if (list?.isEmpty() == true) { - map?.remove(key) - } - } - } - - override fun > unwrap(type: KClass): L? { - if (type.isInstance(this)) { - @Suppress("UNCHECKED_CAST") - return this as L - } - return null - } - - private companion object { - @JvmStatic - private val tableList = MethodHandles.privateLookupIn(HashLookupTable::class.java, MethodHandles.lookup()) - .findVarHandle(HashLookupTable::class.java, "store", ObjectLinkedOpenHashSet::class.java) - } -} Index: obfuscation-explorer/src/main/kotlin/lookup/HashLookupTable.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/lookup/HashLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/lookup/HashLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,117 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.lookup - -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet -import java.lang.invoke.MethodHandles -import java.lang.invoke.MethodType -import java.util.Collections -import kotlin.reflect.KClass - -/** - * [MultiLookupTable] implementation based on hash tables. - */ -open class HashLookupTable : MultiLookupTable { - - private val store: ObjectLinkedOpenHashSet = ObjectLinkedOpenHashSet() - - private val indices: MutableList> = mutableListOf() - - override fun seq(): Sequence = store.asSequence() - - override fun list(): List = Collections.unmodifiableList(store.toList()) - - override val size: Int - get() = store.size - - override fun indexMulti(transformer: LookupIndexTransformer): LookupIndex { - for (index in indices) { - if (lookupIndexTransformer.get(index) === transformer) { - @Suppress("UNCHECKED_CAST") - return index as LookupIndex - } - } - - val index = HashLookupIndex(this, transformer) - rebuildIndex.invoke(index) - indices += index - - return index - } - - override fun add(value: T) { - if (store.add(value)) { - for (index in indices) { - addToIndex.invoke(index, value) - } - } - } - - override fun remove(value: T) { - if (store.remove(value)) { - for (index in indices) { - removeFromIndex.invoke(index, value) - } - } - } - - override fun > unwrap(type: KClass): L? { - if (type.isInstance(this)) { - @Suppress("UNCHECKED_CAST") - return this as L - } - return null - } - - companion object { - @JvmStatic - private val lookupIndexTransformer = - MethodHandles.privateLookupIn(HashLookupIndex::class.java, MethodHandles.lookup()) - .findVarHandle(HashLookupIndex::class.java, "transformer", Function1::class.java) - - @JvmStatic - private val rebuildIndex = - MethodHandles.privateLookupIn(HashLookupIndex::class.java, MethodHandles.lookup()) - .findVirtual( - HashLookupIndex::class.java, - "rebuild", - MethodType.methodType(Void::class.javaPrimitiveType) - ) - - @JvmStatic - private val addToIndex = - MethodHandles.privateLookupIn(HashLookupIndex::class.java, MethodHandles.lookup()) - .findVirtual( - HashLookupIndex::class.java, - "add", - MethodType.methodType(Void::class.javaPrimitiveType, Any::class.java) - ) - - @JvmStatic - private val removeFromIndex = - MethodHandles.privateLookupIn(HashLookupIndex::class.java, MethodHandles.lookup()) - .findVirtual( - HashLookupIndex::class.java, - "remove", - MethodType.methodType(Void::class.javaPrimitiveType, Any::class.java) - ) - } -} Index: obfuscation-explorer/src/main/kotlin/lookup/LookupIndex.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/lookup/LookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/lookup/LookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,36 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.lookup - -import kotlin.reflect.KClass - -/** - * Index for optimized queries from [MultiLookupTable]. - */ -interface LookupIndex { - - /** - * Query the index using the given key. - */ - fun query(key: K?): MultiLookupTable - - fun > unwrap(type: KClass): L? -} Index: obfuscation-explorer/src/main/kotlin/lookup/MultiLookupTable.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/lookup/MultiLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/lookup/MultiLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,96 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.lookup - -import java.util.Collections -import kotlin.reflect.KClass - -typealias SingleLookupIndexTransformer = (T) -> K? -typealias LookupIndexTransformer = (T) -> List - -/** - * Data structure which uses [indices][LookupIndex] to improve query performance of multiple distinct lookups. - */ -interface MultiLookupTable { - - /** - * Get the backing store for this table. This list should not be modified, use [add] or [remove] methods on - * this class instead. - */ - fun seq(): Sequence - - fun list(): List - - fun firstOrNull(): T? { - return seq().firstOrNull() - } - - fun singleOrNull(): T? { - return seq().singleOrNull() - } - - /** - * Returns `true` if this table is empty. - */ - fun isEmpty(): Boolean = size == 0 - - /** - * Returns the number of elements in this table. - */ - val size: Int - - /** - * Create a new [index][LookupIndex] to allow for efficient queries to the data store. Lookup tables with more - * indices have worse write performance, as the indices have to be rebuilt, so a balance is a good idea. - */ - fun indexMulti(transformer: LookupIndexTransformer): LookupIndex - - fun index(transformer: SingleLookupIndexTransformer): LookupIndex = indexMulti { - listOfNotNull(transformer(it)) - } - - /** - * Add a new value to the table. - */ - fun add(value: T) - - /** - * Remove a value from the table. - */ - fun remove(value: T) - - fun > unwrap(type: KClass): L? - - companion object { - private val emptyTable = HashLookupTable() - - @Suppress("UNCHECKED_CAST") - fun empty(): MultiLookupTable = emptyTable as MultiLookupTable - } -} - -/** - * Naive query, not using any optimization, simply look through the raw store for any matches for the given - * predicate and return the result. For repeated queries consider using an [index][MultiLookupTable.index] to improve - * performance. - */ -inline fun MultiLookupTable.query(predicate: (T) -> Boolean): List = - Collections.unmodifiableList(list().filter(predicate)) Index: obfuscation-explorer/src/main/kotlin/mappings/MappingElement.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingElement.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingElement.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,394 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -@file:Suppress("MemberVisibilityCanBePrivate", "DuplicatedCode") - -package io.mcdev.obfex.mappings - -import com.intellij.util.containers.map2Array -import io.mcdev.obfex.Tristate -import io.mcdev.obfex.ref.FieldName -import io.mcdev.obfex.ref.LocalFieldRef -import io.mcdev.obfex.ref.LocalMethodRef -import io.mcdev.obfex.ref.LocalVarIndex -import io.mcdev.obfex.ref.LvtIndex -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.MethodName -import io.mcdev.obfex.ref.ParamIndex -import io.mcdev.obfex.ref.ParamMap -import io.mcdev.obfex.ref.TypeDef -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodRef -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asRef -import it.unimi.dsi.fastutil.objects.ObjectArrayList -import java.lang.IllegalArgumentException -import java.util.ArrayList -import java.util.Collections - -sealed interface MappingElement { - val names: Array - val location: MappingLocation - val mappingSet: MappingSet - - fun name(index: Int): String? = names[index] - fun name(ns: MappingNamespace): String? = name(index(ns)) - - fun index(ns: MappingNamespace): Int = mappingSet.namespaceIndex(ns) -} - -val MappingElement.unnamedFrom: String? - get() = name(MappingNamespace.unnamedFrom(mappingSet)) -val MappingElement.unnamedTo: String? - get() = name(MappingNamespace.unnamedTo(mappingSet)) - -class PackageMappingElement( - override val names: Array, - override val mappingSet: MappingSet, - override val location: MappingLocation, -) : MappingElement - -class ClassMappingElement( - override val names: Array, - val parent: ClassMappingElement? = null, - override val mappingSet: MappingSet, - override val location: MappingLocation = UnknownLocation, -) : MappingElement { - - // classes generally have relatively few members (< 1000) so the naive approach for storing and querying them is - // probably better - private val fieldStore = ObjectArrayList() - private val methodStore = ObjectArrayList() - - fun fullyQualifiedName(index: Int): String? = when (val p = parent) { - is ClassMappingElement -> p.fullyQualifiedName(index) + "." + name(index) - else -> name(index) - } - - fun fullyQualifiedName(ns: MappingNamespace): String? = fullyQualifiedName(mappingSet.namespaceIndex(ns)) - - // fields - - fun fields(): List { - return Collections.unmodifiableList(fieldStore) - } - - fun fields(ref: LocalFieldRef): List { - if (ref.type == null) { - return fieldStore.filter { it.names.contains(ref.name.name) } - } - - // We don't know which namespace this field type is, so attempt to map for each namespace - val mappedTypes = if (ref.type.isMappable()) { - mappingSet.namespaces.map2Array { mappingSet.mapTypeFrom(it, ref.type) } - } else { - Array(mappingSet.namespaces.size) { ref.type } - } - - return fieldStore.filter { mapping -> - mappedTypes.withIndex().any { (i, type) -> - mapping.name(i) == ref.name.name && type == mapping.type - } - } - } - - fun fields(name: FieldName, type: TypeDef? = null): List = - fields(name.asRef(type)) - - fun fields(name: String, type: TypeDef? = null): List = - fields(name.asFieldRef(type)) - - fun fields(ns: MappingNamespace, ref: LocalFieldRef): List { - if (ref.type == null) { - return fieldStore.filter { it.name(ns) == ref.name.name } - } - - val type = if (ns != mappingSet.typeNamespace && ref.type.isMappable()) { - mappingSet.mapTypeFrom(ns, ref.type) - } else { - ref.type - } - - return fieldStore.filter { it.name(ns) == ref.name.name && it.type == type } - } - - fun fields(ns: MappingNamespace, name: FieldName, type: TypeDef? = null): List = - fields(ns, name.asRef(type)) - - fun fields(ns: MappingNamespace, name: String, type: TypeDef? = null): List = - fields(ns, name.asFieldRef(type)) - - fun field(ns: MappingNamespace, ref: LocalFieldRef): FieldMappingElement? = - fields(ns, ref).firstOrNull() - - fun field(ns: MappingNamespace, name: FieldName, type: TypeDef? = null): FieldMappingElement? = - field(ns, name.asRef(type)) - - fun field(ns: MappingNamespace, name: String, type: TypeDef? = null): FieldMappingElement? = - field(ns, name.asFieldRef(type)) - - fun field(ref: LocalFieldRef): FieldMappingElement? { - return mappingSet.namespaces.firstNotNullOfOrNull { ns -> field(ns, ref) } - } - - fun field(name: FieldName, type: TypeDef? = null): FieldMappingElement? = field(name.asRef(type)) - fun field(name: String, type: TypeDef? = null): FieldMappingElement? = field(name.asFieldRef(type)) - - fun addFieldMapping( - names: Array, - location: MappingLocation, - type: TypeDef? = null, - metadata: MemberMetadata = MemberMetadata.UNKNOWN, - ): FieldMappingElement { - val element = FieldMappingElement(names, this, type, metadata, mappingSet, location) - fieldStore.add(element) - return element - } - - // methods - - fun methods(): List { - return Collections.unmodifiableList(methodStore) - } - - fun methods(ref: LocalMethodRef): List { - if (ref.desc == null) { - return methodStore.filter { it.names.contains(ref.name.name) } - } - - // We don't know which namespace this field type is, so attempt to map for each namespace - val mappedTypes = if (ref.desc.isMappable()) { - mappingSet.namespaces.map2Array { mappingSet.mapTypeFrom(it, ref.desc) } - } else { - Array(mappingSet.namespaces.size) { ref.desc } - } - - return methodStore.filter { mapping -> - mappedTypes.withIndex().any { (i, type) -> - mapping.name(i) == ref.name.name && type == mapping.descriptor - } - } - } - - fun methods(name: MethodName, desc: MethodDescriptor? = null): List = - methods(name.asRef(desc)) - - fun methods(name: String, desc: MethodDescriptor? = null): List = - methods(name.asMethodRef(desc)) - - fun methods(ns: MappingNamespace, ref: LocalMethodRef): List { - if (ref.desc == null) { - return methodStore.filter { it.name(ns) == ref.name.name } - } - - val desc = if (ns != mappingSet.typeNamespace) { - mappingSet.mapTypeFrom(ns, ref.desc) - } else { - ref.desc - } - - return methodStore.filter { it.descriptor == desc } - } - - fun methods( - ns: MappingNamespace, - name: MethodName, - desc: MethodDescriptor? = null - ): List = methods(ns, name.asRef(desc)) - - fun methods( - ns: MappingNamespace, - name: String, - desc: MethodDescriptor? = null - ): List = methods(ns, name.asMethodRef(desc)) - - fun method(ns: MappingNamespace, ref: LocalMethodRef): MethodMappingElement? = - methods(ns, ref).firstOrNull() - - fun method(ns: MappingNamespace, name: MethodName, desc: MethodDescriptor? = null): MethodMappingElement? = - method(ns, name.asRef(desc)) - - fun method(ns: MappingNamespace, name: String, desc: MethodDescriptor? = null): MethodMappingElement? = - method(ns, name.asMethodRef(desc)) - - fun method(ref: LocalMethodRef): MethodMappingElement? { - return mappingSet.namespaces.firstNotNullOfOrNull { ns -> method(ns, ref) } - } - - fun method(name: MethodName, desc: MethodDescriptor? = null): MethodMappingElement? = - method(name.asRef(desc)) - - fun method(name: String, desc: MethodDescriptor? = null): MethodMappingElement? = - method(name.asMethodRef(desc)) - - fun addMethodMapping( - names: Array, - location: MappingLocation, - descriptor: MethodDescriptor, - metadata: MemberMetadata = MemberMetadata.UNKNOWN, - ): MethodMappingElement { - val element = MethodMappingElement(names, this, descriptor, metadata, mappingSet, location) - methodStore.add(element) - return element - } -} - -class FieldMappingElement( - override val names: Array, - val containingClass: ClassMappingElement, - val type: TypeDef? = null, - val metadata: MemberMetadata = MemberMetadata.UNKNOWN, - override val mappingSet: MappingSet = containingClass.mappingSet, - override val location: MappingLocation = UnknownLocation, -) : MappingElement - -class MethodMappingElement( - override val names: Array, - val containingClass: ClassMappingElement, - val descriptor: MethodDescriptor, - val metadata: MemberMetadata = MemberMetadata.UNKNOWN, - override val mappingSet: MappingSet = containingClass.mappingSet, - override val location: MappingLocation = UnknownLocation, -) : MappingElement { - - private val paramMappings = ParamMap() // keys should be ParameterRef - private val localVarMappings = ArrayList() // keys should be LvtRef - - fun descriptor(ns: MappingNamespace): String = - "(" + descriptor.params.joinToString("") { mappingSet.mapTypeTo(ns, it).descriptor } + ")" + - mappingSet.mapTypeTo(ns, descriptor.returnType).descriptor - - fun params(): Collection { - return Collections.unmodifiableCollection(paramMappings.values) - } - - fun param(index: ParamIndex): MethodParameterMappingElement? { - return paramMappings[index] - } - - fun param(index: Int): MethodParameterMappingElement? = param(index.asParamIndex()) - - fun addParamMapping( - names: Array, - location: MappingLocation, - paramIndex: ParamIndex, - lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - type: TypeDef? = null, - ): MethodParameterMappingElement { - val existing = paramMappings[paramIndex] - - if (existing != null && location.priority <= existing.location.priority) { - // existing takes precedence, so ignore - return existing - } else { - val element = MethodParameterMappingElement(names, this, paramIndex, lvtIndex, type, mappingSet, location) - paramMappings[paramIndex] = element - return element - } - } - - fun localVars(): Collection { - return Collections.unmodifiableCollection(localVarMappings) - } - - fun localVars( - lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - localVarIndex: LocalVarIndex = LocalVarIndex.UNKNOWN - ): List { - return localVarMappings.filter { - // only filter by values which are known - (!lvtIndex.isKnown || it.lvtIndex == lvtIndex) && - (!localVarIndex.index.isKnown || localVarIndex.index == it.localVarIndex.index) && - (!localVarIndex.localStart.isKnown || localVarIndex.localStart == it.localVarIndex.localStart) && - (!localVarIndex.localEnd.isKnown || localVarIndex.localEnd == it.localVarIndex.localEnd) - } - } - - fun localVars(index: LocalVarIndex): List { - return localVars(localVarIndex = index) - } - - fun localVar(index: LocalVarIndex): LocalVariableMappingElement? { - return localVars(index).firstOrNull() - } - - fun localVars(index: LvtIndex): List { - return localVars(lvtIndex = index) - } - - fun localVar(index: LvtIndex): LocalVariableMappingElement? { - return localVars(index).firstOrNull() - } - - fun addLocalVarMapping( - names: Array, - location: MappingLocation, - localVarIndex: LocalVarIndex = LocalVarIndex.UNKNOWN, - lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - type: TypeDef? = null, - ): LocalVariableMappingElement { - val existing = localVars(localVarIndex = localVarIndex, lvtIndex = lvtIndex) - if (existing.isNotEmpty() && location.priority <= existing.first().location.priority) { - // existing takes precedence, so ignore - return existing.first() - } else { - val element = LocalVariableMappingElement(names, this, localVarIndex, lvtIndex, type, mappingSet, location) - localVarMappings += element - return element - } - } -} - -class MethodParameterMappingElement( - override val names: Array, - val containingMethod: MethodMappingElement, - val index: ParamIndex, - val lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - val type: TypeDef? = null, - override val mappingSet: MappingSet = containingMethod.mappingSet, - override val location: MappingLocation = UnknownLocation, -) : MappingElement { - fun hasLvtIndex() = lvtIndex.isKnown -} - -data class MemberMetadata( - val isStatic: Tristate, - val isSynthetic: Tristate, -) { - companion object { - val UNKNOWN = MemberMetadata(Tristate.UNKNOWN, Tristate.UNKNOWN) - } -} - -class LocalVariableMappingElement( - override val names: Array, - val containingMethod: MethodMappingElement, - val localVarIndex: LocalVarIndex, - val lvtIndex: LvtIndex, - val type: TypeDef? = null, - override val mappingSet: MappingSet = containingMethod.mappingSet, - override val location: MappingLocation = UnknownLocation, -) : MappingElement { - init { - if (!localVarIndex.isKnown && !lvtIndex.isKnown) { - throw IllegalArgumentException("Cannot create LocalVariableMappingElement with unknown indices") - } - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingLocation.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingLocation.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingLocation.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,72 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -import io.mcdev.obfex.MappingPart -import io.mcdev.obfex.ref.LinePriority - -/** - * The location inside a [MappingSetSource] for a particular mapping. - * - * [priority] allows for different occurrences of a mapping to specify whether they should take precedence over another. - * - * For example, if a member mapping exists which indirectly defines a class mapping, that location would be considered - * lower priority than the direct class mapping itself. The priority system allows the indirect mapping to still be used - * if no direct mapping exists. - */ -sealed interface MappingLocation { - /** - * Numeric priority for this mapping, where high values are considered higher priority. - */ - val priority: Int - - fun withPriority(priority: Int): MappingLocation { - return when (this) { - is FileCoords -> copy(priority = priority) - is UnknownLocation -> this - } - } -} - -/** - * A [MappingLocation] within a mapping file. Used in conjunction with a [MappingsFile] - */ -data class FileCoords(val line: Int, val col: Int = 1, override val priority: Int = 0) : MappingLocation { - constructor(line: LinePriority?, col: Int = 1) : this(line?.coord ?: -1, col, line?.priority ?: 0) - constructor(line: LinePriority?, part: MappingPart) : this(line, part.col) - constructor(line: Int, part: MappingPart) : this(line, part.col) - - override fun withPriority(priority: Int): FileCoords { - return super.withPriority(priority) as FileCoords - } -} - -/** - * An unknown [MappingLocation]. - */ -data object UnknownLocation : MappingLocation { - override val priority: Int - get() = Int.MIN_VALUE - - override fun withPriority(priority: Int): MappingLocation { - return this - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingNamespace.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingNamespace.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingNamespace.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,39 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -/** - * A namespace is a collection of names in a mapping. A single mapping set can have an arbitrary number of namespaces, - * each namespace providing a different name for the same unique element. - */ -data class MappingNamespace( - val name: String, - val index: Int, - val associatedSet: MappingSet?, -) { - companion object { - const val UNNAMED_FROM: String = "from" - const val UNNAMED_TO: String = "to" - - fun unnamedFrom(set: MappingSet) = set.namespaceOf(UNNAMED_FROM) - fun unnamedTo(set: MappingSet) = set.namespaceOf(UNNAMED_TO) - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingSet.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingSet.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingSet.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,235 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -import io.mcdev.obfex.mappings.store.MappingLookupTable -import io.mcdev.obfex.ref.ArrayTypeDef -import io.mcdev.obfex.ref.ClassName -import io.mcdev.obfex.ref.ClassTypeDef -import io.mcdev.obfex.ref.FieldRef -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.MethodRef -import io.mcdev.obfex.ref.PackName -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.ReturnTypeDef -import io.mcdev.obfex.ref.VoidTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asPackage - -// TODO this sucks, start over from scratch -@Suppress("MemberVisibilityCanBePrivate") -class MappingSet(namespaceNames: Iterable = emptyList()) { - - /** - * All type definitions for each element is stored using this namespace. - */ - val typeNamespace: MappingNamespace - - /** - * The namespaces present in this mapping set. - */ - val namespaces: Array - - private val packageStore = MappingLookupTable(this) - private val classStore = MappingLookupTable(this) - - init { - val names = namespaceNames.toList() - if (names.isEmpty()) { - typeNamespace = MappingNamespace(MappingNamespace.UNNAMED_FROM, 0, this) - namespaces = arrayOf(typeNamespace, MappingNamespace(MappingNamespace.UNNAMED_TO, 1, this)) - } else if (names.size >= 2) { - namespaces = Array(names.size) { index -> MappingNamespace(names[index], index, this) } - typeNamespace = namespaces[0] - } else { - throw IllegalArgumentException("namespaceNames must contain at least 2 namespaces: $names") - } - } - - fun namespaceOf(name: String): MappingNamespace = namespaceOfOrNull(name) - ?: throw IllegalArgumentException("Could not find namespace: $name") - - fun namespaceOfOrNull(name: String): MappingNamespace? = namespaces.find { it.name == name } - - private fun findNamespace(ns: MappingNamespace): MappingNamespace = if (ns.associatedSet === this) { - ns - } else { - namespaces.find { it.name == ns.name } - ?: throw IllegalArgumentException( - "Provided namespace is not associated with the current MappingSet: ${ns.name}" - ) - } - - fun namespaceIndex(name: String): Int { - return namespaceIndex(namespaceOf(name)) - } - - fun namespaceIndex(ns: MappingNamespace): Int = findNamespace(ns).index - - fun mapType(fromNs: MappingNamespace, toNs: MappingNamespace, typeDef: T): T { -// when (typeDef) { -// is VoidTypeDef, is PrimitiveTypeDef -> return typeDef -// } - - val fromNamespace = findNamespace(fromNs) - val toNamespace = findNamespace(toNs) - if (fromNamespace === toNamespace) { - return typeDef - } - - @Suppress("UNCHECKED_CAST") - return when (typeDef) { - is ArrayTypeDef -> ArrayTypeDef( - mapType(fromNamespace, toNamespace, typeDef.componentType), typeDef.dimension - ) as T - - is ClassTypeDef -> { - val name = classStore.forNamespace(fromNamespace) - .query(typeDef.className.name) - .firstOrNull() - ?.fullyQualifiedName(toNamespace) - ?.asClass() - ?: typeDef.className // fallback to provided name if not found - ClassTypeDef(name) as T - } - - else -> throw IllegalStateException("Unexpected typedef: " + typeDef.javaClass.name) - } - } - - fun mapType(fromNs: MappingNamespace, toNs: MappingNamespace, desc: MethodDescriptor): MethodDescriptor { - return MethodDescriptor(desc.params.map { mapType(fromNs, toNs, it) }, mapType(fromNs, toNs, desc.returnType)) - } - - /** - * Map the given type to the [typeNamespace]. - */ - fun mapTypeTo(ns: MappingNamespace, typeDef: T): T { - return mapType(typeNamespace, ns, typeDef) - } - - /** - * Map the given type to the [typeNamespace]. - */ - fun mapTypeTo(ns: MappingNamespace, desc: MethodDescriptor): MethodDescriptor { - return mapType(typeNamespace, ns, desc) - } - - /** - * Map the given type from the [typeNamespace]. - */ - fun mapTypeFrom(ns: MappingNamespace, typeDef: T): T { - return mapType(ns, typeNamespace, typeDef) - } - - /** - * Map the given type from the [typeNamespace]. - */ - fun mapTypeFrom(ns: MappingNamespace, desc: MethodDescriptor): MethodDescriptor { - return mapType(ns, typeNamespace, desc) - } - - // package - fun packs(): List { - return packageStore.list() - } - - fun packs(name: PackName): List { - return packageStore.byName.query(name.name).list() - } - fun packs(name: String): List = packs(name.asPackage()) - - fun pack(name: PackName): PackageMappingElement? { - return packageStore.byName.query(name.name).firstOrNull() - } - fun pack(name: String): PackageMappingElement? = pack(name.asPackage()) - - fun packs(ns: MappingNamespace, name: PackName): List { - return packageStore.forNamespace(ns).query(name.name).list() - } - fun packs(ns: MappingNamespace, name: String): List = - packs(ns, name.asPackage()) - - fun pack(ns: MappingNamespace, name: PackName): PackageMappingElement? { - return packageStore.forNamespace(ns).query(name.name).firstOrNull() - } - fun pack(ns: MappingNamespace, name: String): PackageMappingElement? = pack(ns, name.asPackage()) - - fun addPackageMapping(names: Array, location: MappingLocation): PackageMappingElement { - val element = PackageMappingElement(names, this, location) - packageStore.add(element) - return element - } - - // class - fun classes(): List { - return classStore.list() - } - - fun classes(name: ClassName): List { - return classStore.byName.query(name.name).list() - } - fun classes(name: String): List = classes(name.asClass()) - - fun clazz(name: ClassName): ClassMappingElement? { - return classStore.byName.query(name.name).firstOrNull() - } - fun clazz(name: String): ClassMappingElement? = clazz(name.asClass()) - - fun classes(ns: MappingNamespace, name: ClassName): List { - return classStore.forNamespace(ns).query(name.name).list() - } - fun classes(ns: MappingNamespace, name: String): List = classes(ns, name.asClass()) - - fun clazz(ns: MappingNamespace, name: ClassName): ClassMappingElement? { - return classStore.forNamespace(ns).query(name.name).firstOrNull() - } - fun clazz(ns: MappingNamespace, name: String): ClassMappingElement? = clazz(ns, name.asClass()) - - fun addClassMapping( - names: Array, - parent: ClassMappingElement?, - location: MappingLocation - ): ClassMappingElement { - val element = ClassMappingElement(names, parent, this, location) - classStore.add(element) - return element - } - - // members - fun fieldMapping(field: FieldRef, ns: MappingNamespace): FieldMappingElement? { - val clazz = clazz(ns, field.containingClass) ?: return null - return clazz.field(ns, field.field) - } - - fun fieldMapping(field: FieldRef): FieldMappingElement? { - return namespaces.firstNotNullOfOrNull { ns -> fieldMapping(field, ns) } - } - - fun methodMapping(method: MethodRef, ns: MappingNamespace): MethodMappingElement? { - val clazz = clazz(ns, method.containingClass) ?: return null - return clazz.method(ns, method.method) - } - - fun methodMapping(method: MethodRef): MethodMappingElement? { - return namespaces.firstNotNullOfOrNull { ns -> methodMapping(method, ns) } - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingSetBuilder.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingSetBuilder.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingSetBuilder.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,412 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -@file:Suppress("MemberVisibilityCanBePrivate") - -package io.mcdev.obfex.mappings - -import com.intellij.util.containers.map2Array -import io.mcdev.obfex.mappings.MappingNamespace.Companion.UNNAMED_FROM -import io.mcdev.obfex.mappings.MappingNamespace.Companion.UNNAMED_TO -import io.mcdev.obfex.ref.ClassName -import io.mcdev.obfex.ref.FieldName -import io.mcdev.obfex.ref.LinePriority -import io.mcdev.obfex.ref.LocalMemberRef -import io.mcdev.obfex.ref.LocalMethodRef -import io.mcdev.obfex.ref.LocalVarIndex -import io.mcdev.obfex.ref.LocalVarName -import io.mcdev.obfex.ref.LvtIndex -import io.mcdev.obfex.ref.MemberName -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.MethodName -import io.mcdev.obfex.ref.PackName -import io.mcdev.obfex.ref.ParamIndex -import io.mcdev.obfex.ref.ParamName -import io.mcdev.obfex.ref.TypeDef -import it.unimi.dsi.fastutil.ints.Int2ObjectFunction -import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap - -interface MappingSetBuilderCore { - fun pack(line: LinePriority? = null, col: Int = 1): PackageMappingBuilder - fun clazz(line: LinePriority? = null, col: Int = 1): ClassMappingBuilder - - fun clazz(ref: NS, line: LinePriority? = null, col: Int = 1): ClassMappingBuilder -} - -class MappingSetBuilder( - val issues: MappingIssuesRegistry, - vararg namespaces: String, -) : MappingSetBuilderCore, MappingIssuesRegistry by issues { - - val namespaces: Array = if (namespaces.isEmpty()) { - arrayOf(UNNAMED_FROM, UNNAMED_TO) - } else { - // Kotlin wants `namespaces` to be Array - @Suppress("UNCHECKED_CAST") - namespaces as Array - } - - val packageMappings = ArrayList() - val classMappings = ArrayList() - - // mapping files often keep mappings lines for the same class together, so this is an easy way to optimize that case - private var lastClassMapping: ClassMappingBuilder? = null - - override fun pack(line: LinePriority?, col: Int): PackageMappingBuilder { - return PackageMappingBuilder(namespaces, this, FileCoords(line, col)).also { packageMappings += it } - } - - override fun clazz(line: LinePriority?, col: Int): ClassMappingBuilder { - return ClassMappingBuilder(namespaces, this, FileCoords(line, col)).also { classMappings += it } - } - - override fun clazz(ref: NS, line: LinePriority?, col: Int): ClassMappingBuilder { - if (lastClassMapping?.names?.get(ref.ns) == ref.v.name) { - return lastClassMapping!! - } - val res = - classMappings.firstOrNull { it.names[ref.ns] == ref.v.name } - ?: ClassMappingBuilder(namespaces, this, FileCoords(line, col)).also { - classMappings += it - it.with(ref) - } - lastClassMapping = res - return res - } - - fun build(): MappingSet { - val set = MappingSet(namespaces.asIterable()) - - packageMappings.forEach { it.build(set, issues) } - classMappings.forEach { it.build(set, issues) } - - return set - } -} - -class PackageMappingBuilder( - namespaces: Array, - val parent: MappingSetBuilder, - var coords: FileCoords, -) : NamingBuilder(namespaces) { - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(set: MappingSet, issues: MappingIssuesRegistry) { - val n = names.map2Array { name -> - if (name == null) { - issues.warning("Package mapping found without target name", coords) - } - name?.takeIf { it.isNotBlank() } - } - if (n.all { it == null }) { - issues.error("Package mapping found with no target names", coords) - } - - set.addPackageMapping(n, coords) - } -} - -class ClassMappingBuilder( - namespaces: Array, - val parent: MappingSetBuilder, - var coords: FileCoords, -) : NamingBuilder(namespaces), MappingIssuesRegistry by parent { - - val fieldMappings = ArrayList() - val methodMappings = ArrayList() - - private var lastMethodMapping: MethodMappingBuilder? = null - - val set: MappingSetBuilder - get() = parent - - fun field(line: LinePriority? = null, col: Int = 1): FieldMappingBuilder { - return FieldMappingBuilder(namespaces, this, FileCoords(line, col)).also { fieldMappings += it } - } - - fun method(line: LinePriority? = null, col: Int = 1): MethodMappingBuilder { - return MethodMappingBuilder(namespaces, this, FileCoords(line, col)).also { methodMappings += it } - } - - fun method(ref: NS, line: LinePriority? = null, col: Int = 1): MethodMappingBuilder { - if (lastMethodMapping?.names?.get(ref.ns) == ref.v.name.name && lastMethodMapping?.desc == ref.v.desc) { - return lastMethodMapping!! - } - val res = - methodMappings.firstOrNull { it.names[ref.ns] == ref.v.name.name } - ?: MethodMappingBuilder(namespaces, this, FileCoords(line, col)).also { - methodMappings += it - it.desc = ref.v.desc - it.with(ref.withValue { name }) - } - lastMethodMapping = res - return res - } - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(set: MappingSet, issues: MappingIssuesRegistry, parentElement: ClassMappingElement? = null) { - val n = names.map2Array { name -> - if (name == null) { - issues.warning("Class mapping found without target name", coords) - } - name?.takeIf { it.isNotBlank() } - } - if (n.all { it == null }) { - issues.error("Class mapping found with no target names", coords) - } - - val element = set.addClassMapping(n, parentElement, coords) - - fieldMappings.forEach { it.build(issues, element) } - methodMappings.forEach { it.build(issues, element) } - } -} - -class FieldMappingBuilder( - namespaces: Array, - val parent: ClassMappingBuilder, - var coords: FileCoords, -) : NamingBuilder(namespaces), MappingIssuesRegistry by parent { - - var type: TypeDef? = null - - var meta: MemberMetadata = MemberMetadata.UNKNOWN - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(issues: MappingIssuesRegistry, parent: ClassMappingElement) { - val n = names.map2Array { name -> - if (name == null) { - issues.warning("Field mapping found without target name", coords) - } - name?.takeIf { it.isNotBlank() } - } - if (n.all { it == null }) { - issues.error("Field mapping found with no target names", coords) - } - - parent.addFieldMapping(n, coords, type, meta) - } -} - -class MethodMappingBuilder( - namespaces: Array, - val parent: ClassMappingBuilder, - var coords: FileCoords, -) : NamingBuilder(namespaces), MappingIssuesRegistry by parent { - - var desc: MethodDescriptor? = null - - val paramMappings = Int2ObjectLinkedOpenHashMap() - val localVarMappings = ArrayList() - - var meta: MemberMetadata = MemberMetadata.UNKNOWN - - fun param(index: ParamIndex, line: LinePriority? = null, col: Int = 1): ParamMappingBuilder { - return paramMappings.compIfAbsent(index.index) { - ParamMappingBuilder(namespaces, this, index, FileCoords(line, col)) - } - } - - // tiny-v2 is the only format that I know of that supports locals, it only requires a local var index, but I could - // see other formats might have different requirements, so this stays as flexible as possible, not requiring any - fun localVar( - localVarIndex: LocalVarIndex = LocalVarIndex.UNKNOWN, - lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - line: LinePriority? = null, - col: Int = 1 - ): LocalVarMappingBuilder { - return localVarMappings.firstOrNull { mapping -> - mapping.localVarIndex == localVarIndex && mapping.lvtIndex == lvtIndex - } ?: LocalVarMappingBuilder(namespaces, this, localVarIndex, lvtIndex, FileCoords(line, col)) - .also { localVarMappings += it } - } - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(issues: MappingIssuesRegistry, parent: ClassMappingElement) { - val n = names.map2Array { name -> - if (name == null) { - issues.warning("Method mapping found without target name", coords) - } - name?.takeIf { it.isNotBlank() } - } - if (n.all { it == null }) { - issues.error("Method mapping found with no target names", coords) - } - - val desc = this.desc ?: return issues.error("Method mappings must have a descriptor", coords) - - val element = parent.addMethodMapping(n, coords, desc, meta) - - paramMappings.values.forEach { it.build(issues, element) } - localVarMappings.forEach { it.build(issues, element) } - } -} - -class ParamMappingBuilder( - namespaces: Array, - val parent: MethodMappingBuilder, - val index: ParamIndex, - var coords: FileCoords, -) : NamingBuilder(namespaces), MappingIssuesRegistry by parent { - - var lvtRef: LvtIndex? = LvtIndex.UNKNOWN - - var type: TypeDef? = null - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(issues: MappingIssuesRegistry, parent: MethodMappingElement) { - val n = names.map2Array { name -> name?.takeIf { it.isNotBlank() } } - if (n.all { it == null }) { - issues.error("Method parameter mapping found with no target names", coords) - } - - parent.addParamMapping(n, coords, index, lvtRef ?: LvtIndex.UNKNOWN, type) - } -} - -class LocalVarMappingBuilder( - namespaces: Array, - val parent: MethodMappingBuilder, - var localVarIndex: LocalVarIndex, - var lvtIndex: LvtIndex, - var coords: FileCoords, -) : NamingBuilder(namespaces), MappingIssuesRegistry by parent { - - var type: TypeDef? = null - - override fun addName(ref: NS) { - names[ref.ns] = ref.v - } - - fun build(issues: MappingIssuesRegistry, parent: MethodMappingElement) { - if (!localVarIndex.isKnown && !lvtIndex.isKnown) { - return issues.error("Method local var mapping found without known any known indices", coords) - } - - val n = names.map2Array { name -> name?.takeIf { it.isNotBlank() } } - if (n.all { it == null }) { - issues.error("Method local var mapping found with no target names", coords) - } - - parent.addLocalVarMapping(n, coords, localVarIndex, lvtIndex, type) - } -} - -abstract class NamingBuilder(val namespaces: Array) { - - val names: Array = arrayOfNulls(namespaces.size) - - operator fun set(ns: String, name: T) { - set(namespaces.indexOf(ns), name) - } - - operator fun set(index: Int, name: T) { - with(NS(name, index)) - } - - fun with(ref: NS) { - addName(ref.forName()) - } - - fun unlessExists(ref: NS) { - if (names[ref.ns] != null) { - return - } - addName(ref.forName()) - } - - protected abstract fun addName(ref: NS) -} - -// as in "NameSpace" -data class NS(val v: V, val ns: Int) { - fun withValue(newV: T): NS = NS(newV, ns) - inline fun withValue(block: V.() -> T): NS = NS(v.block(), ns) -} -fun NS.forName(): NS = NS(v.name, ns) - -fun T.ns(ns: Int): NS = NS(this, ns) -fun > T.ns(ns: Int): NS = NS(this, ns) - -// helpers - -private fun M.compIfAbsent(key: Int, func: Int2ObjectFunction): V - where M : Int2ObjectLinkedOpenHashMap = computeIfAbsent(key, func) - -inline fun MappingSetBuilderCore.pack( - line: LinePriority? = null, - col: Int = 1, - conf: PackageMappingBuilder.() -> Unit, -) = pack(line, col).apply(conf) - -inline fun MappingSetBuilderCore.clazz( - line: LinePriority? = null, - col: Int = 1, - conf: ClassMappingBuilder.() -> Unit, -) = clazz(line, col).apply(conf) - -inline fun MappingSetBuilderCore.clazz( - ref: NS, - line: LinePriority? = null, - col: Int = 1, - conf: ClassMappingBuilder.() -> Unit, -) = clazz(ref, line, col).apply(conf) - -inline fun ClassMappingBuilder.field( - line: LinePriority? = null, - col: Int = 1, - conf: FieldMappingBuilder.() -> Unit, -) = field(line, col).apply(conf) - -inline fun ClassMappingBuilder.method( - line: LinePriority? = null, - col: Int = 1, - conf: MethodMappingBuilder.() -> Unit, -) = method(line, col).apply(conf) - -inline fun MethodMappingBuilder.param( - index: ParamIndex, - line: LinePriority? = null, - col: Int = 1, - conf: ParamMappingBuilder.() -> Unit, -) = param(index, line, col).apply(conf) - -inline fun MethodMappingBuilder.localVar( - localVarIndex: LocalVarIndex = LocalVarIndex.UNKNOWN, - lvtIndex: LvtIndex = LvtIndex.UNKNOWN, - line: LinePriority? = null, - col: Int = 1, - conf: LocalVarMappingBuilder.() -> Unit, -) = localVar(localVarIndex, lvtIndex, line, col).apply(conf) Index: obfuscation-explorer/src/main/kotlin/mappings/MappingSetSource.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingSetSource.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingSetSource.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,69 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.formats.MappingsFormatType - -/** - * Defines an issue (warning / error) related to a parsed mapping file. Ideally the [coords] are provided as well to - * identify where the issue occurs. - */ -data class MappingParseIssue(val message: String, val coords: FileCoords?) - -/** - * Builder interface for registering new issues, shared between several builders. - */ -interface MappingIssuesRegistry { - fun error(message: String, coords: FileCoords? = null) - fun warning(message: String, coords: FileCoords? = null) -} - -sealed interface MappingSetSource { - val errors: List - val warnings: List -} - -class MappingsFile( - val file: VirtualFile, - val type: MappingsFormatType, - override val errors: List = emptyList(), - override val warnings: List = emptyList(), -) : MappingSetSource - -class MappingsFileBuilder( - val file: VirtualFile, - val type: MappingsFormatType, -) : MappingIssuesRegistry { - - val errors: MutableList = mutableListOf() - val warnings: MutableList = mutableListOf() - - override fun error(message: String, coords: FileCoords?) { - errors.add(MappingParseIssue(message, coords)) - } - - override fun warning(message: String, coords: FileCoords?) { - warnings.add(MappingParseIssue(message, coords)) - } - - fun build() = MappingsFile(file, type, errors.toList(), warnings.toList()) -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingsDefinition.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingsDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingsDefinition.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,54 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.formats.MappingsFormatType - -/** - * Complete top-level definition for a collection of mappings, which includes the mappings themselves and their source. - */ -class MappingsDefinition( - val mappings: MappingSet, - val source: MappingSetSource, -) - -class MappingsDefinitionBuilder( - val mappings: MappingSetBuilder, - val source: MappingsFileBuilder, -) : MappingSetBuilderCore by mappings, MappingIssuesRegistry by mappings.issues { - - constructor(fileBuilder: MappingsFileBuilder, vararg namespaces: String) : - this(MappingSetBuilder(fileBuilder, *namespaces), fileBuilder) - - constructor(type: MappingsFormatType, file: VirtualFile, vararg namespaces: String) : - this(MappingsFileBuilder(file, type), *namespaces) - - val namespaces: Array - get() = mappings.namespaces - - val issues: MappingIssuesRegistry - get() = mappings.issues - - fun ns(namespace: String): Int = namespace.indexOf(namespace) - - fun build() = MappingsDefinition(mappings.build(), source.build()) -} Index: obfuscation-explorer/src/main/kotlin/mappings/MappingsFormatParser.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/MappingsFormatParser.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,88 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings - -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.vfs.VirtualFile -import io.mcdev.obfex.mappings.MappingsFormatParser.Companion.EP_NAME -import io.mcdev.obfex.ref.LocalMemberRef -import io.mcdev.obfex.ref.MemberName - -/** - * A parser for Java obfuscation mapping file formats. Provide implementations using the [EP_NAME] extension point. - */ -interface MappingsFormatParser { - - /** - * File extensions this parser expects to see. This will be the first thing checked to determine the file type, if - * multiple parsers share the same extension match then [isSupportedFile] will be used as a fallback. - */ - val expectedFileExtensions: Array - - /** - * Quickly check the file to determine if this parser supports it. Only used as a fallback if multiple parsers - * match the same [expectedFileExtensions]. - */ - fun isSupportedFile(file: VirtualFile): Boolean = false - - /** - * Attempt to parse the given file into a [MappingsDefinition]. If the file type is unknown or not supported by this - * parser, or the file contents are too corrupt to parse, return `null`. - * - * It's generally preferable to return a _partial_ [MappingsDefinition] when the mappings file contains errors (that - * is, it's preferable to skip over errors rather than fail completely). Record parse errors in the - * [MappingsDefinition] so they can be presented to the user. - */ - fun parse(file: VirtualFile): MappingsDefinition? - - companion object { - @JvmStatic - val EP_NAME = ExtensionPointName.create("io.mcdev.obfex.mappingsFormatParser") - } -} - -/** - * A [MappingsFormatParser] for mapping formats without namespaces. - */ -interface UnnamedMappingsFormatParser : MappingsFormatParser { - - /** - * Helper property for unnamed mapping formats. - */ - val unnamedFrom: Int - get() = 0 - - /** - * Helper property for unnamed mapping formats. - */ - val unnamedTo: Int - get() = 1 - - val T.from: NS - get() = ns(unnamedFrom) - val T.to: NS - get() = ns(unnamedTo) - - val > T.from: NS - get() = ns(unnamedFrom) - val > T.to: NS - get() = ns(unnamedTo) -} Index: obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupIndex.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupIndex.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,44 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings.store - -import io.mcdev.obfex.lookup.LookupIndex -import io.mcdev.obfex.mappings.MappingElement -import io.mcdev.obfex.mappings.MappingSet -import kotlin.reflect.KClass - -class MappingLookupIndex( - private val set: MappingSet, - private val index: LookupIndex -) : LookupIndex by index { - - override fun query(key: K?): MappingLookupTable { - return MappingLookupTable(set, index.query(key)) - } - - override fun > unwrap(type: KClass): L? { - if (type.isInstance(this)) { - @Suppress("UNCHECKED_CAST") - return this as L - } - return index.unwrap(type) - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupTable.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/store/MappingLookupTable.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,75 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings.store - -import io.mcdev.obfex.lookup.HashLookupTable -import io.mcdev.obfex.lookup.LookupIndexTransformer -import io.mcdev.obfex.lookup.MultiLookupTable -import io.mcdev.obfex.lookup.SingleLookupIndexTransformer -import io.mcdev.obfex.mappings.MappingElement -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingSet -import kotlin.reflect.KClass - -open class MappingLookupTable( - private val set: MappingSet, - private val table: MultiLookupTable = HashLookupTable() -) : MultiLookupTable by table { - - // lookups based on namespace - private val namespaceIndices = mutableListOf>() - - fun forNamespace(namespaceIndex: Int): MappingLookupIndex { - val lookup = namespaceIndices.firstOrNull { it.index == namespaceIndex } - if (lookup != null) { - return lookup.lookup - } - - val newLookup = index { it.name(namespaceIndex) } - namespaceIndices += NamespaceLookup(namespaceIndex, newLookup) - return newLookup - } - - fun forNamespace(namespace: MappingNamespace): MappingLookupIndex { - val index = set.namespaceIndex(namespace) - return forNamespace(index) - } - - val byName: MappingLookupIndex by lazy { - MappingLookupIndex(set, indexMulti { it.names.filterNotNull() }) - } - - override fun index(transformer: SingleLookupIndexTransformer): MappingLookupIndex { - return MappingLookupIndex(set, table.index(transformer)) - } - - override fun indexMulti(transformer: LookupIndexTransformer): MappingLookupIndex { - return MappingLookupIndex(set, table.indexMulti(transformer)) - } - - override fun > unwrap(type: KClass): L? { - if (type.isInstance(this)) { - @Suppress("UNCHECKED_CAST") - return this as L - } - return table.unwrap(type) - } -} Index: obfuscation-explorer/src/main/kotlin/mappings/store/NamespaceLookup.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/mappings/store/NamespaceLookup.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/mappings/store/NamespaceLookup.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,25 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.mappings.store - -import io.mcdev.obfex.mappings.MappingElement - -data class NamespaceLookup(val index: Int, val lookup: MappingLookupIndex) Index: obfuscation-explorer/src/main/kotlin/ref/ref.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/ref/ref.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/ref/ref.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,224 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.ref - -import io.mcdev.obfex.MappingPart -import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap - -/* - * Mapping names are transparent wrappers around plain strings. The benefit they provide is by allowing transformations - * of the input string in the `as` methods that create them. - */ - -interface MemberName { - val name: String -} - -@JvmInline -value class PackName(override val name: String) : MemberName -@JvmInline -value class ClassName(override val name: String) : MemberName -@JvmInline -value class FieldName(override val name: String) : MemberName -@JvmInline -value class MethodName(override val name: String) : MemberName -@JvmInline -value class ParamName(override val name: String) : MemberName -@JvmInline -value class LocalVarName(override val name: String) : MemberName - -fun String.asPackage(): PackName { - val replaced = this.replace('.', '/') - return if (replaced == "//") { - PackName("/") - } else { - PackName(replaced) - } -} -fun String.asClass(): ClassName = ClassName(this.replace('.', '/')) -fun String.asField(): FieldName = FieldName(this) -fun String.asMethod(): MethodName = MethodName(this) -fun String.asParam(): ParamName = ParamName(this) -fun String.asLocal(): LocalVarName = LocalVarName(this) - -// Most of the time we want to go directly from a MappingPart, so these are just convenience wrappers for that - -fun MappingPart.asPackage(): PackName = value.asPackage() -fun MappingPart.asClass(): ClassName = value.asClass() -fun MappingPart.asField(): FieldName = value.asField() -fun MappingPart.asMethod(): MethodName = value.asMethod() -fun MappingPart.asParam(): ParamName = value.asParam() -fun MappingPart.asLocal(): LocalVarName = value.asLocal() - -/* - * References for Java members. - */ - -interface LocalMemberRef { - val name: T -} - -/** - * Local field reference, no class. - */ -data class LocalFieldRef(override val name: FieldName, val type: TypeDef? = null) : LocalMemberRef { - fun withType(type: TypeDef?): LocalFieldRef = copy(type = type) - fun withoutType(): LocalFieldRef = withType(null) -} - -/** - * Absolute field reference, including class. - */ -data class FieldRef(val containingClass: ClassName, val field: LocalFieldRef) - -// Utilities for creating field refs -fun FieldName.asRef(type: TypeDef? = null): LocalFieldRef = LocalFieldRef(this, type) -fun String.asFieldRef(type: TypeDef? = null): LocalFieldRef = this.asField().asRef(type) -fun String.asFieldRef(type: String?): LocalFieldRef = this.asField().asRef(type?.asTypeDef()) - -fun ClassName.field(name: FieldName, type: TypeDef? = null): FieldRef = FieldRef(this, name.asRef(type)) -fun ClassName.field(ref: LocalFieldRef): FieldRef = FieldRef(this, ref) -/** - * Local method reference, no class. - */ -data class LocalMethodRef(override val name: MethodName, val desc: MethodDescriptor?) : LocalMemberRef { - fun withDesc(desc: MethodDescriptor): LocalMethodRef = copy(desc = desc) -} - -/** - * Absolute method reference, including class. - */ -data class MethodRef(val containingClass: ClassName, val method: LocalMethodRef) - -// Utilities for creating method refs -fun MethodName.asRef(desc: MethodDescriptor? = null): LocalMethodRef = LocalMethodRef(this, desc) -fun String.asMethodRef(desc: MethodDescriptor? = null): LocalMethodRef = this.asMethod().asRef(desc) -fun String.asMethodRef(desc: String?): LocalMethodRef = this.asMethod().asRef(desc?.asMethodDesc()) - -fun ClassName.method(name: MethodName, desc: MethodDescriptor? = null): MethodRef = MethodRef(this, name.asRef(desc)) -fun ClassName.method(ref: LocalMethodRef): MethodRef = MethodRef(this, ref) - -// Similar concept to ParamName and LvtName, but wrapping integers for indices. - -@JvmInline -value class ParamIndex(val index: Int) - -data class LocalVarIndex(val index: Local, val localStart: Local = Local.UNKNOWN, val localEnd: Local = Local.UNKNOWN) { - val isKnown: Boolean - get() = index.isKnown - - companion object { - @JvmStatic - val UNKNOWN = LocalVarIndex(Local.UNKNOWN) - } -} - -@JvmInline -value class LvtIndex(val index: Local) { - val isKnown: Boolean - get() = this.index.isKnown - - companion object { - @JvmStatic - val UNKNOWN = LvtIndex(Local.UNKNOWN) - } -} - -@JvmInline -value class Local(val index: Int) { - val isKnown: Boolean - get() = this.index != -1 - - companion object { - @JvmStatic - val UNKNOWN = Local(-1) - } -} - -fun Int.asParamIndex(): ParamIndex = ParamIndex(this) -fun Int.asLocal(): Local = Local(this) -fun Local.asLocalVar(startIndex: Local = Local.UNKNOWN, endIndex: Local = Local.UNKNOWN): LocalVarIndex = - LocalVarIndex(this, startIndex, endIndex) -fun Int.asLocal(startIndex: Local = Local.UNKNOWN, endIndex: Local = Local.UNKNOWN): LocalVarIndex = - this.asLocal().asLocalVar(startIndex, endIndex) -fun Local.asLvtIndex(): LvtIndex = LvtIndex(this) -fun Int.asLvtIndex(): LvtIndex = this.asLocal().asLvtIndex() - -// LinePriority helps us keep track of which line number we want to use for new elements - -data class LinePriority(val coord: Int, val priority: Int) - -private const val BASE_PRIORITY_VALUE = 0 -private const val HIGH_PRIORITY_VALUE = 100 -private const val LOW_PRIORITY_VALUE = -100 - -val Int.basePriority: LinePriority - get() = priority(BASE_PRIORITY_VALUE) -val LinePriority.basePriority: LinePriority - get() = if (priority == BASE_PRIORITY_VALUE) { - this - } else { - coord.basePriority - } - -val Int.highPriority: LinePriority - get() = priority(HIGH_PRIORITY_VALUE) -val LinePriority.highPriority: LinePriority - get() = if (priority == HIGH_PRIORITY_VALUE) { - this - } else { - coord.highPriority - } - -val Int.lowPriority: LinePriority - get() = priority(LOW_PRIORITY_VALUE) -val LinePriority.lowPriority: LinePriority - get() = if (priority == LOW_PRIORITY_VALUE) { - this - } else { - coord.lowPriority - } - -fun Int.priority(priority: Int) = LinePriority(this, priority) - -// ParamIndex and LvtIndex helpers -class ParamMap( - private val backing: Int2ObjectLinkedOpenHashMap = Int2ObjectLinkedOpenHashMap() -) : MutableMap by backing { - @Deprecated(message = "Use ParameterRef to access", replaceWith = ReplaceWith("this.get(key.asParam())")) - override fun get(key: Int): T? { - return backing.get(key) - } - - @Deprecated(message = "Use ParameterRef to access", replaceWith = ReplaceWith("this.put(key.asParam(), value)")) - override fun put(key: Int, value: T): T? { - return backing.put(key, value) - } - @Deprecated(message = "Use ParameterRef to access", replaceWith = ReplaceWith("this.set(key.asParam(), value)")) - operator fun set(key: Int, value: T): T? { - return backing.put(key, value) - } - - operator fun get(key: ParamIndex): T? = backing.get(key.index) - operator fun set(key: ParamIndex, value: T) { - backing.put(key.index, value) - } -} Index: obfuscation-explorer/src/main/kotlin/ref/types.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/ref/types.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/ref/types.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,199 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.ref - -import io.mcdev.obfex.MappingPart -import java.lang.IllegalStateException - -sealed interface ReturnTypeDef { - val descriptor: String - - fun isMappable(): Boolean - - companion object { - fun parse(desc: String) = desc.asReturnTypeDef() - } -} - -object VoidTypeDef : ReturnTypeDef { - override val descriptor = "V" - - override fun isMappable(): Boolean = false - - override fun toString() = descriptor -} - -sealed interface TypeDef : ReturnTypeDef { - override fun isMappable(): Boolean = when (this) { - is PrimitiveTypeDef -> false - is ClassTypeDef -> true - is ArrayTypeDef -> componentType.isMappable() - } - - companion object { - fun parse(desc: String) = desc.asTypeDef() - } -} - -enum class PrimitiveTypeDef(override val descriptor: String) : TypeDef { - BOOLEAN("Z"), - CHAR("C"), - BYTE("B"), - SHORT("S"), - INT("I"), - LONG("J"), - FLOAT("F"), - DOUBLE("D"); - - override fun toString() = descriptor - - companion object { - fun fromChar(c: Char): PrimitiveTypeDef? { - return when (c) { - 'Z' -> BOOLEAN - 'C' -> CHAR - 'B' -> BYTE - 'S' -> SHORT - 'I' -> INT - 'J' -> LONG - 'F' -> FLOAT - 'D' -> DOUBLE - else -> null - } - } - } -} - -data class ClassTypeDef(val className: ClassName) : TypeDef { - override val descriptor: String - get() = "L${className.name};" - - override fun toString(): String = descriptor -} - -data class ArrayTypeDef(val componentType: TypeDef, val dimension: Int) : TypeDef { - override val descriptor: String - get() = "[".repeat(dimension) + componentType.descriptor - - override fun toString() = descriptor -} - -fun String.asReturnTypeDef(): ReturnTypeDef? = parseType(this, 0)?.type -fun String.asTypeDef(): TypeDef? = parseType(this, 0)?.type as? TypeDef - -private data class TypeReturn(val index: Int, val type: ReturnTypeDef) - -private fun parseType(text: String, index: Int): TypeReturn? { - return when (val c = text[index]) { - 'L' -> { - val endIndex = text.indexOf(';', index + 1) - if (endIndex == -1) { - return null - } - TypeReturn(endIndex + 1, ClassTypeDef(ClassName(text.substring(index + 1, endIndex)))) - } - '[' -> { - var endIndex: Int = -1 - for (i in index + 1 until text.length) { - val next = text[i] - if (next != '[') { - endIndex = i - break - } - } - if (endIndex == -1) { - return null - } - - val componentType = parseType(text, endIndex) ?: return null - if (componentType.type is ArrayTypeDef) { - // should be impossible - throw IllegalStateException() - } else if (componentType.type == VoidTypeDef) { - return null - } - - return TypeReturn( - componentType.index, - ArrayTypeDef(componentType.type as TypeDef, endIndex - index) - ) - } - 'V' -> TypeReturn(index + 1, VoidTypeDef) - else -> PrimitiveTypeDef.fromChar(c)?.let { TypeReturn(index + 1, it) } - } -} - -data class MethodDescriptor(val params: List, val returnType: ReturnTypeDef) { - - fun isMappable(): Boolean = params.any { it.isMappable() } || returnType.isMappable() - - override fun toString(): String = buildString { - append('(') - for (param in params) { - append(param.descriptor) - } - append(')') - append(returnType.descriptor) - } - - companion object { - fun parse(text: MappingPart?, startIndex: Int = 0) = parse(text?.value, startIndex) - fun parse(text: String?, startIndex: Int = 0): MethodDescriptor? { - if (text.isNullOrBlank()) { - return null - } - - if (text.length <= startIndex || text[startIndex] != '(') { - return null - } - - val paramTypes = mutableListOf() - - var index = startIndex + 1 - while (true) { - if (text.length <= index) { - return null - } - if (text[index] == ')') { - index++ - break - } - - val type = parseType(text, index) ?: return null - if (type.type == VoidTypeDef) { - // void not allowed as a param type - return null - } - paramTypes.add(type.type as TypeDef) - index = type.index - } - - val returnType = parseType(text, index) ?: return null - if (text.length > returnType.index) { - return null - } - - return MethodDescriptor(paramTypes, returnType.type) - } - } -} - -fun String.asMethodDesc(): MethodDescriptor? = MethodDescriptor.parse(this) Index: obfuscation-explorer/src/main/kotlin/util.kt =================================================================== --- obfuscation-explorer/src/main/kotlin/util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/kotlin/util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,310 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex - -import com.google.common.base.CharMatcher -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.util.ArrayUtil -import kotlin.contracts.contract - -enum class Tristate { - TRUE, - FALSE, - UNKNOWN, -} - -inline fun hash(func: Hasher.() -> Unit): Int { - val hasher = Hasher() - hasher.func() - return hasher.code -} - -class Hasher { - var code: Int = 1 - private set - - private fun updateHash(value: Int) { - code = 31 * code + value - } - - operator fun Any?.unaryPlus() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Array<*>?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun ByteArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun ShortArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun IntArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun LongArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun FloatArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun DoubleArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun BooleanArray?.unaryPlus() { - updateHash(contentHashCode()) - } - operator fun CharArray?.unaryPlus() { - updateHash(contentHashCode()) - } - - operator fun Byte?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Byte.invoke() { - updateHash(this.hashCode()) - } - operator fun Short?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Short.invoke() { - updateHash(this.hashCode()) - } - operator fun Int?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Int.invoke() { - updateHash(this.hashCode()) - } - operator fun Long?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Long.invoke() { - updateHash(this.hashCode()) - } - operator fun Float?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Float.invoke() { - updateHash(this.hashCode()) - } - operator fun Double?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Double.invoke() { - updateHash(this.hashCode()) - } - operator fun Boolean?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Boolean.invoke() { - updateHash(this.hashCode()) - } - operator fun Char?.invoke() { - updateHash(this?.hashCode() ?: 0) - } - operator fun Char.invoke() { - updateHash(this.hashCode()) - } -} - -private fun emptyArrayUtil(): Array { - /* - * re-use an existing empty array, rather than allocating like emptyArray() does - */ - @Suppress("UNCHECKED_CAST") - return ArrayUtil.EMPTY_OBJECT_ARRAY as Array -} - -data class MappingPart(val col: Int, val value: String) - -private val whitespace = CharMatcher.whitespace() -private val nonWhitespace = whitespace.negate() - -fun String.splitMappingLine(preserveBlank: Boolean = false): Array { - var index = 0 - if (this.isNotEmpty() && whitespace.matches(this[0])) { - index = nonWhitespace.indexIn(this) - if (index == -1) { - return emptyArrayUtil() - } - } - - if (this[index] == '#') { - return emptyArrayUtil() - } - - var arrayIndex = 0 - // 6 should be big enough to handle most lines with a single allocation - var array = arrayOfNulls(6) - while (true) { - if (preserveBlank) { - // With preserveBlank enabled, we don't treat 2 consecutive whitespaces as a group, instead that would - // result in a blank - val nextPart = if (index >= this.length) { - break - } else if (whitespace.matches(this[index])) { - // immediately hit whitespace, so this is blank - "" - } else { - val endIndex = whitespace.indexIn(this, index) - if (endIndex == -1) { - this.substring(index, this.length) - } else { - this.substring(index, endIndex) - } - } - - if (arrayIndex >= array.size) { - array = array.copyOf(array.size * 2) - } - - array[arrayIndex++] = MappingPart(index, nextPart) - index += nextPart.length + 1 - } else { - val startIndex = nonWhitespace.indexIn(this, index) - if (this[startIndex] == '#') { - break - } - - if (arrayIndex >= array.size) { - array = array.copyOf(array.size * 2) - } - - val endIndex = whitespace.indexIn(this, startIndex + 1) - if (endIndex == -1) { - array[arrayIndex++] = MappingPart(startIndex, this.substring(startIndex)) - break - } else { - array[arrayIndex++] = MappingPart(startIndex, this.substring(startIndex, endIndex)) - index = endIndex - } - } - } - - if (arrayIndex == 0) { - return emptyArrayUtil() - } - - @Suppress("UNCHECKED_CAST") - return array.copyOf(arrayIndex) as Array -} - -fun String.isJavaInternalIdentifier(): Boolean { - if (this.isEmpty()) { - return false - } - - var isStart = true - var index = 0 - while (true) { - if (index >= this.length) { - break - } - - val c = this.codePointAt(index++) - if (Character.isSupplementaryCodePoint(c)) { - index++ - } - - when { - isStart -> { - isStart = false - if (!Character.isJavaIdentifierStart(c)) { - return false - } - } - c == '/'.code || c == '.'.code -> { - isStart = true - continue - } - else -> { - if (!Character.isJavaIdentifierPart(c)) { - return false - } - } - } - } - - return true -} - -typealias LineBlock = (lineNum: Int, parts: Array, line: String) -> Boolean -inline fun VirtualFile.forLines(skipLines: Int = 0, preserveBlank: Boolean = false, block: LineBlock) { - contract { - callsInPlace(block) - } - - this.inputStream.bufferedReader(this.charset).use { reader -> - var lineNum = 0 - while (true) { - lineNum++ - val line = reader.readLine() ?: break - if (lineNum <= skipLines) { - continue - } - - val parts = line.splitMappingLine(preserveBlank = preserveBlank) - if (parts.isEmpty()) { - continue - } - - if (!block(lineNum, parts, line)) { - break - } - } - } -} - -/* - * Impl note: For simplicity this considers any single whitespace character as a single indent. That means it treats - * a single space and a single tab character as the same indent level. This lets it handle indent levels for files - * which use tabs or spaces interchangeably, however it leaves files which mix tabs and spaces for indentation in the - * category of "undefined behavior". - */ -typealias IndentedLineBlock = (indent: Int, lineNum: Int, parts: Array, line: String) -> Boolean -inline fun VirtualFile.forLinesIndent(skipLines: Int = 0, preserveBlank: Boolean = false, block: IndentedLineBlock) { - contract { - callsInPlace(block) - } - - this.forLines(skipLines = skipLines, preserveBlank = preserveBlank) { lineNum, parts, line -> - val index = line.firstNonWhitespaceIndex() - if (index < 0) { - // blank line - forLines should skip these, but handle this case anyway - return@forLines true - } - - return@forLines block(index, lineNum, parts, line) - } -} - -fun String.firstNonWhitespaceIndex(): Int = nonWhitespace.indexIn(this) - -fun String.splitOnLast(delimiter: Char): Pair { - val lastIndex = lastIndexOf(delimiter) - if (lastIndex < 0) { - return this to null - } - - return substring(0, lastIndex) to substring(lastIndex + 1) -} -fun MappingPart.splitOnLast(delimiter: Char): Pair = value.splitOnLast(delimiter) Index: obfuscation-explorer/src/main/resources/META-INF/plugin.xml =================================================================== --- obfuscation-explorer/src/main/resources/META-INF/plugin.xml (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/META-INF/plugin.xml (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,110 +0,0 @@ - - - - io.mcdev.obfex - Obfuscation Explorer - DemonWav - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: obfuscation-explorer/src/main/resources/META-INF/pluginIcon.svg =================================================================== --- obfuscation-explorer/src/main/resources/META-INF/pluginIcon.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/META-INF/pluginIcon.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,9 +0,0 @@ - -Obfuscation Mapper Icon - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/csrg.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/csrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/csrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/enigma.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/enigma.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/enigma.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/jam.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/jam.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/jam.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/obfex.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/obfex.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/obfex.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,9 +0,0 @@ - -Obfuscation Mapper Icon - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/proguard.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/proguard.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/proguard.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/srg.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/srg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/srg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/tinyv1.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/tinyv1.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/tinyv1.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/tinyv2.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/tinyv2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/tinyv2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/tsrg.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/tsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/tsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/tsrg2.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/tsrg2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/tsrg2.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/main/resources/fileTypes/xsrg.svg =================================================================== --- obfuscation-explorer/src/main/resources/fileTypes/xsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/main/resources/fileTypes/xsrg.svg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,8 +0,0 @@ - - - - - - - - Index: obfuscation-explorer/src/test/kotlin/TypeParsingTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/TypeParsingTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/TypeParsingTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,221 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex - -import io.mcdev.obfex.ref.ArrayTypeDef -import io.mcdev.obfex.ref.ClassTypeDef -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.ReturnTypeDef -import io.mcdev.obfex.ref.VoidTypeDef -import io.mcdev.obfex.ref.asClass -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Test - -class TypeParsingTest { - - @Test - fun testPrimitiveTypes() { - assertEquals(PrimitiveTypeDef.BOOLEAN, ReturnTypeDef.parse("Z")) - assertEquals(PrimitiveTypeDef.CHAR, ReturnTypeDef.parse("C")) - assertEquals(PrimitiveTypeDef.BYTE, ReturnTypeDef.parse("B")) - assertEquals(PrimitiveTypeDef.SHORT, ReturnTypeDef.parse("S")) - assertEquals(PrimitiveTypeDef.INT, ReturnTypeDef.parse("I")) - assertEquals(PrimitiveTypeDef.LONG, ReturnTypeDef.parse("J")) - assertEquals(PrimitiveTypeDef.FLOAT, ReturnTypeDef.parse("F")) - assertEquals(PrimitiveTypeDef.DOUBLE, ReturnTypeDef.parse("D")) - assertEquals(VoidTypeDef, ReturnTypeDef.parse("V")) - } - - @Test - fun testArrayPrimitiveTypes() { - repeat(10) { i -> - val dim = i + 1 - assertEquals(ArrayTypeDef(PrimitiveTypeDef.BOOLEAN, dim), ReturnTypeDef.parse("[".repeat(dim) + 'Z')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.CHAR, dim), ReturnTypeDef.parse("[".repeat(dim) + 'C')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.BYTE, dim), ReturnTypeDef.parse("[".repeat(dim) + 'B')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.SHORT, dim), ReturnTypeDef.parse("[".repeat(dim) + 'S')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.INT, dim), ReturnTypeDef.parse("[".repeat(dim) + 'I')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.LONG, dim), ReturnTypeDef.parse("[".repeat(dim) + 'J')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.FLOAT, dim), ReturnTypeDef.parse("[".repeat(dim) + 'F')) - assertEquals(ArrayTypeDef(PrimitiveTypeDef.DOUBLE, dim), ReturnTypeDef.parse("[".repeat(dim) + 'D')) - } - } - - @Test - fun testVoidArray() { - assertNull(ReturnTypeDef.parse("[V")) - } - - @Test - fun testClassType() { - assertEquals(ClassTypeDef("java/lang/String".asClass()), ReturnTypeDef.parse("Ljava/lang/String;")) - assertEquals(ClassTypeDef("a".asClass()), ReturnTypeDef.parse("La;")) - } - - @Test - fun testClassArray() { - assertEquals( - ArrayTypeDef(ClassTypeDef("java/lang/String".asClass()), 1), - ReturnTypeDef.parse("[Ljava/lang/String;") - ) - assertEquals( - ArrayTypeDef(ClassTypeDef("java/lang/String".asClass()), 3), - ReturnTypeDef.parse("[[[Ljava/lang/String;") - ) - assertEquals(ArrayTypeDef(ClassTypeDef("a".asClass()), 2), ReturnTypeDef.parse("[[La;")) - } - - @Test - fun testEmptyMethodDesc() { - assertEquals(MethodDescriptor(emptyList(), VoidTypeDef), MethodDescriptor.parse("()V")) - } - - @Test - fun testPrimitiveMethodDesc() { - assertEquals(MethodDescriptor(listOf(PrimitiveTypeDef.INT), VoidTypeDef), MethodDescriptor.parse("(I)V")) - assertEquals( - MethodDescriptor(listOf(PrimitiveTypeDef.INT, PrimitiveTypeDef.INT, PrimitiveTypeDef.INT), VoidTypeDef), - MethodDescriptor.parse("(III)V") - ) - - assertEquals( - MethodDescriptor( - listOf( - PrimitiveTypeDef.CHAR, - PrimitiveTypeDef.BOOLEAN, - PrimitiveTypeDef.BYTE, - PrimitiveTypeDef.SHORT, - PrimitiveTypeDef.INT, - PrimitiveTypeDef.LONG, - PrimitiveTypeDef.FLOAT, - PrimitiveTypeDef.DOUBLE, - ), - VoidTypeDef - ), - MethodDescriptor.parse("(CZBSIJFD)V") - ) - - assertEquals( - MethodDescriptor( - listOf( - PrimitiveTypeDef.CHAR, - PrimitiveTypeDef.BOOLEAN, - PrimitiveTypeDef.BYTE, - PrimitiveTypeDef.SHORT, - PrimitiveTypeDef.INT, - PrimitiveTypeDef.LONG, - PrimitiveTypeDef.FLOAT, - PrimitiveTypeDef.DOUBLE, - ), - PrimitiveTypeDef.CHAR - ), - MethodDescriptor.parse("(CZBSIJFD)C") - ) - } - - @Test - fun testArrayMethodDesc() { - assertEquals( - MethodDescriptor(listOf(ArrayTypeDef(PrimitiveTypeDef.LONG, 2)), ArrayTypeDef(PrimitiveTypeDef.FLOAT, 1)), - MethodDescriptor.parse("([[J)[F") - ) - - assertEquals( - MethodDescriptor( - listOf( - ArrayTypeDef(PrimitiveTypeDef.LONG, 2), - ArrayTypeDef(PrimitiveTypeDef.INT, 1), - ArrayTypeDef(PrimitiveTypeDef.BOOLEAN, 3), - ), - ArrayTypeDef(PrimitiveTypeDef.FLOAT, 1) - ), - MethodDescriptor.parse("([[J[I[[[Z)[F") - ) - } - - @Test - fun testClassMethodDesc() { - assertEquals( - MethodDescriptor( - listOf( - ClassTypeDef("a".asClass()), - ClassTypeDef("b".asClass()), - ClassTypeDef("c".asClass()), - ), - ClassTypeDef("d".asClass()) - ), - MethodDescriptor.parse("(La;Lb;Lc;)Ld;") - ) - - assertEquals( - MethodDescriptor( - listOf( - ClassTypeDef("java.lang.String".asClass()), - ClassTypeDef("java.lang.Object".asClass()), - ), - ClassTypeDef("d".asClass()) - ), - MethodDescriptor.parse("(Ljava/lang/String;Ljava/lang/Object;)Ld;") - ) - - assertEquals( - MethodDescriptor( - listOf( - ClassTypeDef("java.lang.String".asClass()), - ArrayTypeDef(ClassTypeDef("java.lang.Object".asClass()), 2), - ), - ArrayTypeDef(ClassTypeDef("d".asClass()), 1) - ), - MethodDescriptor.parse("(Ljava/lang/String;[[Ljava/lang/Object;)[Ld;") - ) - - assertEquals( - MethodDescriptor( - listOf( - ClassTypeDef("java.lang.String".asClass()), - ArrayTypeDef(ClassTypeDef("java.lang.Object".asClass()), 2), - PrimitiveTypeDef.INT, - PrimitiveTypeDef.INT, - PrimitiveTypeDef.INT, - ), - VoidTypeDef - ), - MethodDescriptor.parse("(Ljava/lang/String;[[Ljava/lang/Object;III)V") - ) - - assertEquals( - MethodDescriptor( - listOf( - ClassTypeDef("java.lang.String".asClass()), - PrimitiveTypeDef.LONG, - ArrayTypeDef(ClassTypeDef("java.lang.Object".asClass()), 2), - PrimitiveTypeDef.INT, - ArrayTypeDef(PrimitiveTypeDef.INT, 1), - PrimitiveTypeDef.INT, - ), - VoidTypeDef - ), - MethodDescriptor.parse("(Ljava/lang/String;J[[Ljava/lang/Object;I[II)V") - ) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/ParserFixture.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/ParserFixture.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/ParserFixture.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,60 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats - -import com.intellij.openapi.fileTypes.PlainTextLanguage -import com.intellij.testFramework.ReadOnlyLightVirtualFile -import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory -import io.mcdev.obfex.mappings.MappingsDefinition -import io.mcdev.obfex.mappings.MappingsFormatParser -import org.junit.jupiter.api.AfterAll -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.TestInstance - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -abstract class ParserFixture { - - private val fixture = IdeaTestFixtureFactory.getFixtureFactory().createBareFixture() - - lateinit var def: MappingsDefinition - - abstract val parser: MappingsFormatParser - - abstract val text: String - - @BeforeAll - fun setup() { - fixture.setUp() - - val file = ReadOnlyLightVirtualFile( - "test.${parser.expectedFileExtensions.first()}", - PlainTextLanguage.INSTANCE, - text - ) - - def = parser.parse(file)!! - } - - @AfterAll - fun teardown() { - fixture.tearDown() - } -} Index: obfuscation-explorer/src/test/kotlin/formats/csrg/CSrgMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/csrg/CSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/csrg/CSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,153 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.csrg - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.ClassTypeDef -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodRef -import io.mcdev.obfex.ref.field -import io.mcdev.obfex.ref.method -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class CSrgMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = CSrgMappingsFormatParser() - - @Language("csrg") - override val text: String = """ - net/minecraft/CommentTest uih - net/minecraft/Test${'$'}Example ght${'$'}ds - net/minecraft/tags/TagsItem af CANDLES - net/minecraft/tags/TagsItem ag READ - com/mojang/math/Divisor a (II)Ljava/lang/Iterable; asIterable - net/minecraft/BlockUtil a (Ljava/util/function/Predicate;Lnet/minecraft/core/BlockPosition${'$'}MutableBlockPosition;Lnet/minecraft/core/EnumDirection;I)I getLimit - net/minecraft/BlockUtil a (Lnet/minecraft/core/BlockPosition;Lnet/minecraft/core/EnumDirection${'$'}EnumAxis;ILnet/minecraft/core/EnumDirection${'$'}EnumAxis;ILjava/util/function/Predicate;)Lnet/minecraft/BlockUtil${'$'}Rectangle; getLargestRectangleAround - net/minecraft/BlockUtil a (Lnet/minecraft/world/level/IBlockAccess;Lnet/minecraft/core/BlockPosition;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/core/EnumDirection;Lnet/minecraft/world/level/block/Block;)Ljava/util/Optional; getTopConnectedBlock - """.trimIndent() - - @Test - fun testField1() { - val mapping = def.mappings.fieldMapping( - "net.minecraft.tags.TagsItem".asClass().field("af".asFieldRef()), - )!! - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("af", fromName) - assertEquals("CANDLES", toName) - } - - @Test - fun testField2() { - val mapping = def.mappings.fieldMapping( - "net.minecraft.tags.TagsItem".asClass().field("ag".asFieldRef()), - )!! - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("ag", fromName) - assertEquals("READ", toName) - } - - @Test - fun testClass() { - val clazz = def.mappings.clazz( - "net.minecraft.CommentTest".asClass(), - )!! - - val fromName = clazz.unnamedFrom - val toName = clazz.unnamedTo - - assertEquals("net/minecraft/CommentTest", fromName) - assertEquals("uih", toName) - } - - @Test - fun testMethod() { - val desc = MethodDescriptor( - listOf( - ClassTypeDef("net/minecraft/core/BlockPosition".asClass()), - ClassTypeDef("net/minecraft/core/EnumDirection\$EnumAxis".asClass()), - PrimitiveTypeDef.INT, - ClassTypeDef("net/minecraft/core/EnumDirection\$EnumAxis".asClass()), - PrimitiveTypeDef.INT, - ClassTypeDef("java/util/function/Predicate".asClass()), - ), - ClassTypeDef("net.minecraft.BlockUtil\$Rectangle".asClass()) - ) - - val method = def.mappings.methodMapping( - "net.minecraft.BlockUtil".asClass().method("a".asMethodRef(desc)), - )!! - - val fromName = method.unnamedFrom - val toName = method.unnamedTo - - assertEquals("a", fromName) - assertEquals("getLargestRectangleAround", toName) - } - - @Test - fun testMethodOtherSide() { - val desc = MethodDescriptor( - listOf( - ClassTypeDef("net/minecraft/world/level/IBlockAccess".asClass()), - ClassTypeDef("net/minecraft/core/BlockPosition".asClass()), - ClassTypeDef("net/minecraft/world/level/block/Block".asClass()), - ClassTypeDef("net/minecraft/core/EnumDirection".asClass()), - ClassTypeDef("net/minecraft/world/level/block/Block".asClass()), - ), - ClassTypeDef("java/util/Optional".asClass()) - ) - - val method = def.mappings.methodMapping( - "net.minecraft.BlockUtil".asClass().method("getTopConnectedBlock".asMethodRef(desc)), - )!! - - val fromName = method.unnamedFrom - val toName = method.unnamedTo - - assertEquals("a", fromName) - assertEquals("getTopConnectedBlock", toName) - } - - @Test - fun testCounts() { - assertEquals(5, def.mappings.classes().size) - assertEquals(2, def.mappings.classes().sumOf { it.fields().size }) - assertEquals(4, def.mappings.classes().sumOf { it.methods().size }) - } - - @Test - fun testWarnings() { - // Missing class mapping warnings - assertEquals(3, def.source.warnings.size) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaLexerTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaLexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaLexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,47 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma - -import com.intellij.testFramework.LexerTestCase -import io.mcdev.obfex.filterCrlf -import io.mcdev.obfex.formats.enigma.lang.EnigmaLayoutLexer -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test - -@DisplayName("Enigma Lexing Test") -class EnigmaLexerTest { - - @Test - @DisplayName("Enigma Lexing Test") - fun test() { - val caller = EnigmaLexerTest::class.java - val basePath = "lexer/fixtures/test.mapping" - val text = caller.getResource(basePath)?.readText()?.trim() ?: Assertions.fail("no test data found") - - val expected = caller.getResource("${basePath.substringBeforeLast('.')}.txt")?.readText()?.trim() - ?: Assertions.fail("no expected data found") - val actual = LexerTestCase.printTokens(text.filter { it != '\r' }, 0, EnigmaLayoutLexer()).trim() - - Assertions.assertEquals(expected.filterCrlf(), actual.filterCrlf()) - } - } - \ No newline at end of file Index: obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/enigma/EnigmaMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,195 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.enigma - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asTypeDef -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class EnigmaMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = EnigmaMappingsFormatParser() - @Language("Enigma") - override val text: String = """ - CLASS net/minecraft/class_2019 net/minecraft/predicate/DamagePredicate - COMMENT asdfasdf - COMMENT asdfasdfasdfa - FIELD field_9520 ANY Lnet/minecraft/class_2019; - FIELD field_9521 sourceEntity Lnet/minecraft/class_2048; - COMMENT sdafasdfasdf - METHOD (Lnet/minecraft/class_2096${'$'}class_2099;Lnet/minecraft/class_2096${'$'}class_2099;Lnet/minecraft/class_2048;Ljava/lang/Boolean;Lnet/minecraft/class_2022;)V - COMMENT asdfasfasdf - ARG 1 dealt - ARG 2 taken - ARG 3 sourceEntity - ARG 4 blocked - ARG 5 type - METHOD method_8839 fromJson (Lcom/google/gson/JsonElement;)Lnet/minecraft/class_2019; - ARG 0 json - CLASS class_2020 Builder - COMMENT asdfasdfa - FIELD field_9526 blocked Ljava/lang/Boolean; - FIELD field_9527 taken Lnet/minecraft/class_2096${'$'}class_2099; - COMMENT asdfasdfadsf - FIELD field_9530 dealt Lnet/minecraft/class_2096${'$'}class_2099; - METHOD method_8841 blocked (Ljava/lang/Boolean;)Lnet/minecraft/class_2019${'$'}class_2020; - COMMENT asfasdf - COMMENT asfasdfasdfasdfsad - ARG 1 blocked - METHOD method_8842 type (Lnet/minecraft/class_2022${'$'}class_2023;)Lnet/minecraft/class_2019${'$'}class_2020; - ARG 1 builder - METHOD method_8843 build ()Lnet/minecraft/class_2019; - CLASS net/minecraft/class_9323 net/minecraft/component/ComponentMap - FIELD field_49584 EMPTY Lnet/minecraft/class_9323; - METHOD method_57828 filtered (Ljava/util/function/Predicate;)Lnet/minecraft/class_9323; - ARG 1 predicate - METHOD method_57833 stream ()Ljava/util/stream/Stream; - CLASS class_9324 Builder - FIELD field_49587 components Lit/unimi/dsi/fastutil/objects/Reference2ObjectMap; - METHOD method_57838 build ()Lnet/minecraft/class_9323; - METHOD method_57840 add (Lnet/minecraft/class_9331;Ljava/lang/Object;)Lnet/minecraft/class_9323${'$'}class_9324; - ARG 1 type - ARG 2 value - METHOD method_58756 put (Lnet/minecraft/class_9331;Ljava/lang/Object;)V - ARG 1 type - ARG 2 value - CLASS class_9325 SimpleComponentMap - """.trimIndent() - .replace(" ", "\t") - - private val from: MappingNamespace - get() = MappingNamespace.unnamedFrom(def.mappings) - private val to: MappingNamespace - get() = MappingNamespace.unnamedTo(def.mappings) - - @Test - fun testClasses() { - assertEquals(5, def.mappings.classes().size) - - val class1 = def.mappings.clazz("net/minecraft/class_2019")!! - val class2 = def.mappings.clazz("net/minecraft/class_2019\$class_2020")!! - val class3 = def.mappings.clazz("net/minecraft/class_9323")!! - val class4 = def.mappings.clazz("net/minecraft/class_9323\$class_9324")!! - val class5 = def.mappings.clazz("net/minecraft/class_9323\$class_9324\$class_9325")!! - - assertEquals("net/minecraft/class_2019", class1.name(from)) - assertEquals("net/minecraft/predicate/DamagePredicate", class1.name(to)) - - assertEquals("net/minecraft/class_2019\$class_2020", class2.name(from)) - assertEquals("net/minecraft/predicate/DamagePredicate\$Builder", class2.name(to)) - - assertEquals("net/minecraft/class_9323", class3.name(from)) - assertEquals("net/minecraft/component/ComponentMap", class3.name(to)) - - assertEquals("net/minecraft/class_9323\$class_9324", class4.name(from)) - assertEquals("net/minecraft/component/ComponentMap\$Builder", class4.name(to)) - - assertEquals("net/minecraft/class_9323\$class_9324\$class_9325", class5.name(from)) - assertEquals("net/minecraft/component/ComponentMap\$Builder\$SimpleComponentMap", class5.name(to)) - } - - @Test - fun testMethods() { - assertEquals(2, def.mappings.clazz("net/minecraft/class_2019")?.methods()?.size) - assertEquals(3, def.mappings.clazz("net/minecraft/class_2019\$class_2020")?.methods()?.size) - assertEquals(2, def.mappings.clazz("net/minecraft/class_9323")?.methods()?.size) - assertEquals(3, def.mappings.clazz("net/minecraft/class_9323\$class_9324")?.methods()?.size) - assertEquals(0, def.mappings.clazz("net/minecraft/class_9323\$class_9324\$class_9325")?.methods()?.size) - - assertEquals("", def.mappings.clazz("net/minecraft/class_2019")?.method("")?.name(to)) - assertEquals("fromJson", def.mappings.clazz("net/minecraft/class_2019")?.method("method_8839")?.name(to)) - - assertEquals( - "blocked", - def.mappings.clazz("net/minecraft/class_2019\$class_2020")?.method("method_8841")?.name(to) - ) - assertEquals( - "type", - def.mappings.clazz("net/minecraft/class_2019\$class_2020")?.method("method_8842")?.name(to) - ) - assertEquals( - "build", - def.mappings.clazz("net/minecraft/class_2019\$class_2020")?.method("method_8843")?.name(to) - ) - - assertEquals("filtered", def.mappings.clazz("net/minecraft/class_9323")?.method("method_57828")?.name(to)) - assertEquals("stream", def.mappings.clazz("net/minecraft/class_9323")?.method("method_57833")?.name(to)) - - assertEquals( - "build", - def.mappings.clazz("net/minecraft/class_9323\$class_9324")?.method("method_57838")?.name(to) - ) - assertEquals( - "add", - def.mappings.clazz("net/minecraft/class_9323\$class_9324")?.method("method_57840")?.name(to) - ) - assertEquals( - "put", - def.mappings.clazz("net/minecraft/class_9323\$class_9324")?.method("method_58756")?.name(to) - ) - } - - @Test - fun testParams() { - val class1 = def.mappings.clazz("net/minecraft/class_2019")!! - val class4 = def.mappings.clazz("net/minecraft/class_9323\$class_9324")!! - - val count = def.mappings.classes() - .flatMap { it.methods() } - .flatMap { it.params() } - .count() - assertEquals(13, count) - - val names = listOf("dealt", "taken", "sourceEntity", "blocked", "type") - val params = class1.method("")!!.params() - for ((i, name) in names.withIndex()) { - val p = params.first { it.index == (i + 1).asParamIndex() } - assertEquals(name, p.name(to)) - } - - val names2 = listOf("type", "value") - val params2 = class4.method("method_57840")!!.params() - for ((i, name) in names2.withIndex()) { - val p = params2.first { it.index == (i + 1).asParamIndex() } - assertEquals(name, p.name(to)) - } - } - - @Test - fun testFields() { - val count = def.mappings.classes() - .flatMap { it.fields() } - .count() - assertEquals(7, count) - - val class1 = def.mappings.clazz("net/minecraft/class_2019")!! - - assertEquals("ANY", class1.field("field_9520")!!.name(to)) - assertEquals("Lnet/minecraft/class_2019;".asTypeDef(), class1.field("field_9520")!!.type) - assertEquals("field_9521", class1.field("sourceEntity")!!.name(from)) - assertEquals("Lnet/minecraft/class_2048;".asTypeDef(), class1.field("sourceEntity")!!.type) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/jam/JamMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/jam/JamMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/jam/JamMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,114 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.jam - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asMethodRef -import io.mcdev.obfex.ref.asParamIndex -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.field -import io.mcdev.obfex.ref.method -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Assertions.assertSame -import org.junit.jupiter.api.Test - -class JamMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = JamMappingsFormatParser() - - @Language("jam") - override val text: String = """ - CL ght net/minecraft/Test - CL ght${'$'}a net/minecraft/Test${'$'}Inner - FD ght rft Ljava/util/logging/Logger; log - MD ght hyuip (I)Z isEven - MP ght hyuip (I)Z 0 num - """.trimIndent() - - @Test - fun testClass() { - val from = def.mappings.clazz("ght".asClass()) - val to = def.mappings.clazz("net/minecraft/Test".asClass()) - - assertSame(from, to) - } - - @Test - fun testField() { - val mapping = def.mappings.fieldMapping( - "ght".asClass() - .field("rft".asFieldRef("Ljava/util/logging/Logger;".asTypeDef())) - )!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("rft", fromName) - assertEquals("log", toName) - } - - @Test - fun testMethod() { - val clazz = def.mappings.clazz("ght".asClass())!! - val mapping = clazz.methods().first { it.unnamedFrom == "hyuip" } - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("hyuip", fromName) - assertEquals("isEven", toName) - - assertEquals( - MethodDescriptor( - listOf(PrimitiveTypeDef.INT), - PrimitiveTypeDef.BOOLEAN - ), - mapping.descriptor - ) - } - - @Test - fun testParam() { - /* TODO - val ref = "net/minecraft/Test".asClass() - .method("isEven".asMethodRef("(I)Z".asMethodDesc())) - - val method = def.mappings.methodMapping(ref)!! - val mapping = method.param(0.asParamIndex())!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertNull(fromName) - assertEquals("num", toName) - */ - } -} Index: obfuscation-explorer/src/test/kotlin/formats/proguard/ProGuardMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/proguard/ProGuardMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/proguard/ProGuardMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,107 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.proguard - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodRef -import io.mcdev.obfex.ref.asTypeDef -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Test - -class ProGuardMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = ProGuardMappingsFormatParser() - - @Language("ProGuard") - override val text: String = """ - com.mojang.math.Axis -> a: - com.mojang.math.Axis XN -> a - com.mojang.math.Axis XP -> b - com.mojang.math.Axis YN -> c - 17:17:com.mojang.math.Axis of(org.joml.Vector3f) -> abcd - 23:23:org.joml.Quaternionf rotationDegrees(float) -> rotationDegrees - com.mojang.math.Constants -> b: - float PI -> a - float RAD_TO_DEG -> b - float DEG_TO_RAD -> c - float EPSILON -> d - 3:3:void () -> - """.trimIndent() - - @Test - fun testCounts() { - assertEquals(2, def.mappings.classes().size) - assertEquals(7, def.mappings.classes().sumOf { it.fields().size }) - assertEquals(3, def.mappings.classes().sumOf { it.methods().size }) - } - - @Test - fun testClass() { - val mapping = def.mappings.clazz("a".asClass())!! - - assertEquals("com/mojang/math/Axis", mapping.unnamedFrom) - assertEquals("a", mapping.unnamedTo) - } - - @Test - fun testFields() { - val clazz = def.mappings.clazz("a".asClass())!! - - val axis = "Lcom/mojang/math/Axis;" - val xn = clazz.field("XN".asFieldRef(axis.asTypeDef()))!! - val xp = clazz.field("b".asFieldRef(axis.asTypeDef()))!! - val yn = clazz.field("YN".asFieldRef(axis.asTypeDef()))!! - - assertEquals("XN", xn.unnamedFrom) - assertEquals("a", xn.unnamedTo) - assertEquals("XP", xp.unnamedFrom) - assertEquals("b", xp.unnamedTo) - assertEquals("YN", yn.unnamedFrom) - assertEquals("c", yn.unnamedTo) - } - - @Test - fun testMethods() { - val clazz = def.mappings.clazz("com.mojang.math.Axis".asClass())!! - - val mapping = clazz.method("of".asMethodRef("(Lorg/joml/Vector3f;)Lcom/mojang/math/Axis;"))!! - - assertEquals("of", mapping.unnamedFrom) - assertEquals("abcd", mapping.unnamedTo) - } - - @Test - fun testInitSkipped() { - /* TODO - val clazz = def.mappings.clazz("com.mojang.math.Constants".asClass())!! - val mapping = clazz.method("".asMethodRef("()V")) - - assertNull(mapping) - */ - } -} Index: obfuscation-explorer/src/test/kotlin/formats/srg/SrgLexerTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/srg/SrgLexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/srg/SrgLexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,47 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg - -import com.intellij.lexer.FlexAdapter -import com.intellij.testFramework.LexerTestCase -import io.mcdev.obfex.filterCrlf -import io.mcdev.obfex.formats.srg.gen.lexer.SrgLexer -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test - -@DisplayName("SRG Lexing Tests") -class SrgLexerTest { - - @Test - @DisplayName("SRG Lexing Test") - fun test() { - val caller = SrgLexerTest::class.java - val basePath = "lexer/fixtures/test.srg" - val text = caller.getResource(basePath)?.readText()?.trim() ?: Assertions.fail("no test data found") - - val expected = caller.getResource("${basePath.substringBeforeLast('.')}.txt")?.readText()?.trim() - ?: Assertions.fail("no expected data found") - val actual = LexerTestCase.printTokens(text.filter { it != '\r' }, 0, FlexAdapter(SrgLexer())).trim() - - Assertions.assertEquals(expected.filterCrlf(), actual.filterCrlf()) - } - } Index: obfuscation-explorer/src/test/kotlin/formats/srg/SrgMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/srg/SrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/srg/SrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,124 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.srg - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asPackage -import io.mcdev.obfex.ref.field -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertSame -import org.junit.jupiter.api.Test - -class SrgMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = SrgMappingsFormatParser() - - @Language("srg") - override val text: String = """ - PK: ./ net/minecraft/server - CL: ght net/minecraft/Test - FD: ght/rft net/minecraft/Test/log - FD: ght${'$'}ds/juh net/minecraft/Test${'$'}Example/server - MD: ght/hyuip (I)Z net/minecraft/Test/isEven (I)Z - MD: ght${'$'}ds/hyuip (I)Z net/minecraft/Test${'$'}Example/isOdd (I)Z - """.trimIndent() - - @Test - fun testPackage() { - val mapping = def.mappings.pack("/".asPackage())!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("/", fromName) - assertEquals("net/minecraft/server", toName) - } - - @Test - fun testPackageOpposite() { - val mapping = def.mappings.pack("net/minecraft/server".asPackage())!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("/", fromName) - assertEquals("net/minecraft/server", toName) - } - - @Test - fun testClass() { - val from = def.mappings.clazz("ght".asClass()) - val to = def.mappings.clazz("net/minecraft/Test".asClass()) - - assertSame(from, to) - } - - @Test - fun testField1() { - val mapping = def.mappings.fieldMapping("ght".asClass().field("rft".asFieldRef()))!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("rft", fromName) - assertEquals("log", toName) - } - - @Test - fun testField2() { - val mapping = - def.mappings.fieldMapping("net/minecraft/Test\$Example".asClass().field("server".asFieldRef()))!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("juh", fromName) - assertEquals("server", toName) - } - - @Test - fun testMethod() { - val clazz = def.mappings.clazz("ght".asClass())!! - val mapping = clazz.methods().first { it.unnamedFrom == "hyuip" } - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("hyuip", fromName) - assertEquals("isEven", toName) - - assertEquals( - MethodDescriptor( - listOf(PrimitiveTypeDef.INT), - PrimitiveTypeDef.BOOLEAN - ), - mapping.descriptor - ) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/tinyv1/TinyV1MappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tinyv1/TinyV1MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tinyv1/TinyV1MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,90 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv1 - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodRef -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNull -import org.junit.jupiter.api.Test - -class TinyV1MappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = TinyV1MappingsFormatParser() - - @Language("TinyV1") - override val text: String = """ - v1 official intermediary test - CLASS a net/minecraft/class_7833 com/example/Test - FIELD a La; a field_40713 - FIELD a La; b abc - METHOD a (F)Lorg/joml/Quaternionf; a method_46349 - METHOD a (Lorg/joml/Vector3f;F)Lorg/joml/Quaternionf; a method_46350 xyz - METHOD a (F)Lorg/joml/Quaternionf; method_46351 - """.trimIndent() - .replace(" ", "\t") - - private val official: MappingNamespace - get() = def.mappings.namespaceOf("official") - private val intermediary: MappingNamespace - get() = def.mappings.namespaceOf("intermediary") - private val test: MappingNamespace - get() = def.mappings.namespaceOf("test") - - @Test - fun testClass() { - val mapping = def.mappings.clazz("a".asClass())!! - - assertEquals(3, mapping.names.size) - assertEquals("a", mapping.name(official)) - assertEquals("net/minecraft/class_7833", mapping.name(intermediary)) - assertEquals("com/example/Test", mapping.name(test)) - } - - @Test - fun testField() { - val clazz = def.mappings.clazz("net/minecraft/class_7833".asClass())!! - - val field = clazz.field("field_40713".asFieldRef("Lnet/minecraft/class_7833;"))!! - - assertEquals(3, field.names.size) - assertEquals("a", field.name(official)) - assertEquals("field_40713", field.name(intermediary)) - assertNull(field.name(test)) - } - - @Test - fun testMethod() { - val clazz = def.mappings.clazz("com/example/Test".asClass())!! - - val method = clazz.method("method_46351".asMethodRef())!! - - assertEquals(3, method.names.size) - assertNull(method.name(official)) - assertEquals("method_46351", method.name(intermediary)) - assertNull(method.name(test)) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2LexerTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2LexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2LexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,47 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2 - -import com.intellij.testFramework.LexerTestCase -import io.mcdev.obfex.filterCrlf -import io.mcdev.obfex.formats.tinyv2.lang.psi.TinyV2LexerAdapter -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test - -@DisplayName("TinyV2 Lexer Test") -class TinyV2LexerTest { - - @Test - @DisplayName("TinyV2 Lexer Test") - fun test() { - val caller = TinyV2LexerTest::class.java - val basePath = "lexer/fixtures/test.tiny" - val text = caller.getResource(basePath)?.readText()?.trim() ?: Assertions.fail("no test data found") - - val expected = caller.getResource("${basePath.substringBeforeLast('.')}.txt")?.readText()?.trim() - ?: Assertions.fail("no test data found") - val actual = LexerTestCase.printTokens(text.filter { it != '\r' }, 0, TinyV2LexerAdapter()).trim() - - Assertions.assertEquals(expected.filterCrlf(), actual.filterCrlf()) - } - } - \ No newline at end of file Index: obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2MappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tinyv2/TinyV2MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,124 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tinyv2 - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.ref.LvtIndex -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.asLocal -import io.mcdev.obfex.ref.asLvtIndex -import io.mcdev.obfex.ref.asParamIndex -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class TinyV2MappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = TinyV2MappingsFormatParser() - - override val text: String = """ - tiny 2 0 source target target2 - c class_1 class1Ns0Rename class1Ns1Rename - f I field_1 field1Ns0Rename field1Ns1Rename - m ()I method_1 method1Ns0Rename method1Ns1Rename - p 1 param_1 param1Ns0Rename param1Ns1Rename - v 2 3 4 var_1 var1Ns0Rename var1Ns1Rename - v 5 6 var_2 var2Ns0Rename var2Ns1Rename - c class_1${'$'}class_2 class1Ns0Rename${'$'}class2Ns0Rename class1Ns1Rename${'$'}class2Ns1Rename - f I field_2 field2Ns0Rename field2Ns1Rename - c class_3 class3Ns0Rename class3Ns1Rename - """.trimIndent() - .replace(" ", "\t") - - private val source: MappingNamespace - get() = def.mappings.namespaceOf("source") - private val target: MappingNamespace - get() = def.mappings.namespaceOf("target") - private val target2: MappingNamespace - get() = def.mappings.namespaceOf("target2") - - @Test - fun testClasses() { - assertEquals(3, def.mappings.classes().count()) - - val class1 = def.mappings.clazz("class1Ns0Rename")!! - assertEquals("class_1", class1.name(source)) - assertEquals("class1Ns0Rename", class1.name(target)) - assertEquals("class1Ns1Rename", class1.name(target2)) - - val class2 = def.mappings.clazz("class3Ns1Rename")!! - assertEquals("class_3", class2.name(source)) - assertEquals("class3Ns0Rename", class2.name(target)) - assertEquals("class3Ns1Rename", class2.name(target2)) - } - - @Test - fun testField() { - val class1 = def.mappings.clazz("class_1")!! - val field = class1.fields().single() - - assertEquals("field_1", field.name(source)) - assertEquals("field1Ns0Rename", field.name(target)) - assertEquals("field1Ns1Rename", field.name(target2)) - assertEquals(PrimitiveTypeDef.INT, field.type) - } - - @Test - fun testMethod() { - val class1 = def.mappings.clazz("class1Ns1Rename")!! - val method = class1.methods().single() - - assertEquals("method_1", method.name(source)) - assertEquals("method1Ns0Rename", method.name(target)) - assertEquals("method1Ns1Rename", method.name(target2)) - } - - @Test - fun testParam() { - val method = def.mappings.clazz("class1Ns1Rename")!!.methods().single() - val param = method.params().single() - - assertEquals(1.asParamIndex(), param.index) - assertEquals("param_1", param.name(source)) - assertEquals("param1Ns0Rename", param.name(target)) - assertEquals("param1Ns1Rename", param.name(target2)) - } - - @Test - fun testLocalVar() { - val method = def.mappings.clazz("class1Ns1Rename")!!.methods().single() - val firstLocal = method.localVars().single { it.lvtIndex == 4.asLvtIndex() } - val secondLocal = method.localVars().single { it.localVarIndex.index == 5.asLocal() } - - assertEquals(2.asLocal(startIndex = 3.asLocal()), firstLocal.localVarIndex) - assertEquals(4.asLvtIndex(), firstLocal.lvtIndex) - assertEquals("var_1", firstLocal.name(source)) - assertEquals("var1Ns0Rename", firstLocal.name(target)) - assertEquals("var1Ns1Rename", firstLocal.name(target2)) - - assertEquals(5.asLocal(startIndex = 6.asLocal()), secondLocal.localVarIndex) - assertEquals(LvtIndex.UNKNOWN, secondLocal.lvtIndex) - assertEquals("var_2", secondLocal.name(source)) - assertEquals("var2Ns0Rename", secondLocal.name(target)) - assertEquals("var2Ns1Rename", secondLocal.name(target2)) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/tsrg/TSrgMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tsrg/TSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tsrg/TSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,135 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.ClassTypeDef -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asMethodDesc -import io.mcdev.obfex.ref.asMethodRef -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.field -import io.mcdev.obfex.ref.method -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNotNull -import org.junit.jupiter.api.Test - -class TSrgMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = TSrgMappingsFormatParser() - - @Language("tsrg") - override val text: String = """ - a net/minecraft/util/text/TextFormatting - a BLACK - b DARK_BLUE - c DARK_GREEN - d DARK_AQUA - e DARK_RED - a (C)La; func_211165_a - a (I)La; func_175744_a - a (La;)La; func_199747_a - b net/minecraft/crash/CrashReport - a field_147150_a - b field_71513_a - a ()Ljava/lang/String; func_71501_a - a (Ljava/io/File;)Z func_147149_a - """.trimIndent() - .replace(" ", "\t") - - @Test - fun testCounts() { - assertEquals(2, def.mappings.classes().size) - val clazzA = def.mappings.clazz("a".asClass())!! - val clazzB = def.mappings.clazz("b".asClass())!! - - assertEquals(5, clazzA.fields().size) - assertEquals(3, clazzA.methods().size) - assertEquals(2, clazzB.fields().size) - assertEquals(2, clazzB.methods().size) - } - - @Test - fun testTypeMapping() { - val mapping = def.mappings.clazz("a".asClass())!! - - val aMethods = mapping.methods().filter { it.unnamedFrom == "a" } - - val returnType = "Lnet/minecraft/util/text/TextFormatting;".asTypeDef() - - for (aMethod in aMethods) { - assertEquals( - returnType, - def.mappings.mapTypeTo(MappingNamespace.unnamedTo(def.mappings), aMethod.descriptor.returnType) - ) - } - } - - @Test - fun testByMappedType() { - /* TODO - val ref = "net/minecraft/util/text/TextFormatting".asClass() - .method("func_211165_a".asMethodRef("(C)Lnet/minecraft/util/text/TextFormatting;".asMethodDesc())) - val mapping = def.mappings.methodMapping(ref) - - assertNotNull(mapping) - */ - } - - @Test - fun testField() { - val mapping = def.mappings.fieldMapping("a".asClass().field("a".asFieldRef()))!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("a", fromName) - assertEquals("BLACK", toName) - } - - @Test - fun testMethod() { - val ref = "b".asClass() - .method( - "a".asMethodRef( - MethodDescriptor( - listOf(), - ClassTypeDef("java/lang/String".asClass()) - ) - ) - ) - - val mapping = def.mappings.methodMapping(ref)!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("a", fromName) - assertEquals("func_71501_a", toName) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2LexerTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2LexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2LexerTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,47 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2 - -import com.intellij.testFramework.LexerTestCase -import io.mcdev.obfex.filterCrlf -import io.mcdev.obfex.formats.tsrg2.lang.TSrg2LayoutLexer -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test - -@DisplayName("TSrg2 Lexer Test") -class TSrg2LexerTest { - - @Test - @DisplayName("TSrg2 Lexer Test") - fun test() { - val caller = TSrg2LexerTest::class.java - val basePath = "lexer/fixtures/test.tsrg2" - val text = caller.getResource(basePath)?.readText()?.trim() ?: Assertions.fail("no test data found") - - val expected = caller.getResource("${basePath.substringBeforeLast('.')}.txt")?.readText()?.trim() - ?: Assertions.fail("no test data found") - val actual = LexerTestCase.printTokens(text.filter { it != '\r' }, 0, TSrg2LayoutLexer()).trim() - - Assertions.assertEquals(expected.filterCrlf(), actual.filterCrlf()) - } - } - \ No newline at end of file Index: obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2MappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/tsrg2/TSrg2MappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,161 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.tsrg2 - -import io.mcdev.obfex.Tristate -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingNamespace -import io.mcdev.obfex.mappings.MappingsFormatParser -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNotNull -import org.junit.jupiter.api.Test - -class TSrg2MappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = TSrg2MappingsFormatParser() - - @Language("tsrg2") - override val text: String = """ - tsrg2 left right - com/mojang/blaze3d/Blaze3D com/mojang/blaze3d/Blaze3D - ()V - getTime ()D m_83640_ - static - process (Lcom/mojang/blaze3d/pipeline/RenderPipeline;F)V m_166118_ - static - 0 p_166119_ p_166119_ - 1 p_166120_ p_166120_ - com/mojang/blaze3d/audio/Channel com/mojang/blaze3d/audio/ChannelTest - BUFFER_DURATION_SECONDS f_166124_ - LOGGER f_83641_ - QUEUED_BUFFER_COUNT f_166125_ - ()V - static - (I)V - 0 p_83648_ p_83648_ - attachBufferStream (Lnet/minecraft/client/sounds/AudioStream;)V m_83658_ - 0 p_83659_ p_83659_ - initialized f_83643_ - attachStaticBuffer (Lcom/mojang/blaze3d/audio/SoundBuffer;)V m_83656_ - 0 p_83657_ TEST - calculateBufferSize (Ljavax/sound/sampled/AudioFormat;I)I m_83660_ - static - 0 p_83661_ p_83661_test - 1 p_83662_ p_83662_test - """.trimIndent() - .replace(" ", "\t") - - private val left: MappingNamespace - get() = def.mappings.namespaceOf("left") - private val right: MappingNamespace - get() = def.mappings.namespaceOf("right") - - @Test - fun testNamespaces() { - assertEquals(2, def.mappings.namespaces.size) - assertEquals("left", def.mappings.namespaces[0].name) - assertEquals("right", def.mappings.namespaces[1].name) - } - - @Test - fun testClasses() { - assertEquals(2, def.mappings.classes().size) - val blaze3d = def.mappings.clazz("com.mojang.blaze3d.Blaze3D") - val channel = def.mappings.clazz("com.mojang.blaze3d.audio.Channel") - - assertNotNull(blaze3d, "blaze3d") - assertNotNull(channel, "channel") - - assertEquals("com/mojang/blaze3d/audio/ChannelTest", channel!!.name(right)) - } - - @Test - fun testMethods() { - val method1 = def.mappings.clazz("com.mojang.blaze3d.Blaze3D")!! - .method("getTime")!! - - assertEquals("getTime", method1.name(left)) - assertEquals("m_83640_", method1.name(right)) - - val method2 = def.mappings.clazz("com.mojang.blaze3d.Blaze3D")!! - .method("process")!! - - assertEquals("process", method2.name(left)) - assertEquals("m_166118_", method2.name(right)) - - val method3 = def.mappings.clazz("com/mojang/blaze3d/audio/Channel")!! - .method("m_83658_")!! - - assertEquals("attachBufferStream", method3.name(left)) - assertEquals("m_83658_", method3.name(right)) - } - - @Test - fun testStatics() { - val method1 = def.mappings.clazz("com.mojang.blaze3d.Blaze3D")!! - .method("getTime")!! - assertEquals(Tristate.TRUE, method1.metadata.isStatic) - - val method2 = def.mappings.clazz("com/mojang/blaze3d/audio/Channel")!! - .method("")!! - assertEquals(Tristate.TRUE, method2.metadata.isStatic) - - val method3 = def.mappings.clazz("com/mojang/blaze3d/audio/Channel")!! - .method("")!! - assertEquals(Tristate.FALSE, method3.metadata.isStatic) - } - - @Test - fun testParams() { - val method1 = def.mappings.clazz("com.mojang.blaze3d.Blaze3D")!! - .method("getTime")!! - - assertEquals(0, method1.params().size) - - val method2 = def.mappings.clazz("com/mojang/blaze3d/audio/Channel")!! - .method("attachStaticBuffer")!! - - assertEquals(1, method2.params().size) - assertEquals("p_83657_", method2.param(0)!!.name(left)) - assertEquals("TEST", method2.param(0)!!.name(right)) - - val method3 = def.mappings.clazz("com/mojang/blaze3d/audio/ChannelTest")!! - .method("calculateBufferSize")!! - - assertEquals(Tristate.TRUE, method3.metadata.isStatic) - assertEquals(2, method3.params().size) - assertEquals("p_83661_", method3.param(0)!!.name(left)) - assertEquals("p_83661_test", method3.param(0)!!.name(right)) - assertEquals("p_83662_", method3.param(1)!!.name(left)) - assertEquals("p_83662_test", method3.param(1)!!.name(right)) - } - - @Test - fun testFields() { - val c = def.mappings.clazz("com/mojang/blaze3d/audio/Channel")!! - - assertEquals(4, c.fields().size) - assertEquals("BUFFER_DURATION_SECONDS", c.field("f_166124_")!!.name(left)) - assertEquals("f_166125_", c.field("QUEUED_BUFFER_COUNT")!!.name(right)) - assertEquals("initialized", c.field("f_83643_")!!.name(left)) - } -} Index: obfuscation-explorer/src/test/kotlin/formats/xsrg/XSrgMappingsFormatParserTest.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/formats/xsrg/XSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/formats/xsrg/XSrgMappingsFormatParserTest.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,128 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex.formats.xsrg - -import io.mcdev.obfex.formats.ParserFixture -import io.mcdev.obfex.mappings.MappingsFormatParser -import io.mcdev.obfex.mappings.unnamedFrom -import io.mcdev.obfex.mappings.unnamedTo -import io.mcdev.obfex.ref.MethodDescriptor -import io.mcdev.obfex.ref.PrimitiveTypeDef -import io.mcdev.obfex.ref.asClass -import io.mcdev.obfex.ref.asFieldRef -import io.mcdev.obfex.ref.asPackage -import io.mcdev.obfex.ref.asTypeDef -import io.mcdev.obfex.ref.field -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertSame -import org.junit.jupiter.api.Test - -class XSrgMappingsFormatParserTest : ParserFixture() { - - override val parser: MappingsFormatParser = XSrgMappingsFormatParser() - - @Language("xsrg") - override val text: String = """ - PK: ./ net/minecraft/server - CL: ght net/minecraft/Test - FD: ght/rft net/minecraft/Test/log - FD: ght${'$'}ds/juh Ljava/lang/Object; net/minecraft/Test${'$'}Example/server Ljava/lang/Object; - MD: ght/hyuip (I)Z net/minecraft/Test/isEven (I)Z - MD: ght${'$'}ds/hyuip (I)Z net/minecraft/Test${'$'}Example/isOdd (I)Z - """.trimIndent() - - @Test - fun testPackage() { - val mapping = def.mappings.pack("/".asPackage())!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("/", fromName) - assertEquals("net/minecraft/server", toName) - } - - @Test - fun testPackageOpposite() { - val mapping = def.mappings.pack("net/minecraft/server".asPackage())!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("/", fromName) - assertEquals("net/minecraft/server", toName) - } - - @Test - fun testClass() { - val from = def.mappings.clazz("ght".asClass()) - val to = def.mappings.clazz("net/minecraft/Test".asClass()) - - assertSame(from, to) - } - - @Test - fun testField1() { - val mapping = def.mappings.fieldMapping("ght".asClass().field("rft".asFieldRef()))!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("rft", fromName) - assertEquals("log", toName) - } - - @Test - fun testField2() { - val mapping = - def.mappings.fieldMapping( - "net/minecraft/Test\$Example".asClass() - .field("server".asFieldRef("Ljava/lang/Object;".asTypeDef())) - )!! - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("juh", fromName) - assertEquals("server", toName) - } - - @Test - fun testMethod() { - val clazz = def.mappings.clazz("ght".asClass())!! - val mapping = clazz.methods().first { it.unnamedFrom == "hyuip" } - - val fromName = mapping.unnamedFrom - val toName = mapping.unnamedTo - - assertEquals("hyuip", fromName) - assertEquals("isEven", toName) - - assertEquals( - MethodDescriptor( - listOf(PrimitiveTypeDef.INT), - PrimitiveTypeDef.BOOLEAN - ), - mapping.descriptor - ) - } -} Index: obfuscation-explorer/src/test/kotlin/test-util.kt =================================================================== --- obfuscation-explorer/src/test/kotlin/test-util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/kotlin/test-util.kt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,23 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2025 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package io.mcdev.obfex - -fun String.filterCrlf() = this.filter { it != '\r' } Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.mapping =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.mapping (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.mapping (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,34 +0,0 @@ -CLASS net/minecraft/class_2019 net/minecraft/predicate/DamagePredicate - FIELD field_9520 ANY Lnet/minecraft/class_2019; - FIELD field_9521 sourceEntity Lnet/minecraft/class_2048; - FIELD field_9522 blocked Ljava/lang/Boolean; - FIELD field_9523 dealt Lnet/minecraft/class_2096$class_2099; - FIELD field_9524 taken Lnet/minecraft/class_2096$class_2099; - FIELD field_9525 type Lnet/minecraft/class_2022; - METHOD (Lnet/minecraft/class_2096$class_2099;Lnet/minecraft/class_2096$class_2099;Lnet/minecraft/class_2048;Ljava/lang/Boolean;Lnet/minecraft/class_2022;)V - ARG 1 dealt - ARG 2 taken - ARG 3 sourceEntity - ARG 4 blocked - ARG 5 type - METHOD method_8838 test (Lnet/minecraft/class_3222;Lnet/minecraft/class_1282;FFZ)Z - ARG 1 player - ARG 2 source - ARG 3 dealt - ARG 4 taken - ARG 5 blocked - METHOD method_8839 fromJson (Lcom/google/gson/JsonElement;)Lnet/minecraft/class_2019; - ARG 0 json - METHOD method_8840 toJson ()Lcom/google/gson/JsonElement; - CLASS class_2020 Builder - FIELD field_9526 blocked Ljava/lang/Boolean; - FIELD field_9527 taken Lnet/minecraft/class_2096$class_2099; - FIELD field_9528 sourceEntity Lnet/minecraft/class_2048; - FIELD field_9529 type Lnet/minecraft/class_2022; - FIELD field_9530 dealt Lnet/minecraft/class_2096$class_2099; - METHOD method_8841 blocked (Ljava/lang/Boolean;)Lnet/minecraft/class_2019$class_2020; - ARG 1 blocked - METHOD method_8842 type (Lnet/minecraft/class_2022$class_2023;)Lnet/minecraft/class_2019$class_2020; - ARG 1 builder - METHOD method_8843 build ()Lnet/minecraft/class_2019; - METHOD method_8844 create ()Lnet/minecraft/class_2019$class_2020; Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.txt =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/enigma/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,347 +0,0 @@ -CLASS_KEY ('CLASS') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('class_2019') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('predicate') -SLASH ('/') -NAME_ELEMENT ('DamagePredicate') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9520') -WHITE_SPACE (' ') -NAME_ELEMENT ('ANY') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2019;') -CRLF ('\n') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9521') -WHITE_SPACE (' ') -NAME_ELEMENT ('sourceEntity') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2048;') -CRLF ('\n') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9522') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -WHITE_SPACE (' ') -CLASS_TYPE ('Ljava/lang/Boolean;') -CRLF ('\n') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9523') -WHITE_SPACE (' ') -NAME_ELEMENT ('dealt') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CRLF ('\n') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9524') -WHITE_SPACE (' ') -NAME_ELEMENT ('taken') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CRLF ('\n') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9525') -WHITE_SPACE (' ') -NAME_ELEMENT ('type') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2022;') -CRLF ('\n') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -CONSTRUCTOR ('') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CLASS_TYPE ('Lnet/minecraft/class_2048;') -CLASS_TYPE ('Ljava/lang/Boolean;') -CLASS_TYPE ('Lnet/minecraft/class_2022;') -CLOSE_PAREN (')') -PRIMITIVE ('V') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('dealt') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('2') -WHITE_SPACE (' ') -NAME_ELEMENT ('taken') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('3') -WHITE_SPACE (' ') -NAME_ELEMENT ('sourceEntity') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('4') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('5') -WHITE_SPACE (' ') -NAME_ELEMENT ('type') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8838') -WHITE_SPACE (' ') -NAME_ELEMENT ('test') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lnet/minecraft/class_3222;') -CLASS_TYPE ('Lnet/minecraft/class_1282;') -PRIMITIVE ('F') -PRIMITIVE ('F') -PRIMITIVE ('Z') -CLOSE_PAREN (')') -PRIMITIVE ('Z') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('player') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('2') -WHITE_SPACE (' ') -NAME_ELEMENT ('source') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('3') -WHITE_SPACE (' ') -NAME_ELEMENT ('dealt') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('4') -WHITE_SPACE (' ') -NAME_ELEMENT ('taken') -CRLF ('\n') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('5') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8839') -WHITE_SPACE (' ') -NAME_ELEMENT ('fromJson') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lcom/google/gson/JsonElement;') -CLOSE_PAREN (')') -CLASS_TYPE ('Lnet/minecraft/class_2019;') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('json') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8840') -WHITE_SPACE (' ') -NAME_ELEMENT ('toJson') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -CLASS_TYPE ('Lcom/google/gson/JsonElement;') -CRLF ('\n') -TAB (' ') -CLASS_KEY ('CLASS') -WHITE_SPACE (' ') -NAME_ELEMENT ('class_2020') -WHITE_SPACE (' ') -NAME_ELEMENT ('Builder') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9526') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -WHITE_SPACE (' ') -CLASS_TYPE ('Ljava/lang/Boolean;') -CRLF ('\n') -TAB (' ') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9527') -WHITE_SPACE (' ') -NAME_ELEMENT ('taken') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CRLF ('\n') -TAB (' ') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9528') -WHITE_SPACE (' ') -NAME_ELEMENT ('sourceEntity') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2048;') -CRLF ('\n') -TAB (' ') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9529') -WHITE_SPACE (' ') -NAME_ELEMENT ('type') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2022;') -CRLF ('\n') -TAB (' ') -TAB (' ') -FIELD_KEY ('FIELD') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_9530') -WHITE_SPACE (' ') -NAME_ELEMENT ('dealt') -WHITE_SPACE (' ') -CLASS_TYPE ('Lnet/minecraft/class_2096$class_2099;') -CRLF ('\n') -TAB (' ') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8841') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Ljava/lang/Boolean;') -CLOSE_PAREN (')') -CLASS_TYPE ('Lnet/minecraft/class_2019$class_2020;') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('blocked') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8842') -WHITE_SPACE (' ') -NAME_ELEMENT ('type') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lnet/minecraft/class_2022$class_2023;') -CLOSE_PAREN (')') -CLASS_TYPE ('Lnet/minecraft/class_2019$class_2020;') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -TAB (' ') -ARG_KEY ('ARG') -WHITE_SPACE (' ') -INDEX ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('builder') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8843') -WHITE_SPACE (' ') -NAME_ELEMENT ('build') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -CLASS_TYPE ('Lnet/minecraft/class_2019;') -CRLF ('\n') -TAB (' ') -TAB (' ') -METHOD_KEY ('METHOD') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_8844') -WHITE_SPACE (' ') -NAME_ELEMENT ('create') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -CLASS_TYPE ('Lnet/minecraft/class_2019$class_2020;') Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.srg =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.srg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.srg (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,10 +0,0 @@ -# CL: yu net/minecraft/Comment -PK: ./ net/minecraft/server -CL: uih net/minecraft/CommentTest # CL: op uk/jr/Operator -CL: ght net/minecraft/Test -CL: ght$ds net/minecraft/Test$Example -CL: ght$ds$bg net/minecraft/Test$Example$Inner -FD: ght/rft net/minecraft/Test/log -FD: ght$ds/juh net/minecraft/Test$Example/server -MD: ght/hyuip (I)Z net/minecraft/Test/isEven (I)Z -MD: ght$ds/hyuip (I)Z net/minecraft/Test$Example/isOdd (I)Z Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.txt =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/srg/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,124 +0,0 @@ -COMMENT ('# CL: yu net/minecraft/Comment') -CRLF ('\n') -PACKAGE_KEY ('PK:') -WHITE_SPACE (' ') -PACKAGE_NAME ('./') -WHITE_SPACE (' ') -PACKAGE_NAME ('net/minecraft/server') -CRLF ('\n') -CLASS_KEY ('CL:') -WHITE_SPACE (' ') -NAME_ELEMENT ('uih') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('CommentTest') -COMMENT (' # CL: op uk/jr/Operator') -CRLF ('\n') -CLASS_KEY ('CL:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test') -CRLF ('\n') -CLASS_KEY ('CL:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght$ds') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test$Example') -CRLF ('\n') -CLASS_KEY ('CL:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght$ds$bg') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test$Example$Inner') -CRLF ('\n') -FIELD_KEY ('FD:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght') -SLASH ('/') -NAME_ELEMENT ('rft') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test') -SLASH ('/') -NAME_ELEMENT ('log') -CRLF ('\n') -FIELD_KEY ('FD:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght$ds') -SLASH ('/') -NAME_ELEMENT ('juh') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test$Example') -SLASH ('/') -NAME_ELEMENT ('server') -CRLF ('\n') -METHOD_KEY ('MD:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght') -SLASH ('/') -NAME_ELEMENT ('hyuip') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('Z') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test') -SLASH ('/') -NAME_ELEMENT ('isEven') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('Z') -CRLF ('\n') -METHOD_KEY ('MD:') -WHITE_SPACE (' ') -NAME_ELEMENT ('ght$ds') -SLASH ('/') -NAME_ELEMENT ('hyuip') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('Z') -WHITE_SPACE (' ') -NAME_ELEMENT ('net') -SLASH ('/') -NAME_ELEMENT ('minecraft') -SLASH ('/') -NAME_ELEMENT ('Test$Example') -SLASH ('/') -NAME_ELEMENT ('isOdd') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('Z') Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.tiny =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.tiny (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.tiny (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,15 +0,0 @@ -tiny 2 0 official intermediary named - someProperty someValue - anotherProperty -c a class_123 pkg/SomeClass - c Class comment - m (III)V a method_456 someMethod - p 1 param_0 x - c Param comment - p 2 param_1 y - p 3 param_2 z - c Method comment - f [I a field_789 someField - c Field comment -c b class_234 pkg/xy/AnotherClass - m (Ljava/lang/String;)I a method_567 anotherMethod Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.txt =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tinyv2/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,135 +0,0 @@ -TINY_KEY ('tiny') -WHITE_SPACE (' ') -VERSION_NUM ('2') -WHITE_SPACE (' ') -VERSION_NUM ('0') -WHITE_SPACE (' ') -NAMESPACE_KEY ('official') -WHITE_SPACE (' ') -NAMESPACE_KEY ('intermediary') -WHITE_SPACE (' ') -NAMESPACE_KEY ('named') -CRLF ('\n') -WHITE_SPACE (' ') -PROPERTY_KEY ('someProperty') -WHITE_SPACE (' ') -PROPERTY_VALUE ('someValue') -CRLF ('\n') -WHITE_SPACE (' ') -PROPERTY_KEY ('anotherProperty') -CRLF ('\n') -CLASS_KEY ('c') -WHITE_SPACE (' ') -NAME_ELEMENT ('a') -WHITE_SPACE (' ') -NAME_ELEMENT ('class_123') -WHITE_SPACE (' ') -NAME_ELEMENT ('pkg') -SLASH ('/') -NAME_ELEMENT ('SomeClass') -CRLF ('\n') -WHITE_SPACE (' ') -COMMENT_KEY ('c') -DOC_TEXT (' Class comment') -CRLF ('\n') -WHITE_SPACE (' ') -METHOD_KEY ('m') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -PRIMITIVE ('I') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -NAME_ELEMENT ('a') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_456') -WHITE_SPACE (' ') -NAME_ELEMENT ('someMethod') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -PARAM_KEY ('p') -WHITE_SPACE (' ') -DIGIT ('1') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -NAME_ELEMENT ('param_0') -WHITE_SPACE (' ') -NAME_ELEMENT ('x') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -COMMENT_KEY ('c') -DOC_TEXT (' Param comment') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -PARAM_KEY ('p') -WHITE_SPACE (' ') -DIGIT ('2') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -NAME_ELEMENT ('param_1') -WHITE_SPACE (' ') -NAME_ELEMENT ('y') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -PARAM_KEY ('p') -WHITE_SPACE (' ') -DIGIT ('3') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -NAME_ELEMENT ('param_2') -WHITE_SPACE (' ') -NAME_ELEMENT ('z') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -COMMENT_KEY ('c') -DOC_TEXT (' Method comment') -CRLF ('\n') -WHITE_SPACE (' ') -FIELD_KEY ('f') -WHITE_SPACE (' ') -CLASS_TYPE ('[I') -WHITE_SPACE (' ') -NAME_ELEMENT ('a') -WHITE_SPACE (' ') -NAME_ELEMENT ('field_789') -WHITE_SPACE (' ') -NAME_ELEMENT ('someField') -CRLF ('\n') -WHITE_SPACE (' ') -WHITE_SPACE (' ') -COMMENT_KEY ('c') -DOC_TEXT (' Field comment') -CRLF ('\n') -CLASS_KEY ('c') -WHITE_SPACE (' ') -NAME_ELEMENT ('b') -WHITE_SPACE (' ') -NAME_ELEMENT ('class_234') -WHITE_SPACE (' ') -NAME_ELEMENT ('pkg') -SLASH ('/') -NAME_ELEMENT ('xy') -SLASH ('/') -NAME_ELEMENT ('AnotherClass') -CRLF ('\n') -WHITE_SPACE (' ') -METHOD_KEY ('m') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Ljava/lang/String;') -CLOSE_PAREN (')') -PRIMITIVE ('I') -WHITE_SPACE (' ') -NAME_ELEMENT ('a') -WHITE_SPACE (' ') -NAME_ELEMENT ('method_567') -WHITE_SPACE (' ') -NAME_ELEMENT ('anotherMethod') Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.tsrg2 =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.tsrg2 (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.tsrg2 (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,26 +0,0 @@ -tsrg2 left right -com/mojang/blaze3d/Blaze3D com/mojang/blaze3d/Blaze3D - ()V - getTime ()D m_83640_ - static - process (Lcom/mojang/blaze3d/pipeline/RenderPipeline;F)V m_166118_ - static - 0 p_166119_ p_166119_ - 1 p_166120_ p_166120_ -com/mojang/blaze3d/audio/Channel com/mojang/blaze3d/audio/ChannelTest - BUFFER_DURATION_SECONDS f_166124_ - LOGGER f_83641_ - QUEUED_BUFFER_COUNT f_166125_ - ()V - static - (I)V - 0 p_83648_ p_83648_ - attachBufferStream (Lnet/minecraft/client/sounds/AudioStream;)V m_83658_ - 0 p_83659_ p_83659_ - initialized f_83643_ - attachStaticBuffer (Lcom/mojang/blaze3d/audio/SoundBuffer;)V m_83656_ - 0 p_83657_ TEST - calculateBufferSize (Ljavax/sound/sampled/AudioFormat;I)I m_83660_ - static - 0 p_83661_ p_83661_test - 1 p_83662_ p_83662_test Index: obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.txt =================================================================== --- obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ obfuscation-explorer/src/test/resources/io/mcdev/obfex/formats/tsrg2/lexer/fixtures/test.txt (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) @@ -1,228 +0,0 @@ -TSRG2_KEY ('tsrg2') -WHITE_SPACE (' ') -NAMESPACE_KEY ('left') -WHITE_SPACE (' ') -NAMESPACE_KEY ('right') -CRLF ('\n') -NAME_ELEMENT ('com') -SLASH ('/') -NAME_ELEMENT ('mojang') -SLASH ('/') -NAME_ELEMENT ('blaze3d') -SLASH ('/') -NAME_ELEMENT ('Blaze3D') -WHITE_SPACE (' ') -NAME_ELEMENT ('com') -SLASH ('/') -NAME_ELEMENT ('mojang') -SLASH ('/') -NAME_ELEMENT ('blaze3d') -SLASH ('/') -NAME_ELEMENT ('Blaze3D') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -INIT ('') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -INIT ('') -CRLF ('\n') -TAB (' ') -NAME_ELEMENT ('getTime') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -PRIMITIVE ('D') -WHITE_SPACE (' ') -NAME_ELEMENT ('m_83640_') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -STATIC ('static') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -NAME_ELEMENT ('process') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lcom/mojang/blaze3d/pipeline/RenderPipeline;') -PRIMITIVE ('F') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -NAME_ELEMENT ('m_166118_') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -STATIC ('static') -CRLF ('\n') -TAB (' ') -TAB (' ') -DIGIT ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_166119_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_166119_') -CRLF ('\n') -TAB (' ') -TAB (' ') -DIGIT ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_166120_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_166120_') -CRLF ('\n') -VIRTUAL_CLOSE ('') -VIRTUAL_CLOSE ('') -NAME_ELEMENT ('com') -SLASH ('/') -NAME_ELEMENT ('mojang') -SLASH ('/') -NAME_ELEMENT ('blaze3d') -SLASH ('/') -NAME_ELEMENT ('audio') -SLASH ('/') -NAME_ELEMENT ('Channel') -WHITE_SPACE (' ') -NAME_ELEMENT ('com') -SLASH ('/') -NAME_ELEMENT ('mojang') -SLASH ('/') -NAME_ELEMENT ('blaze3d') -SLASH ('/') -NAME_ELEMENT ('audio') -SLASH ('/') -NAME_ELEMENT ('ChannelTest') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -NAME_ELEMENT ('BUFFER_DURATION_SECONDS') -WHITE_SPACE (' ') -NAME_ELEMENT ('f_166124_') -CRLF ('\n') -TAB (' ') -NAME_ELEMENT ('LOGGER') -WHITE_SPACE (' ') -NAME_ELEMENT ('f_83641_') -CRLF ('\n') -TAB (' ') -NAME_ELEMENT ('QUEUED_BUFFER_COUNT') -WHITE_SPACE (' ') -NAME_ELEMENT ('f_166125_') -CRLF ('\n') -TAB (' ') -CLINIT ('') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -CLINIT ('') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -STATIC ('static') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -INIT ('') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -INIT ('') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -DIGIT ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83648_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83648_') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -NAME_ELEMENT ('attachBufferStream') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lnet/minecraft/client/sounds/AudioStream;') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -NAME_ELEMENT ('m_83658_') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -DIGIT ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83659_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83659_') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -NAME_ELEMENT ('initialized') -WHITE_SPACE (' ') -NAME_ELEMENT ('f_83643_') -CRLF ('\n') -TAB (' ') -NAME_ELEMENT ('attachStaticBuffer') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Lcom/mojang/blaze3d/audio/SoundBuffer;') -CLOSE_PAREN (')') -PRIMITIVE ('V') -WHITE_SPACE (' ') -NAME_ELEMENT ('m_83656_') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -DIGIT ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83657_') -WHITE_SPACE (' ') -NAME_ELEMENT ('TEST') -CRLF ('\n') -VIRTUAL_CLOSE ('') -TAB (' ') -NAME_ELEMENT ('calculateBufferSize') -WHITE_SPACE (' ') -OPEN_PAREN ('(') -CLASS_TYPE ('Ljavax/sound/sampled/AudioFormat;') -PRIMITIVE ('I') -CLOSE_PAREN (')') -PRIMITIVE ('I') -WHITE_SPACE (' ') -NAME_ELEMENT ('m_83660_') -CRLF ('\n') -VIRTUAL_OPEN ('') -TAB (' ') -TAB (' ') -STATIC ('static') -CRLF ('\n') -TAB (' ') -TAB (' ') -DIGIT ('0') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83661_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83661_test') -CRLF ('\n') -TAB (' ') -TAB (' ') -DIGIT ('1') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83662_') -WHITE_SPACE (' ') -NAME_ELEMENT ('p_83662_test') Index: settings.gradle.kts =================================================================== --- settings.gradle.kts (revision 95c88298e41359f9ef9571c9b029f2165f9a7305) +++ settings.gradle.kts (revision f793d783978567f982ddf90810ca5b746e262e9f) @@ -30,7 +30,6 @@ } rootProject.name = "MinecraftDev" -include("obfuscation-explorer") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")