mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 21:47:42 -05:00
Revert "Add mixins that target the class as a comment. (#168)"
This reverts commit fb3c2c86
This commit is contained in:
@@ -26,8 +26,6 @@ package net.fabricmc.loom.task.fernflower;
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -35,7 +33,6 @@ import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
|
||||
import org.gradle.api.internal.project.ProjectInternal;
|
||||
import org.gradle.api.logging.LogLevel;
|
||||
@@ -50,9 +47,6 @@ import net.fabricmc.loom.task.AbstractDecompileTask;
|
||||
import net.fabricmc.loom.task.ForkingJavaExecTask;
|
||||
import net.fabricmc.loom.util.ConsumingOutputStream;
|
||||
import net.fabricmc.loom.util.OperatingSystem;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.MixinTargetScanner;
|
||||
import net.fabricmc.loom.util.RemappedConfigurationEntry;
|
||||
|
||||
/**
|
||||
* Created by covers1624 on 9/02/19.
|
||||
@@ -67,16 +61,6 @@ public class FernFlowerTask extends AbstractDecompileTask implements ForkingJava
|
||||
throw new UnsupportedOperationException("FernFlowerTask requires a 64bit JVM to run due to the memory requirements");
|
||||
}
|
||||
|
||||
MixinTargetScanner mixinTargetScanner = new MixinTargetScanner(getProject());
|
||||
|
||||
for (RemappedConfigurationEntry modCompileEntry : Constants.MOD_COMPILE_ENTRIES) {
|
||||
mixinTargetScanner.scan(getProject().getConfigurations().getByName(modCompileEntry.getRemappedConfiguration()));
|
||||
}
|
||||
|
||||
String mixinTargetJson = mixinTargetScanner.getClassMixinsJson();
|
||||
File mixinTargetFile = new File(getExtension().getProjectBuildCache(), "mixin_targets.json");
|
||||
FileUtils.writeStringToFile(mixinTargetFile, mixinTargetJson, StandardCharsets.UTF_8);
|
||||
|
||||
Map<String, Object> options = new HashMap<>();
|
||||
options.put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1");
|
||||
options.put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1");
|
||||
@@ -96,7 +80,6 @@ public class FernFlowerTask extends AbstractDecompileTask implements ForkingJava
|
||||
|
||||
args.add("-t=" + getNumThreads());
|
||||
args.add("-m=" + getExtension().getMappingsProvider().tinyMappings.getAbsolutePath());
|
||||
args.add("-j=" + mixinTargetFile.getAbsolutePath());
|
||||
|
||||
//TODO, Decompiler breaks on jemalloc, J9 module-info.class?
|
||||
getLibraries().forEach(f -> args.add("-e=" + f.getAbsolutePath()));
|
||||
|
||||
@@ -52,7 +52,6 @@ public class ForkedFFExecutor {
|
||||
File output = null;
|
||||
File lineMap = null;
|
||||
File mappings = null;
|
||||
File mixins = null;
|
||||
List<File> libraries = new ArrayList<>();
|
||||
int numThreads = 0;
|
||||
|
||||
@@ -92,12 +91,6 @@ public class ForkedFFExecutor {
|
||||
}
|
||||
|
||||
mappings = new File(arg.substring(3));
|
||||
} else if (arg.startsWith("-j=")) {
|
||||
if (mixins != null) {
|
||||
throw new RuntimeException("Unable to use more than one mixin file.");
|
||||
}
|
||||
|
||||
mixins = new File(arg.substring(3));
|
||||
} else if (arg.startsWith("-t=")) {
|
||||
numThreads = Integer.parseInt(arg.substring(3));
|
||||
} else {
|
||||
@@ -114,7 +107,7 @@ public class ForkedFFExecutor {
|
||||
Objects.requireNonNull(output, "Output not set.");
|
||||
Objects.requireNonNull(mappings, "Mappings not set.");
|
||||
|
||||
options.put(IFabricJavadocProvider.PROPERTY_NAME, new TinyJavadocProvider(mappings, mixins));
|
||||
options.put(IFabricJavadocProvider.PROPERTY_NAME, new TinyJavadocProvider(mappings));
|
||||
runFF(options, libraries, input, output, lineMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,12 @@ package net.fabricmc.loom.task.fernflower;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jetbrains.java.decompiler.struct.StructClass;
|
||||
import org.jetbrains.java.decompiler.struct.StructField;
|
||||
import org.jetbrains.java.decompiler.struct.StructMethod;
|
||||
@@ -47,18 +45,15 @@ import net.fabricmc.mapping.tree.ParameterDef;
|
||||
import net.fabricmc.mapping.tree.TinyMappingFactory;
|
||||
import net.fabricmc.mapping.tree.TinyTree;
|
||||
import net.fabricmc.mappings.EntryTriple;
|
||||
import net.fabricmc.loom.util.MixinTargetScanner;
|
||||
|
||||
public class TinyJavadocProvider implements IFabricJavadocProvider {
|
||||
private final Map<String, ClassDef> classes = new HashMap<>();
|
||||
private final Map<EntryTriple, FieldDef> fields = new HashMap<>();
|
||||
private final Map<EntryTriple, MethodDef> methods = new HashMap<>();
|
||||
|
||||
private final Map<String, List<MixinTargetScanner.MixinTargetInfo>> mixins;
|
||||
|
||||
private final String namespace = "named";
|
||||
|
||||
public TinyJavadocProvider(File tinyFile, File mixinTargetFile) {
|
||||
public TinyJavadocProvider(File tinyFile) {
|
||||
final TinyTree mappings = readMappings(tinyFile);
|
||||
|
||||
for (ClassDef classDef : mappings.getClasses()) {
|
||||
@@ -73,38 +68,12 @@ public class TinyJavadocProvider implements IFabricJavadocProvider {
|
||||
methods.put(new EntryTriple(className, methodDef.getName(namespace), methodDef.getDescriptor(namespace)), methodDef);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
mixins = MixinTargetScanner.fromJson(FileUtils.readFileToString(mixinTargetFile, StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read mixin target file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassDoc(StructClass structClass) {
|
||||
StringBuilder comment = new StringBuilder();
|
||||
ClassDef classDef = classes.get(structClass.qualifiedName);
|
||||
|
||||
if (classDef != null && classDef.getComment() != null) {
|
||||
comment.append(classDef.getComment());
|
||||
}
|
||||
|
||||
if (mixins.containsKey(structClass.qualifiedName)) {
|
||||
List<MixinTargetScanner.MixinTargetInfo> mixinList = mixins.get(structClass.qualifiedName);
|
||||
|
||||
if (classDef != null && classDef.getComment() != null) {
|
||||
comment.append("\n");
|
||||
}
|
||||
|
||||
comment.append("Mixins:");
|
||||
|
||||
for (MixinTargetScanner.MixinTargetInfo info : mixinList) {
|
||||
comment.append(String.format("\n\t%s - {@link %s}", info.getModid(), info.getMixinClass().replaceAll("\\$", ".")));
|
||||
}
|
||||
}
|
||||
|
||||
return comment.length() == 0 ? null : comment.toString();
|
||||
return classDef != null ? classDef.getComment() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user