-
-
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.
Merge pull request #16 from QuiltMC/mojmap
proposal of mojmap names and packages
- Loading branch information
Showing
39 changed files
with
1,375 additions
and
117 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
/* | ||
* Copyright 2025 QuiltMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
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); | ||
|
||
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; | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
/* | ||
* Copyright 2025 QuiltMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
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_MAPPING_MERGE, () -> new MappingMergeNameProposer(context.getSingleArgument(Arguments.MERGED_MAPPING_PATH).orElse(null))); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return QuiltEnigmaPlugin.FALLBACK_NAME_PROPOSAL_SERVICE_ID; | ||
} | ||
|
||
@Override | ||
public boolean isFallback() { | ||
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
78 changes: 78 additions & 0 deletions
78
src/main/java/org/quiltmc/enigma_plugin/proposal/MappingMergeNameProposer.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,78 @@ | ||
/* | ||
* Copyright 2025 QuiltMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.quiltmc.enigma_plugin.proposal; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
import org.quiltmc.enigma.api.Enigma; | ||
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; | ||
import org.quiltmc.enigma.api.translation.mapping.EntryMapping; | ||
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree; | ||
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTreeNode; | ||
import org.quiltmc.enigma.api.translation.representation.entry.Entry; | ||
import org.tinylog.Logger; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
/** | ||
* An extremely simple proposer that provides the names of all entries from the given mappings. | ||
* This proposer is meant to be run first so that the names are overridden by all other proposers. | ||
*/ | ||
public class MappingMergeNameProposer extends NameProposer { | ||
public static final String ID = "mapping_merge"; | ||
|
||
private final String mappingPath; | ||
// must be static for now. nasty hack to make sure we don't read mappings twice when also using the package proposer | ||
// we can guarantee that this is nonnull for the other proposer because jar proposal blocks dynamic proposal | ||
private static EntryTree<EntryMapping> mergedMappings; | ||
|
||
@Nullable | ||
public static EntryTree<EntryMapping> getMergedMappings() { | ||
return mergedMappings; | ||
} | ||
|
||
public MappingMergeNameProposer(@Nullable String mappingPath) { | ||
super(ID); | ||
this.mappingPath = mappingPath; | ||
} | ||
|
||
@Override | ||
public void insertProposedNames(Enigma enigma, JarIndex index, Map<Entry<?>, EntryMapping> mappings) { | ||
if (this.mappingPath != null) { | ||
Path path = Path.of(this.mappingPath); | ||
try { | ||
mergedMappings = enigma.readMappings(path).orElse(null); | ||
} catch (Exception e) { | ||
Logger.error(e, "could not read mappings to merge (path: " + path + ")!"); | ||
} | ||
} else { | ||
Logger.error("no mapping path provided for merge, disabling " + this.getSourcePluginId()); | ||
} | ||
|
||
if (mergedMappings != null) { | ||
mergedMappings.getRootNodes().forEach((node) -> this.proposeNodeAndChildren(mappings, node)); | ||
} | ||
} | ||
|
||
private void proposeNodeAndChildren(Map<Entry<?>, EntryMapping> mappings, EntryTreeNode<EntryMapping> node) { | ||
if (node.getValue() != null && node.getValue().targetName() != null) { | ||
this.insertProposal(mappings, node.getEntry(), node.getValue().targetName()); | ||
} | ||
|
||
node.getChildNodes().forEach((child) -> this.proposeNodeAndChildren(mappings, child)); | ||
} | ||
} |
Oops, something went wrong.