Skip to content

Commit

Permalink
why did i think this would be a 1 night fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Sep 26, 2024
1 parent a164fd8 commit f35f563
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
Expand All @@ -25,15 +24,14 @@
import org.quiltmc.enigma_plugin.index.CodecIndex;
import org.quiltmc.enigma_plugin.index.JarIndexer;

import java.util.List;
import java.util.Map;

public class CodecNameProposer extends NameProposer {
public static final String ID = "codecs";
private final CodecIndex index;

public CodecNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public CodecNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(CodecIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ConflictFixProposer extends NameProposer {
private final SimpleTypeSingleIndex index;

public ConflictFixProposer(JarIndexer jarIndex) {
super(ID, null);
super(ID);
this.index = jarIndex.getIndex(SimpleTypeSingleIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma_plugin.index.JarIndexer;
import org.quiltmc.enigma_plugin.index.constant_fields.ConstantFieldIndex;

import java.util.List;
import java.util.Map;

public class ConstantFieldNameProposer extends NameProposer {
public static final String ID = "constant_fields";
private final ConstantFieldIndex fieldIndex;

public ConstantFieldNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public ConstantFieldNameProposer(JarIndexer index) {
super(ID);
this.fieldIndex = index.getIndex(ConstantFieldIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.mapping.EntryRemapper;
Expand All @@ -26,15 +25,14 @@
import org.quiltmc.enigma_plugin.index.ConstructorParametersIndex;
import org.quiltmc.enigma_plugin.index.JarIndexer;

import java.util.List;
import java.util.Map;

public class ConstructorParamsNameProposer extends NameProposer {
public static final String ID = "constructor_params";
private final ConstructorParametersIndex index;

public ConstructorParamsNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public ConstructorParamsNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(ConstructorParametersIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.mapping.EntryRemapper;
Expand All @@ -37,8 +36,8 @@ public class DelegateParametersNameProposer extends NameProposer {
private static final List<String> IGNORED_SOURCE_PLUGIN_IDS = Stream.of(ID, SimpleTypeFieldNameProposer.ID).map(NameProposer::getSourcePluginId).toList();
private final DelegateParametersIndex index;

public DelegateParametersNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public DelegateParametersNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(DelegateParametersIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
Expand All @@ -25,15 +24,14 @@
import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableEntry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;

import java.util.List;
import java.util.Map;

public class EqualsNameProposer extends NameProposer {
public static final String ID = "equals";
private static final MethodDescriptor EQUALS_DESCRIPTOR = new MethodDescriptor("(Ljava/lang/Object;)Z");

public EqualsNameProposer(@Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public EqualsNameProposer() {
super(ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.mapping.EntryRemapper;
Expand All @@ -28,15 +27,14 @@
import org.quiltmc.enigma_plugin.index.JarIndexer;
import org.quiltmc.enigma_plugin.util.Descriptors;

import java.util.List;
import java.util.Map;

public class GetterSetterNameProposer extends NameProposer {
public static final String ID = "getter_setter";
private final GetterSetterIndex index;

public GetterSetterNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public GetterSetterNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(GetterSetterIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma_plugin.index.JarIndexer;
import org.quiltmc.enigma_plugin.index.LoggerIndex;

import java.util.List;
import java.util.Map;

/**
Expand All @@ -34,8 +32,8 @@ public class LoggerNameProposer extends NameProposer {
public static final String ID = "logger";
private final LoggerIndex index;

public LoggerNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public LoggerNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(LoggerIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
Expand All @@ -25,7 +24,6 @@
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;

import java.util.List;
import java.util.Map;

/**
Expand All @@ -35,8 +33,8 @@
public class MojangNameProposer extends NameProposer {
public static final String ID = "map_non_hashed";

public MojangNameProposer(@Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public MojangNameProposer() {
super(ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma_plugin.QuiltEnigmaPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public abstract class NameProposer {
private final String id;

public NameProposer(String id, @Nullable List<NameProposer> proposerList) {
public NameProposer(String id) {
this.id = id;
//this.proposers.addAll(proposerList);
}

public String getSourcePluginId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,20 @@ public class NameProposerService implements NameProposalService {
private final List<NameProposer> nameProposers = new ArrayList<>();

public NameProposerService(JarIndexer indexer, EnigmaServiceContext<NameProposalService> context) {
this.addIfEnabled(context, indexer, Arguments.DISABLE_RECORDS, (index) -> new RecordComponentNameProposer(index, this.nameProposers));
this.addIfEnabled(context, indexer, Arguments.DISABLE_CONSTANT_FIELDS, (index) -> new ConstantFieldNameProposer(index, this.nameProposers));
this.addIfEnabled(context, Arguments.DISABLE_EQUALS, () -> new EqualsNameProposer(this.nameProposers));
this.addIfEnabled(context, indexer, Arguments.DISABLE_LOGGER, (index) -> new LoggerNameProposer(index, this.nameProposers));
this.addIfEnabled(context, indexer, Arguments.DISABLE_CODECS, (index) -> new CodecNameProposer(index, this.nameProposers));
this.addIfNotDisabled(context, Arguments.DISABLE_MAP_NON_HASHED, () -> new MojangNameProposer(this.nameProposers));

SimpleTypeFieldNameProposer proposer;
this.addIfEnabled(context, indexer, Arguments.DISABLE_RECORDS, RecordComponentNameProposer::new);
this.addIfEnabled(context, indexer, Arguments.DISABLE_CONSTANT_FIELDS, ConstantFieldNameProposer::new);
this.addIfEnabled(context, Arguments.DISABLE_EQUALS, EqualsNameProposer::new);
this.addIfEnabled(context, indexer, Arguments.DISABLE_LOGGER, LoggerNameProposer::new);
this.addIfEnabled(context, indexer, Arguments.DISABLE_CODECS, CodecNameProposer::new);
this.addIfNotDisabled(context, Arguments.DISABLE_MAP_NON_HASHED, MojangNameProposer::new);

if (indexer.getIndex(SimpleTypeSingleIndex.class).isEnabled()) {
proposer = new SimpleTypeFieldNameProposer(indexer);
this.nameProposers.add(proposer);
} else {
proposer = null;
this.nameProposers.add(new SimpleTypeFieldNameProposer(indexer));
}

this.addIfEnabled(context, indexer, Arguments.DISABLE_CONSTRUCTOR_PARAMS, (index) -> new ConstructorParamsNameProposer(index, List.of(proposer)));
this.addIfEnabled(context, indexer, Arguments.DISABLE_GETTER_SETTER, (index) -> new GetterSetterNameProposer(index, this.nameProposers));
this.addIfEnabled(context, indexer, Arguments.DISABLE_DELEGATE_PARAMS, (index) -> new DelegateParametersNameProposer(index, List.of(proposer)));
this.addIfEnabled(context, indexer, Arguments.DISABLE_CONSTRUCTOR_PARAMS, ConstructorParamsNameProposer::new);
this.addIfEnabled(context, indexer, Arguments.DISABLE_GETTER_SETTER, GetterSetterNameProposer::new);
this.addIfEnabled(context, indexer, Arguments.DISABLE_DELEGATE_PARAMS, DelegateParametersNameProposer::new);

// conflict fixer must be last in order to get context from other dynamic proposers
this.addIfEnabled(context, indexer, Arguments.DISABLE_CONFLICT_FIXER, ConflictFixProposer::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.quiltmc.enigma_plugin.proposal;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry;
Expand All @@ -26,15 +25,14 @@
import org.quiltmc.enigma_plugin.index.JarIndexer;
import org.quiltmc.enigma_plugin.index.RecordIndex;

import java.util.List;
import java.util.Map;

public class RecordComponentNameProposer extends NameProposer {
public static final String ID = "records";
private final RecordIndex index;

public RecordComponentNameProposer(JarIndexer index, @Nullable List<NameProposer> proposerList) {
super(ID, proposerList);
public RecordComponentNameProposer(JarIndexer index) {
super(ID);
this.index = index.getIndex(RecordIndex.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import org.quiltmc.enigma_plugin.index.JarIndexer;
import org.quiltmc.enigma_plugin.index.simple_type_single.SimpleTypeSingleIndex;

import java.util.ArrayList;
import java.util.Map;

public class SimpleTypeFieldNameProposer extends NameProposer {
public static final String ID = "simple_type_field_names";
private final SimpleTypeSingleIndex index;

public SimpleTypeFieldNameProposer(JarIndexer index) {
super(ID, new ArrayList<>());
super(ID);
this.index = index.getIndex(SimpleTypeSingleIndex.class);
}

Expand Down
4 changes: 2 additions & 2 deletions src/testInputs/java/com/example/z_conflicts/ConflictTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.z_conflicts;

public class ConflictTest {
public int a;
public CharSequence b;
public final int a;
public final CharSequence b;

public ConflictTest(int a, CharSequence b) {
this.a = a;
Expand Down

0 comments on commit f35f563

Please sign in to comment.