Skip to content

Commit

Permalink
Cleanup indexers and add a delegate parameters name proposer (#10)
Browse files Browse the repository at this point in the history
* Start indexer cleanup

* Finish indexer cleanup

* Remove testProject

* Add unit tests

* Fix missing test files

* Add unit test for simple types name proposal

* Fix a bug with single type names

* Cleanup the codec index

* More cleanup, apply licenses

* Use shorter parameter constructor

* Initial delegate parameters impl

* Remove some stuff

* Get parameter names from libraries

* Don't name parameters used in different places

* Unit test for delegate parameters

* Dynamic renames for delegate parameters

* Use a public enigma snapshot

* Fix checkstyle errors and build warnings

* Fix IllegalArgumentException on recursive methods

* Don't propose names for synthetic parameters

* Don't propose names for parameters passed to the same method

* Fix an NPE

* Don't propose duplicate names

* Skip synthetic methods

* Don't load names from the lvt of mappable classes

* Propose names only on root methods

* Add an extra record naming test

* Update enigma to 2.2.0
  • Loading branch information
IotaBread authored Jan 29, 2024
1 parent e13d307 commit f8d55d4
Show file tree
Hide file tree
Showing 56 changed files with 1,784 additions and 443 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ build/
out/
.idea/
*.iml

testMappings/

testProject/output/
testProject/mappings/
90 changes: 87 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.4.0'
}
}

plugins {
id 'java'
id 'maven-publish'
Expand All @@ -8,11 +17,12 @@ plugins {
version '2.1.1'
group 'org.quiltmc'

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

version = version + (System.getenv("GITHUB_ACTIONS") ? "" : "+local")

sourceSets {
testInputs
}

repositories {
mavenCentral()
maven {
Expand All @@ -23,6 +33,7 @@ repositories {
name 'Quilt Snapshots'
url 'https://maven.quiltmc.org/repository/snapshot/'
}
mavenLocal()

// Enigma dependencies
maven {
Expand All @@ -35,6 +46,16 @@ repositories {
// Vineflower snapshots
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}

// Test inputs dependencies
maven {
name 'Minecraft Libraries'
url 'https://libraries.minecraft.net'
}
}

configurations {
enigmaRuntime
}

dependencies {
Expand All @@ -44,20 +65,83 @@ dependencies {
implementation libs.tinylog
implementation libs.annotations

testImplementation libs.junit
testImplementation libs.hamcrest
testRuntimeOnly libs.junit.engine
testImplementation libs.enigma.swing

testInputsImplementation libs.dfu
enigmaRuntime libs.dfu
}

var obfJar = file('build/obf/obf.jar')
var mappings = file('testMappings/')
var profile = file('build/resources/testInputs/profile.json')

task testEnigma(type: JavaExec, dependsOn: ["obfuscateTestInputs", "processTestInputsResources"]) {
mainClass = "org.quiltmc.enigma.gui.Main"
classpath = files(configurations.enigmaRuntime) + sourceSets.test.runtimeClasspath

args('-jar', obfJar, '-mappings', mappings.getAbsolutePath(), '-profile', profile.getAbsolutePath(), '--development')
doFirst {
mappings.mkdirs()
}
}

task testInputsJar(type: Jar) {
from sourceSets.testInputs.output

archiveFileName = "input.jar"
destinationDirectory = file("build/obf")
}

task obfuscateTestInputs(type: proguard.gradle.ProGuardTask) {
dependsOn testInputsJar

verbose
injars testInputsJar
outjars obfJar

libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars sourceSets.testInputs.compileClasspath

dontshrink()
dontoptimize()
keepclasseswithmembers 'public class * {\
\t\tpublic static void main(java.lang.String[]);\
\t}'
keepattributes 'SourceFile'
keepattributes '*Annotation*'
keepattributes 'InnerClasses'
keepattributes 'NestMembers'
keepattributes 'EnclosingMethod'
keepattributes 'Deprecated'
keepattributes 'Signature'
keepattributes 'Record'
printmapping 'build/obf/obf.txt'
}

tasks.test.dependsOn obfuscateTestInputs, processTestInputsResources

license {
rule file('codeformat/FABRIC_MODIFIED_HEADER')
rule file('codeformat/HEADER')

include '**/*.java'
exclude 'com/example/**/*.java'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

withSourcesJar()
}

test {
useJUnitPlatform()
}

publishing {
def ENV = System.getenv()
publications {
Expand Down
9 changes: 8 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[versions]
enigma = "2.1.0"
enigma = "2.2.0"

asm = "9.6"
quilt_json5 = "1.0.3"
tinylog = "2.6.2"
annotations = "23.0.0"

junit = "5.9.3"
hamcrest = "2.2"

dfu = "4.1.27"

[libraries]
Expand All @@ -20,6 +23,10 @@ quilt_json5 = { module = "org.quiltmc:quilt-json5", version.ref = "quilt_json5"
tinylog = { module = "org.tinylog:tinylog-api", version.ref = "tinylog" }
annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }

junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
junit_engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }

dfu = { module = "com.mojang:datafixerupper", version.ref = "dfu" }

[bundles]
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ pluginManagement {
}

rootProject.name = 'quilt-enigma-plugin'
include 'testProject'
7 changes: 4 additions & 3 deletions src/main/java/org/quiltmc/enigma_plugin/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ public class Arguments {
public static final String DISABLE_GETTER_SETTER = "disable_getter_setter";
public static final String DISABLE_CODECS = "disable_codecs";
public static final String DISABLE_MAP_NON_HASHED = "disable_map_non_hashed";
public static final String DISABLE_DELEGATE_PARAMS = "disable_delegate_params";
public static final String CUSTOM_CODECS = "custom_codecs";
public static final String SIMPLE_TYPE_FIELD_NAMES_PATH = "simple_type_field_names_path";

public static <T extends EnigmaService> boolean isDisabled(EnigmaServiceContext<T> context, String arg) {
return isDisabled(context, arg, false);
public static <T extends EnigmaService> boolean getBoolean(EnigmaServiceContext<T> context, String arg) {
return getBoolean(context, arg, false);
}

public static <T extends EnigmaService> boolean isDisabled(EnigmaServiceContext<T> context, String arg, boolean disabledByDefault) {
public static <T extends EnigmaService> boolean getBoolean(EnigmaServiceContext<T> context, String arg, boolean disabledByDefault) {
return context.getSingleArgument(arg).map(Boolean::parseBoolean).orElse(disabledByDefault);
}
}
Loading

0 comments on commit f8d55d4

Please sign in to comment.