-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
126 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/quiltmc/enigma_plugin/proposal/DefaultProposalService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.quiltmc.enigma_plugin.proposal; | ||
|
||
import org.quiltmc.enigma.api.service.EnigmaServiceContext; | ||
import org.quiltmc.enigma.api.service.NameProposalService; | ||
import org.quiltmc.enigma_plugin.Arguments; | ||
import org.quiltmc.enigma_plugin.QuiltEnigmaPlugin; | ||
import org.quiltmc.enigma_plugin.index.JarIndexer; | ||
import org.quiltmc.enigma_plugin.index.simple_type_single.SimpleTypeSingleIndex; | ||
|
||
public class DefaultProposalService extends NameProposerService { | ||
public DefaultProposalService(JarIndexer indexer, EnigmaServiceContext<NameProposalService> context) { | ||
super(); | ||
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()) { | ||
this.add(indexer, SimpleTypeFieldNameProposer::new); | ||
} | ||
|
||
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); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return QuiltEnigmaPlugin.NAME_PROPOSAL_SERVICE_ID; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/quiltmc/enigma_plugin/proposal/FallbackProposalService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.quiltmc.enigma_plugin.proposal; | ||
|
||
import org.quiltmc.enigma.api.service.EnigmaServiceContext; | ||
import org.quiltmc.enigma.api.service.NameProposalService; | ||
import org.quiltmc.enigma_plugin.Arguments; | ||
import org.quiltmc.enigma_plugin.QuiltEnigmaPlugin; | ||
import org.quiltmc.enigma_plugin.index.JarIndexer; | ||
|
||
public class FallbackProposalService extends NameProposerService { | ||
public FallbackProposalService(JarIndexer indexer, EnigmaServiceContext<NameProposalService> context) { | ||
super(); | ||
this.addIfEnabled(context, Arguments.DISABLE_MOJMAP, () -> new MojmapNameProposer(context.getSingleArgument(Arguments.MOJMAP_PATH))); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return QuiltEnigmaPlugin.FALLBACK_NAME_PROPOSAL_SERVICE_ID; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/org/quiltmc/enigma_plugin/proposal/MojmapNameProposer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.quiltmc.enigma_plugin.proposal; | ||
|
||
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; | ||
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; | ||
import org.quiltmc.enigma.api.translation.representation.entry.Entry; | ||
import org.tinylog.Logger; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class MojmapNameProposer extends NameProposer { | ||
public static final String ID = "mojmap"; | ||
|
||
private final String mojmapPath; | ||
private EntryTree<EntryMapping> mojmaps; | ||
|
||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") | ||
public MojmapNameProposer(Optional<String> path) { | ||
super(ID); | ||
|
||
if (path.isPresent()) { | ||
this.mojmapPath = path.get(); | ||
} else { | ||
Logger.error("No mojmap path provided, disabling " + this.getSourcePluginId()); | ||
this.mojmapPath = null; | ||
} | ||
} | ||
|
||
@Override | ||
public void insertProposedNames(JarIndex index, Map<Entry<?>, EntryMapping> mappings) { | ||
// todo read mojmaps | ||
// needs more context (enigma change) | ||
} | ||
|
||
@Override | ||
public void proposeDynamicNames(EntryRemapper remapper, Entry<?> obfEntry, EntryMapping oldMapping, EntryMapping newMapping, Map<Entry<?>, EntryMapping> mappings) { | ||
// todo dynamically fix class names to match their moj package | ||
// todo definitions file | ||
} | ||
|
||
@Override | ||
public boolean fallback() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters