├── .gitattributes ├── .github └── workflows │ └── publish.yml ├── .gitignore ├── LICENSE ├── LICENSE-header.txt ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── proguard.pro ├── settings.gradle └── src ├── main ├── java │ └── net │ │ └── minecraftforge │ │ └── srg2source │ │ ├── ConsoleTool.java │ │ ├── RangeApplyMain.java │ │ ├── RangeExtractMain.java │ │ ├── api │ │ ├── InputSupplier.java │ │ ├── OutputSupplier.java │ │ ├── RangeApplierBuilder.java │ │ ├── RangeExtractorBuilder.java │ │ └── SourceVersion.java │ │ ├── apply │ │ ├── ClassMeta.java │ │ ├── ExceptorClass.java │ │ └── RangeApplier.java │ │ ├── asm │ │ ├── CompilationUnitResolverTransfomer.java │ │ ├── RangeExtractorTransformer.java │ │ └── TransformationService.java │ │ ├── extract │ │ ├── ExtractUtil.java │ │ ├── MixinProcessor.java │ │ ├── RangeExtractor.java │ │ └── SymbolReferenceWalker.java │ │ ├── mixin │ │ ├── Accessor.java │ │ ├── AnnotationBase.java │ │ ├── IAnnotationProcessor.java │ │ ├── Interface.java │ │ ├── Invoker.java │ │ ├── Mixin.java │ │ ├── MixinAnnotation.java │ │ ├── MixinInfo.java │ │ ├── Overwrite.java │ │ └── Shadow.java │ │ ├── range │ │ ├── IRange.java │ │ ├── RangeMap.java │ │ ├── RangeMapBuilder.java │ │ └── entries │ │ │ ├── ClassLiteral.java │ │ │ ├── ClassReference.java │ │ │ ├── FieldLiteral.java │ │ │ ├── FieldReference.java │ │ │ ├── LocalVariableReference.java │ │ │ ├── MetaEntry.java │ │ │ ├── MethodLiteral.java │ │ │ ├── MethodReference.java │ │ │ ├── MixinAccessorMeta.java │ │ │ ├── PackageReference.java │ │ │ ├── ParameterReference.java │ │ │ ├── RangeEntry.java │ │ │ └── StructuralEntry.java │ │ └── util │ │ ├── MemberInfo.java │ │ ├── TransformingUtil.java │ │ ├── Util.java │ │ └── io │ │ ├── ChainedInputSupplier.java │ │ ├── ConfLogger.java │ │ ├── FolderSupplier.java │ │ ├── ZipInputSupplier.java │ │ └── ZipOutputSupplier.java └── resources │ └── META-INF │ └── cpw.mods.modlauncher.api.ITransformationService └── test ├── java └── net │ └── minecraftforge │ └── srg2source │ └── test │ ├── Java16Tests.java │ ├── MemoryOutputSupplier.java │ ├── MinecraftTest.java │ ├── MixinTests.java │ ├── SimpleInputSupplier.java │ ├── SimpleTestBase.java │ ├── SingleTests.java │ └── WalkerTest.java └── resources ├── AnonClass ├── original.range └── original │ └── AnonClass.txt ├── GenericClasses ├── original.range └── original │ └── GenericClasses.txt ├── ImportSpaces ├── mapped.range ├── mapped │ └── ImportSpaces.txt ├── original.range └── original │ └── ImportSpaces.txt ├── InnerClass ├── original.range └── original │ └── InnerClass.txt ├── Lambda ├── original.range └── original │ └── Lambda.txt ├── LocalClass ├── original.range └── original │ └── LocalClass.txt ├── Mixins ├── Accessor │ ├── FactoryImply │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FactoryImply.txt │ │ ├── original.range │ │ └── original │ │ │ └── FactoryImply.txt │ ├── FactoryNamed │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FactoryNamed.txt │ │ ├── original.range │ │ └── original │ │ │ └── FactoryNamed.txt │ ├── FieldGetterImply │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FieldGetterImply.txt │ │ ├── original.range │ │ └── original │ │ │ └── FieldGetterImply.txt │ ├── FieldGetterNamed │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FieldGetterNamed.txt │ │ ├── original.range │ │ └── original │ │ │ └── FieldGetterNamed.txt │ ├── FieldSetterImply │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FieldSetterImply.txt │ │ ├── original.range │ │ └── original │ │ │ └── FieldSetterImply.txt │ ├── FieldSetterNamed │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── FieldSetterNamed.txt │ │ ├── original.range │ │ └── original │ │ │ └── FieldSetterNamed.txt │ ├── MethodProxyImply │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── MethodProxyImply.txt │ │ ├── original.range │ │ └── original │ │ │ └── MethodProxyImply.txt │ └── MethodProxyNamed │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ └── MethodProxyNamed.txt │ │ ├── original.range │ │ └── original │ │ └── MethodProxyNamed.txt ├── Implements │ └── SimpleImplements │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ └── SimpleImplements.txt │ │ ├── original.range │ │ └── original │ │ └── SimpleImplements.txt ├── Mixin │ ├── HardTargetMulti │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── HardTargetMulti.txt │ │ ├── original.range │ │ └── original │ │ │ └── HardTargetMulti.txt │ ├── HardTargetSingle │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── HardTargetSingle.txt │ │ ├── original.range │ │ └── original │ │ │ └── HardTargetSingle.txt │ ├── SoftTargetMulti │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ │ └── SoftTargetMulti.txt │ │ ├── original.range │ │ └── original │ │ │ └── SoftTargetMulti.txt │ └── SoftTargetSingle │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ └── SoftTargetSingle.txt │ │ ├── original.range │ │ └── original │ │ └── SoftTargetSingle.txt ├── Overwrite │ └── OverwriteImply │ │ ├── mapped.range │ │ ├── mapped.tsrg │ │ ├── mapped │ │ └── OverwriteImply.txt │ │ ├── original.range │ │ └── original │ │ └── OverwriteImply.txt └── Shadow │ ├── ShadowField │ ├── mapped.range │ ├── mapped.tsrg │ ├── mapped │ │ └── ShadowField.txt │ ├── original.range │ └── original │ │ └── ShadowField.txt │ └── ShadowMethod │ ├── mapped.range │ ├── mapped.tsrg │ ├── mapped │ └── ShadowMethod.txt │ ├── original.range │ └── original │ └── ShadowMethod.txt ├── NestedGenerics ├── original.range └── original │ └── Test.txt ├── PackageInfo ├── original.range └── original │ └── test │ └── package-info.txt ├── PatternMatch ├── original.range └── original │ └── PatternMatch.txt ├── RecordCanonical ├── mapped.range ├── mapped.tsrg ├── mapped │ └── RecordCanonical.txt ├── original.range └── original │ └── RecordCanonical.txt ├── RecordCompact ├── mapped.range ├── mapped.tsrg ├── mapped │ └── RecordCompact.txt ├── original.range └── original │ └── RecordCompact.txt ├── RecordComplex ├── mapped.range ├── mapped.tsrg ├── mapped │ └── RecordComplex.txt ├── original.range └── original │ └── RecordComplex.txt ├── RecordSimple ├── mapped.range ├── mapped.tsrg ├── mapped │ └── RecordSimple.txt ├── original.range └── original │ └── RecordSimple.txt ├── Whitespace ├── mapped.range ├── mapped.tsrg ├── mapped │ └── not_test │ │ └── package-info.txt ├── original.range └── original │ └── test │ └── package-info.txt └── test.marker /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.txt text eol=lf 3 | *.range text eol=lf 4 | *.bat text eol=crlf 5 | *.patch text eol=lf 6 | *.java text eol=lf 7 | *.gradle text eol=crlf 8 | *.png binary 9 | *.gif binary 10 | *.exe binary 11 | *.dll binary 12 | *.jar binary 13 | *.lzma binary 14 | *.zip binary 15 | *.pyd binary 16 | *.cfg text eol=lf 17 | *.py text eol=lf 18 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | branches: [ "*" ] 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | build: 12 | uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main 13 | with: 14 | java: 17 15 | gradle_tasks: "publish" 16 | artifact_name: "Srg2Source" 17 | secrets: 18 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 19 | PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }} 20 | PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }} 21 | PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }} 22 | MAVEN_USER: ${{ secrets.MAVEN_USER }} 23 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | build 3 | .gradle 4 | run 5 | .settings 6 | .classpath 7 | .project 8 | lib 9 | eclipse 10 | *.rangemap 11 | fml/ 12 | remapper.log 13 | cb.rangemap 14 | MCP/MCP.iml 15 | MCP/MCP.iws 16 | MCP/MCP.rangemap 17 | *.srg 18 | patches/ 19 | .pydevproject 20 | .idea 21 | *.iml 22 | *.ipr 23 | /out/ 24 | RunDir 25 | rundir 26 | MINECRAFT_TEST* 27 | repo/ 28 | /logs/ 29 | /_test/ 30 | /src/main/resources/META-INF/MANIFEST.MF 31 | -------------------------------------------------------------------------------- /LICENSE-header.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Forge Development LLC 2 | SPDX-License-Identifier: LGPL-2.1-only -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Srg2Source v4.1 2 | 3 | A tool for renaming symbols (classes, methods, fields, parameters, and variables) in Java source code using .srg mappings. 4 | 5 | For porting, Minecraft, CraftBukkit, mods, plugins, etc. 6 | 7 | ## Usage 8 | 9 | java -jar Srg2Source-fatjar.jar --extract [SourceDir] [LibrariesDir] [RangeMapOutput] 10 | java -jar Srg2Source-fatjar.jar --apply --srcRoot [SourceDir] --srcRangeMap [RangeMap] --srgFiles [SRGFile] --excFiles [ExcFile] --outDir [Output] 11 | 12 | ## See also 13 | 14 | Inspired by the Frans-Willem's binary remapper ApplySrg, originally from https://github.com/Frans-Willem/SrgTools (updated version at https://github.com/agaricusb/SrgTools) 15 | 16 | More remapping tools and generated .srgs: https://github.com/agaricusb/MinecraftRemapping 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MinecraftForge/Srg2Source/a521287b763725205ef9ed9183899b8bb38d65bb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /proguard.pro: -------------------------------------------------------------------------------- 1 | -dontoptimize 2 | -dontobfuscate 3 | #-dontpreverify 4 | -dontwarn javax.annotation.** 5 | -dontwarn javax.inject.** 6 | -dontwarn com.google.** 7 | -dontwarn com.ibm.** 8 | -dontwarn org.osgi.** 9 | -dontwarn org.apache.** 10 | -dontwarn cpw.mods.modlauncher.** 11 | 12 | 13 | # Keep - Applications. Keep all application classes, along with their 'main' 14 | # methods. 15 | -keepclasseswithmembers public class * { 16 | public static void main(java.lang.String[]); 17 | } 18 | 19 | # Also keep - Enumerations. Keep the special static methods that are required in 20 | # enumeration classes. 21 | -keepclassmembers enum * { 22 | public static **[] values(); 23 | public static ** valueOf(java.lang.String); 24 | } 25 | 26 | # Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI, 27 | # along with the special 'createUI' method. 28 | -keep class * extends javax.swing.plaf.ComponentUI { 29 | public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent); 30 | } 31 | 32 | # Keep names - Native method names. Keep all native class/method names. 33 | -keepclasseswithmembers,allowshrinking class * { 34 | native ; 35 | } 36 | 37 | # Keep all of our API 38 | -keepclassmembers public class net.minecraftforge.** { 39 | *; 40 | } 41 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven { url = 'https://maven.minecraftforge.net/' } 5 | } 6 | } 7 | 8 | plugins { 9 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' 10 | } 11 | 12 | dependencyResolutionManagement { 13 | versionCatalogs { 14 | libs { 15 | // Main 16 | library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3') 17 | library('securemodules', 'net.minecraftforge:securemodules:2.2.21') 18 | library('srgutils', 'net.minecraftforge:srgutils:0.5.11') 19 | library('nulls', 'org.jetbrains:annotations:26.0.2') // Got to have our null annotations! 20 | 21 | library('eclipse-jdt', 'org.eclipse.jdt:org.eclipse.jdt.core:3.40.0') 22 | library('eclipse-runtime', 'org.eclipse.platform:org.eclipse.core.runtime:3.32.0') 23 | library('eclipse-resources', 'org.eclipse.platform:org.eclipse.core.resources:3.22.0') 24 | library('eclipse-jobs', 'org.eclipse.platform:org.eclipse.core.jobs:3.15.400') 25 | library('eclipse-types', 'org.eclipse.platform:org.eclipse.core.contenttype:3.9.600') 26 | bundle('eclipse', ['eclipse-jdt', 'eclipse-runtime', 'eclipse-resources', 'eclipse-jobs', 'eclipse-types']) 27 | 28 | // Test 29 | library('ml', 'net.minecraftforge:modlauncher:10.1.4') 30 | library('jimfs', 'com.google.jimfs:jimfs:1.3.0') 31 | 32 | version('junit', '5.12.0') 33 | library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') 34 | library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') 35 | library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.12.0') 36 | bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher']) 37 | 38 | version('asm', '9.7.1') 39 | library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm') 40 | library('asm-tree', 'org.ow2.asm', 'asm-tree').versionRef('asm') 41 | bundle('asm', ['asm', 'asm-tree']) 42 | 43 | version('powermock', '2.0.9') 44 | library('powermock-core', 'org.powermock', 'powermock-core').versionRef('powermock') 45 | library('powermock-reflect', 'org.powermock', 'powermock-reflect').versionRef('powermock') 46 | bundle('powermock', ['powermock-core', 'powermock-reflect']) 47 | } 48 | } 49 | } 50 | 51 | rootProject.name = 'Srg2Source' 52 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/ConsoleTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source; 7 | 8 | import java.nio.file.Files; 9 | import java.nio.file.Paths; 10 | import java.util.ArrayList; 11 | import java.util.Deque; 12 | import java.util.HashMap; 13 | import java.util.LinkedList; 14 | import java.util.List; 15 | import java.util.Locale; 16 | import java.util.Map; 17 | import java.util.stream.Collectors; 18 | 19 | import net.minecraftforge.srg2source.extract.RangeExtractor; 20 | import net.minecraftforge.srg2source.util.TransformingUtil; 21 | 22 | public class ConsoleTool { 23 | public static void main(String[] args) throws Exception { 24 | System.setProperty("osgi.nls.warnings", "ignore"); //Shutup Eclipse in our trimmed fat-jar. 25 | if (RangeExtractor.hasBeenASMPatched()) { 26 | Redefined.main(args); 27 | } else { 28 | var tcl = TransformingUtil.createTransformer(); 29 | 30 | Class cls = Class.forName(ConsoleTool.class.getName() + "$Redefined", true, tcl); 31 | 32 | cls.getDeclaredMethod("main", String[].class).invoke(null, new Object[] {args}); 33 | } 34 | } 35 | 36 | @SuppressWarnings("unused") 37 | public static class Redefined { 38 | public static void main(String[] args) throws Exception { 39 | Task target = null; 40 | Map tasks = new HashMap<>(); 41 | for (Task t : Task.values()) 42 | tasks.put("--" + t.name().toLowerCase(Locale.ENGLISH), t); 43 | 44 | Deque que = new LinkedList<>(); 45 | for(String arg : args) 46 | que.add(arg); 47 | 48 | List _args = new ArrayList(); 49 | 50 | String arg; 51 | while ((arg = que.poll()) != null) { 52 | if (tasks.containsKey(arg.toLowerCase(Locale.ENGLISH))) { 53 | if (target != null) 54 | throw new IllegalArgumentException("Only one task allowed at a time, trued to run " + arg + " when " + target + " already set"); 55 | target = tasks.get(arg.toLowerCase(Locale.ENGLISH)); 56 | } else if ("--cfg".equals(arg)) { 57 | String cfg = que.poll(); 58 | if (cfg == null) 59 | throw new IllegalArgumentException("Invalid --cfg entry, missing file path"); 60 | Files.readAllLines(Paths.get(cfg)).forEach(que::add); 61 | } 62 | else if (arg.startsWith("--cfg=")) 63 | Files.readAllLines(Paths.get(arg.substring(6))).forEach(que::add); 64 | else 65 | _args.add(arg); 66 | } 67 | 68 | if (target == null) 69 | System.out.println("Must specify a task to run: " + tasks.keySet().stream().collect(Collectors.joining(", "))); 70 | else 71 | target.task.accept(_args.toArray(new String[_args.size()])); 72 | } 73 | } 74 | 75 | private static enum Task { 76 | APPLY(RangeApplyMain::main), 77 | EXTRACT(RangeExtractMain::main); 78 | 79 | private Consumer task; 80 | private Task(Consumer task) { 81 | this.task = task; 82 | } 83 | } 84 | 85 | @FunctionalInterface 86 | public interface Consumer { 87 | void accept(T t) throws Exception; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/RangeApplyMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.nio.file.Path; 11 | import java.util.Arrays; 12 | import java.util.List; 13 | import joptsimple.OptionException; 14 | import joptsimple.OptionParser; 15 | import joptsimple.OptionSet; 16 | import joptsimple.OptionSpec; 17 | import joptsimple.ValueConverter; 18 | import joptsimple.util.PathConverter; 19 | import net.minecraftforge.srg2source.api.RangeApplierBuilder; 20 | 21 | public class RangeApplyMain { 22 | private static final ValueConverter PATH_CONVERTER = new PathConverter(); 23 | 24 | public static void main(String[] args) throws IOException { 25 | OptionParser parser = new OptionParser(); 26 | OptionSpec helpArg = parser.acceptsAll(a("h", "help")).forHelp(); 27 | OptionSpec inputArg = parser.acceptsAll(a("in", "input", "srcRoot")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER).required(); 28 | OptionSpec outArg = parser.acceptsAll(a("out", "output", "outDir")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER).required(); 29 | OptionSpec excArg = parser.acceptsAll(a("exc", "excFiles")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER); 30 | OptionSpec mappingArg = parser.acceptsAll(a("map", "srg", "srgFiles")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER).required(); 31 | //TODO: Encoding arguments 32 | 33 | OptionSpec rangeArg = parser.acceptsAll(a("rm", "range", "srcRangeMap")).withRequiredArg().ofType(File.class).required(); 34 | OptionSpec importArg = parser.acceptsAll(a("keepImports")).withOptionalArg().ofType(Boolean.class).defaultsTo(true); 35 | //OptionSpec annArg = parser.acceptsAll(a("annotate")).withOptionalArg().ofType(Boolean.class).defaultsTo(false); 36 | 37 | 38 | //Somewhat hacky things that are used for specific usecases 39 | OptionSpec sortImportArg = parser.acceptsAll(a("sortImports")); 40 | OptionSpec guessLambdasArg = parser.acceptsAll(a("guessLambdas")); 41 | OptionSpec guessLocalsArg = parser.acceptsAll(a("guessLocals")); 42 | 43 | try 44 | { 45 | OptionSet options = parser.parse(args); 46 | 47 | if (options.has(helpArg)) { 48 | parser.printHelpOn(System.out); 49 | return; 50 | } 51 | 52 | File range = options.valueOf(rangeArg); 53 | Path output = options.valueOf(outArg); 54 | boolean keepImports = options.has(importArg) && options.valueOf(importArg); 55 | 56 | System.out.println("Range: " + range); 57 | System.out.println("Output: " + output); 58 | System.out.println("Imports: " + keepImports); 59 | System.out.println("Sort: " + options.has(sortImportArg)); 60 | System.out.println("Lambdas: " + options.has(guessLambdasArg)); 61 | System.out.println("Locals: " + options.has(guessLocalsArg)); 62 | 63 | RangeApplierBuilder builder = new RangeApplierBuilder() 64 | .range(range) 65 | .output(output) 66 | .guessLambdas(options.has(guessLambdasArg)) 67 | .guessLocals(options.has(guessLocalsArg)) 68 | .sortImports(options.has(sortImportArg)); 69 | 70 | if (options.has(mappingArg)) 71 | { 72 | options.valuesOf(mappingArg).forEach(v -> { 73 | System.out.println("Map: " + v); 74 | builder.srg(v); 75 | }); 76 | } 77 | 78 | options.valuesOf(inputArg).forEach(v -> { 79 | System.out.println("Input: " + v); 80 | builder.input(v); 81 | }); 82 | 83 | if (options.has(excArg)) 84 | { 85 | options.valuesOf(excArg).forEach(v -> { 86 | System.out.println("Exc: " + v); 87 | builder.exc(v); 88 | }); 89 | } 90 | 91 | if (keepImports) 92 | builder.keepImports(); 93 | else 94 | builder.trimImports(); 95 | 96 | builder.build().run(); 97 | } 98 | catch (OptionException e) 99 | { 100 | parser.printHelpOn(System.out); 101 | e.printStackTrace(); 102 | } 103 | } 104 | 105 | private static List a(String... values) { 106 | return Arrays.asList(values); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/RangeExtractMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.nio.file.Path; 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | import java.util.stream.Collectors; 15 | 16 | import joptsimple.OptionException; 17 | import joptsimple.OptionParser; 18 | import joptsimple.OptionSet; 19 | import joptsimple.OptionSpec; 20 | import joptsimple.ValueConverter; 21 | import joptsimple.util.PathConverter; 22 | import net.minecraftforge.srg2source.api.RangeExtractorBuilder; 23 | import net.minecraftforge.srg2source.api.SourceVersion; 24 | 25 | public class RangeExtractMain { 26 | private static final ValueConverter PATH_CONVERTER = new PathConverter(); 27 | /* 28 | * TODO: 29 | * Support Source Directories/Inputs on the classpath. Which is the sourcepathEntries argument in 30 | * org.eclipse.jdt.core.dom.ASTParser.setEnvironment(String[], String[], String[], boolean) 31 | * This would need patching to support InputSupplier's 32 | * 33 | * Runtime detection of JDT patch, and re launch in TransformingClassloader if not detected. 34 | * 35 | * Find a way to pass RangeExtractor instance to our JDT hook so we can run multiple batches at once. 36 | */ 37 | 38 | public static void main(String[] args) throws IOException { 39 | OptionParser parser = new OptionParser(); 40 | OptionSpec libArg = parser.acceptsAll(Arrays.asList("e", "lib")).withRequiredArg().ofType(File.class); 41 | OptionSpec inputArg = parser.acceptsAll(Arrays.asList("in", "input")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER).required(); 42 | OptionSpec outputArg = parser.acceptsAll(Arrays.asList("out", "output")).withRequiredArg().withValuesConvertedBy(PATH_CONVERTER).required(); 43 | OptionSpec batch = parser.accepts("batch").withOptionalArg().ofType(Boolean.class).defaultsTo(true); 44 | OptionSpec mixins = parser.accepts("mixins").withOptionalArg().ofType(Boolean.class).defaultsTo(true); 45 | OptionSpec mixins_fatal = parser.accepts("fatalmixins").withOptionalArg().ofType(Boolean.class).defaultsTo(false); 46 | //TODO: Encoding argument 47 | OptionSpec jversionArg = parser.acceptsAll(Arrays.asList("sc", "source-compatibility")).withRequiredArg().ofType(SourceVersion.class).defaultsTo(SourceVersion.JAVA_1_8) 48 | .withValuesConvertedBy(new ValueConverter() { 49 | @Override 50 | public SourceVersion convert(String value) { 51 | return SourceVersion.parse(value); 52 | } 53 | 54 | @Override 55 | public Class valueType() { 56 | return SourceVersion.class; 57 | } 58 | 59 | @Override 60 | public String valuePattern() { 61 | List ret = new ArrayList<>(); 62 | for (SourceVersion v : SourceVersion.values()) { 63 | ret.add(v.name()); 64 | ret.add(v.getSpec()); 65 | } 66 | return ret.stream().collect(Collectors.joining(",")); 67 | } 68 | }); 69 | 70 | try { 71 | OptionSet options = parser.parse(args); 72 | boolean enableMixins = options.has(mixins) && options.valueOf(mixins); 73 | boolean fatalMixins = enableMixins && (options.has(mixins_fatal) && options.valueOf(mixins_fatal)); 74 | System.out.println("Compat: " + options.valueOf(jversionArg)); 75 | System.out.println("Output: " + options.valueOf(outputArg)); 76 | System.out.println("Batch: " + options.valueOf(batch)); 77 | System.out.println("Mixins: " + enableMixins); 78 | System.out.println("Fatal: " + fatalMixins); 79 | 80 | RangeExtractorBuilder builder = new RangeExtractorBuilder() 81 | .sourceCompatibility(options.valueOf(jversionArg)) 82 | .output(options.valueOf(outputArg)) 83 | .batch(options.valueOf(batch)); 84 | 85 | if (options.has(libArg)) { 86 | options.valuesOf(libArg).forEach(v -> { 87 | System.out.println("Lib: " + v); 88 | builder.library(v); 89 | }); 90 | } 91 | 92 | options.valuesOf(inputArg).forEach(v -> { 93 | System.out.println("Input: " + v); 94 | builder.input(v); 95 | }); 96 | 97 | if (enableMixins) 98 | builder.enableMixins(); 99 | if (fatalMixins) 100 | builder.fatalMixins(); 101 | 102 | builder.build().run(); 103 | } catch (OptionException e) { 104 | parser.printHelpOn(System.out); 105 | e.printStackTrace(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/api/InputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.api; 7 | 8 | import java.io.Closeable; 9 | import java.io.InputStream; 10 | import java.nio.charset.Charset; 11 | import java.util.List; 12 | 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | public interface InputSupplier extends Closeable { 16 | /** 17 | * The absolute path of the root entity of the given resource, be it a file or directory. 18 | * The passed resource may only be useful when there are resources from multiple roots. 19 | * @param resource The resource to find the root for 20 | * @return The absolute path of the root entity of the given resource, be it a file or directory. 21 | */ 22 | @Nullable 23 | String getRoot(String resource); 24 | 25 | /** 26 | * Opens an input stream to the specified resource. You are expected to close this stream yourself. 27 | * Returns null if the resource does not exist. 28 | * @param relPath Relative path separated with '/' and having no preceding slash. 29 | * @return InputStream for the specified path 30 | */ 31 | @Nullable 32 | InputStream getInput(String relPath); 33 | 34 | /** 35 | * Gathers all the names of all the resources with the given ending in their name. 36 | * These paths are guaranteed to be relative. This will never return null, and return an empty list instead. 37 | * @param endFilter Filter to match the end of files names 38 | * @return A list containing all files matching the filter 39 | */ 40 | List gatherAll(String endFilter); 41 | 42 | /** 43 | * Get the encoding to be used when processing this specified resource as code. 44 | * If you do not know this resource, return null. 45 | * Returning null will default to UTF_8. 46 | * 47 | * @param resouce The resource that we will be reading. 48 | * @return Encoding charset, or Null if unknown. 49 | */ 50 | @Nullable 51 | default Charset getEncoding(String resource) { 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/api/OutputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.api; 7 | 8 | import java.io.Closeable; 9 | import java.io.OutputStream; 10 | 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | public interface OutputSupplier extends Closeable { 14 | /** 15 | * Opens an output stream to the specified resource. The resource will be created if it does not already exist. You are expected to close this stream yourself. 16 | * @param relPath Relative path separated with '/' and having no preceding slash. 17 | * @return An output we can stream data to 18 | */ 19 | @Nullable 20 | public OutputStream getOutput(String relPath); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/api/SourceVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.api; 7 | 8 | import org.eclipse.jdt.core.JavaCore; 9 | 10 | public enum SourceVersion { 11 | JAVA_1_6(JavaCore.VERSION_1_6), 12 | JAVA_1_7(JavaCore.VERSION_1_7), 13 | JAVA_1_8(JavaCore.VERSION_1_8), 14 | JAVA_9(JavaCore.VERSION_9), 15 | JAVA_10(JavaCore.VERSION_10), 16 | JAVA_11(JavaCore.VERSION_11), 17 | JAVA_12(JavaCore.VERSION_12), 18 | JAVA_13(JavaCore.VERSION_13), 19 | JAVA_14(JavaCore.VERSION_14), 20 | JAVA_15(JavaCore.VERSION_15), 21 | JAVA_16(JavaCore.VERSION_16), 22 | JAVA_17(JavaCore.VERSION_17), 23 | JAVA_18(JavaCore.VERSION_18), 24 | JAVA_19(JavaCore.VERSION_19), 25 | JAVA_20(JavaCore.VERSION_20), 26 | JAVA_21(JavaCore.VERSION_21), 27 | JAVA_22(JavaCore.VERSION_22), 28 | JAVA_23(JavaCore.VERSION_23), 29 | ; 30 | 31 | private String spec; 32 | private SourceVersion(String spec) { 33 | this.spec = spec; 34 | } 35 | 36 | public String getSpec() { 37 | return spec; 38 | } 39 | 40 | public static SourceVersion parse(String name) { 41 | if (name == null) 42 | return null; 43 | 44 | for (SourceVersion v : SourceVersion.values()) { 45 | if (v.name().equals(name) || v.getSpec().equals(name)) 46 | return v; 47 | } 48 | 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/apply/ClassMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.apply; 7 | 8 | import java.util.HashMap; 9 | import java.util.Locale; 10 | import java.util.Map; 11 | 12 | import net.minecraftforge.srg2source.range.RangeMap; 13 | import net.minecraftforge.srg2source.range.entries.MetaEntry; 14 | import net.minecraftforge.srg2source.range.entries.MixinAccessorMeta; 15 | 16 | public class ClassMeta { 17 | public static ClassMeta create(RangeApplier applier, Map ranges) { 18 | ClassMeta ret = new ClassMeta(applier); 19 | for (RangeMap range : ranges.values()) { 20 | for (MetaEntry entry : range.getMeta()) { 21 | switch (entry.getType()) { 22 | case MIXIN_ACCESSOR: { 23 | MixinAccessorMeta acc = (MixinAccessorMeta)entry; 24 | ret.accessors.computeIfAbsent(acc.getOwner().getOwner(), k -> new HashMap<>()).put(acc.getOwner().getName() + acc.getOwner().getDesc(), acc); 25 | break; 26 | } 27 | } 28 | } 29 | } 30 | return ret; 31 | } 32 | 33 | private final RangeApplier applier; 34 | private final Map> accessors = new HashMap<>(); 35 | 36 | private ClassMeta(RangeApplier applier) { 37 | this.applier = applier; //TODO: Abstract this to a IMapper interface? 38 | } 39 | 40 | public String mapMethod(String owner, String name, String desc) { 41 | Map tmp = accessors.get(owner); 42 | if (tmp == null) 43 | return name; 44 | 45 | MixinAccessorMeta acc = tmp.get(name + desc); 46 | if (acc == null) 47 | return name; 48 | 49 | String tName = acc.getTarget().getName(); 50 | 51 | if (acc.getTarget().getDesc().indexOf('(') == -1) { //Fields 52 | String renamed = this.applier.mapField(acc.getTarget().getOwner(), tName); 53 | if (renamed != name) 54 | return acc.getPrefix() + renamed.substring(0, 1).toUpperCase(Locale.ROOT) + renamed.substring(1); 55 | } else { 56 | if ("".equals(tName)) { 57 | String renamed = this.applier.mapClass(acc.getTarget().getOwner()); 58 | if (renamed != acc.getTarget().getOwner()) { 59 | int idx = renamed.lastIndexOf('$'); 60 | if (idx != -1) renamed = renamed.substring(idx + 1); 61 | idx = renamed.lastIndexOf('/'); 62 | if (idx != -1) renamed = renamed.substring(idx + 1); 63 | return acc.getPrefix() + renamed.substring(0, 1).toUpperCase(Locale.ROOT) + renamed.substring(1); 64 | } 65 | } else { 66 | String renamed = this.applier.mapMethod(acc.getTarget().getOwner(), tName, acc.getTarget().getDesc()); 67 | if (renamed != name) 68 | return acc.getPrefix() + renamed.substring(0, 1).toUpperCase(Locale.ROOT) + renamed.substring(1); 69 | } 70 | } 71 | return name; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/apply/ExceptorClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.apply; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | import java.nio.charset.Charset; 13 | import java.nio.charset.StandardCharsets; 14 | import java.nio.file.Files; 15 | import java.nio.file.Path; 16 | import java.util.Collections; 17 | import java.util.HashMap; 18 | import java.util.HashSet; 19 | import java.util.List; 20 | import java.util.Map; 21 | import java.util.Set; 22 | import java.util.stream.Collectors; 23 | 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | public class ExceptorClass { 27 | public static Map create(Path path) throws IOException { 28 | return create(path, StandardCharsets.UTF_8); 29 | } 30 | public static Map create(Path path, Charset encoding) throws IOException { 31 | return create(path, encoding, null); 32 | } 33 | public static Map create(Path path, Charset encoding, Map parent) throws IOException { 34 | Map> params = new HashMap<>(); 35 | Map> exceptions = new HashMap<>(); 36 | Set known = new HashSet<>(); 37 | 38 | parent.forEach((k,v) -> { 39 | if (v.params != null) 40 | params.put(k, new HashMap<>(v.params)); 41 | if (v.exceptions != null) 42 | exceptions.put(k, new HashMap<>(v.exceptions)); 43 | known.add(k); 44 | }); 45 | 46 | try (InputStream stream = Files.newInputStream(path)) { 47 | List lines = new BufferedReader(new InputStreamReader(stream, encoding)).lines().collect(Collectors.toList()); 48 | for (int x = 0; x < lines.size(); x++) { 49 | String line = stripComment(lines.get(x)).trim(); 50 | 51 | if (line.isEmpty()) 52 | continue; 53 | 54 | int idx = line.indexOf('='); 55 | if (idx == -1) 56 | throw new IllegalArgumentException("Invalid Exceptor line #" + x + ": " + lines.get(x)); 57 | 58 | String key = line.substring(0, idx); 59 | String value = line.substring(idx + 1); 60 | 61 | idx = key.indexOf('.'); 62 | if (idx == -1 || value.isEmpty()) 63 | throw new IllegalArgumentException("Invalid Exceptor line #" + x + ": " + lines.get(x)); 64 | String cls = key.substring(0, idx); 65 | String mtd = key.substring(idx + 1); 66 | 67 | idx = value.indexOf('|'); 68 | String excps = idx == -1 ? value : value.substring(0, idx); 69 | String args = idx == -1 ? "" : value.substring(idx + 1); 70 | 71 | if (!excps.isEmpty()) 72 | exceptions.computeIfAbsent(cls, k -> new HashMap<>()).put(mtd, excps.split(",")); 73 | if (!args.isEmpty()) 74 | params.computeIfAbsent(cls, k -> new HashMap<>()).put(mtd, args.split(",")); 75 | known.add(cls); 76 | } 77 | } 78 | 79 | Map ret = new HashMap<>(); 80 | for (String cls : known) 81 | ret.put(cls, new ExceptorClass(params.get(cls), exceptions.get(cls))); 82 | 83 | return ret; 84 | } 85 | 86 | private static String stripComment(String line) { 87 | int idx = line.indexOf('#'); 88 | return idx == -1 ? line : line.substring(0, idx); 89 | } 90 | 91 | @Nullable 92 | private final Map params; 93 | @Nullable 94 | private final Map exceptions; 95 | 96 | private ExceptorClass(Map params, Map exceptions) { 97 | if (params != null && !params.isEmpty()) 98 | this.params = Collections.unmodifiableMap(params); 99 | else 100 | this.params = null; 101 | if (exceptions != null && !exceptions.isEmpty()) 102 | this.exceptions = Collections.unmodifiableMap(exceptions); 103 | else 104 | this.exceptions = null; 105 | } 106 | 107 | @Nullable 108 | public String mapParam(String name, String desc, int index, String old) { 109 | String[] args = this.params.get(name + desc); 110 | if (args == null || index >= args.length) 111 | return null; 112 | return args[index]; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/asm/CompilationUnitResolverTransfomer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.asm; 7 | 8 | import java.util.Collections; 9 | import java.util.Set; 10 | 11 | import org.objectweb.asm.Opcodes; 12 | import org.objectweb.asm.Type; 13 | import org.objectweb.asm.tree.AbstractInsnNode; 14 | import org.objectweb.asm.tree.ClassNode; 15 | import org.objectweb.asm.tree.InsnNode; 16 | import org.objectweb.asm.tree.MethodInsnNode; 17 | import org.objectweb.asm.tree.MethodNode; 18 | 19 | import cpw.mods.modlauncher.api.ITransformer; 20 | import cpw.mods.modlauncher.api.ITransformerVotingContext; 21 | import cpw.mods.modlauncher.api.TransformerVoteResult; 22 | import net.minecraftforge.srg2source.extract.RangeExtractor; 23 | 24 | /* 25 | * Eclipse's JDT does not support non file based source loocations. 26 | * We have to patch the line that loads the characters from the file to redirect into our input suppliers. 27 | * We are specifically patching this line: https://github.com/eclipse/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java#L1013 28 | * From: contents = Util.getFileCharContent(new File(sourceUnitPath), encoding); 29 | * To: contents = RangeExtractor.getFileCharContent(sourceUnitPath, encoding); 30 | */ 31 | public class CompilationUnitResolverTransfomer implements ITransformer { 32 | private static final String RESOLVE_METHOD = "resolve([Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Lorg/eclipse/jdt/core/dom/FileASTRequestor;ILjava/util/Map;I)V"; 33 | private static final String GET_CONTENTS = "org/eclipse/jdt/internal/compiler/util/Util.getFileCharContent(Ljava/io/File;Ljava/lang/String;)[C"; 34 | private static final String HOOK_OWNER = Type.getInternalName(RangeExtractor.class); 35 | private static final String HOOK_DESC = Type.getMethodDescriptor(Type.getType(char[].class), Type.getType(String.class), Type.getType(String.class)); 36 | 37 | @Override 38 | public ClassNode transform(ClassNode input, ITransformerVotingContext context) { 39 | System.out.println("Tansforming: " + input.name); 40 | 41 | MethodNode resolve = input.methods.stream().filter(e -> RESOLVE_METHOD.equals(e.name + e.desc)).findFirst().orElse(null); 42 | if (resolve == null) 43 | throw new IllegalStateException("Could not find resolve target on " + input.name + " JDT Mismatch?: " + RESOLVE_METHOD); 44 | 45 | for (int x = 0; x < resolve.instructions.size(); x++) { 46 | if (resolve.instructions.get(x).getType() == AbstractInsnNode.METHOD_INSN) { 47 | MethodInsnNode mtd = (MethodInsnNode)resolve.instructions.get(x); 48 | if (GET_CONTENTS.equals(mtd.owner + "." + mtd.name + mtd.desc)) { 49 | if ( 50 | resolve.instructions.get(x - 5).getOpcode() == Opcodes.NEW && 51 | resolve.instructions.get(x - 4).getOpcode() == Opcodes.DUP && 52 | resolve.instructions.get(x - 3).getOpcode() == Opcodes.ALOAD && 53 | resolve.instructions.get(x - 2).getOpcode() == Opcodes.INVOKESPECIAL && 54 | resolve.instructions.get(x - 1).getOpcode() == Opcodes.ALOAD 55 | ) { 56 | resolve.instructions.set(resolve.instructions.get(x - 5), new InsnNode(Opcodes.NOP)); // NEW File 57 | resolve.instructions.set(resolve.instructions.get(x - 4), new InsnNode(Opcodes.NOP)); // DUP 58 | resolve.instructions.set(resolve.instructions.get(x - 2), new InsnNode(Opcodes.NOP)); // INVOKESTATIC 59 | mtd.owner = HOOK_OWNER; 60 | mtd.desc = HOOK_DESC; 61 | System.out.println("Patched " + input.name); 62 | } else { 63 | throw new IllegalStateException("Found Util.getFileCharContents call, with unexpected context"); 64 | } 65 | } 66 | } 67 | } 68 | 69 | return input; 70 | } 71 | 72 | @Override 73 | public TransformerVoteResult castVote(ITransformerVotingContext context) { 74 | return TransformerVoteResult.YES; 75 | } 76 | 77 | @Override 78 | public Set targets() { 79 | return Collections.singleton(Target.targetClass("org.eclipse.jdt.core.dom.CompilationUnitResolver")); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/asm/RangeExtractorTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.asm; 7 | 8 | import java.util.Collections; 9 | import java.util.Set; 10 | 11 | import org.objectweb.asm.Opcodes; 12 | import org.objectweb.asm.tree.ClassNode; 13 | import org.objectweb.asm.tree.InsnNode; 14 | import org.objectweb.asm.tree.MethodNode; 15 | 16 | import cpw.mods.modlauncher.api.ITransformer; 17 | import cpw.mods.modlauncher.api.ITransformerVotingContext; 18 | import cpw.mods.modlauncher.api.TransformerVoteResult; 19 | 20 | public class RangeExtractorTransformer implements ITransformer { 21 | @Override 22 | public ClassNode transform(ClassNode input, ITransformerVotingContext context) { 23 | System.out.println("Tansforming: " + input.name); 24 | 25 | MethodNode resolve = input.methods.stream().filter(e -> "hasBeenASMPatched".equals(e.name) && "()Z".equals(e.desc)).findFirst().orElse(null); 26 | if (resolve == null) 27 | throw new IllegalStateException("Could not find hasBeenASMPatched()Z target on " + input.name + " Broken Transformer"); 28 | 29 | resolve.instructions.clear(); 30 | resolve.instructions.add(new InsnNode(Opcodes.ICONST_1)); 31 | resolve.instructions.add(new InsnNode(Opcodes.IRETURN)); 32 | 33 | System.out.println("Patched " + input.name); 34 | 35 | return input; 36 | } 37 | 38 | @Override 39 | public TransformerVoteResult castVote(ITransformerVotingContext context) { 40 | return TransformerVoteResult.YES; 41 | } 42 | 43 | @Override 44 | public Set targets() { 45 | return Collections.singleton(Target.targetClass("net.minecraftforge.srg2source.extract.RangeExtractor")); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/asm/TransformationService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.asm; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.Set; 11 | 12 | import cpw.mods.modlauncher.api.IEnvironment; 13 | import cpw.mods.modlauncher.api.ITransformationService; 14 | import cpw.mods.modlauncher.api.ITransformer; 15 | import cpw.mods.modlauncher.api.IncompatibleEnvironmentException; 16 | 17 | public class TransformationService implements ITransformationService { 18 | @Override 19 | public String name() { 20 | return "JDTPatcher"; 21 | } 22 | 23 | @Override 24 | public void initialize(IEnvironment environment) {} 25 | 26 | @Override 27 | public void onLoad(IEnvironment env, Set otherServices) throws IncompatibleEnvironmentException {} 28 | 29 | @SuppressWarnings("rawtypes") 30 | @Override 31 | public List transformers() { 32 | return Arrays.asList(new CompilationUnitResolverTransfomer(), new RangeExtractorTransformer()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/mixin/AnnotationBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.mixin; 7 | 8 | import org.eclipse.jdt.core.dom.ASTNode; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import net.minecraftforge.srg2source.extract.MixinProcessor; 12 | import net.minecraftforge.srg2source.extract.SymbolReferenceWalker; 13 | import net.minecraftforge.srg2source.range.RangeMapBuilder; 14 | 15 | public abstract class AnnotationBase implements IAnnotationProcessor { 16 | protected final MixinProcessor processor; 17 | protected final MixinAnnotation type; 18 | 19 | protected AnnotationBase(MixinProcessor processor, MixinAnnotation type) { 20 | this.processor = processor; 21 | this.type = type; 22 | } 23 | 24 | @Override 25 | public String getType() { 26 | return this.type.getType(); 27 | } 28 | 29 | protected SymbolReferenceWalker getWalker() { 30 | return processor.getWalker(); 31 | } 32 | 33 | protected RangeMapBuilder getBuilder() { 34 | return processor.getBuilder(); 35 | } 36 | 37 | protected String getFilename() { 38 | return getBuilder().getFilename(); 39 | } 40 | 41 | @Nullable 42 | protected MixinInfo getInfo(String owner) { 43 | return processor.getInfo(owner); 44 | } 45 | 46 | protected boolean error(ASTNode node, String message) { 47 | String error = "ERROR: " + getFilename() + " @ " + node.getStartPosition() + ": " + message; 48 | getWalker().error(error); 49 | if (getWalker().getExtractor().areMixinsFatal()) 50 | throw new IllegalStateException(error); 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/mixin/IAnnotationProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.mixin; 7 | 8 | import org.eclipse.jdt.core.dom.MarkerAnnotation; 9 | import org.eclipse.jdt.core.dom.NormalAnnotation; 10 | import org.eclipse.jdt.core.dom.SingleMemberAnnotation; 11 | 12 | public interface IAnnotationProcessor { 13 | String getType(); 14 | default boolean process(NormalAnnotation node) { 15 | throw new IllegalArgumentException('@' + getType() + " can not be a normal annotation, it is expected to have no value"); 16 | } 17 | 18 | default boolean process(SingleMemberAnnotation node) { 19 | throw new IllegalArgumentException('@' + getType() + " can not be a sinlge member annotation, it has no known \"value\" method"); 20 | } 21 | 22 | default boolean process(MarkerAnnotation node) { 23 | throw new IllegalArgumentException('@' + getType() + " can not be a marker annotation, it has to have a value of some kind"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/mixin/Invoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.mixin; 7 | 8 | import net.minecraftforge.srg2source.extract.MixinProcessor; 9 | 10 | /* 11 | * See Accessor, Invokers are almost identicle to Accessors except that they are designed to invoke methods specifically. 12 | * The method name can be either specified in the 'value' of the annotation. 13 | * Or it can be derived from the annotated method name. 14 | * If the annotated method starts with "call" or "invoke" followed by a capital letter. Then the target is the method name 15 | * minus the prefix, and with the first letter lowercased. Unless the entire Method name is uppercased. 16 | * 17 | * However, there is a special case for Invokers for constructors. 18 | * Since is not a valid source level name, it must be specified in the annotation. 19 | * Or it can be the fully qualified name of the class to be constructed. 20 | */ 21 | public class Invoker extends Accessor { 22 | public Invoker(MixinProcessor processor) { 23 | super(processor, MixinAnnotation.INVOKER); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/mixin/MixinAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.mixin; 7 | 8 | import java.util.Arrays; 9 | import java.util.Map; 10 | import java.util.function.Function; 11 | import java.util.stream.Collectors; 12 | 13 | import org.jetbrains.annotations.Nullable; 14 | 15 | import net.minecraftforge.srg2source.extract.MixinProcessor; 16 | 17 | public enum MixinAnnotation { 18 | ACCESSOR ("gen/Accessor", Accessor::new), 19 | INVOKER ("gen/Invoker", Invoker::new), 20 | INTERFACE ("Interface", Interface::new), 21 | /* 22 | * All these remaining types use the 'selector' system of Mixin, which is super complex 23 | * and I have no good idea right now how to manage them. 24 | */ 25 | //AT ("injection/At", At::new), 26 | //INJECT ("injection/Inject", Inject::new), 27 | //AT_CODE ("injection/InjectionPoint$AtCode", AtCode::new), 28 | //MODIFY_ARG ("injection/ModifyArg", ModifyArg::new), 29 | //MODIFY_ARGS("injection/ModifyArgs", ModifyArgs::new), 30 | //MODIFY_CONSTANT("injection/ModifyConstant", ModifyConstant::new), 31 | //MODIFY_VARIABLE("injection/ModifyVariable", ModifyVariable::new), 32 | //REDIRECT ("injection/Redirect", Redirect::new), 33 | MIXIN ("Mixin", Mixin::new), 34 | OVERWRITE ("Overwrite", Overwrite::new), 35 | SHADOW ("Shadow", Shadow::new), 36 | 37 | /* These annotations are metadata thing that we don't care about during remapping. 38 | * We should probably write tests for these for completeness, but I don't think they actually do anything. 39 | COERCE ("injection/Coerce", Coerce::new), 40 | CONSTANT ("injection/Constant", Constant::new), 41 | DEBUG ("Debug", Debug::new), 42 | DYNAMIC ("Dynamic", Dynamic::new), 43 | FINAL ("Final", Final::new), 44 | GROUP ("injection/Group", Group::new), 45 | IMPLEMENTS ("Implements", Implements::new), - This one just wraps a bunch of @Interface 46 | INTRINSIC ("Intrinsic", Intrinsic:new), 47 | MUTABLE ("Mutable", Mutable::new), 48 | UNIQUE ("Unique", Unique::new), 49 | SLICE ("injection/Slice", Slice::new), 50 | SURROGATE ("injection/Surrogate", Surrogate::new), 51 | */ 52 | 53 | /* These are markers for things that do not exist on the class path, so there is no way for us to resolve. 54 | * We just have to hope the user knows what they are doing 55 | PSUEDO ("Psuedo", Psuedo::new), 56 | SOFT_OVERRIDE("SoftOverride", SoftOverride::new), 57 | */ 58 | 59 | /* Pretty sure these are meta and not public facing 60 | ANNOTATION_TYPE("injection/struct/InjectionInfo$AnnotationType", Annotationtype::new), 61 | HANDLER_PREFIX ("injection/struct/InjectionInfo$HandlerPrefix", HandlerPrefix::new), 62 | MIXIN_INNER ("transformer/meta/MixinInner", MixinInner::new), 63 | MIXIN_MERGED ("transformer/meta/MixinMerged", MixinMerged::new), 64 | MIXIN_PROXY ("transformer/meta/MixinProxy", MixinProxy::new), 65 | MIXIN_RENAMED ("transformer/meta/MixinRenamed", MixinRenamed::new), 66 | */ 67 | ; 68 | 69 | private static final Map values = Arrays.asList(values()).stream().collect(Collectors.toMap(e -> e.getType(), e -> e)); 70 | private final String type; 71 | private final Function factory; 72 | 73 | private MixinAnnotation(String type, Function factory) { 74 | this.type = "org/spongepowered/asm/mixin/" + type; 75 | this.factory = factory; 76 | } 77 | 78 | @Nullable 79 | public static MixinAnnotation getByType(String type) { 80 | return values.get(type); 81 | } 82 | 83 | public String getType() { 84 | return this.type; 85 | } 86 | 87 | public IAnnotationProcessor newInstance(MixinProcessor processor) { 88 | return this.factory.apply(processor); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/mixin/Overwrite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.mixin; 7 | 8 | import org.eclipse.jdt.core.dom.ASTNode; 9 | import org.eclipse.jdt.core.dom.IMethodBinding; 10 | import org.eclipse.jdt.core.dom.MarkerAnnotation; 11 | import org.eclipse.jdt.core.dom.MethodDeclaration; 12 | import org.eclipse.jdt.core.dom.NormalAnnotation; 13 | 14 | import net.minecraftforge.srg2source.extract.ExtractUtil; 15 | import net.minecraftforge.srg2source.extract.MixinProcessor; 16 | 17 | /* 18 | * @Overwrite defines a method that must replace an existing method inside the targeted class. 19 | * The method name, and signature must match the targeted method. 20 | * There are three known values for this, all optional. 21 | * String constraints: When this should apply, we don't care we're just renaming. 22 | * boolean remap: Same as all other remap values, we might care, but not right now 23 | * String[] aliases: These are potential string literals holding the method name of the target method. 24 | * This we could care about, however at the current point in time we don't. 25 | * I think this is mainly for multi-target mixins, and each entry could be the name in one specific target. 26 | * Perhaps support it? If we can find a proper test case. 27 | */ 28 | public class Overwrite extends AnnotationBase { 29 | public Overwrite(MixinProcessor processor) { 30 | super(processor, MixinAnnotation.OVERWRITE); 31 | } 32 | 33 | @Override 34 | public boolean process(NormalAnnotation node) { 35 | if (node.getParent().getNodeType() != ASTNode.METHOD_DECLARATION) 36 | return error(node, "Invalid @Overwrite, Must be attached to a method declaration"); 37 | IMethodBinding method = ((MethodDeclaration)node.getParent()).resolveBinding(); 38 | 39 | /* 40 | Set aliases = new HashSet<>(); 41 | for (MemberValuePair mvp : ((List)node.values())) { 42 | switch (mvp.getName().toString()) { 43 | case "constraints": 44 | case "remap": 45 | break; 46 | case "aliases": 47 | if (mvp.getValue().getNodeType() == ASTNode.STRING_LITERAL) 48 | aliases.add((StringLiteral)mvp.getValue()); 49 | else if (mvp.getValue().getNodeType() == ASTNode.ARRAY_INITIALIZER) { 50 | ArrayInitializer init = (ArrayInitializer)mvp.getValue(); 51 | for (Expression exp : ((List)init.expressions())) { 52 | if (exp.getNodeType() == ASTNode.STRING_LITERAL) 53 | aliases.add((StringLiteral)exp); 54 | else 55 | return error(node, "Could not determine aliases value for @Overwrite annotation: " + node.toString()); 56 | } 57 | } else 58 | return error(node, "Could not determine aliases value for @Overwrite annotation: " + node.toString()); 59 | break; 60 | default: 61 | return error(node, "Unknown value entry in @Overwrite annotation: " + node.toString()); 62 | } 63 | } 64 | */ 65 | 66 | MixinInfo info = getInfo(ExtractUtil.getInternalName(getBuilder().getFilename(), method.getDeclaringClass(), node)); 67 | if (info == null) 68 | return error(node, "Could not determine @Mixin owner for @Overwrite method: " + node.toString()); 69 | info.addOverwrite(method.getName(), ExtractUtil.getDescriptor(method)); 70 | 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean process(MarkerAnnotation node) { 76 | if (node.getParent().getNodeType() != ASTNode.METHOD_DECLARATION) 77 | return error(node, "Invalid @Overwrite, Must be attached to a method declaration"); 78 | IMethodBinding method = ((MethodDeclaration)node.getParent()).resolveBinding(); 79 | MixinInfo info = getInfo(ExtractUtil.getInternalName(getBuilder().getFilename(), method.getDeclaringClass(), node)); 80 | if (info == null) 81 | return error(node, "Could not determine @Mixin owner for @Overwrite method: " + node.toString()); 82 | info.addOverwrite(method.getName(), ExtractUtil.getDescriptor(method)); 83 | return true; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/IRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range; 7 | 8 | public interface IRange { 9 | int getStart(); 10 | int getLength(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/ClassLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class ClassLiteral extends RangeEntry { 14 | 15 | public static ClassLiteral create(int start, int length, String text, String className) { 16 | return new ClassLiteral(start, length, text, className); 17 | } 18 | 19 | static ClassLiteral read(int spec, int start, int length, String text, String data) { 20 | List pts = Util.unquote(data, 1); 21 | if (pts.size() != 1) 22 | throw new IllegalArgumentException("Invalid Class Literal: " + data); 23 | return new ClassLiteral(start, length, text, pts.get(0)); 24 | } 25 | 26 | private final String className; 27 | 28 | protected ClassLiteral(int start, int length, String text, String className) { 29 | super(RangeEntry.Type.CLASS_LITERAL, start, length, text); 30 | this.className = className; 31 | } 32 | 33 | public String getClassName() { 34 | return this.className; 35 | } 36 | 37 | @Override 38 | protected String getExtraFields() { 39 | return "Internal: " + className; 40 | } 41 | 42 | @Override 43 | protected void writeInternal(Consumer out) { 44 | out.accept(Util.quote(className)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/ClassReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class ClassReference extends RangeEntry { 14 | 15 | public static ClassReference create(int start, int length, String text, String className, boolean qualified) { 16 | return new ClassReference(start, length, text, className, qualified); 17 | } 18 | 19 | static ClassReference read(int spec, int start, int length, String text, String data) { 20 | List pts = Util.unquote(data, 2); 21 | if (pts.size() != 2) 22 | throw new IllegalArgumentException("Invalid Class reference: " + data); 23 | return new ClassReference(start, length, text, pts.get(1), Boolean.parseBoolean(pts.get(0))); 24 | } 25 | 26 | private final String className; 27 | private final boolean qualified; 28 | 29 | protected ClassReference(int start, int length, String text, String className, boolean qualified) { 30 | super(RangeEntry.Type.CLASS, start, length, text); 31 | this.className = className; 32 | this.qualified = qualified; 33 | } 34 | 35 | public String getClassName() { 36 | return this.className; 37 | } 38 | 39 | public boolean isQualified() { 40 | return this.qualified; 41 | } 42 | 43 | @Override 44 | protected String getExtraFields() { 45 | return "Internal: " + className + ", Qualified: " + qualified; 46 | } 47 | 48 | @Override 49 | protected void writeInternal(Consumer out) { 50 | out.accept(Util.quote(Boolean.toString(qualified), className)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/FieldLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class FieldLiteral extends RangeEntry { 14 | public static FieldLiteral create(int start, int length, String text, String owner, String name) { 15 | return new FieldLiteral(start, length, text, owner, name); 16 | } 17 | 18 | static FieldLiteral read(int spec, int start, int length, String text, String data) { 19 | List pts = Util.unquote(data, 2); 20 | if (pts.size() != 2) 21 | throw new IllegalArgumentException("Invalid Field Literal Missing Owner and name"); 22 | return new FieldLiteral(start, length, text, pts.get(0), pts.get(1)); 23 | } 24 | 25 | private final String owner; 26 | private final String name; 27 | 28 | protected FieldLiteral(int start, int length, String text, String owner, String name) { 29 | super(RangeEntry.Type.FIELD_LITERAL, start, length, text); 30 | this.owner = owner; 31 | this.name = name; 32 | } 33 | 34 | public String getName() { 35 | return this.name; 36 | } 37 | 38 | public String getOwner() { 39 | return owner; 40 | } 41 | 42 | @Override 43 | protected String getExtraFields() { 44 | return "Owner: " + owner + ", Name: " + name; 45 | } 46 | 47 | @Override 48 | protected void writeInternal(Consumer out) { 49 | out.accept(Util.quote(owner, name)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/FieldReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.function.Consumer; 9 | 10 | public class FieldReference extends RangeEntry { 11 | public static FieldReference create(int start, int length, String text, String owner) { 12 | return new FieldReference(start, length, text, owner); 13 | } 14 | 15 | static FieldReference read(int spec, int start, int length, String text, String data) { 16 | if (data == null || data.isEmpty()) 17 | throw new IllegalArgumentException("Invalid Field reference Missing Owner"); 18 | return new FieldReference(start, length, text, data); 19 | } 20 | 21 | private final String owner; 22 | 23 | protected FieldReference(int start, int length, String text, String owner) { 24 | super(RangeEntry.Type.FIELD, start, length, text); 25 | this.owner = owner; 26 | } 27 | 28 | public String getName() { // The text is the field name.. Is there any case where this is not true? 29 | return getText(); 30 | } 31 | 32 | public String getOwner() { 33 | return owner; 34 | } 35 | 36 | @Override 37 | protected String getExtraFields() { 38 | return "Owner: " + owner; 39 | } 40 | 41 | @Override 42 | protected void writeInternal(Consumer out) { 43 | out.accept(owner); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/LocalVariableReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class LocalVariableReference extends RangeEntry { 14 | 15 | public static LocalVariableReference create(int start, int length, String text, String owner, String name, String desc, int index, String varType) { 16 | return new LocalVariableReference(start, length, text, owner, name, desc, index, varType); 17 | } 18 | 19 | static LocalVariableReference read(int spec, int start, int length, String text, String data) { 20 | List pts = Util.unquote(data, 4); 21 | if (pts.size() != 5) 22 | throw new IllegalArgumentException("Invalid Local Varaible reference: " + data); 23 | return new LocalVariableReference(start, length, text, pts.get(0), pts.get(1), pts.get(2), Integer.parseInt(pts.get(3)), pts.get(4)); 24 | } 25 | 26 | private final String owner; 27 | private final String name; 28 | private final String desc; 29 | private final int index; 30 | private final String varType; 31 | 32 | protected LocalVariableReference(int start, int length, String text, String owner, String name, String desc, int index, String varType) { 33 | super(RangeEntry.Type.LOCAL_VARIABLE, start, length, text); 34 | this.owner = owner; 35 | this.name = name; 36 | this.desc = desc; 37 | this.index = index; 38 | this.varType = varType; 39 | } 40 | 41 | public String getOwner() { 42 | return this.owner; 43 | } 44 | 45 | public String getName() { 46 | return this.name; 47 | } 48 | 49 | public String getDescriptor() { 50 | return this.desc; 51 | } 52 | 53 | public int getIndex() { 54 | return this.index; 55 | } 56 | 57 | public String getVarType() { 58 | return this.varType; 59 | } 60 | 61 | @Override 62 | protected String getExtraFields() { 63 | return "Owner: " + owner + ", Name: " + name + ", Descriptor: " + desc + ", Index: " + index + ", VarType: " + this.varType; 64 | } 65 | 66 | @Override 67 | protected void writeInternal(Consumer out) { 68 | try { 69 | out.accept(Util.quote(owner, name, desc, Integer.toString(index), varType)); 70 | } catch (Exception e) { 71 | System.currentTimeMillis(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/MetaEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.Locale; 9 | import java.util.function.Consumer; 10 | import java.util.function.Function; 11 | 12 | public abstract class MetaEntry { 13 | public enum Type { 14 | MIXIN_ACCESSOR(MixinAccessorMeta::read), 15 | ; 16 | 17 | private Function read; 18 | private Type(Function read) { 19 | this.read = read; 20 | } 21 | 22 | private MetaEntry read(String data) { 23 | return this.read.apply(data); 24 | } 25 | } 26 | 27 | public static MetaEntry read(int spec, String data) { 28 | int idx = data.indexOf(' '); 29 | String type = idx == -1 ? data : data.substring(0, idx); 30 | data = idx == -1 ? "" : data.substring(idx + 1); 31 | 32 | Type t = null; 33 | try { 34 | t = Type.valueOf(type.toUpperCase(Locale.ENGLISH)); 35 | } catch (IllegalArgumentException e) { 36 | throw new IllegalArgumentException("Unknown Meta Type: " + type); 37 | } 38 | return t.read(data); 39 | } 40 | 41 | private final Type type; 42 | protected MetaEntry(Type type) { 43 | this.type = type; 44 | } 45 | 46 | public Type getType() { 47 | return this.type; 48 | } 49 | 50 | public final void write(Consumer out) { 51 | this.writeInternal(l -> out.accept("meta " + this.type.name().toLowerCase(Locale.ENGLISH) + (l == null || l.isEmpty() ? "" : ' ' + l))); 52 | } 53 | 54 | protected abstract void writeInternal(Consumer out); 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/MethodLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class MethodLiteral extends RangeEntry { 14 | public static MethodLiteral create(int start, int length, String text, String owner, String name, String desc) { 15 | return new MethodLiteral(start, length, text, owner, name, desc); 16 | } 17 | 18 | static MethodLiteral read(int spec, int start, int length, String text, String data) { 19 | List pts = Util.unquote(data, 3); 20 | if (pts.size() != 3) 21 | throw new IllegalArgumentException("Invalid String Literal Missing Owner, name, or descriptor"); 22 | return new MethodLiteral(start, length, text, pts.get(0), pts.get(1), pts.get(2)); 23 | } 24 | 25 | private final String owner; 26 | private final String name; 27 | private final String desc; 28 | 29 | protected MethodLiteral(int start, int length, String text, String owner, String name, String desc) { 30 | super(RangeEntry.Type.METHOD_LITERAL, start, length, text); 31 | this.owner = owner; 32 | this.name = name; 33 | this.desc = desc; 34 | } 35 | 36 | public String getName() { 37 | return this.name; 38 | } 39 | 40 | public String getOwner() { 41 | return owner; 42 | } 43 | 44 | public String getDescriptor() { 45 | return desc; 46 | } 47 | 48 | @Override 49 | protected String getExtraFields() { 50 | return "Owner: " + owner + ", Name: " + name + ", Descriptor:" + desc; 51 | } 52 | 53 | @Override 54 | protected void writeInternal(Consumer out) { 55 | out.accept(Util.quote(owner, name, desc)); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/MethodReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class MethodReference extends RangeEntry { 14 | 15 | public static MethodReference create(int start, int length, String text, String owner, String name, String desc) { 16 | return new MethodReference(start, length, text, owner, name, desc); 17 | } 18 | 19 | static MethodReference read(int spec, int start, int length, String text, String data) { 20 | List pts = Util.unquote(data, 3); 21 | if (pts.size() != 3) 22 | throw new IllegalArgumentException("Invalid Method reference: " + data); 23 | return new MethodReference(start, length, text, pts.get(0), pts.get(1), pts.get(2)); 24 | } 25 | 26 | private final String owner; 27 | private final String name; 28 | private final String desc; 29 | 30 | protected MethodReference(int start, int length, String text, String owner, String name, String desc) { 31 | super(RangeEntry.Type.METHOD, start, length, text); 32 | this.owner = owner; 33 | this.name = name; 34 | this.desc = desc; 35 | } 36 | 37 | public String getOwner() { 38 | return this.owner; 39 | } 40 | 41 | public String getName() { 42 | return this.name; 43 | } 44 | 45 | public String getDescriptor() { 46 | return this.desc; 47 | } 48 | 49 | @Override 50 | protected String getExtraFields() { 51 | return "Owner: " + owner + ", Name: " + name + ", Descriptor: " + desc; 52 | } 53 | 54 | @Override 55 | protected void writeInternal(Consumer out) { 56 | out.accept(Util.quote(owner, name, desc)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/MixinAccessorMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.MemberInfo; 12 | import net.minecraftforge.srg2source.util.Util; 13 | 14 | public class MixinAccessorMeta extends MetaEntry { 15 | public static MixinAccessorMeta create(String owner, String name, String desc, String targetOwner, String targetName, String targetDesc, String prefix) { 16 | return new MixinAccessorMeta(new MemberInfo(owner, name, desc), new MemberInfo(targetOwner, targetName, targetDesc), prefix); 17 | } 18 | 19 | public static MixinAccessorMeta read(String data) { 20 | List pts = Util.unquote(data, 7); 21 | if (pts.size() != 7) 22 | throw new IllegalArgumentException("Invalid Mixin Accessor Meta: " + data); 23 | return create(pts.get(0), pts.get(1), pts.get(2), pts.get(3), pts.get(4), pts.get(5), pts.get(6)); 24 | } 25 | 26 | private final MemberInfo owner; 27 | private final MemberInfo target; 28 | private final String prefix; 29 | 30 | private MixinAccessorMeta(MemberInfo owner, MemberInfo target, String prefix) { 31 | super(MetaEntry.Type.MIXIN_ACCESSOR); 32 | this.owner = owner; 33 | this.target = target; 34 | this.prefix = prefix; 35 | } 36 | 37 | public MemberInfo getOwner() { 38 | return this.owner; 39 | } 40 | 41 | public MemberInfo getTarget() { 42 | return this.target; 43 | } 44 | 45 | public String getPrefix() { 46 | return this.prefix; 47 | } 48 | 49 | @Override 50 | protected void writeInternal(Consumer out) { 51 | out.accept(Util.quote( 52 | this.owner.getOwner(), this.owner.getName(), this.owner.getDesc(), 53 | this.target.getOwner(), this.target.getName(), this.target.getDesc(), 54 | this.prefix 55 | )); 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "MixinAccessorMeta[" + prefix +", " + this.owner + " -> " + this.target + ']'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/PackageReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.function.Consumer; 9 | 10 | public class PackageReference extends RangeEntry { 11 | public static PackageReference create(int start, int length, String name) { 12 | return new PackageReference(start, length, name); 13 | } 14 | 15 | static PackageReference read(int spec, int start, int length, String text, String data) { 16 | return new PackageReference(start, length, text); 17 | } 18 | 19 | protected PackageReference(int start, int length, String text) { 20 | super(Type.PACKAGE, start, length, text); 21 | } 22 | 23 | @Override 24 | protected void writeInternal(Consumer out) { 25 | out.accept(null); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/ParameterReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.function.Consumer; 10 | 11 | import net.minecraftforge.srg2source.util.Util; 12 | 13 | public class ParameterReference extends RangeEntry { 14 | 15 | public static ParameterReference create(int start, int length, String text, String owner, String name, String desc, int index) { 16 | return new ParameterReference(start, length, text, owner, name, desc, index); 17 | } 18 | 19 | static ParameterReference read(int spec, int start, int length, String text, String data) { 20 | List pts = Util.unquote(data, 3); 21 | if (pts.size() != 4) 22 | throw new IllegalArgumentException("Invalid Parameter reference: " + data); 23 | return new ParameterReference(start, length, text, pts.get(0), pts.get(1), pts.get(2), Integer.parseInt(pts.get(3))); 24 | } 25 | 26 | private final String owner; 27 | private final String name; 28 | private final String desc; 29 | private final int index; 30 | 31 | protected ParameterReference(int start, int length, String text, String owner, String name, String desc, int index) { 32 | super(RangeEntry.Type.PARAMETER, start, length, text); 33 | if (owner == null) 34 | System.currentTimeMillis(); 35 | this.owner = owner; 36 | this.name = name; 37 | this.desc = desc; 38 | this.index = index; 39 | } 40 | 41 | public String getOwner() { 42 | return this.owner; 43 | } 44 | 45 | public String getName() { 46 | return this.name; 47 | } 48 | 49 | public String getDescriptor() { 50 | return this.desc; 51 | } 52 | 53 | public int getIndex() { 54 | return this.index; 55 | } 56 | 57 | @Override 58 | protected String getExtraFields() { 59 | return "Owner: " + owner + ", Name: " + name + ", Descriptor: " + desc + ", Index: " + index; 60 | } 61 | 62 | @Override 63 | protected void writeInternal(Consumer out) { 64 | try { 65 | out.accept(Util.quote(owner, name, desc, Integer.toString(index))); 66 | } catch (Exception e) { 67 | System.currentTimeMillis(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/RangeEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.List; 9 | import java.util.Locale; 10 | import java.util.function.Consumer; 11 | 12 | import net.minecraftforge.srg2source.range.IRange; 13 | import net.minecraftforge.srg2source.util.Util; 14 | 15 | public abstract class RangeEntry implements IRange { 16 | public enum Type { 17 | PACKAGE(PackageReference::read), 18 | CLASS(ClassReference::read), 19 | CLASS_LITERAL(ClassLiteral::read), 20 | FIELD(FieldReference::read), 21 | FIELD_LITERAL(FieldLiteral::read), 22 | METHOD(MethodReference::read), 23 | METHOD_LITERAL(MethodLiteral::read), 24 | PARAMETER(ParameterReference::read), 25 | LOCAL_VARIABLE(LocalVariableReference::read), 26 | ; 27 | 28 | private Factory factory; 29 | private Type(Factory factory) { 30 | this.factory = factory; 31 | } 32 | private RangeEntry read(int spec, String data) { 33 | List pts = Util.unquote(data, 3); 34 | if (pts.size() < 3) 35 | throw new IllegalArgumentException("Invalid line, must contain atleast 3 parts: " + data); 36 | return this.factory.create(spec, Integer.parseInt(pts.get(0)), Integer.parseInt(pts.get(1)), pts.get(2), pts.size() == 4 ? pts.get(3) : ""); 37 | } 38 | } 39 | 40 | public static RangeEntry read(int spec, String type, String data) { 41 | Type ret = null; 42 | try { 43 | ret = Type.valueOf(type.toUpperCase(Locale.ENGLISH)); 44 | } catch (IllegalArgumentException e) { 45 | throw new IllegalArgumentException("Unknown Structure Type: " + type.toUpperCase(Locale.ENGLISH)); 46 | } 47 | return ret.read(spec, data); 48 | } 49 | 50 | private final Type type; 51 | private final int start; 52 | private final int length; 53 | private final String text; 54 | private String toString = null; 55 | 56 | protected RangeEntry(Type type, int start, int length, String text) { 57 | this.type = type; 58 | this.start = start; 59 | this.length = length; 60 | this.text = text; 61 | } 62 | 63 | public Type getType() { 64 | return this.type; 65 | } 66 | 67 | @Override 68 | public int getStart() { 69 | return this.start; 70 | } 71 | 72 | @Override 73 | public int getLength() { 74 | return this.length; 75 | } 76 | 77 | public String getText() { 78 | return this.text; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | if (toString == null) { 84 | String extra = getExtraFields(); 85 | toString = getClass().getSimpleName() + '[' + start + ':' + length + 86 | ", \"" + text + "\"" + 87 | (extra == null ? "" : ", " + extra) + 88 | "]"; 89 | } 90 | return toString; 91 | } 92 | 93 | protected String getExtraFields() { 94 | return null; 95 | } 96 | 97 | public final void write(Consumer out) { 98 | this.writeInternal(l -> out.accept(this.type.name().toLowerCase(Locale.ENGLISH) + ' ' + 99 | getStart() + ' ' + getLength() + ' ' + Util.quote(getText()) + (l == null ? "" : ' ' + l))); 100 | } 101 | 102 | protected abstract void writeInternal(Consumer out); 103 | 104 | @FunctionalInterface 105 | interface Factory { 106 | T create(int spec, int start, int length, String text, String data); 107 | } 108 | } -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/range/entries/StructuralEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.range.entries; 7 | 8 | import java.util.Locale; 9 | import java.util.function.BiFunction; 10 | import java.util.function.Consumer; 11 | 12 | import net.minecraftforge.srg2source.range.IRange; 13 | 14 | public class StructuralEntry implements IRange { 15 | public enum Type { 16 | CLASS, 17 | METHOD((me, data) -> { 18 | String[] pts = data.split(" "); 19 | if (pts.length != 4) 20 | throw new IllegalArgumentException("Missing required parts. Parts Length: " + pts.length); 21 | return new StructuralEntry(me, Integer.parseInt(pts[0]), Integer.parseInt(pts[1]), pts[2], pts[2]); 22 | }), 23 | ENUM, 24 | ANNOTATION, 25 | INTERFACE, 26 | RECORD; 27 | 28 | private BiFunction read; 29 | private Type(BiFunction read) { 30 | this.read = read; 31 | } 32 | private Type() { 33 | this((me, data) -> { 34 | String[] pts = data.split(" "); 35 | if (pts.length != 3) 36 | throw new IllegalArgumentException("Missing required parts. Parts Length: " + pts.length); 37 | return new StructuralEntry(me, Integer.parseInt(pts[0]), Integer.parseInt(pts[1]), pts[2], null); 38 | }); 39 | } 40 | 41 | private StructuralEntry read(String data) { 42 | return this.read.apply(this, data); 43 | } 44 | } 45 | 46 | public static StructuralEntry createAnnotation(int start, int length, String name) { 47 | return new StructuralEntry(Type.ANNOTATION, start, length, name, null); 48 | } 49 | 50 | public static StructuralEntry createClass(int start, int length, String name) { 51 | return new StructuralEntry(Type.CLASS, start, length, name, null); 52 | } 53 | 54 | public static StructuralEntry createEnum(int start, int length, String name) { 55 | return new StructuralEntry(Type.ENUM, start, length, name, null); 56 | } 57 | 58 | public static StructuralEntry createRecord(int start, int length, String name) { 59 | return new StructuralEntry(Type.RECORD, start, length, name, null); 60 | } 61 | 62 | public static StructuralEntry createInterface(int start, int length, String name) { 63 | return new StructuralEntry(Type.INTERFACE, start, length, name, null); 64 | } 65 | 66 | public static StructuralEntry createMethod(int start, int length, String name, String desc) { 67 | return new StructuralEntry(Type.METHOD, start, length, name, desc); 68 | } 69 | 70 | public static StructuralEntry read(int spec, String type, String data) { 71 | Type t = null; 72 | try { 73 | t = Type.valueOf(type.toUpperCase(Locale.ENGLISH)); 74 | } catch (IllegalArgumentException e) { 75 | throw new IllegalArgumentException("Unknown Structure Type: " + type); 76 | } 77 | return t.read(data); 78 | } 79 | 80 | private final Type type; 81 | private final int start; 82 | private final int length; 83 | private final String name; 84 | private final String desc; 85 | 86 | private StructuralEntry(Type type, int start, int length, String name, String desc) { 87 | this.type = type; 88 | this.start = start; 89 | this.length = length; 90 | this.name = name; 91 | this.desc = desc; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return "StructuralEntry[type: " + type.name() + 97 | ", Start: " + start + ", Len: " + length + 98 | ", Name: \"" + name + "\", Desc: \"" + desc + "\"]"; 99 | } 100 | 101 | public Type getType() { 102 | return this.type; 103 | } 104 | 105 | @Override 106 | public int getStart() { 107 | return this.start; 108 | } 109 | 110 | @Override 111 | public int getLength() { 112 | return this.length; 113 | } 114 | 115 | public String getName() { 116 | return this.name; 117 | } 118 | 119 | public String getDescriptor() { 120 | return this.desc; 121 | } 122 | 123 | public void write(Consumer out) { 124 | String line = this.type.name().toLowerCase(Locale.ENGLISH) + "def " 125 | + start + ' ' + length + ' ' + name; 126 | if (this.type == Type.METHOD) 127 | line += ' ' + desc; 128 | out.accept(line); 129 | } 130 | } -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/MemberInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util; 7 | 8 | import java.util.Objects; 9 | 10 | public class MemberInfo { 11 | private final String owner; 12 | private final String name; 13 | private final String desc; 14 | 15 | public MemberInfo(String owner, String name, String desc) { 16 | this.owner = owner; 17 | this.name = name; 18 | this.desc = desc; 19 | } 20 | 21 | public String getOwner() { 22 | return this.owner; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getDesc() { 30 | return this.desc; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return this.owner + '/' + this.name + this.desc; 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | return Objects.hash(this.owner, this.name, this.desc); 41 | } 42 | 43 | @Override 44 | public boolean equals(Object o) { 45 | if (o == null || getClass() != o.getClass()) return false; 46 | MemberInfo m = (MemberInfo)o; 47 | return Objects.equals(this.owner, m.owner) && 48 | Objects.equals(this.name, m.name) && 49 | Objects.equals(this.desc, m.desc); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util; 7 | 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.OutputStream; 12 | import java.nio.charset.Charset; 13 | import java.nio.file.Path; 14 | import java.nio.file.Paths; 15 | import java.security.MessageDigest; 16 | import java.security.NoSuchAlgorithmException; 17 | import java.util.ArrayList; 18 | import java.util.Arrays; 19 | import java.util.Formatter; 20 | import java.util.List; 21 | import java.util.stream.Collectors; 22 | import java.util.stream.IntStream; 23 | 24 | import net.minecraftforge.srg2source.ConsoleTool; 25 | 26 | public class Util { 27 | /** 28 | * Get the top-level class required to be declared in a file by its given name, if in the main tree 29 | * This is an internal name, including slashes for packages components 30 | */ 31 | public static String getTopLevelClassForFilename(String filename) { 32 | filename = filename.replace('\\', '/'); 33 | if (filename.startsWith("/")) 34 | filename = filename.substring(1); 35 | 36 | 37 | int lastSlash = filename.lastIndexOf('/'); 38 | int lastDot = filename.lastIndexOf('.'); 39 | if (lastDot > lastSlash) 40 | filename = filename.substring(0, lastDot); 41 | 42 | return filename; 43 | } 44 | 45 | public static int transferTo(InputStream input, OutputStream output) throws IOException { 46 | byte[] buf = new byte[1024]; 47 | int total = 0; 48 | int cnt; 49 | 50 | while ((cnt = input.read(buf)) > 0) { 51 | output.write(buf, 0, cnt); 52 | total += cnt; 53 | } 54 | 55 | return total; 56 | } 57 | 58 | public static byte[] readStream(InputStream input) throws IOException { 59 | ByteArrayOutputStream output = new ByteArrayOutputStream(); 60 | transferTo(input, output); 61 | return output.toByteArray(); 62 | } 63 | 64 | public static String md5(String data, Charset encoding) { 65 | try { 66 | MessageDigest md = MessageDigest.getInstance("MD5"); 67 | md.update(data.getBytes(encoding)); 68 | return hex(md.digest()); 69 | } catch (NoSuchAlgorithmException e) { 70 | throw new RuntimeException(e); 71 | } 72 | } 73 | 74 | private static String hex(byte[] data) { 75 | return IntStream.range(0, data.length).collect(StringBuilder::new, (sb,i)->new Formatter(sb).format("%02x", data[i] & 0xFF), StringBuilder::append).toString(); 76 | } 77 | 78 | /* 79 | * Quotes a string if it either has a space, or it has a " as the first character 80 | */ 81 | public static String quote(String data) { 82 | if (data.indexOf(' ') != -1 || data.indexOf('"') == 0) 83 | data = '"' + data.replaceAll("\"", "\\\\\"") + '"'; 84 | return data; 85 | } 86 | 87 | public static String quote(String... data) { 88 | return Arrays.stream(data).map(Util::quote).collect(Collectors.joining(" ")); 89 | } 90 | 91 | /* 92 | * Will attempt to remove the specified number of quoted strings from the input. 93 | * The resulting list will have no more then `count` entries. 94 | */ 95 | public static List unquote(String data, int count) { 96 | List ret = new ArrayList<>(); 97 | for (int x = 0; x < count; x++) { 98 | if (data.charAt(0) != '"') { 99 | int idx = data.indexOf(' '); 100 | if (idx == -1) 101 | break; 102 | ret.add(data.substring(0, idx)); 103 | data = data.substring(idx + 1); 104 | } else { 105 | int idx = data.indexOf('"', 1); 106 | while (idx != -1 && data.charAt(idx - 1) == '\\') 107 | idx = data.indexOf('"', idx + 1); 108 | 109 | if (idx == -1 || data.charAt(idx -1) == '\\') 110 | throw new IllegalArgumentException("Improperly quoted string: " + data); 111 | 112 | idx = data.indexOf(' ', idx); 113 | ret.add(data.substring(1, idx - 1).replace("\\\"", "\"")); 114 | if (idx == -1) { 115 | data = null; 116 | break; 117 | } else 118 | data = data.substring(idx + 1); 119 | } 120 | } 121 | if (data != null) 122 | ret.add(data); 123 | return ret; 124 | } 125 | 126 | public static Path getClassRoot(String cls) { 127 | var url = ConsoleTool.class.getResource("/" + cls.replace('.', '/') + ".class"); 128 | if (url == null) 129 | return null; 130 | String path = url.toString().substring(0, url.toString().length() - cls.length() - 6); 131 | if ("jar".equals(url.getProtocol()) && path.endsWith("!/")) 132 | path = path.substring(4, path.length() - 2); 133 | if (path.startsWith("file:")) 134 | path = path.substring(6); 135 | return Paths.get(path); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/io/ChainedInputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util.io; 7 | 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.nio.charset.Charset; 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.Collection; 14 | import java.util.List; 15 | import java.util.stream.Collectors; 16 | 17 | import net.minecraftforge.srg2source.api.InputSupplier; 18 | 19 | public class ChainedInputSupplier implements InputSupplier { 20 | private List children; 21 | 22 | public ChainedInputSupplier(InputSupplier... children) { 23 | this.children = Arrays.asList(children); 24 | } 25 | 26 | public ChainedInputSupplier(Collection children) { 27 | this.children = new ArrayList<>(children); 28 | } 29 | 30 | @Override 31 | public void close() throws IOException { 32 | for (InputSupplier child : children) 33 | child.close(); 34 | } 35 | 36 | @Override 37 | public String getRoot(String resource) { 38 | return children.stream().map(c -> c.getRoot(resource)).filter(r -> r != null).findFirst().orElse(null); 39 | } 40 | 41 | @Override 42 | public InputStream getInput(String resource) { 43 | return children.stream().map(c -> c.getInput(resource)).filter(r -> r != null).findFirst().orElse(null); 44 | } 45 | 46 | @Override 47 | public List gatherAll(String endFilter) { 48 | return children.stream().flatMap(c -> c.gatherAll(endFilter).stream()).distinct().collect(Collectors.toList()); 49 | } 50 | 51 | @Override 52 | public Charset getEncoding(String resource) { 53 | return children.stream().map(c -> c.getEncoding(resource)).filter(r -> r != null).findFirst().orElse(null); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/io/ConfLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util.io; 7 | 8 | import java.io.PrintStream; 9 | 10 | @SuppressWarnings("rawtypes") 11 | public abstract class ConfLogger { 12 | private PrintStream logger = System.out; 13 | private PrintStream errorLogger = System.err; 14 | 15 | protected void log(String s) { 16 | logger.println(s); 17 | } 18 | 19 | public void error(String s) { 20 | errorLogger.println(s); 21 | } 22 | 23 | public PrintStream getLogger() { 24 | return logger; 25 | } 26 | 27 | @SuppressWarnings("unchecked") 28 | public T setLogger(PrintStream value) { 29 | this.logger = value; 30 | return (T)this; 31 | } 32 | 33 | public PrintStream getErrorLogger() { 34 | return errorLogger; 35 | } 36 | 37 | @SuppressWarnings("unchecked") 38 | public T setErrorLogger(PrintStream errorLogger) { 39 | this.errorLogger = errorLogger; 40 | return (T)this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/io/FolderSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util.io; 7 | 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.OutputStream; 11 | import java.nio.charset.Charset; 12 | import java.nio.file.Files; 13 | import java.nio.file.Path; 14 | import java.nio.file.StandardOpenOption; 15 | import java.util.Collections; 16 | import java.util.List; 17 | import java.util.stream.Collectors; 18 | 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import net.minecraftforge.srg2source.api.InputSupplier; 22 | import net.minecraftforge.srg2source.api.OutputSupplier; 23 | 24 | public class FolderSupplier implements InputSupplier, OutputSupplier { 25 | public static FolderSupplier create(Path root, @Nullable Charset encoding) throws IOException { 26 | if (!Files.exists(root)) 27 | Files.createDirectories(root); 28 | return new FolderSupplier(root, encoding); 29 | } 30 | 31 | private final Path root; 32 | private final String sroot; 33 | @Nullable 34 | private final Charset encoding; 35 | 36 | protected FolderSupplier(Path root, @Nullable Charset encoding) { 37 | this.root = root; 38 | this.sroot = root.toAbsolutePath().toString(); 39 | this.encoding = encoding; 40 | } 41 | 42 | @Override 43 | @Nullable 44 | public OutputStream getOutput(String relPath) { 45 | try { 46 | Path target = root.resolve(relPath); 47 | if (!Files.exists(target)) { 48 | Path parent = target.getParent(); 49 | if (!Files.exists(parent)) 50 | Files.createDirectories(parent); 51 | } 52 | return Files.newOutputStream(target); 53 | } catch (IOException e) { 54 | return null; 55 | } 56 | } 57 | 58 | @Override 59 | @Nullable 60 | public InputStream getInput(String relPath) { 61 | try { 62 | Path target = root.resolve(relPath); 63 | if (!Files.exists(target)) 64 | return null; 65 | return Files.newInputStream(target, StandardOpenOption.READ); 66 | } catch (IOException e) { 67 | return null; 68 | } 69 | } 70 | 71 | @Override 72 | public List gatherAll(String endFilter) { 73 | try { 74 | return Files.walk(root).filter(Files::isRegularFile) 75 | .map(root::relativize).map(Path::toString) 76 | .filter(p -> p.endsWith(endFilter)) 77 | .sorted().collect(Collectors.toList()); 78 | } catch (IOException e) { 79 | e.printStackTrace(); 80 | return Collections.emptyList(); 81 | } 82 | } 83 | 84 | @Override 85 | public void close() throws IOException { 86 | // they are files.. what do you want me to do? 87 | } 88 | 89 | @Override 90 | @Nullable 91 | public String getRoot(String resource) { 92 | return sroot; 93 | } 94 | 95 | @Override 96 | @Nullable 97 | public Charset getEncoding(String resource) { 98 | return encoding; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/io/ZipInputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util.io; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.nio.charset.Charset; 12 | import java.nio.file.Files; 13 | import java.nio.file.Path; 14 | import java.util.HashMap; 15 | import java.util.LinkedList; 16 | import java.util.List; 17 | import java.util.Map; 18 | import java.util.zip.ZipEntry; 19 | import java.util.zip.ZipInputStream; 20 | 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | import net.minecraftforge.srg2source.api.InputSupplier; 24 | import net.minecraftforge.srg2source.util.Util; 25 | 26 | public class ZipInputSupplier implements InputSupplier { 27 | public static ZipInputSupplier create(Path path, @Nullable Charset encoding) throws IOException { 28 | Map data = new HashMap<>(); 29 | try (InputStream in = Files.newInputStream(path); 30 | ZipInputStream zin = new ZipInputStream(in)) { 31 | ZipEntry entry; 32 | while ((entry = zin.getNextEntry()) != null) 33 | data.put(entry.getName(), Util.readStream(zin)); 34 | } 35 | 36 | return new ZipInputSupplier(path.toString(), data, encoding); 37 | } 38 | 39 | private final String root; 40 | private final Map data; 41 | private final Charset encoding; 42 | 43 | private ZipInputSupplier(String root, Map data, @Nullable Charset encoding) { 44 | this.root = root; 45 | this.data = data; 46 | this.encoding = encoding; 47 | } 48 | 49 | @Override 50 | public void close() throws IOException { 51 | // useless here, since we read the zip ahead of time. 52 | // I wonder when this might actually be useful.. 53 | } 54 | 55 | @Override 56 | public InputStream getInput(String relPath) { 57 | try { 58 | return new ByteArrayInputStream(data.get(relPath)); 59 | } catch (Exception e) { 60 | return null; 61 | } 62 | } 63 | 64 | @Override 65 | public List gatherAll(String endFilter) { 66 | LinkedList out = new LinkedList(); 67 | 68 | for (String key : data.keySet()) 69 | if (key.endsWith(endFilter)) 70 | out.add(key); 71 | 72 | return out; 73 | } 74 | 75 | @Override 76 | public String getRoot(String resource) { 77 | return root; 78 | } 79 | 80 | @Override 81 | public Charset getEncoding(String resource) { 82 | return encoding; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/net/minecraftforge/srg2source/util/io/ZipOutputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.util.io; 7 | 8 | import java.io.File; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | import java.io.OutputStream; 12 | import java.nio.file.Files; 13 | import java.nio.file.Path; 14 | import java.util.zip.ZipEntry; 15 | import java.util.zip.ZipOutputStream; 16 | 17 | import net.minecraftforge.srg2source.api.OutputSupplier; 18 | 19 | public class ZipOutputSupplier implements OutputSupplier { 20 | private final ZipOutputStream zout; 21 | private EntryOutStream tempOut; 22 | 23 | public ZipOutputSupplier(File out) throws IOException { 24 | out = out.getAbsoluteFile(); //Make sure we know the parent or else getParentFile nulls 25 | if (!out.exists()) { 26 | out.getParentFile().mkdirs(); 27 | out.createNewFile(); 28 | } 29 | zout = new ZipOutputStream(new FileOutputStream(out)); 30 | } 31 | 32 | public ZipOutputSupplier(Path out) throws IOException { 33 | if (!Files.exists(out)) { 34 | Path parent = out.toAbsolutePath().getParent(); 35 | if (!Files.exists(parent)) 36 | Files.createDirectories(parent); 37 | } 38 | zout = new ZipOutputStream(Files.newOutputStream(out)); 39 | } 40 | 41 | public ZipOutputSupplier(ZipOutputStream stream) { 42 | zout = stream; 43 | } 44 | 45 | @Override 46 | public void close() throws IOException { 47 | zout.flush(); 48 | zout.close(); 49 | } 50 | 51 | @Override 52 | public OutputStream getOutput(String relPath) { 53 | if (tempOut != null) 54 | throw new IllegalStateException("You must close the previous stream before getting a new one!"); 55 | 56 | try { 57 | zout.putNextEntry(new ZipEntry(relPath)); 58 | } catch (IOException e) { 59 | return null; 60 | } 61 | 62 | return new EntryOutStream(); 63 | } 64 | 65 | private class EntryOutStream extends OutputStream { 66 | @Override 67 | public void write(int paramInt) throws IOException { 68 | zout.write(paramInt); 69 | } 70 | 71 | @Override 72 | public void close() throws IOException { 73 | zout.closeEntry(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/cpw.mods.modlauncher.api.ITransformationService: -------------------------------------------------------------------------------- 1 | net.minecraftforge.srg2source.asm.TransformationService 2 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/Java16Tests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import net.minecraftforge.srg2source.api.SourceVersion; 9 | 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | import org.junit.jupiter.api.Test; 14 | 15 | public class Java16Tests extends SimpleTestBase { 16 | @Override protected String getPrefix() { return ""; } 17 | @Override protected List getLibraries(){ return Collections.emptyList(); } 18 | @Override protected void testClass(String name) { super.testClass(name, SourceVersion.JAVA_16); } 19 | 20 | @Test public void testRecordSimple() { testClass("RecordSimple"); } 21 | @Test public void testPatternMatch() { testClass("PatternMatch"); } 22 | @Test public void testRecordCompact() { testClass("RecordCompact"); } 23 | @Test public void testRecordCanonical() { testClass("RecordCanonical"); } 24 | @Test public void testRecordComplex() { testClass("RecordComplex"); } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/MemoryOutputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.IOException; 10 | import java.io.OutputStream; 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | import net.minecraftforge.srg2source.api.OutputSupplier; 17 | 18 | public class MemoryOutputSupplier implements OutputSupplier { 19 | private List byIndex = new ArrayList(); 20 | private Map data = new HashMap(); 21 | 22 | @Override public void close() throws IOException {} 23 | 24 | @Override 25 | public OutputStream getOutput(final String relPath) 26 | { 27 | return new ByteArrayOutputStream() 28 | { 29 | public void close() throws IOException { 30 | MemoryOutputSupplier.this.data.put(relPath, this.toByteArray()); 31 | MemoryOutputSupplier.this.byIndex.add(relPath); 32 | } 33 | }; 34 | } 35 | 36 | public String get(int idx) 37 | { 38 | return new String(data.get(byIndex.get(idx))); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/MixinTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | import net.minecraftforge.srg2source.api.RangeExtractorBuilder; 14 | 15 | public abstract class MixinTests extends SimpleTestBase { 16 | @Override protected String getPrefix() { return "Mixins/" + getClass().getSimpleName(); } 17 | @Override protected List getLibraries(){ return Arrays.asList("org.spongepowered:mixin:0.8"); } 18 | @Override protected RangeExtractorBuilder customize(RangeExtractorBuilder builder) { return builder.enableMixins().fatalMixins(); }; 19 | 20 | public static class Mixin extends MixinTests { 21 | @Test public void testHardTargetSingle() { testClass("HardTargetSingle"); } 22 | @Test public void testHardTargetMulti() { testClass("HardTargetMulti"); } 23 | @Test public void testSoftTargetSingle() { testClass("SoftTargetSingle"); } 24 | @Test public void testSoftTargetMulti() { testClass("SoftTargetMulti"); } 25 | } 26 | 27 | public static class Shadow extends MixinTests { 28 | @Test public void testShadowField() { testClass("ShadowField"); } 29 | @Test public void testShadowMethod() { testClass("ShadowMethod"); } 30 | } 31 | 32 | public static class Accessor extends MixinTests { 33 | @Test public void testFieldGetterImply() { testClass("FieldGetterImply"); } 34 | @Test public void testFieldSetterImply() { testClass("FieldSetterImply"); } 35 | @Test public void testFieldGetterNamed() { testClass("FieldGetterNamed"); } 36 | @Test public void testFieldSetterNamed() { testClass("FieldSetterNamed"); } 37 | 38 | @Test public void testMethodProxyImply() { testClass("MethodProxyImply"); } 39 | @Test public void testMethodProxyNamed() { testClass("MethodProxyNamed"); } 40 | 41 | @Test public void testFactoryImply() { testClass("FactoryImply"); } 42 | @Test public void testFactoryNamed() { testClass("FactoryNamed"); } 43 | } 44 | 45 | public static class Implements extends MixinTests { 46 | @Test public void testSimpleImplements() { testClass("SimpleImplements"); } 47 | } 48 | 49 | public static class Overwrite extends MixinTests { 50 | @Test public void testOverwriteImply() { testClass("OverwriteImply"); } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/SimpleInputSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | import net.minecraftforge.srg2source.api.InputSupplier; 14 | 15 | public class SimpleInputSupplier implements InputSupplier { 16 | String resource = null; 17 | String clsName = null; 18 | 19 | public SimpleInputSupplier(String resource, String clsName) { 20 | this.resource = resource; 21 | this.clsName = clsName; 22 | } 23 | 24 | @Override public void close() throws IOException{} 25 | @Override public String getRoot(String resource) { return ""; } 26 | @Override 27 | public InputStream getInput(String relPath) 28 | { 29 | try 30 | { 31 | return getClass().getResourceAsStream("/" + resource + ".txt"); 32 | } 33 | catch (Exception e) 34 | { 35 | return null; 36 | } 37 | } 38 | 39 | @Override 40 | public List gatherAll(String endFilter) 41 | { 42 | return Arrays.asList("/" + clsName.replace('.', '/') + ".java"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/SingleTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import java.util.Collections; 9 | import java.util.List; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | public class SingleTests extends SimpleTestBase { 14 | @Override protected String getPrefix() { return ""; } 15 | @Override protected List getLibraries(){ return Collections.emptyList(); } 16 | 17 | //@Test public void testLambda() { testClass("Lambda"); } 18 | @Test public void testGenerics() { testClass("GenericClasses"); } 19 | @Test public void testAnonClass() { testClass("AnonClass" ); } 20 | @Test public void testInnerClass() { testClass("InnerClass" ); } 21 | @Test public void testLocalClass() { testClass("LocalClass" ); } 22 | @Test public void testImportSpaces() { testClass("ImportSpaces" ); } 23 | @Test public void testNestedGenerics() { testClass("NestedGenerics"); } 24 | @Test public void testPackageInfo() { testClass("PackageInfo" ); } 25 | //@Test public void testCache() { testClass("GenericClasses"); } 26 | @Test public void testWhiteSpace() { testClass("Whitespace" ); } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/net/minecraftforge/srg2source/test/WalkerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Forge Development LLC 3 | * SPDX-License-Identifier: LGPL-2.1-only 4 | */ 5 | 6 | package net.minecraftforge.srg2source.test; 7 | 8 | import java.lang.reflect.Method; 9 | import java.lang.reflect.Modifier; 10 | import java.util.Arrays; 11 | import java.util.Set; 12 | import java.util.stream.Collectors; 13 | 14 | import org.eclipse.jdt.core.dom.ASTVisitor; 15 | import org.junit.jupiter.api.Assertions; 16 | import org.junit.jupiter.api.Test; 17 | 18 | import net.minecraftforge.srg2source.extract.SymbolReferenceWalker; 19 | 20 | public class WalkerTest { 21 | private static boolean methodFilter(Method mtd) { 22 | int mods = mtd.getModifiers(); 23 | return "visit".equals(mtd.getName()) && !mtd.isSynthetic() && 24 | !Modifier.isStatic(mods) && 25 | (Modifier.isPublic(mods) || !Modifier.isProtected(mods)) && 26 | mtd.getParameterCount() == 1; 27 | } 28 | 29 | private static String toJava(Method mtd) { 30 | return "@Override " + 31 | (Modifier.isPublic(mtd.getModifiers()) ? "public" : "protected") + 32 | " boolean visit(" + 33 | mtd.getParameterTypes()[0].getSimpleName() + 34 | " node) { return true; }"; 35 | } 36 | 37 | private static Set getMethods(Class cls) { 38 | return Arrays.stream(cls.getDeclaredMethods()).filter(WalkerTest::methodFilter).map(WalkerTest::toJava).collect(Collectors.toSet()); 39 | } 40 | 41 | /** 42 | * Make sure that our visitor knows about all visit methods. 43 | * This is mainly a reminder to me and future developers to 44 | * make sure that we notice changes in the visitor when updating the library. 45 | */ 46 | @Test 47 | public void testWalkerOverrides() { 48 | Set needed = getMethods(ASTVisitor.class); 49 | Set has = getMethods(new SymbolReferenceWalker(null, null, false).getVisitor().getClass()); 50 | needed.removeAll(has); 51 | String code = needed.stream().sorted().collect(Collectors.joining("\n")); 52 | System.out.println(code); 53 | Assertions.assertTrue(needed.isEmpty(), "Missing Overrides:\n" + code); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/resources/AnonClass/original.range: -------------------------------------------------------------------------------- 1 | start 1 AnonClass.java e36cb4b5ad527aba7e7dc8754a86a095 2 | classdef 0 488 AnonClass 3 | # Start CLASS AnonClass 4 | class 13 9 AnonClass false AnonClass 5 | classdef 29 220 AnonClass$Nested 6 | # Start CLASS AnonClass$Nested 7 | class 42 6 Nested false AnonClass$Nested 8 | class 71 6 Object false java/lang/Object 9 | field 78 4 test AnonClass$Nested 10 | class 89 6 Object false java/lang/Object 11 | classdef 106 136 AnonClass$Nested$1 12 | # Start CLASS AnonClass$Nested$1 13 | class 128 6 String false java/lang/String 14 | field 135 5 value AnonClass$Nested$1 15 | methoddef 161 71 getValue ()Ljava/lang/String; 16 | # Start METHOD getValue()Ljava/lang/String; 17 | class 169 6 String false java/lang/String 18 | method 176 8 getValue AnonClass$Nested$1 getValue ()Ljava/lang/String; 19 | field 212 5 value AnonClass$Nested$1 20 | # End METHOD 21 | # End CLASS 22 | # End CLASS 23 | methoddef 255 231 main ([Ljava/lang/String;)V 24 | # Start METHOD main([Ljava/lang/String;)V 25 | method 274 4 main AnonClass main ([Ljava/lang/String;)V 26 | class 279 6 String false java/lang/String 27 | parameter 288 4 args AnonClass main ([Ljava/lang/String;)V 0 28 | class 308 6 Object false java/lang/Object 29 | local_variable 315 4 test AnonClass main ([Ljava/lang/String;)V 1 Ljava/lang/Object; 30 | class 326 6 Object false java/lang/Object 31 | classdef 343 136 AnonClass$1 32 | # Start CLASS AnonClass$1 33 | class 365 6 String false java/lang/String 34 | field 372 5 value AnonClass$1 35 | methoddef 398 71 getValue ()Ljava/lang/String; 36 | # Start METHOD getValue()Ljava/lang/String; 37 | class 406 6 String false java/lang/String 38 | method 413 8 getValue AnonClass$1 getValue ()Ljava/lang/String; 39 | field 449 5 value AnonClass$1 40 | # End METHOD 41 | # End CLASS 42 | # End METHOD 43 | # End CLASS 44 | end 45 | -------------------------------------------------------------------------------- /src/test/resources/AnonClass/original/AnonClass.txt: -------------------------------------------------------------------------------- 1 | public class AnonClass 2 | { 3 | public class Nested 4 | { 5 | private Object test = new Object() 6 | { 7 | private String value = "a"; 8 | 9 | private String getValue() { 10 | return value; 11 | } 12 | }; 13 | } 14 | 15 | public static void main(String[] args) 16 | { 17 | Object test = new Object() 18 | { 19 | private String value = "b"; 20 | 21 | private String getValue() { 22 | return value; 23 | } 24 | }; 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/GenericClasses/original.range: -------------------------------------------------------------------------------- 1 | start 1 GenericClasses.java 95d478a9e8ed24c5ab28ca4d7ca384d1 2 | classdef 68 488 GenericClasses 3 | # Start CLASS GenericClasses 4 | class 81 14 GenericClasses false GenericClasses 5 | interfacedef 102 66 GenericClasses$IFoo 6 | # Start INTERFACE GenericClasses$IFoo 7 | class 127 4 IFoo false GenericClasses$IFoo 8 | methoddef 149 13 bar (Ljava/lang/Object;)Ljava/lang/Object; 9 | # Start METHOD bar(Ljava/lang/Object;)Ljava/lang/Object; 10 | method 151 3 bar GenericClasses$IFoo bar (Ljava/lang/Object;)Ljava/lang/Object; 11 | parameter 157 3 arg GenericClasses$IFoo bar (Ljava/lang/Object;)Ljava/lang/Object; 0 12 | # End METHOD 13 | # End INTERFACE 14 | methoddef 174 114 func (Ljava/util/Collection;)Ljava/util/concurrent/Callable; 15 | # Start METHOD func(Ljava/util/Collection;)Ljava/util/concurrent/Callable; 16 | class 192 8 Callable false java/util/concurrent/Callable 17 | method 207 4 func GenericClasses func (Ljava/util/Collection;)Ljava/util/concurrent/Callable; 18 | class 212 10 Collection false java/util/Collection 19 | parameter 226 3 par GenericClasses func (Ljava/util/Collection;)Ljava/util/concurrent/Callable; 0 20 | local_variable 252 1 t GenericClasses func (Ljava/util/Collection;)Ljava/util/concurrent/Callable; 1 Ljava/util/concurrent/Callable; 21 | parameter 256 3 par GenericClasses func (Ljava/util/Collection;)Ljava/util/concurrent/Callable; 0 22 | # End METHOD 23 | methoddef 294 260 main ()V 24 | # Start METHOD main()V 25 | method 313 4 main GenericClasses main ()V 26 | class 334 4 IFoo false GenericClasses$IFoo 27 | class 339 6 String false java/lang/String 28 | local_variable 347 4 fizz GenericClasses main ()V 0 LGenericClasses$IFoo; 29 | class 358 4 IFoo false GenericClasses$IFoo 30 | class 363 6 String false java/lang/String 31 | classdef 381 110 GenericClasses$1 32 | # Start CLASS GenericClasses$1 33 | class 402 6 String false java/lang/String 34 | methoddef 395 86 bar (Ljava/lang/String;)Ljava/lang/String; 35 | # Start METHOD bar(Ljava/lang/String;)Ljava/lang/String; 36 | method 409 3 bar GenericClasses$IFoo bar (Ljava/lang/Object;)Ljava/lang/Object; 37 | class 413 6 String false java/lang/String 38 | parameter 420 3 arg GenericClasses$1 bar (Ljava/lang/String;)Ljava/lang/String; 0 39 | # End METHOD 40 | # End CLASS 41 | local_variable 501 4 fizz GenericClasses main ()V 0 LGenericClasses$IFoo; 42 | method 506 3 bar GenericClasses$IFoo bar (Ljava/lang/Object;)Ljava/lang/Object; 43 | class 527 4 IFoo false GenericClasses$IFoo 44 | local_variable 532 4 fizz GenericClasses main ()V 0 LGenericClasses$IFoo; 45 | method 538 3 bar GenericClasses$IFoo bar (Ljava/lang/Object;)Ljava/lang/Object; 46 | # End METHOD 47 | # End CLASS 48 | end 49 | -------------------------------------------------------------------------------- /src/test/resources/GenericClasses/original/GenericClasses.txt: -------------------------------------------------------------------------------- 1 | import java.util.Collection; 2 | import java.util.concurrent.Callable; 3 | 4 | public class GenericClasses 5 | { 6 | private static interface IFoo 7 | { 8 | V bar(V arg); 9 | } 10 | 11 | public > T func(Collection par) 12 | { 13 | for (T t : par); 14 | return null; 15 | } 16 | 17 | public static void main() 18 | { 19 | IFoo fizz = new IFoo() 20 | { 21 | public String bar(String arg) 22 | { 23 | return null; 24 | } 25 | }; 26 | fizz.bar(null); 27 | ((IFoo)fizz).bar(null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/resources/ImportSpaces/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 ImportSpaces.java aa1657675a24ae5f4d082034248b9f42 2 | classdef 203 151 ImportSpaces 3 | # Start CLASS ImportSpaces 4 | class 216 12 ImportSpaces false ImportSpaces 5 | methoddef 233 119 main ([Ljava/lang/String;)V 6 | # Start METHOD main([Ljava/lang/String;)V 7 | method 252 4 main ImportSpaces main ([Ljava/lang/String;)V 8 | class 257 6 String false java/lang/String 9 | parameter 266 4 args ImportSpaces main ([Ljava/lang/String;)V 0 10 | class 278 4 List false java/util/List 11 | class 283 4 Date false java/util/Date 12 | local_variable 289 3 tmp ImportSpaces main ([Ljava/lang/String;)V 1 Ljava/util/List; 13 | class 295 11 Collections false java/util/Collections 14 | method 307 9 emptyList java/util/Collections emptyList ()Ljava/util/List; 15 | class 324 4 List false java/util/List 16 | class 329 4 File false java/io/File 17 | local_variable 335 5 files ImportSpaces main ([Ljava/lang/String;)V 2 Ljava/util/List; 18 | # End METHOD 19 | # End CLASS 20 | end 21 | -------------------------------------------------------------------------------- /src/test/resources/ImportSpaces/mapped/ImportSpaces.txt: -------------------------------------------------------------------------------- 1 | //We have spaces between imports 2 | import java.util.List; 3 | 4 | import java.util.Collections; 5 | //And a comment between them 6 | import java.util.Date; //And a comment on the end 7 | 8 | import java.io.*; //Test Wildcards 9 | 10 | public class ImportSpaces { 11 | public static void main(String[] args) { 12 | List tmp = Collections.emptyList(); 13 | List files = null; 14 | } 15 | } -------------------------------------------------------------------------------- /src/test/resources/ImportSpaces/original.range: -------------------------------------------------------------------------------- 1 | start 1 ImportSpaces.java aa1657675a24ae5f4d082034248b9f42 2 | classdef 203 151 ImportSpaces 3 | # Start CLASS ImportSpaces 4 | class 216 12 ImportSpaces false ImportSpaces 5 | methoddef 233 119 main ([Ljava/lang/String;)V 6 | # Start METHOD main([Ljava/lang/String;)V 7 | method 252 4 main ImportSpaces main ([Ljava/lang/String;)V 8 | class 257 6 String false java/lang/String 9 | parameter 266 4 args ImportSpaces main ([Ljava/lang/String;)V 0 10 | class 278 4 List false java/util/List 11 | class 283 4 Date false java/util/Date 12 | local_variable 289 3 tmp ImportSpaces main ([Ljava/lang/String;)V 1 Ljava/util/List; 13 | class 295 11 Collections false java/util/Collections 14 | method 307 9 emptyList java/util/Collections emptyList ()Ljava/util/List; 15 | class 324 4 List false java/util/List 16 | class 329 4 File false java/io/File 17 | local_variable 335 5 files ImportSpaces main ([Ljava/lang/String;)V 2 Ljava/util/List; 18 | # End METHOD 19 | # End CLASS 20 | end 21 | -------------------------------------------------------------------------------- /src/test/resources/ImportSpaces/original/ImportSpaces.txt: -------------------------------------------------------------------------------- 1 | //We have spaces between imports 2 | import java.util.List; 3 | 4 | import java.util.Collections; 5 | //And a comment between them 6 | import java.util.Date; //And a comment on the end 7 | 8 | import java.io.*; //Test Wildcards 9 | 10 | public class ImportSpaces { 11 | public static void main(String[] args) { 12 | List tmp = Collections.emptyList(); 13 | List files = null; 14 | } 15 | } -------------------------------------------------------------------------------- /src/test/resources/InnerClass/original.range: -------------------------------------------------------------------------------- 1 | start 1 InnerClass.java 2a9eace10eeacad626a7062f74792b31 2 | classdef 0 467 InnerClass 3 | # Start CLASS InnerClass 4 | class 13 10 InnerClass false InnerClass 5 | classdef 30 347 InnerClass$Inner 6 | # Start CLASS InnerClass$Inner 7 | class 51 5 Inner false InnerClass$Inner 8 | classdef 71 183 InnerClass$Inner$Nested 9 | # Start CLASS InnerClass$Inner$Nested 10 | class 92 6 Nested false InnerClass$Inner$Nested 11 | class 129 6 String false java/lang/String 12 | field 136 5 value InnerClass$Inner$Nested 13 | methoddef 162 82 getValue ()Ljava/lang/String; 14 | # Start METHOD getValue()Ljava/lang/String; 15 | class 169 6 String false java/lang/String 16 | method 176 8 getValue InnerClass$Inner$Nested getValue ()Ljava/lang/String; 17 | field 224 5 value InnerClass$Inner$Nested 18 | # End METHOD 19 | # End CLASS 20 | class 272 6 String false java/lang/String 21 | field 279 5 value InnerClass$Inner 22 | methoddef 301 70 getValue ()Ljava/lang/String; 23 | # Start METHOD getValue()Ljava/lang/String; 24 | class 308 6 String false java/lang/String 25 | method 315 8 getValue InnerClass$Inner getValue ()Ljava/lang/String; 26 | field 355 5 value InnerClass$Inner 27 | # End METHOD 28 | # End CLASS 29 | methoddef 383 82 main ([Ljava/lang/String;)V 30 | # Start METHOD main([Ljava/lang/String;)V 31 | method 402 4 main InnerClass main ([Ljava/lang/String;)V 32 | class 407 6 String false java/lang/String 33 | parameter 416 4 args InnerClass main ([Ljava/lang/String;)V 0 34 | class 440 5 Inner false InnerClass$Inner 35 | method 448 8 getValue InnerClass$Inner getValue ()Ljava/lang/String; 36 | # End METHOD 37 | # End CLASS 38 | end 39 | -------------------------------------------------------------------------------- /src/test/resources/InnerClass/original/InnerClass.txt: -------------------------------------------------------------------------------- 1 | public class InnerClass 2 | { 3 | private static class Inner 4 | { 5 | private static class Nested 6 | { 7 | private String value = "a"; 8 | 9 | public String getValue() 10 | { 11 | return value; 12 | } 13 | } 14 | 15 | private String value = "b"; 16 | 17 | public String getValue() 18 | { 19 | return value; 20 | } 21 | } 22 | 23 | public static void main(String[] args) 24 | { 25 | new Inner().getValue(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/test/resources/Lambda/original.range: -------------------------------------------------------------------------------- 1 | start 1 Lambda.java 4c05901959835b10dc5618de02e3cd87 2 | classdef 0 348 Lambda 3 | # Start CLASS Lambda 4 | class 13 6 Lambda false Lambda 5 | class 40 8 Runnable false java/lang/Runnable 6 | field 49 10 workerTask Lambda 7 | methoddef 62 283 lambda[run] ()V 8 | # Start METHOD lambda[run]()V 9 | class 159 5 Error false java/lang/Error 10 | methoddef 62 283 run ()V 11 | # Start METHOD run()V 12 | This should have a reference to Error 13 | class 301 9 Throwable false java/lang/Throwable 14 | # End METHOD 15 | # End METHOD 16 | # End CLASS 17 | end 18 | -------------------------------------------------------------------------------- /src/test/resources/Lambda/original/Lambda.txt: -------------------------------------------------------------------------------- 1 | public class Lambda 2 | { 3 | private final Runnable workerTask = () -> 4 | { 5 | try 6 | { 7 | try 8 | { 9 | } 10 | catch (Error ignored) //These two error handlers have to have the same name, AND be in a lambda 11 | { 12 | } 13 | } 14 | catch (Throwable ignored) 15 | { 16 | } 17 | }; 18 | } -------------------------------------------------------------------------------- /src/test/resources/LocalClass/original.range: -------------------------------------------------------------------------------- 1 | start 1 LocalClass.java b16cc963b787387f46824bf70a5ed60e 2 | classdef 0 996 LocalClass 3 | # Start CLASS LocalClass 4 | class 13 10 LocalClass false LocalClass 5 | classdef 30 287 LocalClass$Nested 6 | # Start CLASS LocalClass$Nested 7 | class 43 6 Nested false LocalClass$Nested 8 | methoddef 64 247 test ()V 9 | # Start METHOD test()V 10 | method 77 4 test LocalClass$Nested test ()V 11 | classdef 106 195 LocalClass$Nested$1Local 12 | # Start CLASS LocalClass$Nested$1Local 13 | class 112 5 Local false LocalClass$Nested$1Local 14 | class 156 6 String false java/lang/String 15 | field 163 5 value LocalClass$Nested$1Local 16 | methoddef 193 94 getValue ()Ljava/lang/String; 17 | # Start METHOD getValue()Ljava/lang/String; 18 | class 200 6 String false java/lang/String 19 | method 207 8 getValue LocalClass$Nested$1Local getValue ()Ljava/lang/String; 20 | field 263 5 value LocalClass$Nested$1Local 21 | # End METHOD 22 | # End CLASS 23 | # End METHOD 24 | # End CLASS 25 | methoddef 323 239 funA ()V 26 | # Start METHOD funA()V 27 | method 335 4 funA LocalClass funA ()V 28 | classdef 356 167 LocalClass$1Local 29 | # Start CLASS LocalClass$1Local 30 | class 362 5 Local false LocalClass$1Local 31 | class 398 6 String false java/lang/String 32 | field 405 5 value LocalClass$1Local 33 | methoddef 431 82 getValue ()Ljava/lang/String; 34 | # Start METHOD getValue()Ljava/lang/String; 35 | class 438 6 String false java/lang/String 36 | method 445 8 getValue LocalClass$1Local getValue ()Ljava/lang/String; 37 | field 493 5 value LocalClass$1Local 38 | # End METHOD 39 | # End CLASS 40 | class 537 5 Local false LocalClass$1Local 41 | method 545 8 getValue LocalClass$1Local getValue ()Ljava/lang/String; 42 | # End METHOD 43 | methoddef 568 239 funB ()V 44 | # Start METHOD funB()V 45 | method 580 4 funB LocalClass funB ()V 46 | classdef 601 167 LocalClass$2Local 47 | # Start CLASS LocalClass$2Local 48 | class 607 5 Local false LocalClass$2Local 49 | class 643 6 String false java/lang/String 50 | field 650 5 value LocalClass$2Local 51 | methoddef 676 82 getValue ()Ljava/lang/String; 52 | # Start METHOD getValue()Ljava/lang/String; 53 | class 683 6 String false java/lang/String 54 | method 690 8 getValue LocalClass$2Local getValue ()Ljava/lang/String; 55 | field 738 5 value LocalClass$2Local 56 | # End METHOD 57 | # End CLASS 58 | class 782 5 Local false LocalClass$2Local 59 | method 790 8 getValue LocalClass$2Local getValue ()Ljava/lang/String; 60 | # End METHOD 61 | interfacedef 813 181 LocalClass$ITest 62 | # Start INTERFACE LocalClass$ITest 63 | class 830 5 ITest false LocalClass$ITest 64 | methoddef 846 142 inFoo ()V 65 | # Start METHOD inFoo()V 66 | method 859 5 inFoo LocalClass$ITest inFoo ()V 67 | classdef 879 67 LocalClass$ITest$1Target 68 | # Start CLASS LocalClass$ITest$1Target 69 | class 885 6 Target false LocalClass$ITest$1Target 70 | methoddef 909 25 test ()Ljava/lang/Object; 71 | # Start METHOD test()Ljava/lang/Object; 72 | method 911 4 test LocalClass$ITest$1Target test ()Ljava/lang/Object; 73 | # End METHOD 74 | # End CLASS 75 | class 961 6 Target false LocalClass$ITest$1Target 76 | class 968 6 String false java/lang/String 77 | # End METHOD 78 | # End INTERFACE 79 | # End CLASS 80 | end 81 | -------------------------------------------------------------------------------- /src/test/resources/LocalClass/original/LocalClass.txt: -------------------------------------------------------------------------------- 1 | public class LocalClass 2 | { 3 | public class Nested 4 | { 5 | private void test() 6 | { 7 | class Local 8 | { 9 | private String value = "b"; 10 | 11 | public String getValue() 12 | { 13 | return value; 14 | } 15 | } 16 | } 17 | } 18 | 19 | public void funA() 20 | { 21 | class Local 22 | { 23 | private String value = "a"; 24 | 25 | public String getValue() 26 | { 27 | return value; 28 | } 29 | } 30 | 31 | new Local().getValue(); 32 | } 33 | 34 | public void funB() 35 | { 36 | class Local 37 | { 38 | private String value = "a"; 39 | 40 | public String getValue() 41 | { 42 | return value; 43 | } 44 | } 45 | 46 | new Local().getValue(); 47 | } 48 | 49 | public interface ITest { 50 | default void inFoo() { 51 | class Target { 52 | T test() { return null; } 53 | } 54 | new Target(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryImply/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FactoryImply.java e6e5fd5f1c438486a9931a231fe2c553 2 | # Start Meta 3 | meta mixin_accessor FactoryImply newArrayList (I)Ljava/util/ArrayList; java/util/ArrayList (I)V new 4 | meta mixin_accessor FactoryImply createArrayList (I)Ljava/util/ArrayList; java/util/ArrayList (I)V create 5 | # End Meta 6 | classdef 120 273 FactoryImply 7 | # Start CLASS FactoryImply 8 | class 121 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 127 9 ArrayList false java/util/ArrayList 10 | class 157 12 FactoryImply false FactoryImply 11 | methoddef 174 60 newArrayList (I)Ljava/util/ArrayList; 12 | # Start METHOD newArrayList(I)Ljava/util/ArrayList; 13 | class 175 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 14 | class 202 9 ArrayList false java/util/ArrayList 15 | method 212 12 newArrayList FactoryImply newArrayList (I)Ljava/util/ArrayList; 16 | parameter 229 3 cap FactoryImply newArrayList (I)Ljava/util/ArrayList; 0 17 | # End METHOD 18 | methoddef 240 79 createArrayList (I)Ljava/util/ArrayList; 19 | # Start METHOD createArrayList(I)Ljava/util/ArrayList; 20 | class 241 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 21 | method 249 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 22 | class 283 9 ArrayList false java/util/ArrayList 23 | method 293 15 createArrayList FactoryImply createArrayList (I)Ljava/util/ArrayList; 24 | parameter 313 4 size FactoryImply createArrayList (I)Ljava/util/ArrayList; 0 25 | # End METHOD 26 | methoddef 325 66 test ()V 27 | # Start METHOD test()V 28 | method 330 4 test FactoryImply test ()V 29 | method 345 12 newArrayList FactoryImply newArrayList (I)Ljava/util/ArrayList; 30 | method 368 15 createArrayList FactoryImply createArrayList (I)Ljava/util/ArrayList; 31 | # End METHOD 32 | # End CLASS 33 | end 34 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryImply/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/Vector -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryImply/mapped/FactoryImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.ArrayList; 5 | 6 | @Mixin(ArrayList.class) 7 | public class FactoryImply { 8 | @Invoker 9 | private abstract ArrayList newArrayList(int cap); 10 | 11 | @Invoker(remap = false) 12 | private abstract ArrayList createArrayList(int size); 13 | 14 | void test() { 15 | this.newArrayList(1); 16 | this.createArrayList(2); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryImply/original.range: -------------------------------------------------------------------------------- 1 | start 1 FactoryImply.java 6b4ee5d059bee933ee1627145ad15e8f 2 | # Start Meta 3 | meta mixin_accessor FactoryImply newVector (I)Ljava/util/Vector; java/util/Vector (I)V new 4 | meta mixin_accessor FactoryImply createVector (I)Ljava/util/Vector; java/util/Vector (I)V create 5 | # End Meta 6 | classdef 117 252 FactoryImply 7 | # Start CLASS FactoryImply 8 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 124 6 Vector false java/util/Vector 10 | class 151 12 FactoryImply false FactoryImply 11 | methoddef 168 54 newVector (I)Ljava/util/Vector; 12 | # Start METHOD newVector(I)Ljava/util/Vector; 13 | class 169 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 14 | class 196 6 Vector false java/util/Vector 15 | method 203 9 newVector FactoryImply newVector (I)Ljava/util/Vector; 16 | parameter 217 3 cap FactoryImply newVector (I)Ljava/util/Vector; 0 17 | # End METHOD 18 | methoddef 228 73 createVector (I)Ljava/util/Vector; 19 | # Start METHOD createVector(I)Ljava/util/Vector; 20 | class 229 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 21 | method 237 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 22 | class 271 6 Vector false java/util/Vector 23 | method 278 12 createVector FactoryImply createVector (I)Ljava/util/Vector; 24 | parameter 295 4 size FactoryImply createVector (I)Ljava/util/Vector; 0 25 | # End METHOD 26 | methoddef 307 60 test ()V 27 | # Start METHOD test()V 28 | method 312 4 test FactoryImply test ()V 29 | method 327 9 newVector FactoryImply newVector (I)Ljava/util/Vector; 30 | method 347 12 createVector FactoryImply createVector (I)Ljava/util/Vector; 31 | # End METHOD 32 | # End CLASS 33 | end 34 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryImply/original/FactoryImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class FactoryImply { 8 | @Invoker 9 | private abstract Vector newVector(int cap); 10 | 11 | @Invoker(remap = false) 12 | private abstract Vector createVector(int size); 13 | 14 | void test() { 15 | this.newVector(1); 16 | this.createVector(2); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryNamed/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FactoryNamed.java ce2a5619bd175dea558f00eadbf84646 2 | classdef 120 507 FactoryNamed 3 | # Start CLASS FactoryNamed 4 | class 121 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 127 9 ArrayList false java/util/ArrayList 6 | class 157 12 FactoryNamed false FactoryNamed 7 | methoddef 174 64 newFoo (I)Ljava/util/ArrayList; 8 | # Start METHOD newFoo(I)Ljava/util/ArrayList; 9 | class 175 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 10 | class 212 9 ArrayList false java/util/ArrayList 11 | method 222 6 newFoo FactoryNamed newFoo (I)Ljava/util/ArrayList; 12 | parameter 233 3 cap FactoryNamed newFoo (I)Ljava/util/ArrayList; 0 13 | # End METHOD 14 | methoddef 244 77 newBar (I)Ljava/util/ArrayList; 15 | # Start METHOD newBar(I)Ljava/util/ArrayList; 16 | class 245 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 17 | class_literal 253 21 "\"java.util.ArrayList\"" java/util/ArrayList 18 | class 295 9 ArrayList false java/util/ArrayList 19 | method 305 6 newBar FactoryNamed newBar (I)Ljava/util/ArrayList; 20 | parameter 316 3 cap FactoryNamed newBar (I)Ljava/util/ArrayList; 0 21 | # End METHOD 22 | methoddef 327 91 createFoo (I)Ljava/util/ArrayList; 23 | # Start METHOD createFoo(I)Ljava/util/ArrayList; 24 | class 328 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 25 | method 336 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 26 | method 351 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 27 | class 388 9 ArrayList false java/util/ArrayList 28 | method 398 9 createFoo FactoryNamed createFoo (I)Ljava/util/ArrayList; 29 | parameter 412 4 size FactoryNamed createFoo (I)Ljava/util/ArrayList; 0 30 | # End METHOD 31 | methoddef 424 104 createBar (I)Ljava/util/ArrayList; 32 | # Start METHOD createBar(I)Ljava/util/ArrayList; 33 | class 425 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 34 | method 433 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 35 | method 448 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 36 | class_literal 456 21 "\"java/util/ArrayList\"" java/util/ArrayList 37 | class 498 9 ArrayList false java/util/ArrayList 38 | method 508 9 createBar FactoryNamed createBar (I)Ljava/util/ArrayList; 39 | parameter 522 4 size FactoryNamed createBar (I)Ljava/util/ArrayList; 0 40 | # End METHOD 41 | methoddef 534 91 test ()V 42 | # Start METHOD test()V 43 | method 539 4 test FactoryNamed test ()V 44 | method 554 6 newFoo FactoryNamed newFoo (I)Ljava/util/ArrayList; 45 | method 571 6 newBar FactoryNamed newBar (I)Ljava/util/ArrayList; 46 | method 588 9 createFoo FactoryNamed createFoo (I)Ljava/util/ArrayList; 47 | method 608 9 createBar FactoryNamed createBar (I)Ljava/util/ArrayList; 48 | # End METHOD 49 | # End CLASS 50 | end 51 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryNamed/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/Vector -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryNamed/mapped/FactoryNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.ArrayList; 5 | 6 | @Mixin(ArrayList.class) 7 | public class FactoryNamed { 8 | @Invoker("") 9 | private abstract ArrayList newFoo(int cap); 10 | 11 | @Invoker("java.util.ArrayList") 12 | private abstract ArrayList newBar(int cap); 13 | 14 | @Invoker(remap = false, value = "") 15 | private abstract ArrayList createFoo(int size); 16 | 17 | @Invoker(remap = false, value = "java/util/ArrayList") 18 | private abstract ArrayList createBar(int size); 19 | 20 | void test() { 21 | this.newFoo(1); 22 | this.newBar(2); 23 | this.createFoo(3); 24 | this.createBar(4); 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryNamed/original.range: -------------------------------------------------------------------------------- 1 | start 1 FactoryNamed.java 3fc699d47368e3219b50ef9be10a145e 2 | classdef 117 486 FactoryNamed 3 | # Start CLASS FactoryNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 12 FactoryNamed false FactoryNamed 7 | methoddef 168 61 newFoo (I)Ljava/util/Vector; 8 | # Start METHOD newFoo(I)Ljava/util/Vector; 9 | class 169 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 10 | class 206 6 Vector false java/util/Vector 11 | method 213 6 newFoo FactoryNamed newFoo (I)Ljava/util/Vector; 12 | parameter 224 3 cap FactoryNamed newFoo (I)Ljava/util/Vector; 0 13 | # End METHOD 14 | methoddef 235 71 newBar (I)Ljava/util/Vector; 15 | # Start METHOD newBar(I)Ljava/util/Vector; 16 | class 236 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 17 | class_literal 244 18 "\"java.util.Vector\"" java/util/Vector 18 | class 283 6 Vector false java/util/Vector 19 | method 290 6 newBar FactoryNamed newBar (I)Ljava/util/Vector; 20 | parameter 301 3 cap FactoryNamed newBar (I)Ljava/util/Vector; 0 21 | # End METHOD 22 | methoddef 312 88 createFoo (I)Ljava/util/Vector; 23 | # Start METHOD createFoo(I)Ljava/util/Vector; 24 | class 313 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 25 | method 321 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 26 | method 336 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 27 | class 373 6 Vector false java/util/Vector 28 | method 380 9 createFoo FactoryNamed createFoo (I)Ljava/util/Vector; 29 | parameter 394 4 size FactoryNamed createFoo (I)Ljava/util/Vector; 0 30 | # End METHOD 31 | methoddef 406 98 createBar (I)Ljava/util/Vector; 32 | # Start METHOD createBar(I)Ljava/util/Vector; 33 | class 407 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 34 | method 415 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 35 | method 430 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 36 | class_literal 438 18 "\"java/util/Vector\"" java/util/Vector 37 | class 477 6 Vector false java/util/Vector 38 | method 484 9 createBar FactoryNamed createBar (I)Ljava/util/Vector; 39 | parameter 498 4 size FactoryNamed createBar (I)Ljava/util/Vector; 0 40 | # End METHOD 41 | methoddef 510 91 test ()V 42 | # Start METHOD test()V 43 | method 515 4 test FactoryNamed test ()V 44 | method 530 6 newFoo FactoryNamed newFoo (I)Ljava/util/Vector; 45 | method 547 6 newBar FactoryNamed newBar (I)Ljava/util/Vector; 46 | method 564 9 createFoo FactoryNamed createFoo (I)Ljava/util/Vector; 47 | method 584 9 createBar FactoryNamed createBar (I)Ljava/util/Vector; 48 | # End METHOD 49 | # End CLASS 50 | end 51 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FactoryNamed/original/FactoryNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class FactoryNamed { 8 | @Invoker("") 9 | private abstract Vector newFoo(int cap); 10 | 11 | @Invoker("java.util.Vector") 12 | private abstract Vector newBar(int cap); 13 | 14 | @Invoker(remap = false, value = "") 15 | private abstract Vector createFoo(int size); 16 | 17 | @Invoker(remap = false, value = "java/util/Vector") 18 | private abstract Vector createBar(int size); 19 | 20 | void test() { 21 | this.newFoo(1); 22 | this.newBar(2); 23 | this.createFoo(3); 24 | this.createBar(4); 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterImply/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FieldGetterImply.java f25fcc4f135507bd42136884417b27f3 2 | # Start Meta 3 | meta mixin_accessor FieldGetterImply getCapacityIncrement ()I java/util/Vector capacityIncrement I get 4 | meta mixin_accessor FieldGetterImply getElementCount ()I java/util/Vector elementCount I get 5 | meta mixin_accessor FieldGetterImply isCapacityIncrement ()I java/util/Vector capacityIncrement I is 6 | # End Meta 7 | classdef 117 422 FieldGetterImply 8 | # Start CLASS FieldGetterImply 9 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 10 | class 124 6 Vector false java/util/Vector 11 | class 151 16 FieldGetterImply false FieldGetterImply 12 | methoddef 172 55 getCapacityIncrement ()I 13 | # Start METHOD getCapacityIncrement()I 14 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 15 | method 204 20 getCapacityIncrement FieldGetterImply getCapacityIncrement ()I 16 | # End METHOD 17 | methoddef 233 50 getElementCount ()I 18 | # Start METHOD getElementCount()I 19 | class 234 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 20 | method 265 15 getElementCount FieldGetterImply getElementCount ()I 21 | # End METHOD 22 | methoddef 289 54 isCapacityIncrement ()I 23 | # Start METHOD isCapacityIncrement()I 24 | class 290 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 25 | method 321 19 isCapacityIncrement FieldGetterImply isCapacityIncrement ()I 26 | # End METHOD 27 | methoddef 422 115 test ()V 28 | # Start METHOD test()V 29 | method 434 4 test FieldGetterImply test ()V 30 | local_variable 451 1 x FieldGetterImply test ()V 0 I 31 | method 459 20 getCapacityIncrement FieldGetterImply getCapacityIncrement ()I 32 | method 487 15 getElementCount FieldGetterImply getElementCount ()I 33 | method 511 19 isCapacityIncrement FieldGetterImply isCapacityIncrement ()I 34 | # End METHOD 35 | # End CLASS 36 | end 37 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterImply/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | capacityIncrement elementCount 3 | elementCount capacityIncrement -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterImply/mapped/FieldGetterImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldGetterImply { 7 | @Accessor 8 | public abstract int getCapacityIncrement(); 9 | 10 | @Accessor 11 | public abstract int getElementCount(); 12 | 13 | @Accessor 14 | public abstract int isCapacityIncrement(); // 'is' is usually for booleans, but Vector doesn't have a boolean field 15 | 16 | public void test() { 17 | int x = 18 | getCapacityIncrement() + 19 | getElementCount() + 20 | isCapacityIncrement(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterImply/original.range: -------------------------------------------------------------------------------- 1 | start 1 FieldGetterImply.java db6ad4454a7c577a49bef2ec1ad39ce3 2 | # Start Meta 3 | meta mixin_accessor FieldGetterImply getElementCount ()I java/util/Vector elementCount I get 4 | meta mixin_accessor FieldGetterImply getCapacityIncrement ()I java/util/Vector capacityIncrement I get 5 | meta mixin_accessor FieldGetterImply isElementCount ()I java/util/Vector elementCount I is 6 | # End Meta 7 | classdef 117 412 FieldGetterImply 8 | # Start CLASS FieldGetterImply 9 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 10 | class 124 6 Vector false java/util/Vector 11 | class 151 16 FieldGetterImply false FieldGetterImply 12 | methoddef 172 50 getElementCount ()I 13 | # Start METHOD getElementCount()I 14 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 15 | method 204 15 getElementCount FieldGetterImply getElementCount ()I 16 | # End METHOD 17 | methoddef 228 55 getCapacityIncrement ()I 18 | # Start METHOD getCapacityIncrement()I 19 | class 229 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 20 | method 260 20 getCapacityIncrement FieldGetterImply getCapacityIncrement ()I 21 | # End METHOD 22 | methoddef 289 49 isElementCount ()I 23 | # Start METHOD isElementCount()I 24 | class 290 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 25 | method 321 14 isElementCount FieldGetterImply isElementCount ()I 26 | # End METHOD 27 | methoddef 417 110 test ()V 28 | # Start METHOD test()V 29 | method 429 4 test FieldGetterImply test ()V 30 | local_variable 446 1 x FieldGetterImply test ()V 0 I 31 | method 454 15 getElementCount FieldGetterImply getElementCount ()I 32 | method 477 20 getCapacityIncrement FieldGetterImply getCapacityIncrement ()I 33 | method 506 14 isElementCount FieldGetterImply isElementCount ()I 34 | # End METHOD 35 | # End CLASS 36 | end 37 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterImply/original/FieldGetterImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldGetterImply { 7 | @Accessor 8 | public abstract int getElementCount(); 9 | 10 | @Accessor 11 | public abstract int getCapacityIncrement(); 12 | 13 | @Accessor 14 | public abstract int isElementCount(); // 'is' is usually for booleans, but Vector doesn't have a boolean field 15 | 16 | public void test() { 17 | int x = 18 | getElementCount() + 19 | getCapacityIncrement() + 20 | isElementCount(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterNamed/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FieldGetterNamed.java d026e8565d1ed07ebaafde4697565781 2 | classdef 117 422 FieldGetterNamed 3 | # Start CLASS FieldGetterNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 FieldGetterNamed false FieldGetterNamed 7 | methoddef 172 68 getSomething ()I 8 | # Start METHOD getSomething()I 9 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 10 | field_literal 182 19 "\"capacityIncrement\"" java/util/Vector capacityIncrement 11 | method 225 12 getSomething FieldGetterNamed getSomething ()I 12 | # End METHOD 13 | methoddef 246 59 getOther ()I 14 | # Start METHOD getOther()I 15 | class 247 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 16 | field_literal 256 14 "\"elementCount\"" java/util/Vector elementCount 17 | method 294 8 getOther FieldGetterNamed getOther ()I 18 | # End METHOD 19 | methoddef 311 61 isBob ()I 20 | # Start METHOD isBob()I 21 | class 312 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 22 | field_literal 321 19 "\"capacityIncrement\"" java/util/Vector capacityIncrement 23 | method 364 5 isBob FieldGetterNamed isBob ()I 24 | # End METHOD 25 | methoddef 451 86 test ()V 26 | # Start METHOD test()V 27 | method 463 4 test FieldGetterNamed test ()V 28 | local_variable 480 1 x FieldGetterNamed test ()V 0 I 29 | method 488 12 getSomething FieldGetterNamed getSomething ()I 30 | method 508 8 getOther FieldGetterNamed getOther ()I 31 | method 525 5 isBob FieldGetterNamed isBob ()I 32 | # End METHOD 33 | # End CLASS 34 | end 35 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterNamed/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | capacityIncrement elementCount 3 | elementCount capacityIncrement -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterNamed/mapped/FieldGetterNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldGetterNamed { 7 | @Accessor("capacityIncrement") 8 | public abstract int getSomething(); 9 | 10 | @Accessor("elementCount") 11 | public abstract int getOther(); 12 | 13 | @Accessor("capacityIncrement") 14 | public abstract int isBob(); // 'is' is usually for booleans, but Vector doesn't have a boolean field 15 | 16 | public void test() { 17 | int x = 18 | getSomething() + 19 | getOther() + 20 | isBob(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterNamed/original.range: -------------------------------------------------------------------------------- 1 | start 1 FieldGetterNamed.java 20cff37e0f49578e7e9d8f002880174b 2 | classdef 117 417 FieldGetterNamed 3 | # Start CLASS FieldGetterNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 FieldGetterNamed false FieldGetterNamed 7 | methoddef 172 63 getSomething ()I 8 | # Start METHOD getSomething()I 9 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 10 | field_literal 182 14 "\"elementCount\"" java/util/Vector elementCount 11 | method 220 12 getSomething FieldGetterNamed getSomething ()I 12 | # End METHOD 13 | methoddef 241 64 getOther ()I 14 | # Start METHOD getOther()I 15 | class 242 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 16 | field_literal 251 19 "\"capacityIncrement\"" java/util/Vector capacityIncrement 17 | method 294 8 getOther FieldGetterNamed getOther ()I 18 | # End METHOD 19 | methoddef 311 56 isBob ()I 20 | # Start METHOD isBob()I 21 | class 312 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 22 | field_literal 321 14 "\"elementCount\"" java/util/Vector elementCount 23 | method 359 5 isBob FieldGetterNamed isBob ()I 24 | # End METHOD 25 | methoddef 446 86 test ()V 26 | # Start METHOD test()V 27 | method 458 4 test FieldGetterNamed test ()V 28 | local_variable 475 1 x FieldGetterNamed test ()V 0 I 29 | method 483 12 getSomething FieldGetterNamed getSomething ()I 30 | method 503 8 getOther FieldGetterNamed getOther ()I 31 | method 520 5 isBob FieldGetterNamed isBob ()I 32 | # End METHOD 33 | # End CLASS 34 | end 35 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldGetterNamed/original/FieldGetterNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldGetterNamed { 7 | @Accessor("elementCount") 8 | public abstract int getSomething(); 9 | 10 | @Accessor("capacityIncrement") 11 | public abstract int getOther(); 12 | 13 | @Accessor("elementCount") 14 | public abstract int isBob(); // 'is' is usually for booleans, but Vector doesn't have a boolean field 15 | 16 | public void test() { 17 | int x = 18 | getSomething() + 19 | getOther() + 20 | isBob(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterImply/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FieldSetterImply.java 59f2c5fb1522ef7357a7e0585c93408b 2 | # Start Meta 3 | meta mixin_accessor FieldSetterImply setCapacityIncrement (I)V java/util/Vector capacityIncrement I set 4 | meta mixin_accessor FieldSetterImply setElementCount (I)V java/util/Vector elementCount I set 5 | # End Meta 6 | classdef 117 268 FieldSetterImply 7 | # Start CLASS FieldSetterImply 8 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 124 6 Vector false java/util/Vector 10 | class 151 16 FieldSetterImply false FieldSetterImply 11 | methoddef 172 65 setCapacityIncrement (I)V 12 | # Start METHOD setCapacityIncrement(I)V 13 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 14 | method 205 20 setCapacityIncrement FieldSetterImply setCapacityIncrement (I)V 15 | parameter 230 5 value FieldSetterImply setCapacityIncrement (I)V 0 16 | # End METHOD 17 | methoddef 243 60 setElementCount (I)V 18 | # Start METHOD setElementCount(I)V 19 | class 244 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 20 | method 276 15 setElementCount FieldSetterImply setElementCount (I)V 21 | parameter 296 5 value FieldSetterImply setElementCount (I)V 0 22 | # End METHOD 23 | methoddef 309 74 test ()V 24 | # Start METHOD test()V 25 | method 321 4 test FieldSetterImply test ()V 26 | method 334 20 setCapacityIncrement FieldSetterImply setCapacityIncrement (I)V 27 | method 360 15 setElementCount FieldSetterImply setElementCount (I)V 28 | # End METHOD 29 | # End CLASS 30 | end 31 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterImply/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | capacityIncrement elementCount 3 | elementCount capacityIncrement -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterImply/mapped/FieldSetterImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldSetterImply { 7 | @Accessor 8 | public abstract void setCapacityIncrement(int value); 9 | 10 | @Accessor 11 | public abstract void setElementCount(int value); 12 | 13 | public void test() { 14 | setCapacityIncrement(1); 15 | setElementCount(2); 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterImply/original.range: -------------------------------------------------------------------------------- 1 | start 1 FieldSetterImply.java 25812664c4307c0bc9d5b2005b760d29 2 | # Start Meta 3 | meta mixin_accessor FieldSetterImply setElementCount (I)V java/util/Vector elementCount I set 4 | meta mixin_accessor FieldSetterImply setCapacityIncrement (I)V java/util/Vector capacityIncrement I set 5 | # End Meta 6 | classdef 117 268 FieldSetterImply 7 | # Start CLASS FieldSetterImply 8 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 124 6 Vector false java/util/Vector 10 | class 151 16 FieldSetterImply false FieldSetterImply 11 | methoddef 172 60 setElementCount (I)V 12 | # Start METHOD setElementCount(I)V 13 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 14 | method 205 15 setElementCount FieldSetterImply setElementCount (I)V 15 | parameter 225 5 value FieldSetterImply setElementCount (I)V 0 16 | # End METHOD 17 | methoddef 238 65 setCapacityIncrement (I)V 18 | # Start METHOD setCapacityIncrement(I)V 19 | class 239 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 20 | method 271 20 setCapacityIncrement FieldSetterImply setCapacityIncrement (I)V 21 | parameter 296 5 value FieldSetterImply setCapacityIncrement (I)V 0 22 | # End METHOD 23 | methoddef 309 74 test ()V 24 | # Start METHOD test()V 25 | method 321 4 test FieldSetterImply test ()V 26 | method 334 15 setElementCount FieldSetterImply setElementCount (I)V 27 | method 355 20 setCapacityIncrement FieldSetterImply setCapacityIncrement (I)V 28 | # End METHOD 29 | # End CLASS 30 | end 31 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterImply/original/FieldSetterImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldSetterImply { 7 | @Accessor 8 | public abstract void setElementCount(int value); 9 | 10 | @Accessor 11 | public abstract void setCapacityIncrement(int value); 12 | 13 | public void test() { 14 | setElementCount(1); 15 | setCapacityIncrement(2); 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterNamed/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 FieldSetterNamed.java 64cdb767b0e70fed08a9dd99dddfd0b6 2 | classdef 117 259 FieldSetterNamed 3 | # Start CLASS FieldSetterNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 FieldSetterNamed false FieldSetterNamed 7 | methoddef 172 72 setFoo (I)V 8 | # Start METHOD setFoo(I)V 9 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 10 | field_literal 182 19 "\"capacityIncrement\"" java/util/Vector capacityIncrement 11 | method 226 6 setFoo FieldSetterNamed setFoo (I)V 12 | parameter 237 5 value FieldSetterNamed setFoo (I)V 0 13 | # End METHOD 14 | methoddef 250 67 setBar (I)V 15 | # Start METHOD setBar(I)V 16 | class 251 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 17 | field_literal 260 14 "\"elementCount\"" java/util/Vector elementCount 18 | method 299 6 setBar FieldSetterNamed setBar (I)V 19 | parameter 310 5 value FieldSetterNamed setBar (I)V 0 20 | # End METHOD 21 | methoddef 323 51 test ()V 22 | # Start METHOD test()V 23 | method 335 4 test FieldSetterNamed test ()V 24 | method 348 6 setFoo FieldSetterNamed setFoo (I)V 25 | method 360 6 setBar FieldSetterNamed setBar (I)V 26 | # End METHOD 27 | # End CLASS 28 | end 29 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterNamed/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | capacityIncrement elementCount 3 | elementCount capacityIncrement -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterNamed/mapped/FieldSetterNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldSetterNamed { 7 | @Accessor("capacityIncrement") 8 | public abstract void setFoo(int value); 9 | 10 | @Accessor("elementCount") 11 | public abstract void setBar(int value); 12 | 13 | public void test() { 14 | setFoo(1); 15 | setBar(2); 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterNamed/original.range: -------------------------------------------------------------------------------- 1 | start 1 FieldSetterNamed.java 06f6a27d4a894a393a87afdab221ef0d 2 | classdef 117 259 FieldSetterNamed 3 | # Start CLASS FieldSetterNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 FieldSetterNamed false FieldSetterNamed 7 | methoddef 172 67 setFoo (I)V 8 | # Start METHOD setFoo(I)V 9 | class 173 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 10 | field_literal 182 14 "\"elementCount\"" java/util/Vector elementCount 11 | method 221 6 setFoo FieldSetterNamed setFoo (I)V 12 | parameter 232 5 value FieldSetterNamed setFoo (I)V 0 13 | # End METHOD 14 | methoddef 245 72 setBar (I)V 15 | # Start METHOD setBar(I)V 16 | class 246 8 Accessor false org/spongepowered/asm/mixin/gen/Accessor 17 | field_literal 255 19 "\"capacityIncrement\"" java/util/Vector capacityIncrement 18 | method 299 6 setBar FieldSetterNamed setBar (I)V 19 | parameter 310 5 value FieldSetterNamed setBar (I)V 0 20 | # End METHOD 21 | methoddef 323 51 test ()V 22 | # Start METHOD test()V 23 | method 335 4 test FieldSetterNamed test ()V 24 | method 348 6 setFoo FieldSetterNamed setFoo (I)V 25 | method 360 6 setBar FieldSetterNamed setBar (I)V 26 | # End METHOD 27 | # End CLASS 28 | end 29 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/FieldSetterNamed/original/FieldSetterNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Accessor; 3 | import java.util.Vector; 4 | 5 | @Mixin(Vector.class) 6 | public class FieldSetterNamed { 7 | @Accessor("elementCount") 8 | public abstract void setFoo(int value); 9 | 10 | @Accessor("capacityIncrement") 11 | public abstract void setBar(int value); 12 | 13 | public void test() { 14 | setFoo(1); 15 | setBar(2); 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyImply/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 MethodProxyImply.java c16583aa2c0e775d4ff231def5ee8954 2 | # Start Meta 3 | meta mixin_accessor MethodProxyImply callGrow (I)V java/util/Vector grow (I)V call 4 | meta mixin_accessor MethodProxyImply invokeEnsureCapacityHelper (I)V java/util/Vector ensureCapacityHelper (I)V invoke 5 | # End Meta 6 | classdef 117 278 MethodProxyImply 7 | # Start CLASS MethodProxyImply 8 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 124 6 Vector false java/util/Vector 10 | class 151 16 MethodProxyImply false MethodProxyImply 11 | methoddef 172 51 callGrow (I)V 12 | # Start METHOD callGrow(I)V 13 | class 173 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 14 | method 205 8 callGrow MethodProxyImply callGrow (I)V 15 | parameter 218 3 cap MethodProxyImply callGrow (I)V 0 16 | # End METHOD 17 | methoddef 229 85 invokeEnsureCapacityHelper (I)V 18 | # Start METHOD invokeEnsureCapacityHelper(I)V 19 | class 230 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 20 | method 238 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 21 | method 277 26 invokeEnsureCapacityHelper MethodProxyImply invokeEnsureCapacityHelper (I)V 22 | parameter 308 4 size MethodProxyImply invokeEnsureCapacityHelper (I)V 0 23 | # End METHOD 24 | methoddef 320 73 test ()V 25 | # Start METHOD test()V 26 | method 325 4 test MethodProxyImply test ()V 27 | method 340 8 callGrow MethodProxyImply callGrow (I)V 28 | method 359 26 invokeEnsureCapacityHelper MethodProxyImply invokeEnsureCapacityHelper (I)V 29 | # End METHOD 30 | # End CLASS 31 | end 32 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyImply/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | grow (I)V ensureCapacityHelper 3 | ensureCapacityHelper (I)V grow -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyImply/mapped/MethodProxyImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class MethodProxyImply { 8 | @Invoker 9 | private abstract void callGrow(int cap); 10 | 11 | @Invoker(remap = false) 12 | private abstract void invokeEnsureCapacityHelper(int size); 13 | 14 | void test() { 15 | this.callGrow(1); 16 | this.invokeEnsureCapacityHelper(1); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyImply/original.range: -------------------------------------------------------------------------------- 1 | start 1 MethodProxyImply.java 5c557aa003ee22c4685799b7a45693cb 2 | # Start Meta 3 | meta mixin_accessor MethodProxyImply callEnsureCapacityHelper (I)V java/util/Vector ensureCapacityHelper (I)V call 4 | meta mixin_accessor MethodProxyImply invokeGrow (I)V java/util/Vector grow (I)V invoke 5 | # End Meta 6 | classdef 117 278 MethodProxyImply 7 | # Start CLASS MethodProxyImply 8 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 9 | class 124 6 Vector false java/util/Vector 10 | class 151 16 MethodProxyImply false MethodProxyImply 11 | methoddef 172 67 callEnsureCapacityHelper (I)V 12 | # Start METHOD callEnsureCapacityHelper(I)V 13 | class 173 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 14 | method 205 24 callEnsureCapacityHelper MethodProxyImply callEnsureCapacityHelper (I)V 15 | parameter 234 3 cap MethodProxyImply callEnsureCapacityHelper (I)V 0 16 | # End METHOD 17 | methoddef 245 69 invokeGrow (I)V 18 | # Start METHOD invokeGrow(I)V 19 | class 246 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 20 | method 254 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 21 | method 293 10 invokeGrow MethodProxyImply invokeGrow (I)V 22 | parameter 308 4 size MethodProxyImply invokeGrow (I)V 0 23 | # End METHOD 24 | methoddef 320 73 test ()V 25 | # Start METHOD test()V 26 | method 325 4 test MethodProxyImply test ()V 27 | method 340 24 callEnsureCapacityHelper MethodProxyImply callEnsureCapacityHelper (I)V 28 | method 375 10 invokeGrow MethodProxyImply invokeGrow (I)V 29 | # End METHOD 30 | # End CLASS 31 | end 32 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyImply/original/MethodProxyImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class MethodProxyImply { 8 | @Invoker 9 | private abstract void callEnsureCapacityHelper(int cap); 10 | 11 | @Invoker(remap = false) 12 | private abstract void invokeGrow(int size); 13 | 14 | void test() { 15 | this.callEnsureCapacityHelper(1); 16 | this.invokeGrow(1); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyNamed/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 MethodProxyNamed.java 081c9869c7cbfa9af8f36903f6eca025 2 | classdef 117 282 MethodProxyNamed 3 | # Start CLASS MethodProxyNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 MethodProxyNamed false MethodProxyNamed 7 | methoddef 172 58 callFoo (I)V 8 | # Start METHOD callFoo(I)V 9 | class 173 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 10 | method_literal 181 6 "\"grow\"" java/util/Vector grow (I)V 11 | method 213 7 callFoo MethodProxyNamed callFoo (I)V 12 | parameter 225 3 cap MethodProxyNamed callFoo (I)V 0 13 | # End METHOD 14 | methoddef 236 100 invokeBar (I)V 15 | # Start METHOD invokeBar(I)V 16 | class 237 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 17 | method 245 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 18 | method 260 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 19 | method_literal 268 22 "\"ensureCapacityHelper\"" java/util/Vector ensureCapacityHelper (I)V 20 | method 316 9 invokeBar MethodProxyNamed invokeBar (I)V 21 | parameter 330 4 size MethodProxyNamed invokeBar (I)V 0 22 | # End METHOD 23 | methoddef 342 55 test ()V 24 | # Start METHOD test()V 25 | method 347 4 test MethodProxyNamed test ()V 26 | method 362 7 callFoo MethodProxyNamed callFoo (I)V 27 | method 380 9 invokeBar MethodProxyNamed invokeBar (I)V 28 | # End METHOD 29 | # End CLASS 30 | end 31 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyNamed/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | grow (I)V ensureCapacityHelper 3 | ensureCapacityHelper (I)V grow -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyNamed/mapped/MethodProxyNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class MethodProxyNamed { 8 | @Invoker("grow") 9 | private abstract void callFoo(int cap); 10 | 11 | @Invoker(remap = false, value = "ensureCapacityHelper") 12 | private abstract void invokeBar(int size); 13 | 14 | void test() { 15 | this.callFoo(1); 16 | this.invokeBar(1); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyNamed/original.range: -------------------------------------------------------------------------------- 1 | start 1 MethodProxyNamed.java 28638eb32552ef375176eb4df4981613 2 | classdef 117 282 MethodProxyNamed 3 | # Start CLASS MethodProxyNamed 4 | class 118 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 124 6 Vector false java/util/Vector 6 | class 151 16 MethodProxyNamed false MethodProxyNamed 7 | methoddef 172 74 callFoo (I)V 8 | # Start METHOD callFoo(I)V 9 | class 173 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 10 | method_literal 181 22 "\"ensureCapacityHelper\"" java/util/Vector ensureCapacityHelper (I)V 11 | method 229 7 callFoo MethodProxyNamed callFoo (I)V 12 | parameter 241 3 cap MethodProxyNamed callFoo (I)V 0 13 | # End METHOD 14 | methoddef 252 84 invokeBar (I)V 15 | # Start METHOD invokeBar(I)V 16 | class 253 7 Invoker false org/spongepowered/asm/mixin/gen/Invoker 17 | method 261 5 remap org/spongepowered/asm/mixin/gen/Invoker remap ()Z 18 | method 276 5 value org/spongepowered/asm/mixin/gen/Invoker value ()Ljava/lang/String; 19 | method_literal 284 6 "\"grow\"" java/util/Vector grow (I)V 20 | method 316 9 invokeBar MethodProxyNamed invokeBar (I)V 21 | parameter 330 4 size MethodProxyNamed invokeBar (I)V 0 22 | # End METHOD 23 | methoddef 342 55 test ()V 24 | # Start METHOD test()V 25 | method 347 4 test MethodProxyNamed test ()V 26 | method 362 7 callFoo MethodProxyNamed callFoo (I)V 27 | method 380 9 invokeBar MethodProxyNamed invokeBar (I)V 28 | # End METHOD 29 | # End CLASS 30 | end 31 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Accessor/MethodProxyNamed/original/MethodProxyNamed.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.gen.Invoker; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class MethodProxyNamed { 8 | @Invoker("ensureCapacityHelper") 9 | private abstract void callFoo(int cap); 10 | 11 | @Invoker(remap = false, value = "grow") 12 | private abstract void invokeBar(int size); 13 | 14 | void test() { 15 | this.callFoo(1); 16 | this.invokeBar(1); 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Implements/SimpleImplements/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 SimpleImplements.java 5d3ce8434e0d384a550396b9360e8d1b 2 | classdef 162 148 SimpleImplements 3 | # Start CLASS SimpleImplements 4 | class 163 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 169 6 Vector false java/util/Vector 6 | class 184 10 Implements false org/spongepowered/asm/mixin/Implements 7 | class 197 9 Interface false org/spongepowered/asm/mixin/Interface 8 | method 207 5 iface org/spongepowered/asm/mixin/Interface iface ()Ljava/lang/Class; 9 | class 215 13 AutoCloseable false java/lang/AutoCloseable 10 | method 236 6 prefix org/spongepowered/asm/mixin/Interface prefix ()Ljava/lang/String; 11 | class 268 16 SimpleImplements false SimpleImplements 12 | methoddef 289 19 pre$close ()V 13 | # Start METHOD pre$close()V 14 | method 298 5 close java/lang/AutoCloseable close ()V 15 | # End METHOD 16 | # End CLASS 17 | end 18 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Implements/SimpleImplements/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/lang/AutoCloseable java/lang/Runnable 2 | close ()V run -------------------------------------------------------------------------------- /src/test/resources/Mixins/Implements/SimpleImplements/mapped/SimpleImplements.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Implements; 3 | import org.spongepowered.asm.mixin.Interface; 4 | 5 | import java.util.Vector; 6 | 7 | @Mixin(Vector.class) 8 | @Implements({@Interface(iface = AutoCloseable.class, prefix = "pre$")}) 9 | public class SimpleImplements { 10 | void pre$close() {} 11 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Implements/SimpleImplements/original.range: -------------------------------------------------------------------------------- 1 | start 1 SimpleImplements.java 83bde69016718c349d40fded0251da02 2 | classdef 162 141 SimpleImplements 3 | # Start CLASS SimpleImplements 4 | class 163 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 169 6 Vector false java/util/Vector 6 | class 184 10 Implements false org/spongepowered/asm/mixin/Implements 7 | class 197 9 Interface false org/spongepowered/asm/mixin/Interface 8 | method 207 5 iface org/spongepowered/asm/mixin/Interface iface ()Ljava/lang/Class; 9 | class 215 8 Runnable false java/lang/Runnable 10 | method 231 6 prefix org/spongepowered/asm/mixin/Interface prefix ()Ljava/lang/String; 11 | class 263 16 SimpleImplements false SimpleImplements 12 | methoddef 284 17 pre$run ()V 13 | # Start METHOD pre$run()V 14 | method 293 3 run java/lang/Runnable run ()V 15 | # End METHOD 16 | # End CLASS 17 | end 18 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Implements/SimpleImplements/original/SimpleImplements.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Implements; 3 | import org.spongepowered.asm.mixin.Interface; 4 | 5 | import java.util.Vector; 6 | 7 | @Mixin(Vector.class) 8 | @Implements({@Interface(iface = Runnable.class, prefix = "pre$")}) 9 | public class SimpleImplements { 10 | void pre$run() {} 11 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetMulti/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 HardTargetMulti.java 9d6713bd26885482cf11c37927080fc0 2 | classdef 96 72 HardTargetMulti 3 | # Start CLASS HardTargetMulti 4 | class 97 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 104 6 Vector false java/util/Vector 6 | class 118 9 ArrayList false java/util/ArrayList 7 | class 149 15 HardTargetMulti false HardTargetMulti 8 | # End CLASS 9 | end 10 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetMulti/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/List 2 | java/util/Vector java/util/Collection -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetMulti/mapped/HardTargetMulti.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import java.util.Vector; 3 | import java.util.ArrayList; 4 | 5 | @Mixin({Vector.class, ArrayList.class}) 6 | public class HardTargetMulti { 7 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetMulti/original.range: -------------------------------------------------------------------------------- 1 | start 1 HardTargetMulti.java 7a6c75fdb490d1ecb9287b04de35c14c 2 | classdef 95 71 HardTargetMulti 3 | # Start CLASS HardTargetMulti 4 | class 96 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 103 10 Collection false java/util/Collection 6 | class 121 4 List false java/util/List 7 | class 147 15 HardTargetMulti false HardTargetMulti 8 | # End CLASS 9 | end 10 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetMulti/original/HardTargetMulti.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import java.util.Collection; 3 | import java.util.List; 4 | 5 | @Mixin({Collection.class, List.class}) 6 | public class HardTargetMulti { 7 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetSingle/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 HardTargetSingle.java cb69f19725aeb886a2345fb2bb197edd 2 | classdef 71 57 HardTargetSingle 3 | # Start CLASS HardTargetSingle 4 | class 72 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 78 9 ArrayList false java/util/ArrayList 6 | class 108 16 HardTargetSingle false HardTargetSingle 7 | # End CLASS 8 | end 9 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetSingle/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/List -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetSingle/mapped/HardTargetSingle.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import java.util.ArrayList; 3 | 4 | @Mixin(ArrayList.class) 5 | public class HardTargetSingle { 6 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetSingle/original.range: -------------------------------------------------------------------------------- 1 | start 1 HardTargetSingle.java 4ac2c970ba4672b578773366c737ced7 2 | classdef 66 52 HardTargetSingle 3 | # Start CLASS HardTargetSingle 4 | class 67 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 73 4 List false java/util/List 6 | class 98 16 HardTargetSingle false HardTargetSingle 7 | # End CLASS 8 | end 9 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/HardTargetSingle/original/HardTargetSingle.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import java.util.List; 3 | 4 | @Mixin(List.class) 5 | public class HardTargetSingle { 6 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetMulti/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 SoftTargetMulti.java 109c27b8a4cf2b81dc5319724cf0af87 2 | classdef 43 95 SoftTargetSingle 3 | # Start CLASS SoftTargetSingle 4 | class 44 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | method 50 7 targets org/spongepowered/asm/mixin/Mixin targets ()[Ljava/lang/String; 6 | class_literal 61 18 "\"java/util/Vector\"" java/util/Vector 7 | class_literal 81 21 "\"java.util.ArrayList\"" java/util/ArrayList 8 | class 118 16 SoftTargetSingle false SoftTargetSingle 9 | # End CLASS 10 | end 11 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetMulti/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/List 2 | java/util/Vector java/util/Collection -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetMulti/mapped/SoftTargetMulti.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | 3 | @Mixin(targets = {"java/util/Vector", "java.util.ArrayList"}) 4 | public class SoftTargetSingle { 5 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetMulti/original.range: -------------------------------------------------------------------------------- 1 | start 1 SoftTargetMulti.java 0075cc6f3623eed30307ceda3edd7b8e 2 | classdef 43 94 SoftTargetSingle 3 | # Start CLASS SoftTargetSingle 4 | class 44 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | method 50 7 targets org/spongepowered/asm/mixin/Mixin targets ()[Ljava/lang/String; 6 | class_literal 61 22 "\"java/util/Collection\"" java/util/Collection 7 | class_literal 85 16 "\"java.util.List\"" java/util/List 8 | class 117 16 SoftTargetSingle false SoftTargetSingle 9 | # End CLASS 10 | end 11 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetMulti/original/SoftTargetMulti.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | 3 | @Mixin(targets = {"java/util/Collection", "java.util.List"}) 4 | public class SoftTargetSingle { 5 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetSingle/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 SoftTargetSingle.java a110f4da1fda9f24fba39cc7910afd72 2 | classdef 43 73 SoftTargetSingle 3 | # Start CLASS SoftTargetSingle 4 | class 44 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | method 50 7 targets org/spongepowered/asm/mixin/Mixin targets ()[Ljava/lang/String; 6 | class_literal 60 21 "\"java.util.ArrayList\"" java/util/ArrayList 7 | class 96 16 SoftTargetSingle false SoftTargetSingle 8 | # End CLASS 9 | end 10 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetSingle/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/ArrayList java/util/List -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetSingle/mapped/SoftTargetSingle.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | 3 | @Mixin(targets = "java.util.ArrayList") 4 | public class SoftTargetSingle { 5 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetSingle/original.range: -------------------------------------------------------------------------------- 1 | start 1 SoftTargetSingle.java 38f4b69226b69c47a74d5fd689156efa 2 | classdef 43 68 SoftTargetSingle 3 | # Start CLASS SoftTargetSingle 4 | class 44 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | method 50 7 targets org/spongepowered/asm/mixin/Mixin targets ()[Ljava/lang/String; 6 | class_literal 60 16 "\"java.util.List\"" java/util/List 7 | class 91 16 SoftTargetSingle false SoftTargetSingle 8 | # End CLASS 9 | end 10 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Mixin/SoftTargetSingle/original/SoftTargetSingle.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | 3 | @Mixin(targets = "java.util.List") 4 | public class SoftTargetSingle { 5 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Overwrite/OverwriteImply/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 OverwriteImply.java 6f453ad575d1418cb0e4e3891ddafb84 2 | classdef 115 104 OverwriteImply 3 | # Start CLASS OverwriteImply 4 | class 116 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 122 6 Vector false java/util/Vector 6 | class 149 14 OverwriteImply false OverwriteImply 7 | methoddef 168 49 contains (Ljava/lang/Object;)Z 8 | # Start METHOD contains(Ljava/lang/Object;)Z 9 | class 169 9 Overwrite false org/spongepowered/asm/mixin/Overwrite 10 | method 196 8 contains java/util/Collection contains (Ljava/lang/Object;)Z 11 | class 205 6 Object false java/lang/Object 12 | parameter 212 1 e OverwriteImply contains (Ljava/lang/Object;)Z 0 13 | # End METHOD 14 | # End CLASS 15 | end 16 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Overwrite/OverwriteImply/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Collection java/util/Collection 2 | contains (Ljava/lang/Object;)Z remove -------------------------------------------------------------------------------- /src/test/resources/Mixins/Overwrite/OverwriteImply/mapped/OverwriteImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Overwrite; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class OverwriteImply { 8 | @Overwrite 9 | public boolean contains(Object e) {} 10 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Overwrite/OverwriteImply/original.range: -------------------------------------------------------------------------------- 1 | start 1 OverwriteImply.java f164bf66bdd505c7a4868861497989a6 2 | classdef 115 102 OverwriteImply 3 | # Start CLASS OverwriteImply 4 | class 116 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 122 6 Vector false java/util/Vector 6 | class 149 14 OverwriteImply false OverwriteImply 7 | methoddef 168 47 remove (Ljava/lang/Object;)Z 8 | # Start METHOD remove(Ljava/lang/Object;)Z 9 | class 169 9 Overwrite false org/spongepowered/asm/mixin/Overwrite 10 | method 196 6 remove java/util/Collection remove (Ljava/lang/Object;)Z 11 | class 203 6 Object false java/lang/Object 12 | parameter 210 1 e OverwriteImply remove (Ljava/lang/Object;)Z 0 13 | # End METHOD 14 | # End CLASS 15 | end 16 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Overwrite/OverwriteImply/original/OverwriteImply.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Overwrite; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class OverwriteImply { 8 | @Overwrite 9 | public boolean remove(Object e) {} 10 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowField/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 ShadowField.java 57d80bce25fcb9233d95b007ea9d30ca 2 | classdef 112 220 ShadowField 3 | # Start CLASS ShadowField 4 | class 113 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 119 6 Vector false java/util/Vector 6 | class 146 11 ShadowField false ShadowField 7 | class 163 6 Shadow false org/spongepowered/asm/mixin/Shadow 8 | field 184 17 capacityIncrement java/util/Vector 9 | class 209 6 Shadow false org/spongepowered/asm/mixin/Shadow 10 | method 216 5 remap org/spongepowered/asm/mixin/Shadow remap ()Z 11 | field 245 12 elementCount java/util/Vector 12 | methoddef 264 66 test ()V 13 | # Start METHOD test()V 14 | method 269 4 test ShadowField test ()V 15 | field 284 17 capacityIncrement java/util/Vector 16 | field 311 12 elementCount java/util/Vector 17 | # End METHOD 18 | # End CLASS 19 | end 20 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowField/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | capacityIncrement elementCount 3 | elementCount capacityIncrement -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowField/mapped/ShadowField.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Shadow; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class ShadowField { 8 | @Shadow 9 | private int capacityIncrement; 10 | 11 | @Shadow(remap = false) 12 | private int elementCount; 13 | 14 | void test() { 15 | this.capacityIncrement++; 16 | this.elementCount++; 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowField/original.range: -------------------------------------------------------------------------------- 1 | start 1 ShadowField.java ef48073a3539271c9da933dfbf785def 2 | classdef 112 220 ShadowField 3 | # Start CLASS ShadowField 4 | class 113 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 119 6 Vector false java/util/Vector 6 | class 146 11 ShadowField false ShadowField 7 | class 163 6 Shadow false org/spongepowered/asm/mixin/Shadow 8 | field 184 12 elementCount java/util/Vector 9 | class 204 6 Shadow false org/spongepowered/asm/mixin/Shadow 10 | method 211 5 remap org/spongepowered/asm/mixin/Shadow remap ()Z 11 | field 240 17 capacityIncrement java/util/Vector 12 | methoddef 264 66 test ()V 13 | # Start METHOD test()V 14 | method 269 4 test ShadowField test ()V 15 | field 284 12 elementCount java/util/Vector 16 | field 306 17 capacityIncrement java/util/Vector 17 | # End METHOD 18 | # End CLASS 19 | end 20 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowField/original/ShadowField.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Shadow; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class ShadowField { 8 | @Shadow 9 | private int elementCount; 10 | 11 | @Shadow(remap = false) 12 | private int capacityIncrement; 13 | 14 | void test() { 15 | this.elementCount++; 16 | this.capacityIncrement++; 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowMethod/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 ShadowMethod.java 1b0162a095376e981b92dd9cfd6b7ce0 2 | classdef 112 425 ShadowMethod 3 | # Start CLASS ShadowMethod 4 | class 113 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 119 6 Vector false java/util/Vector 6 | class 146 12 ShadowMethod false ShadowMethod 7 | methoddef 163 46 grow (I)V 8 | # Start METHOD grow(I)V 9 | class 164 6 Shadow false org/spongepowered/asm/mixin/Shadow 10 | method 195 4 grow java/util/Vector grow (I)V 11 | parameter 204 3 cap ShadowMethod grow (I)V 0 12 | # End METHOD 13 | methoddef 215 78 ensureCapacityHelper (I)V 14 | # Start METHOD ensureCapacityHelper(I)V 15 | class 216 6 Shadow false org/spongepowered/asm/mixin/Shadow 16 | method 223 5 remap org/spongepowered/asm/mixin/Shadow remap ()Z 17 | method 262 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 18 | parameter 287 4 size ShadowMethod ensureCapacityHelper (I)V 0 19 | # End METHOD 20 | methoddef 299 53 shadow$grow (I)V 21 | # Start METHOD shadow$grow(I)V 22 | class 300 6 Shadow false org/spongepowered/asm/mixin/Shadow 23 | method 338 4 grow java/util/Vector grow (I)V 24 | parameter 347 3 cap ShadowMethod shadow$grow (I)V 0 25 | # End METHOD 26 | methoddef 358 67 foo$grow (I)V 27 | # Start METHOD foo$grow(I)V 28 | class 359 6 Shadow false org/spongepowered/asm/mixin/Shadow 29 | method 366 6 prefix org/spongepowered/asm/mixin/Shadow prefix ()Ljava/lang/String; 30 | method 411 4 grow java/util/Vector grow (I)V 31 | parameter 420 3 cap ShadowMethod foo$grow (I)V 0 32 | # End METHOD 33 | methoddef 431 104 test ()V 34 | # Start METHOD test()V 35 | method 436 4 test ShadowMethod test ()V 36 | method 451 4 grow java/util/Vector grow (I)V 37 | method 466 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 38 | method 504 4 grow java/util/Vector grow (I)V 39 | method 523 4 grow java/util/Vector grow (I)V 40 | # End METHOD 41 | # End CLASS 42 | end 43 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowMethod/mapped.tsrg: -------------------------------------------------------------------------------- 1 | java/util/Vector java/util/Vector 2 | grow (I)V ensureCapacityHelper 3 | ensureCapacityHelper (I)V grow -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowMethod/mapped/ShadowMethod.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Shadow; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class ShadowMethod { 8 | @Shadow 9 | private abstract void grow(int cap); 10 | 11 | @Shadow(remap = false) 12 | private abstract void ensureCapacityHelper(int size); 13 | 14 | @Shadow 15 | private abstract void shadow$grow(int cap); 16 | 17 | @Shadow(prefix = "foo$") 18 | private abstract void foo$grow(int cap); 19 | 20 | void test() { 21 | this.grow(1); 22 | this.ensureCapacityHelper(1); 23 | this.shadow$grow(1); 24 | this.foo$grow(1); 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowMethod/original.range: -------------------------------------------------------------------------------- 1 | start 1 ShadowMethod.java e148f7ef498beba2c12b8f442a38dc71 2 | classdef 112 489 ShadowMethod 3 | # Start CLASS ShadowMethod 4 | class 113 5 Mixin false org/spongepowered/asm/mixin/Mixin 5 | class 119 6 Vector false java/util/Vector 6 | class 146 12 ShadowMethod false ShadowMethod 7 | methoddef 163 62 ensureCapacityHelper (I)V 8 | # Start METHOD ensureCapacityHelper(I)V 9 | class 164 6 Shadow false org/spongepowered/asm/mixin/Shadow 10 | method 195 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 11 | parameter 220 3 cap ShadowMethod ensureCapacityHelper (I)V 0 12 | # End METHOD 13 | methoddef 231 62 grow (I)V 14 | # Start METHOD grow(I)V 15 | class 232 6 Shadow false org/spongepowered/asm/mixin/Shadow 16 | method 239 5 remap org/spongepowered/asm/mixin/Shadow remap ()Z 17 | method 278 4 grow java/util/Vector grow (I)V 18 | parameter 287 4 size ShadowMethod grow (I)V 0 19 | # End METHOD 20 | methoddef 299 69 shadow$ensureCapacityHelper (I)V 21 | # Start METHOD shadow$ensureCapacityHelper(I)V 22 | class 300 6 Shadow false org/spongepowered/asm/mixin/Shadow 23 | method 338 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 24 | parameter 363 3 cap ShadowMethod shadow$ensureCapacityHelper (I)V 0 25 | # End METHOD 26 | methoddef 374 83 foo$ensureCapacityHelper (I)V 27 | # Start METHOD foo$ensureCapacityHelper(I)V 28 | class 375 6 Shadow false org/spongepowered/asm/mixin/Shadow 29 | method 382 6 prefix org/spongepowered/asm/mixin/Shadow prefix ()Ljava/lang/String; 30 | method 427 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 31 | parameter 452 3 cap ShadowMethod foo$ensureCapacityHelper (I)V 0 32 | # End METHOD 33 | methoddef 463 136 test ()V 34 | # Start METHOD test()V 35 | method 468 4 test ShadowMethod test ()V 36 | method 483 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 37 | method 514 4 grow java/util/Vector grow (I)V 38 | method 536 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 39 | method 571 20 ensureCapacityHelper java/util/Vector ensureCapacityHelper (I)V 40 | # End METHOD 41 | # End CLASS 42 | end 43 | -------------------------------------------------------------------------------- /src/test/resources/Mixins/Shadow/ShadowMethod/original/ShadowMethod.txt: -------------------------------------------------------------------------------- 1 | import org.spongepowered.asm.mixin.Mixin; 2 | import org.spongepowered.asm.mixin.Shadow; 3 | 4 | import java.util.Vector; 5 | 6 | @Mixin(Vector.class) 7 | public class ShadowMethod { 8 | @Shadow 9 | private abstract void ensureCapacityHelper(int cap); 10 | 11 | @Shadow(remap = false) 12 | private abstract void grow(int size); 13 | 14 | @Shadow 15 | private abstract void shadow$ensureCapacityHelper(int cap); 16 | 17 | @Shadow(prefix = "foo$") 18 | private abstract void foo$ensureCapacityHelper(int cap); 19 | 20 | void test() { 21 | this.ensureCapacityHelper(1); 22 | this.grow(1); 23 | this.shadow$ensureCapacityHelper(1); 24 | this.foo$ensureCapacityHelper(1); 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/NestedGenerics/original.range: -------------------------------------------------------------------------------- 1 | start 1 Test.java 54514bf85b42bb005dfc2db581502b75 2 | classdef 97 189 Test 3 | # Start CLASS Test 4 | class 110 4 Test false Test 5 | methoddef 118 166 main ([Ljava/lang/String;)V 6 | # Start METHOD main([Ljava/lang/String;)V 7 | method 137 4 main Test main ([Ljava/lang/String;)V 8 | class 142 6 String false java/lang/String 9 | parameter 151 4 args Test main ([Ljava/lang/String;)V 0 10 | class 161 3 Map false java/util/Map 11 | class 165 4 Test false Test 12 | class 171 3 Set false java/util/Set 13 | class 175 6 String false java/lang/String 14 | local_variable 184 3 map Test main ([Ljava/lang/String;)V 1 Ljava/util/Map; 15 | class 194 7 HashMap false java/util/HashMap 16 | local_variable 209 3 map Test main ([Ljava/lang/String;)V 1 Ljava/util/Map; 17 | method 213 15 computeIfAbsent java/util/Map computeIfAbsent (Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object; 18 | class 233 4 Test false Test 19 | parameter 241 1 k Test lambda$0 (LTest;)Ljava/util/Set; 0 20 | methoddef 241 20 lambda$0 (LTest;)Ljava/util/Set; 21 | # Start METHOD lambda$0(LTest;)Ljava/util/Set; 22 | class 250 7 HashSet false java/util/HashSet 23 | # End METHOD 24 | method 263 3 add java/util/Collection add (Ljava/lang/Object;)Z 25 | # End METHOD 26 | # End CLASS 27 | end 28 | -------------------------------------------------------------------------------- /src/test/resources/NestedGenerics/original/Test.txt: -------------------------------------------------------------------------------- 1 | import java.util.Set; 2 | import java.util.HashSet; 3 | import java.util.Map; 4 | import java.util.HashMap; 5 | 6 | public class Test { 7 | public static void main(String[] args) { 8 | Map> map = new HashMap<>(); 9 | map.computeIfAbsent(new Test(), k -> new HashSet<>()).add("TestString"); 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/PackageInfo/original.range: -------------------------------------------------------------------------------- 1 | start 1 test/package-info.java 2a280dbefb43cfe3a936f52dc94fb4b8 2 | class 1 10 Deprecated false java/lang/Deprecated 3 | class 13 9 Generated false javax/annotation/processing/Generated 4 | package 40 4 test 5 | end 6 | -------------------------------------------------------------------------------- /src/test/resources/PackageInfo/original/test/package-info.txt: -------------------------------------------------------------------------------- 1 | @Deprecated 2 | @Generated("TEST!") 3 | package test; 4 | 5 | import java.lang.Deprecated; 6 | import javax.annotation.processing.Generated; -------------------------------------------------------------------------------- /src/test/resources/PatternMatch/original.range: -------------------------------------------------------------------------------- 1 | start 1 PatternMatch.java f33129ec73af9959c29cfd833c9117a5 2 | classdef 0 162 PatternMatch 3 | # Start CLASS PatternMatch 4 | class 13 12 PatternMatch false PatternMatch 5 | methoddef 32 128 test (Ljava/lang/Object;)V 6 | # Start METHOD test(Ljava/lang/Object;)V 7 | method 44 4 test PatternMatch test (Ljava/lang/Object;)V 8 | class 49 6 Object false java/lang/Object 9 | parameter 56 5 param PatternMatch test (Ljava/lang/Object;)V 0 10 | parameter 77 5 param PatternMatch test (Ljava/lang/Object;)V 0 11 | class 94 6 String false java/lang/String 12 | local_variable 101 3 str PatternMatch test (Ljava/lang/Object;)V 1 Ljava/lang/String; 13 | class 120 6 System false java/lang/System 14 | field 127 3 out java/lang/System 15 | method 131 7 println java/io/PrintStream println (Ljava/lang/String;)V 16 | local_variable 139 3 str PatternMatch test (Ljava/lang/Object;)V 1 Ljava/lang/String; 17 | # End METHOD 18 | # End CLASS 19 | end 20 | -------------------------------------------------------------------------------- /src/test/resources/PatternMatch/original/PatternMatch.txt: -------------------------------------------------------------------------------- 1 | public class PatternMatch { 2 | public void test(Object param) { 3 | if (param instanceof String str) { 4 | System.out.println(str); 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /src/test/resources/RecordCanonical/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 RecordCanonical.java 8302ef9c11b966d672577a467f3ec4de 2 | recorddef 0 229 RecordCanonical 3 | # Start RECORD RecordCanonical 4 | class 14 15 RecordCanonical false RecordCanonical 5 | class 30 6 String false java/lang/String 6 | methoddef 30 15 (Ljava/lang/String;I)V 7 | # Start METHOD (Ljava/lang/String;I)V 8 | field 37 1 b RecordCanonical 9 | field 44 1 a RecordCanonical 10 | # End METHOD 11 | methoddef 53 174 (Ljava/lang/String;I)V 12 | # Start METHOD (Ljava/lang/String;I)V 13 | method 60 15 RecordCanonical RecordCanonical (Ljava/lang/String;I)V 14 | class 76 6 String false java/lang/String 15 | field 83 1 b RecordCanonical 16 | field 90 1 a RecordCanonical 17 | field 108 1 b RecordCanonical 18 | field 112 1 b RecordCanonical 19 | field 127 1 a RecordCanonical 20 | field 153 1 a RecordCanonical 21 | field 157 1 a RecordCanonical 22 | field 194 1 a RecordCanonical 23 | field 198 1 b RecordCanonical 24 | method 200 8 hashCode java/lang/Object hashCode ()I 25 | # End METHOD 26 | # End RECORD 27 | end 28 | -------------------------------------------------------------------------------- /src/test/resources/RecordCanonical/mapped.tsrg: -------------------------------------------------------------------------------- 1 | RecordCanonical RecordCanonical 2 | b a 3 | a b 4 | (Ljava/lang/String;I)V -------------------------------------------------------------------------------- /src/test/resources/RecordCanonical/mapped/RecordCanonical.txt: -------------------------------------------------------------------------------- 1 | public record RecordCanonical(String b, int a) { 2 | public RecordCanonical(String b, int a) { 3 | this.b = b; 4 | if (a > 0) { 5 | this.a = a; 6 | } else { 7 | this.a = b.hashCode(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/RecordCanonical/original.range: -------------------------------------------------------------------------------- 1 | start 1 RecordCanonical.java 9bcc25ef22a58fb07d01aab099106703 2 | recorddef 0 229 RecordCanonical 3 | # Start RECORD RecordCanonical 4 | class 14 15 RecordCanonical false RecordCanonical 5 | class 30 6 String false java/lang/String 6 | methoddef 30 15 (Ljava/lang/String;I)V 7 | # Start METHOD (Ljava/lang/String;I)V 8 | field 37 1 a RecordCanonical 9 | field 44 1 b RecordCanonical 10 | # End METHOD 11 | methoddef 53 174 (Ljava/lang/String;I)V 12 | # Start METHOD (Ljava/lang/String;I)V 13 | method 60 15 RecordCanonical RecordCanonical (Ljava/lang/String;I)V 14 | class 76 6 String false java/lang/String 15 | field 83 1 a RecordCanonical 16 | field 90 1 b RecordCanonical 17 | field 108 1 a RecordCanonical 18 | field 112 1 a RecordCanonical 19 | field 127 1 b RecordCanonical 20 | field 153 1 b RecordCanonical 21 | field 157 1 b RecordCanonical 22 | field 194 1 b RecordCanonical 23 | field 198 1 a RecordCanonical 24 | method 200 8 hashCode java/lang/Object hashCode ()I 25 | # End METHOD 26 | # End RECORD 27 | end 28 | -------------------------------------------------------------------------------- /src/test/resources/RecordCanonical/original/RecordCanonical.txt: -------------------------------------------------------------------------------- 1 | public record RecordCanonical(String a, int b) { 2 | public RecordCanonical(String a, int b) { 3 | this.a = a; 4 | if (b > 0) { 5 | this.b = b; 6 | } else { 7 | this.b = a.hashCode(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/RecordCompact/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 RecordCompact.java 34140c933c2ff9dc2beb308fc60f49ab 2 | recorddef 0 87 RecordCompact 3 | # Start RECORD RecordCompact 4 | class 14 13 RecordCompact false RecordCompact 5 | methoddef 28 5 (I)V 6 | # Start METHOD (I)V 7 | field 32 1 b RecordCompact 8 | # End METHOD 9 | methoddef 41 44 (I)V 10 | # Start METHOD (I)V 11 | method 48 13 RecordCompact RecordCompact (I)V 12 | field 72 1 b RecordCompact 13 | # End METHOD 14 | # End RECORD 15 | end 16 | -------------------------------------------------------------------------------- /src/test/resources/RecordCompact/mapped.tsrg: -------------------------------------------------------------------------------- 1 | RecordCompact RecordCompact 2 | b a 3 | (I)V -------------------------------------------------------------------------------- /src/test/resources/RecordCompact/mapped/RecordCompact.txt: -------------------------------------------------------------------------------- 1 | public record RecordCompact(int b) { 2 | public RecordCompact { 3 | b += 1; 4 | } 5 | } -------------------------------------------------------------------------------- /src/test/resources/RecordCompact/original.range: -------------------------------------------------------------------------------- 1 | start 1 RecordCompact.java ea005fc13e6445d36496b1f7e6cf0882 2 | recorddef 0 87 RecordCompact 3 | # Start RECORD RecordCompact 4 | class 14 13 RecordCompact false RecordCompact 5 | methoddef 28 5 (I)V 6 | # Start METHOD (I)V 7 | field 32 1 a RecordCompact 8 | # End METHOD 9 | methoddef 41 44 (I)V 10 | # Start METHOD (I)V 11 | method 48 13 RecordCompact RecordCompact (I)V 12 | field 72 1 a RecordCompact 13 | # End METHOD 14 | # End RECORD 15 | end 16 | -------------------------------------------------------------------------------- /src/test/resources/RecordCompact/original/RecordCompact.txt: -------------------------------------------------------------------------------- 1 | public record RecordCompact(int a) { 2 | public RecordCompact { 3 | a += 1; 4 | } 5 | } -------------------------------------------------------------------------------- /src/test/resources/RecordComplex/mapped.tsrg: -------------------------------------------------------------------------------- 1 | tsrg2 left right 2 | RecordComplex RecordComplex 3 | a d 4 | b e 5 | c f 6 | a ()I d 7 | b ()Ljava/util/Map; e 8 | c ()[Ljava/lang/String; f -------------------------------------------------------------------------------- /src/test/resources/RecordComplex/mapped/RecordComplex.txt: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | import java.util.Objects; 5 | import java.util.function.Supplier; 6 | 7 | public record RecordComplex(int a, Map b, String... c) { 8 | private static final Supplier DEFAULT_FACTORY = RecordComplex::new; 9 | private static int counter = 5; 10 | 11 | public static RecordComplex createDefault() { 12 | counter++; 13 | return DEFAULT_FACTORY.get(); 14 | } 15 | 16 | public RecordComplex { 17 | if (a > 100) 18 | throw new IllegalStateException("a cannot be greater than 100!"); 19 | } 20 | 21 | private RecordComplex() { 22 | this(50, new HashMap<>()); 23 | } 24 | 25 | public int a() { 26 | return a == 0 ? 100 : a; 27 | } 28 | 29 | public Map b() { 30 | return b instanceof HashMap hashMap ? hashMap : null; 31 | } 32 | 33 | public String[] c() { 34 | throw new UnsupportedOperationException("Can't do that!"); 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) 40 | return true; 41 | if (o == null || getClass() != o.getClass()) 42 | return false; 43 | RecordComplex that = (RecordComplex) o; 44 | return a == that.a && b.equals(that.b) && Arrays.equals(c, that.c); 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = Objects.hash(a, b); 50 | result = 31 * result + Arrays.hashCode(c); 51 | return result; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "RecordComplex[a=" + a + ", b=" + b + ", c=" + Arrays.toString(c) + "]"; 57 | } 58 | } -------------------------------------------------------------------------------- /src/test/resources/RecordComplex/original/RecordComplex.txt: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | import java.util.HashMap; 3 | import java.util.Map; 4 | import java.util.Objects; 5 | import java.util.function.Supplier; 6 | 7 | public record RecordComplex(int d, Map e, String... f) { 8 | private static final Supplier DEFAULT_FACTORY = RecordComplex::new; 9 | private static int counter = 5; 10 | 11 | public static RecordComplex createDefault() { 12 | counter++; 13 | return DEFAULT_FACTORY.get(); 14 | } 15 | 16 | public RecordComplex { 17 | if (d > 100) 18 | throw new IllegalStateException("a cannot be greater than 100!"); 19 | } 20 | 21 | private RecordComplex() { 22 | this(50, new HashMap<>()); 23 | } 24 | 25 | public int d() { 26 | return d == 0 ? 100 : d; 27 | } 28 | 29 | public Map e() { 30 | return e instanceof HashMap hashMap ? hashMap : null; 31 | } 32 | 33 | public String[] f() { 34 | throw new UnsupportedOperationException("Can't do that!"); 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) 40 | return true; 41 | if (o == null || getClass() != o.getClass()) 42 | return false; 43 | RecordComplex that = (RecordComplex) o; 44 | return d == that.d && e.equals(that.e) && Arrays.equals(f, that.f); 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = Objects.hash(d, e); 50 | result = 31 * result + Arrays.hashCode(f); 51 | return result; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "RecordComplex[a=" + d + ", b=" + e + ", c=" + Arrays.toString(f) + "]"; 57 | } 58 | } -------------------------------------------------------------------------------- /src/test/resources/RecordSimple/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 RecordSimple.java 9ac473292325c5569c378efb816089db 2 | recorddef 0 46 RecordSimple 3 | # Start RECORD RecordSimple 4 | class 14 12 RecordSimple false RecordSimple 5 | methoddef 27 15 (ILjava/lang/String;)V 6 | # Start METHOD (ILjava/lang/String;)V 7 | field 31 1 b RecordSimple 8 | class 34 6 String false java/lang/String 9 | field 41 1 a RecordSimple 10 | # End METHOD 11 | # End RECORD 12 | end 13 | -------------------------------------------------------------------------------- /src/test/resources/RecordSimple/mapped.tsrg: -------------------------------------------------------------------------------- 1 | RecordSimple RecordSimple 2 | a b 3 | b a 4 | (ILjava/lang/String;)V -------------------------------------------------------------------------------- /src/test/resources/RecordSimple/mapped/RecordSimple.txt: -------------------------------------------------------------------------------- 1 | public record RecordSimple(int b, String a) {} -------------------------------------------------------------------------------- /src/test/resources/RecordSimple/original.range: -------------------------------------------------------------------------------- 1 | start 1 RecordSimple.java 3aa2d2b1c9363c614f91f80c95265687 2 | recorddef 0 46 RecordSimple 3 | # Start RECORD RecordSimple 4 | class 14 12 RecordSimple false RecordSimple 5 | methoddef 27 15 (ILjava/lang/String;)V 6 | # Start METHOD (ILjava/lang/String;)V 7 | field 31 1 a RecordSimple 8 | class 34 6 String false java/lang/String 9 | field 41 1 b RecordSimple 10 | # End METHOD 11 | # End RECORD 12 | end 13 | -------------------------------------------------------------------------------- /src/test/resources/RecordSimple/original/RecordSimple.txt: -------------------------------------------------------------------------------- 1 | public record RecordSimple(int a, String b) {} -------------------------------------------------------------------------------- /src/test/resources/Whitespace/mapped.range: -------------------------------------------------------------------------------- 1 | start 1 not_test/package-info.java 69666c5b162c8c5492587fa74dd8f632 2 | class 1 10 Deprecated false java/lang/Deprecated 3 | class 13 9 Generated false javax/annotation/processing/Generated 4 | package 40 8 not_test 5 | end 6 | -------------------------------------------------------------------------------- /src/test/resources/Whitespace/mapped.tsrg: -------------------------------------------------------------------------------- 1 | not_test/package-info test/package-info -------------------------------------------------------------------------------- /src/test/resources/Whitespace/mapped/not_test/package-info.txt: -------------------------------------------------------------------------------- 1 | @Deprecated 2 | @Generated("TEST!") 3 | package not_test; 4 | 5 | import java.lang.Deprecated; 6 | import javax.annotation.processing.Generated; 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/Whitespace/original.range: -------------------------------------------------------------------------------- 1 | start 1 test/package-info.java 47def38968ac3cd467186548e76512b7 2 | class 1 10 Deprecated false java/lang/Deprecated 3 | class 13 9 Generated false javax/annotation/processing/Generated 4 | package 40 4 test 5 | end 6 | -------------------------------------------------------------------------------- /src/test/resources/Whitespace/original/test/package-info.txt: -------------------------------------------------------------------------------- 1 | @Deprecated 2 | @Generated("TEST!") 3 | package test; 4 | 5 | import java.lang.Deprecated; 6 | import javax.annotation.processing.Generated; 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/test.marker: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MinecraftForge/Srg2Source/a521287b763725205ef9ed9183899b8bb38d65bb/src/test/resources/test.marker --------------------------------------------------------------------------------