diff --git a/build.gradle b/build.gradle index ffceccf2..0c4c6932 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ subprojects { } } - group = 'net.fabricmc' + group = 'net.fabricmc.matcher' version = rootProject.version checkstyle { @@ -62,4 +62,12 @@ subprojects { // disable 'missing' warnings options.addStringOption('Xdoclint:all,-missing', '-quiet') } + + publishing { + publications { + "$project.name"(MavenPublication) { + from components.java + } + } + } } diff --git a/matcher-cli/build.gradle b/matcher-cli/build.gradle index f79ea40d..ce5a1f51 100644 --- a/matcher-cli/build.gradle +++ b/matcher-cli/build.gradle @@ -1,8 +1,9 @@ plugins { id 'application' - id 'org.gradlex.extra-java-module-info' } +archivesBaseName = 'matcher-cli' + java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/matcher-cli/src/main/java/matcher/cli/Main.java b/matcher-cli/src/main/java/matcher/cli/Main.java index 9d033b5c..50237186 100644 --- a/matcher-cli/src/main/java/matcher/cli/Main.java +++ b/matcher-cli/src/main/java/matcher/cli/Main.java @@ -2,7 +2,7 @@ import matcher.cli.provider.builtin.AdditionalPluginsCliParameterProvider; import matcher.cli.provider.builtin.AutomatchCliCommandProvider; -import matcher.config.Config; +import matcher.model.config.Config; public class Main { public static void main(String[] args) { diff --git a/matcher-cli/src/main/java/matcher/cli/provider/builtin/AutomatchCliCommandProvider.java b/matcher-cli/src/main/java/matcher/cli/provider/builtin/AutomatchCliCommandProvider.java index 528b7cc1..a78cc420 100644 --- a/matcher-cli/src/main/java/matcher/cli/provider/builtin/AutomatchCliCommandProvider.java +++ b/matcher-cli/src/main/java/matcher/cli/provider/builtin/AutomatchCliCommandProvider.java @@ -15,12 +15,12 @@ import matcher.Matcher; import matcher.cli.MatcherCli; import matcher.cli.provider.CliCommandProvider; -import matcher.config.Config; -import matcher.config.ProjectConfig; -import matcher.mapping.MappingField; -import matcher.mapping.Mappings; +import matcher.model.config.Config; +import matcher.model.config.ProjectConfig; +import matcher.model.mapping.MappingField; +import matcher.model.mapping.Mappings; +import matcher.model.type.ClassEnvironment; import matcher.serdes.MatchesIo; -import matcher.type.ClassEnvironment; /** * Provides the default {@code automatch} command. diff --git a/matcher-core/build.gradle b/matcher-core/build.gradle index d933cf0a..cf7019c7 100644 --- a/matcher-core/build.gradle +++ b/matcher-core/build.gradle @@ -1,6 +1,4 @@ -plugins { - id 'java-library' -} +archivesBaseName = 'matcher-core' java { sourceCompatibility = JavaVersion.VERSION_11 @@ -18,10 +16,5 @@ tasks.withType(JavaCompile).configureEach { } dependencies { - api "net.fabricmc:mapping-io:${mappingio_version}" - api "org.ow2.asm:asm:${asm_version}" - api "org.ow2.asm:asm-tree:${asm_version}" - api "org.slf4j:slf4j-api:${slf4j_version}" - implementation "org.ow2.asm:asm-commons:${asm_version}" - implementation "org.ow2.asm:asm-util:${asm_version}" + api project(':matcher-model') } diff --git a/matcher-core/src/main/java/matcher/Matcher.java b/matcher-core/src/main/java/matcher/Matcher.java index 121b604b..f1afe280 100644 --- a/matcher-core/src/main/java/matcher/Matcher.java +++ b/matcher-core/src/main/java/matcher/Matcher.java @@ -29,23 +29,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import matcher.classifier.ClassClassifier; -import matcher.classifier.ClassifierLevel; -import matcher.classifier.FieldClassifier; -import matcher.classifier.IRanker; -import matcher.classifier.MethodClassifier; -import matcher.classifier.MethodVarClassifier; -import matcher.classifier.RankResult; -import matcher.config.Config; -import matcher.config.ProjectConfig; -import matcher.type.ClassEnv; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.InputFile; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.classifier.ClassClassifier; +import matcher.model.classifier.ClassifierLevel; +import matcher.model.classifier.FieldClassifier; +import matcher.model.classifier.IRanker; +import matcher.model.classifier.MethodClassifier; +import matcher.model.classifier.MethodVarClassifier; +import matcher.model.classifier.RankResult; +import matcher.model.config.Config; +import matcher.model.config.ProjectConfig; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.InputFile; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class Matcher { public static void init() { diff --git a/matcher-core/src/main/java/matcher/serdes/MatchesIo.java b/matcher-core/src/main/java/matcher/serdes/MatchesIo.java index 01b58a75..fdb18452 100644 --- a/matcher-core/src/main/java/matcher/serdes/MatchesIo.java +++ b/matcher-core/src/main/java/matcher/serdes/MatchesIo.java @@ -16,16 +16,16 @@ import java.util.function.DoubleConsumer; import matcher.Matcher; -import matcher.config.Config; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.InputFile; -import matcher.type.InputFile.HashType; -import matcher.type.LocalClassEnv; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.config.Config; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.InputFile; +import matcher.model.type.InputFile.HashType; +import matcher.model.type.LocalClassEnv; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class MatchesIo { public static void read(Path path, List inputDirs, boolean verifyInputs, Matcher matcher, DoubleConsumer progressReceiver) { diff --git a/matcher-core/src/main/java/module-info.java b/matcher-core/src/main/java/module-info.java index c41821ee..13d0f100 100644 --- a/matcher-core/src/main/java/module-info.java +++ b/matcher-core/src/main/java/module-info.java @@ -1,20 +1,8 @@ module matcher.core { - requires java.prefs; - requires org.objectweb.asm.commons; - requires org.objectweb.asm.tree.analysis; - requires org.objectweb.asm.util; - requires transitive net.fabricmc.mappingio; - requires transitive org.objectweb.asm; - requires transitive org.objectweb.asm.tree; - requires transitive org.slf4j; + requires transitive matcher.model; uses matcher.Plugin; exports matcher; - exports matcher.bcremap; - exports matcher.classifier; - exports matcher.config; - exports matcher.mapping; exports matcher.serdes; - exports matcher.type; } diff --git a/matcher-gui/build.gradle b/matcher-gui/build.gradle index 053e62c3..a8ca864c 100644 --- a/matcher-gui/build.gradle +++ b/matcher-gui/build.gradle @@ -1,9 +1,10 @@ plugins { id 'application' id 'org.openjfx.javafxplugin' - id 'org.gradlex.extra-java-module-info' } +archivesBaseName = 'matcher-gui' + java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/matcher-gui/src/main/java/matcher/gui/Main.java b/matcher-gui/src/main/java/matcher/gui/Main.java index 15e5f80f..1eae3ad5 100644 --- a/matcher-gui/src/main/java/matcher/gui/Main.java +++ b/matcher-gui/src/main/java/matcher/gui/Main.java @@ -8,7 +8,7 @@ import matcher.PluginLoader; import matcher.cli.MatcherCli; import matcher.cli.provider.builtin.AdditionalPluginsCliParameterProvider; -import matcher.config.Config; +import matcher.model.config.Config; import matcher.gui.cli.PreLaunchGuiCliParameterProvider; public class Main { diff --git a/matcher-gui/src/main/java/matcher/gui/MatcherGui.java b/matcher-gui/src/main/java/matcher/gui/MatcherGui.java index 504e30e5..5159b5d1 100644 --- a/matcher-gui/src/main/java/matcher/gui/MatcherGui.java +++ b/matcher-gui/src/main/java/matcher/gui/MatcherGui.java @@ -44,11 +44,7 @@ import net.fabricmc.mappingio.MappingReader; import matcher.Matcher; -import matcher.NameType; import matcher.cli.MatcherCli; -import matcher.config.Config; -import matcher.config.ProjectConfig; -import matcher.config.Theme; import matcher.gui.cli.PostLaunchGuiCliParameterProvider; import matcher.gui.srcprocess.BuiltinDecompiler; import matcher.gui.ui.BottomPane; @@ -60,10 +56,14 @@ import matcher.gui.ui.Shortcuts; import matcher.gui.ui.menu.MainMenuBar; import matcher.gui.ui.menu.NewProjectPane; -import matcher.mapping.MappingField; -import matcher.mapping.Mappings; -import matcher.type.ClassEnvironment; -import matcher.type.MatchType; +import matcher.model.NameType; +import matcher.model.config.Config; +import matcher.model.config.ProjectConfig; +import matcher.model.config.Theme; +import matcher.model.mapping.MappingField; +import matcher.model.mapping.Mappings; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.MatchType; public class MatcherGui extends Application { @Override diff --git a/matcher-gui/src/main/java/matcher/gui/cli/PostLaunchGuiCliParameterProvider.java b/matcher-gui/src/main/java/matcher/gui/cli/PostLaunchGuiCliParameterProvider.java index b6d5958a..08a3c039 100644 --- a/matcher-gui/src/main/java/matcher/gui/cli/PostLaunchGuiCliParameterProvider.java +++ b/matcher-gui/src/main/java/matcher/gui/cli/PostLaunchGuiCliParameterProvider.java @@ -9,8 +9,8 @@ import matcher.cli.provider.CliParameterProvider; import matcher.cli.provider.builtin.BuiltinCliParameters; -import matcher.config.ProjectConfig; import matcher.gui.MatcherGui; +import matcher.model.config.ProjectConfig; public class PostLaunchGuiCliParameterProvider implements CliParameterProvider { public PostLaunchGuiCliParameterProvider(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/cli/PreLaunchGuiCliParameterProvider.java b/matcher-gui/src/main/java/matcher/gui/cli/PreLaunchGuiCliParameterProvider.java index e9ddcfeb..ace360ac 100644 --- a/matcher-gui/src/main/java/matcher/gui/cli/PreLaunchGuiCliParameterProvider.java +++ b/matcher-gui/src/main/java/matcher/gui/cli/PreLaunchGuiCliParameterProvider.java @@ -4,8 +4,8 @@ import matcher.Matcher; import matcher.cli.provider.CliParameterProvider; -import matcher.config.Config; -import matcher.config.Theme; +import matcher.model.config.Config; +import matcher.model.config.Theme; public class PreLaunchGuiCliParameterProvider implements CliParameterProvider { @Parameter(names = {BuiltinGuiCliParameters.THEME}) diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/Cfr.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/Cfr.java index 50b9f194..95f6031c 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/Cfr.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/Cfr.java @@ -14,9 +14,9 @@ import org.benf.cfr.reader.bytecode.analysis.parse.utils.Pair; import matcher.Matcher; -import matcher.NameType; -import matcher.type.ClassFeatureExtractor; -import matcher.type.ClassInstance; +import matcher.model.NameType; +import matcher.model.type.ClassFeatureExtractor; +import matcher.model.type.ClassInstance; public class Cfr implements Decompiler { @Override diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/Decompiler.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/Decompiler.java index 27904ebf..37d1af57 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/Decompiler.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/Decompiler.java @@ -1,9 +1,9 @@ package matcher.gui.srcprocess; -import matcher.NameType; -import matcher.type.ClassEnvironment; -import matcher.type.ClassFeatureExtractor; -import matcher.type.ClassInstance; +import matcher.model.NameType; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassFeatureExtractor; +import matcher.model.type.ClassInstance; public interface Decompiler { static String decompile(ClassEnvironment env, Decompiler decompiler, ClassInstance cls, NameType nameType) { diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlPrinter.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlPrinter.java index 453d2b79..ae74aca8 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlPrinter.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlPrinter.java @@ -133,8 +133,8 @@ import com.github.javaparser.printer.configuration.Indentation.IndentType; import com.github.javaparser.utils.Utils; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; public class HtmlPrinter extends DefaultPrettyPrinterVisitor { public HtmlPrinter(TypeResolver typeResolver) { diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlUtil.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlUtil.java index f4cd1749..1832d340 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlUtil.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/HtmlUtil.java @@ -2,8 +2,8 @@ import java.util.regex.Pattern; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; public class HtmlUtil { public static String getId(MethodInstance method) { diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/Jadx.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/Jadx.java index ef95c052..cc99436c 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/Jadx.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/Jadx.java @@ -13,10 +13,10 @@ import jadx.plugins.input.java.JavaClassReader; import jadx.plugins.input.java.data.JavaClassData; -import matcher.NameType; -import matcher.Util; -import matcher.type.ClassFeatureExtractor; -import matcher.type.ClassInstance; +import matcher.model.Util; +import matcher.model.NameType; +import matcher.model.type.ClassFeatureExtractor; +import matcher.model.type.ClassInstance; public class Jadx implements Decompiler { @Override diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/Procyon.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/Procyon.java index 846bd2ff..80a41706 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/Procyon.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/Procyon.java @@ -11,9 +11,9 @@ import com.strobel.decompiler.PlainTextOutput; import matcher.Matcher; -import matcher.NameType; -import matcher.type.ClassFeatureExtractor; -import matcher.type.ClassInstance; +import matcher.model.NameType; +import matcher.model.type.ClassFeatureExtractor; +import matcher.model.type.ClassInstance; public class Procyon implements Decompiler { @Override diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/SrcDecorator.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/SrcDecorator.java index 80c8e485..9089c393 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/SrcDecorator.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/SrcDecorator.java @@ -8,6 +8,7 @@ import com.github.javaparser.JavaParser; import com.github.javaparser.JavaToken; +import com.github.javaparser.JavaToken.Kind; import com.github.javaparser.ParseResult; import com.github.javaparser.ParserConfiguration; import com.github.javaparser.ParserConfiguration.LanguageLevel; @@ -15,7 +16,6 @@ import com.github.javaparser.Problem; import com.github.javaparser.Range; import com.github.javaparser.TokenRange; -import com.github.javaparser.JavaToken.Kind; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Node; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; @@ -30,11 +30,11 @@ import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import matcher.Matcher; -import matcher.NameType; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class SrcDecorator { public static String decorate(String src, ClassInstance cls, NameType nameType) { diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/TypeResolver.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/TypeResolver.java index 87c3fe90..095c0d74 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/TypeResolver.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/TypeResolver.java @@ -24,12 +24,12 @@ import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.VoidType; -import matcher.NameType; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.ClassEnv; -import matcher.type.Matchable; -import matcher.type.MethodInstance; +import matcher.model.NameType; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.Matchable; +import matcher.model.type.MethodInstance; class TypeResolver { public void setup(ClassInstance rootCls, NameType nameType, CompilationUnit cu) { diff --git a/matcher-gui/src/main/java/matcher/gui/srcprocess/Vineflower.java b/matcher-gui/src/main/java/matcher/gui/srcprocess/Vineflower.java index ed729d95..3213d5aa 100644 --- a/matcher-gui/src/main/java/matcher/gui/srcprocess/Vineflower.java +++ b/matcher-gui/src/main/java/matcher/gui/srcprocess/Vineflower.java @@ -19,9 +19,9 @@ import org.jetbrains.java.decompiler.main.extern.IResultSaver; import matcher.Matcher; -import matcher.NameType; -import matcher.type.ClassFeatureExtractor; -import matcher.type.ClassInstance; +import matcher.model.NameType; +import matcher.model.type.ClassFeatureExtractor; +import matcher.model.type.ClassInstance; public class Vineflower implements Decompiler { @Override diff --git a/matcher-gui/src/main/java/matcher/gui/ui/BottomPane.java b/matcher-gui/src/main/java/matcher/gui/ui/BottomPane.java index 5629a976..5d54472c 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/BottomPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/BottomPane.java @@ -12,17 +12,17 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; -import matcher.classifier.ClassifierLevel; -import matcher.classifier.FieldClassifier; -import matcher.classifier.MethodClassifier; -import matcher.classifier.RankResult; import matcher.gui.MatcherGui; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.classifier.ClassifierLevel; +import matcher.model.classifier.FieldClassifier; +import matcher.model.classifier.MethodClassifier; +import matcher.model.classifier.RankResult; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class BottomPane extends StackPane implements IGuiComponent { public BottomPane(MatcherGui gui, MatchPaneSrc srcPane, MatchPaneDst dstPane) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/IFwdGuiComponent.java b/matcher-gui/src/main/java/matcher/gui/ui/IFwdGuiComponent.java index 807d2858..fc7ff907 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/IFwdGuiComponent.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/IFwdGuiComponent.java @@ -3,11 +3,11 @@ import java.util.Collection; import java.util.Set; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public interface IFwdGuiComponent extends IGuiComponent { Collection getComponents(); diff --git a/matcher-gui/src/main/java/matcher/gui/ui/IGuiComponent.java b/matcher-gui/src/main/java/matcher/gui/ui/IGuiComponent.java index da11dffc..0be2599e 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/IGuiComponent.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/IGuiComponent.java @@ -2,11 +2,11 @@ import java.util.Set; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public interface IGuiComponent { default void onProjectChange() { } diff --git a/matcher-gui/src/main/java/matcher/gui/ui/ISelectionProvider.java b/matcher-gui/src/main/java/matcher/gui/ui/ISelectionProvider.java index 0ebd239c..67f2eac3 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/ISelectionProvider.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/ISelectionProvider.java @@ -1,12 +1,12 @@ package matcher.gui.ui; -import matcher.classifier.RankResult; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.classifier.RankResult; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public interface ISelectionProvider { ClassInstance getSelectedClass(); diff --git a/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneDst.java b/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneDst.java index 5a1d68d1..2e230053 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneDst.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneDst.java @@ -19,23 +19,23 @@ import javafx.scene.layout.VBox; import matcher.Matcher; -import matcher.NameType; -import matcher.classifier.ClassClassifier; -import matcher.classifier.ClassifierLevel; -import matcher.classifier.FieldClassifier; -import matcher.classifier.MethodClassifier; -import matcher.classifier.MethodVarClassifier; -import matcher.classifier.RankResult; import matcher.gui.MatcherGui; -import matcher.type.ClassEnv; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.Matchable; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.classifier.ClassClassifier; +import matcher.model.classifier.ClassifierLevel; +import matcher.model.classifier.FieldClassifier; +import matcher.model.classifier.MethodClassifier; +import matcher.model.classifier.MethodVarClassifier; +import matcher.model.classifier.RankResult; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.Matchable; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class MatchPaneDst extends SplitPane implements IFwdGuiComponent, ISelectionProvider { public MatchPaneDst(MatcherGui gui, MatchPaneSrc srcPane) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneSrc.java b/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneSrc.java index 2e04c04f..d1ff1b08 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneSrc.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/MatchPaneSrc.java @@ -30,18 +30,18 @@ import javafx.scene.paint.Color; import matcher.Matcher; -import matcher.NameType; -import matcher.Util; -import matcher.config.Config; import matcher.gui.MatcherGui; import matcher.gui.MatcherGui.SortKey; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.Matchable; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.config.Config; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.Matchable; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class MatchPaneSrc extends SplitPane implements IFwdGuiComponent, ISelectionProvider { public MatchPaneSrc(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/FileMenu.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/FileMenu.java index 37cf3164..4afa70ee 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/FileMenu.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/FileMenu.java @@ -27,17 +27,17 @@ import net.fabricmc.mappingio.MappingReader; import net.fabricmc.mappingio.format.MappingFormat; -import matcher.Util; -import matcher.config.Config; import matcher.gui.MatcherGui; import matcher.gui.MatcherGui.SelectedFile; import matcher.gui.ui.menu.LoadMappingsPane.MappingsLoadSettings; import matcher.gui.ui.menu.LoadProjectPane.ProjectLoadSettings; import matcher.gui.ui.menu.SaveMappingsPane.MappingsSaveSettings; -import matcher.mapping.Mappings; +import matcher.model.Util; +import matcher.model.config.Config; +import matcher.model.mapping.Mappings; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.MatchType; import matcher.serdes.MatchesIo; -import matcher.type.ClassEnvironment; -import matcher.type.MatchType; public class FileMenu extends Menu { FileMenu(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/FixRecordNamesPane.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/FixRecordNamesPane.java index 3e17e3eb..509a25e7 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/FixRecordNamesPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/FixRecordNamesPane.java @@ -9,8 +9,8 @@ import javafx.scene.control.Label; import javafx.scene.layout.GridPane; -import matcher.NameType; import matcher.gui.ui.GuiConstants; +import matcher.model.NameType; class FixRecordNamesPane extends GridPane { FixRecordNamesPane() { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/LoadMappingsPane.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/LoadMappingsPane.java index f77a56f5..9c52195d 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/LoadMappingsPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/LoadMappingsPane.java @@ -15,7 +15,7 @@ import javafx.scene.layout.HBox; import matcher.gui.ui.GuiConstants; -import matcher.mapping.MappingField; +import matcher.model.mapping.MappingField; class LoadMappingsPane extends GridPane { LoadMappingsPane(List namespaces) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/MappingMenu.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/MappingMenu.java index 17261d5a..74aaaeb9 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/MappingMenu.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/MappingMenu.java @@ -9,7 +9,7 @@ import matcher.gui.MatcherGui; import matcher.gui.ui.menu.FixRecordNamesPane.NamespaceSettings; -import matcher.mapping.MappingPropagator; +import matcher.model.mapping.MappingPropagator; public class MappingMenu extends Menu { MappingMenu(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/MatchingMenu.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/MatchingMenu.java index fd6f8069..d063ba7d 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/MatchingMenu.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/MatchingMenu.java @@ -9,7 +9,7 @@ import matcher.Matcher.MatchingStatus; import matcher.gui.MatcherGui; -import matcher.type.MatchType; +import matcher.model.type.MatchType; public class MatchingMenu extends Menu { MatchingMenu(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/NewProjectPane.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/NewProjectPane.java index 07bdc711..28a2b782 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/NewProjectPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/NewProjectPane.java @@ -34,11 +34,11 @@ import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Window; -import matcher.config.ProjectConfig; import matcher.gui.MatcherGui; import matcher.gui.MatcherGui.SelectedFile; import matcher.gui.ui.GuiConstants; import matcher.gui.ui.GuiUtil; +import matcher.model.config.ProjectConfig; public class NewProjectPane extends GridPane { public NewProjectPane(ProjectConfig config, Window window, Node okButton) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/SaveMappingsPane.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/SaveMappingsPane.java index aa680557..d03a139f 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/SaveMappingsPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/SaveMappingsPane.java @@ -12,9 +12,9 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import matcher.NameType; import matcher.gui.ui.GuiConstants; -import matcher.mapping.MappingsExportVerbosity; +import matcher.model.NameType; +import matcher.model.mapping.MappingsExportVerbosity; class SaveMappingsPane extends GridPane { SaveMappingsPane(boolean offerNamespaces) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/UidMenu.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/UidMenu.java index 65953844..eab50f29 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/UidMenu.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/UidMenu.java @@ -19,18 +19,18 @@ import javafx.scene.control.SeparatorMenuItem; import matcher.Matcher; -import matcher.config.Config; -import matcher.config.UidConfig; import matcher.gui.MatcherGui; -import matcher.type.ClassEnv; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.Matchable; -import matcher.type.MatchType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.config.Config; +import matcher.model.config.UidConfig; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.Matchable; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class UidMenu extends Menu { UidMenu(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/UidSetupPane.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/UidSetupPane.java index 5384990f..c952261a 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/UidSetupPane.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/UidSetupPane.java @@ -9,8 +9,8 @@ import javafx.scene.layout.GridPane; import javafx.stage.Window; -import matcher.config.UidConfig; import matcher.gui.ui.GuiConstants; +import matcher.model.config.UidConfig; public class UidSetupPane extends GridPane { UidSetupPane(UidConfig config, Window window, Node okButton) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/menu/ViewMenu.java b/matcher-gui/src/main/java/matcher/gui/ui/menu/ViewMenu.java index 38707c6f..4ca80196 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/menu/ViewMenu.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/menu/ViewMenu.java @@ -7,14 +7,14 @@ import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; -import matcher.NameType; -import matcher.config.Config; -import matcher.config.Theme; -import matcher.gui.ui.GuiUtil; -import matcher.gui.ui.IGuiComponent; import matcher.gui.MatcherGui; import matcher.gui.MatcherGui.SortKey; import matcher.gui.srcprocess.BuiltinDecompiler; +import matcher.gui.ui.GuiUtil; +import matcher.gui.ui.IGuiComponent; +import matcher.model.NameType; +import matcher.model.config.Config; +import matcher.model.config.Theme; public class ViewMenu extends Menu implements IGuiComponent { ViewMenu(MatcherGui gui) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/BytecodeTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/BytecodeTab.java index a90ae8ef..5a595740 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/BytecodeTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/BytecodeTab.java @@ -5,14 +5,14 @@ import org.objectweb.asm.util.TraceClassVisitor; -import matcher.NameType; import matcher.gui.MatcherGui; import matcher.gui.srcprocess.HtmlUtil; import matcher.gui.ui.ISelectionProvider; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; +import matcher.model.NameType; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; public class BytecodeTab extends WebViewTab { public BytecodeTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassInfoTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassInfoTab.java index 0c321b3c..90026223 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassInfoTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassInfoTab.java @@ -15,15 +15,15 @@ import javafx.scene.layout.GridPane; import org.objectweb.asm.tree.ClassNode; -import matcher.NameType; -import matcher.Util; -import matcher.Util.AFElementType; -import matcher.type.ClassInstance; -import matcher.type.Matchable; import matcher.gui.MatcherGui; import matcher.gui.ui.GuiConstants; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.Util.AFElementType; +import matcher.model.type.ClassInstance; +import matcher.model.type.Matchable; public class ClassInfoTab extends Tab implements IGuiComponent { public ClassInfoTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassScoresTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassScoresTab.java index 9e676eca..9114e764 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassScoresTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/ClassScoresTab.java @@ -6,12 +6,12 @@ import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; -import matcher.classifier.ClassifierResult; -import matcher.classifier.RankResult; -import matcher.type.ClassInstance; -import matcher.type.MatchType; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.classifier.ClassifierResult; +import matcher.model.classifier.RankResult; +import matcher.model.type.ClassInstance; +import matcher.model.type.MatchType; public class ClassScoresTab extends Tab implements IGuiComponent { public ClassScoresTab(ISelectionProvider selectionProvider) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/FieldInfoTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/FieldInfoTab.java index a965baad..dbd7892d 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/FieldInfoTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/FieldInfoTab.java @@ -13,14 +13,14 @@ import javafx.scene.layout.GridPane; import org.objectweb.asm.tree.FieldNode; -import matcher.NameType; -import matcher.Util; -import matcher.Util.AFElementType; -import matcher.type.FieldInstance; import matcher.gui.MatcherGui; import matcher.gui.ui.GuiConstants; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.Util.AFElementType; +import matcher.model.type.FieldInstance; public class FieldInfoTab extends Tab implements IGuiComponent { public FieldInfoTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/HierarchyTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/HierarchyTab.java index bcad3c8b..0efafee7 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/HierarchyTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/HierarchyTab.java @@ -16,8 +16,8 @@ import javafx.scene.layout.VBox; import javafx.util.Callback; -import matcher.type.ClassInstance; import matcher.gui.ui.IGuiComponent; +import matcher.model.type.ClassInstance; public class HierarchyTab extends Tab implements IGuiComponent { public HierarchyTab() { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/HtmlTextifier.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/HtmlTextifier.java index 32273727..62d255dd 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/HtmlTextifier.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/HtmlTextifier.java @@ -53,11 +53,11 @@ import org.objectweb.asm.util.TextifierSupport; import org.objectweb.asm.util.TraceSignatureVisitor; -import matcher.NameType; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; import matcher.gui.srcprocess.HtmlUtil; +import matcher.model.NameType; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; final class HtmlTextifier extends Textifier { HtmlTextifier(ClassInstance cls, NameType nameType) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/MemberScoresTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/MemberScoresTab.java index 4478309b..0e8b466e 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/MemberScoresTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/MemberScoresTab.java @@ -3,14 +3,14 @@ import javafx.scene.control.Tab; import javafx.scene.control.TableView; -import matcher.classifier.ClassifierResult; -import matcher.classifier.RankResult; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.classifier.ClassifierResult; +import matcher.model.classifier.RankResult; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; public class MemberScoresTab extends Tab implements IGuiComponent { public MemberScoresTab(ISelectionProvider selectionProvider) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodInfoTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodInfoTab.java index 76e313fb..c26b56f8 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodInfoTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodInfoTab.java @@ -16,16 +16,16 @@ import javafx.scene.layout.GridPane; import org.objectweb.asm.tree.MethodNode; -import matcher.NameType; -import matcher.Util; -import matcher.Util.AFElementType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; import matcher.gui.MatcherGui; import matcher.gui.ui.GuiConstants; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.Util.AFElementType; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class MethodInfoTab extends Tab implements IGuiComponent { public MethodInfoTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodVarScoresTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodVarScoresTab.java index 3351a7cc..bb66b1e5 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodVarScoresTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/MethodVarScoresTab.java @@ -3,12 +3,12 @@ import javafx.scene.control.Tab; import javafx.scene.control.TableView; -import matcher.classifier.ClassifierResult; -import matcher.classifier.RankResult; -import matcher.type.MatchType; -import matcher.type.MethodVarInstance; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.classifier.ClassifierResult; +import matcher.model.classifier.RankResult; +import matcher.model.type.MatchType; +import matcher.model.type.MethodVarInstance; public class MethodVarScoresTab extends Tab implements IGuiComponent { public MethodVarScoresTab(ISelectionProvider selectionProvider) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/SourcecodeTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/SourcecodeTab.java index 578bedb7..913b4808 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/SourcecodeTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/SourcecodeTab.java @@ -4,18 +4,18 @@ import java.io.StringWriter; import java.util.Set; -import matcher.NameType; -import matcher.gui.ui.ISelectionProvider; import matcher.gui.MatcherGui; import matcher.gui.srcprocess.Decompiler; import matcher.gui.srcprocess.HtmlUtil; import matcher.gui.srcprocess.SrcDecorator; import matcher.gui.srcprocess.SrcDecorator.SrcParseException; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MatchType; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; +import matcher.gui.ui.ISelectionProvider; +import matcher.model.NameType; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MatchType; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; public class SourcecodeTab extends WebViewTab { public SourcecodeTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/VarInfoTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/VarInfoTab.java index 2d04f4fd..282e2bb7 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/VarInfoTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/VarInfoTab.java @@ -10,12 +10,12 @@ import javafx.scene.control.Tab; import javafx.scene.layout.GridPane; -import matcher.NameType; -import matcher.type.MethodVarInstance; import matcher.gui.MatcherGui; import matcher.gui.ui.GuiConstants; import matcher.gui.ui.IGuiComponent; import matcher.gui.ui.ISelectionProvider; +import matcher.model.NameType; +import matcher.model.type.MethodVarInstance; public class VarInfoTab extends Tab implements IGuiComponent { public VarInfoTab(MatcherGui gui, ISelectionProvider selectionProvider, boolean unmatchedTmp) { diff --git a/matcher-gui/src/main/java/matcher/gui/ui/tab/WebViewTab.java b/matcher-gui/src/main/java/matcher/gui/ui/tab/WebViewTab.java index 700340f2..55ee0d3f 100644 --- a/matcher-gui/src/main/java/matcher/gui/ui/tab/WebViewTab.java +++ b/matcher-gui/src/main/java/matcher/gui/ui/tab/WebViewTab.java @@ -15,9 +15,9 @@ import javafx.scene.control.Tab; import javafx.scene.web.WebView; -import matcher.config.Config; -import matcher.gui.ui.IGuiComponent; import matcher.gui.srcprocess.HtmlUtil; +import matcher.gui.ui.IGuiComponent; +import matcher.model.config.Config; abstract class WebViewTab extends Tab implements IGuiComponent.Selectable { protected WebViewTab(String text, String templatePath) { diff --git a/matcher-gui/src/main/java/module-info.java b/matcher-gui/src/main/java/module-info.java index c31230b1..1d94ed27 100644 --- a/matcher-gui/src/main/java/module-info.java +++ b/matcher-gui/src/main/java/module-info.java @@ -1,7 +1,6 @@ module matcher.gui { requires cfr; requires com.github.javaparser.core; - requires java.prefs; requires org.objectweb.asm.util; requires org.vineflower.vineflower; requires procyon.compilertools; diff --git a/matcher-model/build.gradle b/matcher-model/build.gradle new file mode 100644 index 00000000..3753dc12 --- /dev/null +++ b/matcher-model/build.gradle @@ -0,0 +1,25 @@ +archivesBaseName = 'matcher-model' + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + + if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_11)) { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 11 +} + +dependencies { + api "net.fabricmc:mapping-io:${mappingio_version}" + api "org.ow2.asm:asm:${asm_version}" + api "org.ow2.asm:asm-tree:${asm_version}" + api "org.slf4j:slf4j-api:${slf4j_version}" + implementation "org.ow2.asm:asm-commons:${asm_version}" + implementation "org.ow2.asm:asm-util:${asm_version}" +} diff --git a/matcher-core/src/main/java/matcher/NameType.java b/matcher-model/src/main/java/matcher/model/NameType.java similarity index 99% rename from matcher-core/src/main/java/matcher/NameType.java rename to matcher-model/src/main/java/matcher/model/NameType.java index db9493ec..0b1d0691 100644 --- a/matcher-core/src/main/java/matcher/NameType.java +++ b/matcher-model/src/main/java/matcher/model/NameType.java @@ -1,4 +1,4 @@ -package matcher; +package matcher.model; import java.util.NoSuchElementException; import java.util.Objects; diff --git a/matcher-core/src/main/java/matcher/SignatureInference.java b/matcher-model/src/main/java/matcher/model/SignatureInference.java similarity index 82% rename from matcher-core/src/main/java/matcher/SignatureInference.java rename to matcher-model/src/main/java/matcher/model/SignatureInference.java index 6daf39f2..0ef4271d 100644 --- a/matcher-core/src/main/java/matcher/SignatureInference.java +++ b/matcher-model/src/main/java/matcher/model/SignatureInference.java @@ -1,21 +1,21 @@ -package matcher; +package matcher.model; import java.util.HashSet; import java.util.Set; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; -import matcher.type.Signature.ClassTypeSignature; -import matcher.type.Signature.FieldSignature; -import matcher.type.Signature.JavaTypeSignature; -import matcher.type.Signature.MethodSignature; -import matcher.type.Signature.ReferenceTypeSignature; -import matcher.type.Signature.SimpleClassTypeSignature; -import matcher.type.Signature.ThrowsSignature; -import matcher.type.Signature.TypeArgument; -import matcher.type.Signature.TypeParameter; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.Signature.ClassTypeSignature; +import matcher.model.type.Signature.FieldSignature; +import matcher.model.type.Signature.JavaTypeSignature; +import matcher.model.type.Signature.MethodSignature; +import matcher.model.type.Signature.ReferenceTypeSignature; +import matcher.model.type.Signature.SimpleClassTypeSignature; +import matcher.model.type.Signature.ThrowsSignature; +import matcher.model.type.Signature.TypeArgument; +import matcher.model.type.Signature.TypeParameter; public final class SignatureInference { public static void process(ClassEnvironment env) { diff --git a/matcher-core/src/main/java/matcher/SimilarityChecker.java b/matcher-model/src/main/java/matcher/model/SimilarityChecker.java similarity index 90% rename from matcher-core/src/main/java/matcher/SimilarityChecker.java rename to matcher-model/src/main/java/matcher/model/SimilarityChecker.java index adf97080..a88e87ee 100644 --- a/matcher-core/src/main/java/matcher/SimilarityChecker.java +++ b/matcher-model/src/main/java/matcher/model/SimilarityChecker.java @@ -1,11 +1,11 @@ -package matcher; - -import matcher.classifier.ClassifierUtil; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +package matcher.model; + +import matcher.model.classifier.ClassifierUtil; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public final class SimilarityChecker { public static float compare(ClassInstance a, ClassInstance b) { diff --git a/matcher-core/src/main/java/matcher/Util.java b/matcher-model/src/main/java/matcher/model/Util.java similarity index 92% rename from matcher-core/src/main/java/matcher/Util.java rename to matcher-model/src/main/java/matcher/model/Util.java index 33e1fb19..b3a9b612 100644 --- a/matcher-core/src/main/java/matcher/Util.java +++ b/matcher-model/src/main/java/matcher/model/Util.java @@ -1,4 +1,4 @@ -package matcher; +package matcher.model; import java.io.Closeable; import java.io.IOException; @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.IdentityHashMap; +import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -29,8 +30,33 @@ import org.objectweb.asm.Handle; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.MethodInsnNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import matcher.model.classifier.RankResult; public class Util { + public static double getScore(double rawScore, double maxScore) { + double ret = rawScore / maxScore; + + return ret * ret; + } + + public static boolean checkRank(List> ranking, double absThreshold, double relThreshold, double maxScore) { + if (ranking.isEmpty()) return false; + + double score = getScore(ranking.get(0).getScore(), maxScore); + if (score < absThreshold) return false; + + if (ranking.size() == 1) { + return true; + } else { + double nextScore = getScore(ranking.get(1).getScore(), maxScore); + + return nextScore < score * (1 - relThreshold); + } + } + public static Set newIdentityHashSet() { return Collections.newSetFromMap(new IdentityHashMap<>()); //new IdentityHashSet<>(); } @@ -215,7 +241,7 @@ public static Handle getTargetHandle(Handle bsm, Object[] bsmArgs) { } else if (isIrrelevantBsm(bsm)) { return null; } else { - Matcher.LOGGER.warn("Unknown invokedynamic bsm: {}/{}{} (tag={} iif={})", + logger.warn("Unknown invokedynamic bsm: {}/{}{} (tag={} iif={})", bsm.getOwner(), bsm.getName(), bsm.getDesc(), bsm.getTag(), bsm.isInterface()); return null; @@ -372,5 +398,6 @@ public static int compareNatural(String a, String b) { } } + private static final Logger logger = LoggerFactory.getLogger(Util.class); public static final Object asmNodeSync = new Object(); } diff --git a/matcher-core/src/main/java/matcher/bcremap/AsmClassRemapper.java b/matcher-model/src/main/java/matcher/model/bcremap/AsmClassRemapper.java similarity index 99% rename from matcher-core/src/main/java/matcher/bcremap/AsmClassRemapper.java rename to matcher-model/src/main/java/matcher/model/bcremap/AsmClassRemapper.java index 834f9c64..d67bbc09 100644 --- a/matcher-core/src/main/java/matcher/bcremap/AsmClassRemapper.java +++ b/matcher-model/src/main/java/matcher/model/bcremap/AsmClassRemapper.java @@ -1,4 +1,4 @@ -package matcher.bcremap; +package matcher.model.bcremap; import java.util.Arrays; import java.util.IdentityHashMap; @@ -15,7 +15,7 @@ import org.objectweb.asm.commons.MethodRemapper; import org.objectweb.asm.tree.ClassNode; -import matcher.Util; +import matcher.model.Util; public class AsmClassRemapper extends ClassRemapper { public static void process(ClassNode source, AsmRemapper remapper, ClassVisitor sink) { diff --git a/matcher-core/src/main/java/matcher/bcremap/AsmRemapper.java b/matcher-model/src/main/java/matcher/model/bcremap/AsmRemapper.java similarity index 91% rename from matcher-core/src/main/java/matcher/bcremap/AsmRemapper.java rename to matcher-model/src/main/java/matcher/model/bcremap/AsmRemapper.java index ae8c7c95..c4697aef 100644 --- a/matcher-core/src/main/java/matcher/bcremap/AsmRemapper.java +++ b/matcher-model/src/main/java/matcher/model/bcremap/AsmRemapper.java @@ -1,13 +1,13 @@ -package matcher.bcremap; +package matcher.model.bcremap; import org.objectweb.asm.commons.Remapper; -import matcher.NameType; -import matcher.type.ClassEnv; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class AsmRemapper extends Remapper { public AsmRemapper(ClassEnv env, NameType nameType) { diff --git a/matcher-core/src/main/java/matcher/classifier/ClassClassifier.java b/matcher-model/src/main/java/matcher/model/classifier/ClassClassifier.java similarity index 96% rename from matcher-core/src/main/java/matcher/classifier/ClassClassifier.java rename to matcher-model/src/main/java/matcher/model/classifier/ClassClassifier.java index 9719d641..ee6ef1f7 100644 --- a/matcher-core/src/main/java/matcher/classifier/ClassClassifier.java +++ b/matcher-model/src/main/java/matcher/model/classifier/ClassClassifier.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.ArrayList; import java.util.Arrays; @@ -16,14 +16,13 @@ import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; -import matcher.Matcher; -import matcher.Util; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; -import matcher.type.Signature.ClassSignature; +import matcher.model.Util; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; +import matcher.model.type.Signature.ClassSignature; public class ClassClassifier { public static void init() { @@ -420,7 +419,7 @@ public double getScore(ClassInstance clsA, ClassInstance clsB, ClassEnvironment @Override public double getScore(ClassInstance clsA, ClassInstance clsB, ClassEnvironment env) { /*if (clsA.getName().equals("agl") && clsB.getName().equals("aht")) { - Matcher.LOGGER.info(); + logger.info(); }*/ final double absThreshold = 0.8; @@ -435,7 +434,7 @@ public double getScore(ClassInstance clsA, ClassInstance clsB, ClassEnvironment if (!method.isMatchable()) continue; List> ranking = MethodClassifier.rank(method, clsB.getMethods(), level, env); - if (Matcher.checkRank(ranking, absThreshold, relThreshold, maxScore)) match += Matcher.getScore(ranking.get(0).getScore(), maxScore); + if (Util.checkRank(ranking, absThreshold, relThreshold, maxScore)) match += Util.getScore(ranking.get(0).getScore(), maxScore); } } @@ -446,7 +445,7 @@ public double getScore(ClassInstance clsA, ClassInstance clsB, ClassEnvironment if (!field.isMatchable()) continue; List> ranking = FieldClassifier.rank(field, clsB.getFields(), level, env); - if (Matcher.checkRank(ranking, absThreshold, relThreshold, maxScore)) match += Matcher.getScore(ranking.get(0).getScore(), maxScore); + if (Util.checkRank(ranking, absThreshold, relThreshold, maxScore)) match += Util.getScore(ranking.get(0).getScore(), maxScore); } } diff --git a/matcher-core/src/main/java/matcher/classifier/ClassifierLevel.java b/matcher-model/src/main/java/matcher/model/classifier/ClassifierLevel.java similarity index 79% rename from matcher-core/src/main/java/matcher/classifier/ClassifierLevel.java rename to matcher-model/src/main/java/matcher/model/classifier/ClassifierLevel.java index 03b51364..c38c410d 100644 --- a/matcher-core/src/main/java/matcher/classifier/ClassifierLevel.java +++ b/matcher-model/src/main/java/matcher/model/classifier/ClassifierLevel.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; public enum ClassifierLevel { Initial, diff --git a/matcher-core/src/main/java/matcher/classifier/ClassifierResult.java b/matcher-model/src/main/java/matcher/model/classifier/ClassifierResult.java similarity index 92% rename from matcher-core/src/main/java/matcher/classifier/ClassifierResult.java rename to matcher-model/src/main/java/matcher/model/classifier/ClassifierResult.java index 0baf5284..f830e5ac 100644 --- a/matcher-core/src/main/java/matcher/classifier/ClassifierResult.java +++ b/matcher-model/src/main/java/matcher/model/classifier/ClassifierResult.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; public class ClassifierResult { public ClassifierResult(IClassifier classifier, double score) { diff --git a/matcher-core/src/main/java/matcher/classifier/ClassifierUtil.java b/matcher-model/src/main/java/matcher/model/classifier/ClassifierUtil.java similarity index 95% rename from matcher-core/src/main/java/matcher/classifier/ClassifierUtil.java rename to matcher-model/src/main/java/matcher/model/classifier/ClassifierUtil.java index 4939c747..078d82e1 100644 --- a/matcher-core/src/main/java/matcher/classifier/ClassifierUtil.java +++ b/matcher-model/src/main/java/matcher/model/classifier/ClassifierUtil.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.ArrayList; import java.util.Arrays; @@ -36,18 +36,19 @@ import org.objectweb.asm.tree.VarInsnNode; import org.objectweb.asm.util.Textifier; import org.objectweb.asm.util.TraceMethodVisitor; - -import matcher.Matcher; -import matcher.Util; -import matcher.classifier.MatchingCache.CacheToken; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.Matchable; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodType; -import matcher.type.MethodVarInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import matcher.model.Util; +import matcher.model.classifier.MatchingCache.CacheToken; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.Matchable; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodType; +import matcher.model.type.MethodVarInstance; public class ClassifierUtil { public static boolean checkPotentialEquality(ClassInstance a, ClassInstance b) { @@ -378,10 +379,10 @@ private static int compareInsns(AbstractInsnNode insnA, AbstractInsnNode ins implB.getOwner(), implB.getName(), implB.getDesc(), Util.isCallToInterface(implB), env) ? COMPARED_SIMILAR : COMPARED_DISTINCT; default: - Matcher.LOGGER.warn("Unexpected impl tag: {}", implA.getTag()); + logger.warn("Unexpected impl tag: {}", implA.getTag()); } } else if (!Util.isIrrelevantBsm(a.bsm)) { - Matcher.LOGGER.warn("Unknown invokedynamic bsm: {}/{}{} (tag={} iif={})", + logger.warn("Unknown invokedynamic bsm: {}/{}{} (tag={} iif={})", a.bsm.getOwner(), a.bsm.getName(), a.bsm.getDesc(), a.bsm.getTag(), a.bsm.isInterface()); } @@ -624,10 +625,10 @@ private static int[] mapLists(T listA, T listB, ListElementRetriever int[] mapLists(T listA, T listB, ListElementRetriever= COMPARED_DISTINCT) { assert c - keepCost == COMPARED_DISTINCT; - //Matcher.LOGGER.debug("{}/{} rep {} -> {}", i-1, j-1, toString(elementRetriever.apply(listA, i - 1)), toString(elementRetriever.apply(listB, j - 1))); + //logger.debug("{}/{} rep {} -> {}", i-1, j-1, toString(elementRetriever.apply(listA, i - 1)), toString(elementRetriever.apply(listB, j - 1))); ret[i - 1] = -1; } else { - //Matcher.LOGGER.debug("{}/{} eq {} - {}", i-1, j-1, toString(elementRetriever.apply(listA, i - 1)), toString(elementRetriever.apply(listB, j - 1))); + //logger.debug("{}/{} eq {} - {}", i-1, j-1, toString(elementRetriever.apply(listA, i - 1)), toString(elementRetriever.apply(listB, j - 1))); ret[i - 1] = j - 1; /*U e = elementRetriever.apply(listA, i - 1); @@ -660,11 +661,11 @@ private static int[] mapLists(T listA, T listB, ListElementRetriever ilMapCacheToken = new CacheToken<>(); } diff --git a/matcher-core/src/main/java/matcher/classifier/FieldClassifier.java b/matcher-model/src/main/java/matcher/model/classifier/FieldClassifier.java similarity index 97% rename from matcher-core/src/main/java/matcher/classifier/FieldClassifier.java rename to matcher-model/src/main/java/matcher/model/classifier/FieldClassifier.java index afa9b790..5ac90387 100644 --- a/matcher-core/src/main/java/matcher/classifier/FieldClassifier.java +++ b/matcher-model/src/main/java/matcher/model/classifier/FieldClassifier.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.ArrayList; import java.util.Collections; @@ -14,12 +14,12 @@ import org.objectweb.asm.tree.FieldInsnNode; import org.objectweb.asm.tree.InsnList; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.Signature.FieldSignature; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.Signature.FieldSignature; public class FieldClassifier { public static void init() { diff --git a/matcher-core/src/main/java/matcher/classifier/IClassifier.java b/matcher-model/src/main/java/matcher/model/classifier/IClassifier.java similarity index 62% rename from matcher-core/src/main/java/matcher/classifier/IClassifier.java rename to matcher-model/src/main/java/matcher/model/classifier/IClassifier.java index c1061569..c6140341 100644 --- a/matcher-core/src/main/java/matcher/classifier/IClassifier.java +++ b/matcher-model/src/main/java/matcher/model/classifier/IClassifier.java @@ -1,6 +1,6 @@ -package matcher.classifier; +package matcher.model.classifier; -import matcher.type.ClassEnvironment; +import matcher.model.type.ClassEnvironment; public interface IClassifier { String getName(); diff --git a/matcher-core/src/main/java/matcher/classifier/IRanker.java b/matcher-model/src/main/java/matcher/model/classifier/IRanker.java similarity index 68% rename from matcher-core/src/main/java/matcher/classifier/IRanker.java rename to matcher-model/src/main/java/matcher/model/classifier/IRanker.java index a8ca811a..ec7ae678 100644 --- a/matcher-core/src/main/java/matcher/classifier/IRanker.java +++ b/matcher-model/src/main/java/matcher/model/classifier/IRanker.java @@ -1,8 +1,8 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.List; -import matcher.type.ClassEnvironment; +import matcher.model.type.ClassEnvironment; public interface IRanker { List> rank(T src, T[] dsts, ClassifierLevel level, ClassEnvironment env, double maxMismatch); diff --git a/matcher-core/src/main/java/matcher/classifier/MatchingCache.java b/matcher-model/src/main/java/matcher/model/classifier/MatchingCache.java similarity index 94% rename from matcher-core/src/main/java/matcher/classifier/MatchingCache.java rename to matcher-model/src/main/java/matcher/model/classifier/MatchingCache.java index caf0d0e1..e2674a0a 100644 --- a/matcher-core/src/main/java/matcher/classifier/MatchingCache.java +++ b/matcher-model/src/main/java/matcher/model/classifier/MatchingCache.java @@ -1,10 +1,10 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiFunction; -import matcher.type.Matchable; +import matcher.model.type.Matchable; public class MatchingCache { @SuppressWarnings("unchecked") diff --git a/matcher-core/src/main/java/matcher/classifier/MethodClassifier.java b/matcher-model/src/main/java/matcher/model/classifier/MethodClassifier.java similarity index 97% rename from matcher-core/src/main/java/matcher/classifier/MethodClassifier.java rename to matcher-model/src/main/java/matcher/model/classifier/MethodClassifier.java index 8a309a91..87017b24 100644 --- a/matcher-core/src/main/java/matcher/classifier/MethodClassifier.java +++ b/matcher-model/src/main/java/matcher/model/classifier/MethodClassifier.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.ArrayList; import java.util.Arrays; @@ -16,13 +16,13 @@ import org.objectweb.asm.tree.InvokeDynamicInsnNode; import org.objectweb.asm.tree.MethodInsnNode; -import matcher.Util; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; -import matcher.type.Signature.MethodSignature; +import matcher.model.Util; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; +import matcher.model.type.Signature.MethodSignature; public class MethodClassifier { public static void init() { diff --git a/matcher-core/src/main/java/matcher/classifier/MethodVarClassifier.java b/matcher-model/src/main/java/matcher/model/classifier/MethodVarClassifier.java similarity index 97% rename from matcher-core/src/main/java/matcher/classifier/MethodVarClassifier.java rename to matcher-model/src/main/java/matcher/model/classifier/MethodVarClassifier.java index ab642405..7a9a0db7 100644 --- a/matcher-core/src/main/java/matcher/classifier/MethodVarClassifier.java +++ b/matcher-model/src/main/java/matcher/model/classifier/MethodVarClassifier.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.ArrayList; import java.util.Collections; @@ -11,8 +11,8 @@ import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.VarInsnNode; -import matcher.type.ClassEnvironment; -import matcher.type.MethodVarInstance; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.MethodVarInstance; public class MethodVarClassifier { public static void init() { diff --git a/matcher-core/src/main/java/matcher/classifier/RankResult.java b/matcher-model/src/main/java/matcher/model/classifier/RankResult.java similarity index 93% rename from matcher-core/src/main/java/matcher/classifier/RankResult.java rename to matcher-model/src/main/java/matcher/model/classifier/RankResult.java index f595086f..c48dca17 100644 --- a/matcher-core/src/main/java/matcher/classifier/RankResult.java +++ b/matcher-model/src/main/java/matcher/model/classifier/RankResult.java @@ -1,4 +1,4 @@ -package matcher.classifier; +package matcher.model.classifier; import java.util.List; diff --git a/matcher-core/src/main/java/matcher/config/Config.java b/matcher-model/src/main/java/matcher/model/config/Config.java similarity index 99% rename from matcher-core/src/main/java/matcher/config/Config.java rename to matcher-model/src/main/java/matcher/model/config/Config.java index 8a659a1d..fc0b9ba5 100644 --- a/matcher-core/src/main/java/matcher/config/Config.java +++ b/matcher-model/src/main/java/matcher/model/config/Config.java @@ -1,4 +1,4 @@ -package matcher.config; +package matcher.model.config; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/matcher-core/src/main/java/matcher/config/ProjectConfig.java b/matcher-model/src/main/java/matcher/model/config/ProjectConfig.java similarity index 99% rename from matcher-core/src/main/java/matcher/config/ProjectConfig.java rename to matcher-model/src/main/java/matcher/model/config/ProjectConfig.java index 11059c36..535dd287 100644 --- a/matcher-core/src/main/java/matcher/config/ProjectConfig.java +++ b/matcher-model/src/main/java/matcher/model/config/ProjectConfig.java @@ -1,4 +1,4 @@ -package matcher.config; +package matcher.model.config; import java.nio.file.Path; import java.util.Collections; diff --git a/matcher-core/src/main/java/matcher/config/Theme.java b/matcher-model/src/main/java/matcher/model/config/Theme.java similarity index 97% rename from matcher-core/src/main/java/matcher/config/Theme.java rename to matcher-model/src/main/java/matcher/model/config/Theme.java index ac15d2cf..1ef60908 100644 --- a/matcher-core/src/main/java/matcher/config/Theme.java +++ b/matcher-model/src/main/java/matcher/model/config/Theme.java @@ -1,4 +1,4 @@ -package matcher.config; +package matcher.model.config; import java.net.URL; diff --git a/matcher-core/src/main/java/matcher/config/UidConfig.java b/matcher-model/src/main/java/matcher/model/config/UidConfig.java similarity index 98% rename from matcher-core/src/main/java/matcher/config/UidConfig.java rename to matcher-model/src/main/java/matcher/model/config/UidConfig.java index db7891e6..06ec7e9a 100644 --- a/matcher-core/src/main/java/matcher/config/UidConfig.java +++ b/matcher-model/src/main/java/matcher/model/config/UidConfig.java @@ -1,4 +1,4 @@ -package matcher.config; +package matcher.model.config; import java.net.InetSocketAddress; import java.util.prefs.Preferences; diff --git a/matcher-core/src/main/java/matcher/mapping/MappedElementComparators.java b/matcher-model/src/main/java/matcher/model/mapping/MappedElementComparators.java similarity index 93% rename from matcher-core/src/main/java/matcher/mapping/MappedElementComparators.java rename to matcher-model/src/main/java/matcher/model/mapping/MappedElementComparators.java index bf6b2cc1..83a52ac6 100644 --- a/matcher-core/src/main/java/matcher/mapping/MappedElementComparators.java +++ b/matcher-model/src/main/java/matcher/model/mapping/MappedElementComparators.java @@ -1,13 +1,13 @@ -package matcher.mapping; +package matcher.model.mapping; import java.util.Comparator; import java.util.Objects; -import matcher.NameType; -import matcher.type.ClassInstance; -import matcher.type.Matchable; -import matcher.type.MemberInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.type.ClassInstance; +import matcher.model.type.Matchable; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodVarInstance; public final class MappedElementComparators { public static > Comparator byName(NameType ns) { diff --git a/matcher-core/src/main/java/matcher/mapping/MappingField.java b/matcher-model/src/main/java/matcher/model/mapping/MappingField.java similarity index 88% rename from matcher-core/src/main/java/matcher/mapping/MappingField.java rename to matcher-model/src/main/java/matcher/model/mapping/MappingField.java index a55e1dfb..295eaecc 100644 --- a/matcher-core/src/main/java/matcher/mapping/MappingField.java +++ b/matcher-model/src/main/java/matcher/model/mapping/MappingField.java @@ -1,6 +1,6 @@ -package matcher.mapping; +package matcher.model.mapping; -import matcher.NameType; +import matcher.model.NameType; public enum MappingField { PLAIN("Plain", NameType.PLAIN), diff --git a/matcher-core/src/main/java/matcher/mapping/MappingPropagator.java b/matcher-model/src/main/java/matcher/model/mapping/MappingPropagator.java similarity index 81% rename from matcher-core/src/main/java/matcher/mapping/MappingPropagator.java rename to matcher-model/src/main/java/matcher/model/mapping/MappingPropagator.java index 5aab9841..813816ba 100644 --- a/matcher-core/src/main/java/matcher/mapping/MappingPropagator.java +++ b/matcher-model/src/main/java/matcher/model/mapping/MappingPropagator.java @@ -1,17 +1,19 @@ -package matcher.mapping; +package matcher.model.mapping; import java.util.Objects; import java.util.Set; import java.util.function.DoubleConsumer; -import matcher.Matcher; -import matcher.NameType; -import matcher.Util; -import matcher.type.ClassEnvironment; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.ClassEnvironment; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public final class MappingPropagator { public static boolean propagateNames(ClassEnvironment env, DoubleConsumer progressReceiver) { @@ -88,7 +90,7 @@ public static boolean propagateNames(ClassEnvironment env, DoubleConsumer progre } } - Matcher.LOGGER.info("Propagated {} method names and {} method arg names", propagatedMethodNames, propagatedArgNames); + logger.info("Propagated {} method names and {} method arg names", propagatedMethodNames, propagatedArgNames); return propagatedMethodNames > 0 || propagatedArgNames > 0; } @@ -115,10 +117,10 @@ public static boolean fixRecordMemberNames(ClassEnvironment env, NameType nameTy if (linkedMethod.isNameObfuscated() && (!field.isNameObfuscated() || !linkedMethod.hasMappedName() || field.hasMappedName())) { - Matcher.LOGGER.debug("Copying record component name for method {} from field {} -> {}", linkedMethod, field, fieldName); + logger.debug("Copying record component name for method {} from field {} -> {}", linkedMethod, field, fieldName); linkedMethod.setMappedName(fieldName); } else { - Matcher.LOGGER.debug("Copying record component name for field {} from method {} -> {}", field, linkedMethod, methodName); + logger.debug("Copying record component name for field {} from method {} -> {}", field, linkedMethod, methodName); field.setMappedName(methodName); } @@ -126,8 +128,10 @@ public static boolean fixRecordMemberNames(ClassEnvironment env, NameType nameTy } } - Matcher.LOGGER.info("Fixed {} record names.", modified); + logger.info("Fixed {} record names.", modified); return modified > 0; } + + private static final Logger logger = LoggerFactory.getLogger(MappingPropagator.class); } diff --git a/matcher-core/src/main/java/matcher/mapping/Mappings.java b/matcher-model/src/main/java/matcher/model/mapping/Mappings.java similarity index 92% rename from matcher-core/src/main/java/matcher/mapping/Mappings.java rename to matcher-model/src/main/java/matcher/model/mapping/Mappings.java index 81d2867b..95f394e1 100644 --- a/matcher-core/src/main/java/matcher/mapping/Mappings.java +++ b/matcher-model/src/main/java/matcher/model/mapping/Mappings.java @@ -1,4 +1,4 @@ -package matcher.mapping; +package matcher.model.mapping; import java.io.IOException; import java.nio.file.Path; @@ -8,6 +8,9 @@ import java.util.List; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import net.fabricmc.mappingio.FlatMappingVisitor; import net.fabricmc.mappingio.MappedElementKind; import net.fabricmc.mappingio.MappingReader; @@ -17,18 +20,17 @@ import net.fabricmc.mappingio.adapter.RegularAsFlatMappingVisitor; import net.fabricmc.mappingio.format.MappingFormat; -import matcher.Matcher; -import matcher.NameType; -import matcher.Util; -import matcher.type.ClassEnv; -import matcher.type.ClassInstance; -import matcher.type.FieldInstance; -import matcher.type.LocalClassEnv; -import matcher.type.Matchable; -import matcher.type.MatchableKind; -import matcher.type.MemberInstance; -import matcher.type.MethodInstance; -import matcher.type.MethodVarInstance; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.ClassEnv; +import matcher.model.type.ClassInstance; +import matcher.model.type.FieldInstance; +import matcher.model.type.LocalClassEnv; +import matcher.model.type.Matchable; +import matcher.model.type.MatchableKind; +import matcher.model.type.MemberInstance; +import matcher.model.type.MethodInstance; +import matcher.model.type.MethodVarInstance; public class Mappings { public static void load(Path path, MappingFormat format, @@ -81,7 +83,7 @@ public boolean visitClass(String srcName) { cur = cls = findClass(srcName, fieldSource, env); if (cls == null) { - if (warnedClasses.add(srcName)) Matcher.LOGGER.warn("Can't find mapped class {}", srcName); + if (warnedClasses.add(srcName)) logger.warn("Can't find mapped class {}", srcName); return false; } @@ -97,7 +99,7 @@ public boolean visitMethod(String srcName, String srcDesc) { cur = method = cls.getMethod(srcName, srcDesc, fieldSource.type); if (method == null || !method.isReal()) { - Matcher.LOGGER.warn("Can't find mapped method {}/{}{}", + logger.warn("Can't find mapped method {}/{}{}", cls.getName(fieldSource.type), srcName, srcDesc); return false; } @@ -133,28 +135,28 @@ public boolean visitMethodVar(int asmIndex, int lvIndex, int startOpIdx, int end private MethodVarInstance getMethodVar(int varIndex, int lvIndex, int startOpIdx, int asmIndex, boolean isArg) { if (isArg && varIndex < -1 || varIndex >= method.getArgs().length) { - Matcher.LOGGER.warn("Invalid var index {} for method {}", varIndex, method); + logger.warn("Invalid var index {} for method {}", varIndex, method); } else if (lvIndex < -1 || lvIndex >= (isArg ? method.getArgs() : method.getVars()).length * 2 + 1) { - Matcher.LOGGER.warn("Invalid lv index {} for method {}", lvIndex, method); + logger.warn("Invalid lv index {} for method {}", lvIndex, method); } else if (asmIndex < -1) { - Matcher.LOGGER.warn("Invalid lv asm index {} for method {}", asmIndex, method); + logger.warn("Invalid lv asm index {} for method {}", asmIndex, method); } else { if (!isArg || varIndex == -1) { if (asmIndex >= 0) { varIndex = findVarIndexByAsm(isArg ? method.getArgs() : method.getVars(), asmIndex); if (varIndex == -1) { - Matcher.LOGGER.warn("Invalid lv asm index {} for method {}", asmIndex, method); + logger.warn("Invalid lv asm index {} for method {}", asmIndex, method); return null; } } else if (lvIndex <= -1) { - Matcher.LOGGER.warn("Missing arg+lvt index {} for method {}", lvIndex, method); + logger.warn("Missing arg+lvt index {} for method {}", lvIndex, method); return null; } else { varIndex = findVarIndexByLv(isArg ? method.getArgs() : method.getVars(), lvIndex, startOpIdx); if (varIndex == -1) { - Matcher.LOGGER.warn("Invalid lv index {} for method {}", lvIndex, method); + logger.warn("Invalid lv index {} for method {}", lvIndex, method); return null; } } @@ -163,12 +165,12 @@ private MethodVarInstance getMethodVar(int varIndex, int lvIndex, int startOpIdx MethodVarInstance var = isArg ? method.getArg(varIndex) : method.getVar(varIndex); if (lvIndex != -1 && var.getLvIndex() != lvIndex) { - Matcher.LOGGER.warn("Mismatched lv index {} for method {}", lvIndex, method); + logger.warn("Mismatched lv index {} for method {}", lvIndex, method); return null; } if (asmIndex != -1 && var.getAsmIndex() != asmIndex) { - Matcher.LOGGER.warn("Mismatched lv asm index {} for method {}", asmIndex, method); + logger.warn("Mismatched lv asm index {} for method {}", asmIndex, method); return null; } @@ -187,7 +189,7 @@ public boolean visitField(String srcName, String srcDesc) { cur = field = cls.getField(srcName, srcDesc, fieldSource.type); if (field == null || !field.isReal()) { - Matcher.LOGGER.warn("Can't find mapped field {}/{}", cls.getName(fieldSource.type), srcName); + logger.warn("Can't find mapped field {}/{}", cls.getName(fieldSource.type), srcName); return false; } @@ -226,7 +228,7 @@ public void visitDstName(MappedElementKind targetKind, int namespace, String nam String prefix = env.getGlobal().classUidPrefix; if (!name.startsWith(prefix)) { - Matcher.LOGGER.warn("Invalid uid class name {}", name); + logger.warn("Invalid uid class name {}", name); return; } else { int innerNameStart = name.lastIndexOf('$') + 1; @@ -236,7 +238,7 @@ public void visitDstName(MappedElementKind targetKind, int namespace, String nam int subPrefixStart = prefix.lastIndexOf('/') + 1; if (!name.startsWith(prefix.substring(subPrefixStart), innerNameStart)) { - Matcher.LOGGER.warn("Invalid uid class name {}", name); + logger.warn("Invalid uid class name {}", name); return; } else { uidStr = name.substring(innerNameStart + prefix.length() - subPrefixStart); @@ -248,7 +250,7 @@ public void visitDstName(MappedElementKind targetKind, int namespace, String nam int uid = Integer.parseInt(uidStr); if (uid < 0) { - Matcher.LOGGER.warn("Invalid class uid {}", uid); + logger.warn("Invalid class uid {}", uid); return; } else if (cls.getUid() < 0 || cls.getUid() > uid || replace) { cls.setUid(uid); @@ -284,13 +286,13 @@ public void visitDstName(MappedElementKind targetKind, int namespace, String nam String prefix = env.getGlobal().fieldUidPrefix; if (!name.startsWith(prefix)) { - Matcher.LOGGER.warn("Invalid uid field name {}", name); + logger.warn("Invalid uid field name {}", name); return; } else { int uid = Integer.parseInt(name.substring(prefix.length())); if (uid < 0) { - Matcher.LOGGER.warn("Invalid field uid {}", uid); + logger.warn("Invalid field uid {}", uid); return; } else if (field.getUid() < 0 || field.getUid() > uid || replace) { for (FieldInstance f : field.getAllHierarchyMembers()) { @@ -328,13 +330,13 @@ public void visitDstName(MappedElementKind targetKind, int namespace, String nam String prefix = env.getGlobal().methodUidPrefix; if (!name.startsWith(prefix)) { - Matcher.LOGGER.warn("Invalid uid method name {}", name); + logger.warn("Invalid uid method name {}", name); return; } else { int uid = Integer.parseInt(name.substring(prefix.length())); if (uid < 0) { - Matcher.LOGGER.warn("Invalid method uid {}", uid); + logger.warn("Invalid method uid {}", uid); return; } else if (method.getUid() < 0 || method.getUid() > uid || replace) { for (MethodInstance m : method.getAllHierarchyMembers()) { @@ -411,7 +413,7 @@ public void visitComment(MappedElementKind targetKind, String comment) { throw t; } - Matcher.LOGGER.info("Loaded mappings for {} classes, {} methods ({} args, {} vars) and {} fields (comments: {}/{}/{}).", + logger.info("Loaded mappings for {} classes, {} methods ({} args, {} vars) and {} fields (comments: {}/{}/{}).", dstNameCounts[MatchableKind.CLASS.ordinal()], dstNameCounts[MatchableKind.METHOD.ordinal()], dstNameCounts[MatchableKind.METHOD_ARG.ordinal()], @@ -857,6 +859,7 @@ public static void clear(ClassEnv env) { } } + private static final Logger logger = LoggerFactory.getLogger(Mappings.class); public static final String metaUidNextClass = "uid-next-class"; public static final String metaUidNextMethod = "uid-next-method"; public static final String metaUidNextField = "uid-next-field"; diff --git a/matcher-core/src/main/java/matcher/mapping/MappingsExportVerbosity.java b/matcher-model/src/main/java/matcher/model/mapping/MappingsExportVerbosity.java similarity index 67% rename from matcher-core/src/main/java/matcher/mapping/MappingsExportVerbosity.java rename to matcher-model/src/main/java/matcher/model/mapping/MappingsExportVerbosity.java index 40301b5b..c6ad13d7 100644 --- a/matcher-core/src/main/java/matcher/mapping/MappingsExportVerbosity.java +++ b/matcher-model/src/main/java/matcher/model/mapping/MappingsExportVerbosity.java @@ -1,4 +1,4 @@ -package matcher.mapping; +package matcher.model.mapping; public enum MappingsExportVerbosity { MINIMAL, ROOTS, FULL; diff --git a/matcher-core/src/main/java/matcher/type/Analysis.java b/matcher-model/src/main/java/matcher/model/type/Analysis.java similarity index 98% rename from matcher-core/src/main/java/matcher/type/Analysis.java rename to matcher-model/src/main/java/matcher/model/type/Analysis.java index 53d9666e..c39492d9 100644 --- a/matcher-core/src/main/java/matcher/type/Analysis.java +++ b/matcher-model/src/main/java/matcher/model/type/Analysis.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.io.PrintWriter; import java.io.StringWriter; @@ -46,17 +46,18 @@ import org.objectweb.asm.util.Printer; import org.objectweb.asm.util.Textifier; import org.objectweb.asm.util.TraceMethodVisitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import matcher.Matcher; -import matcher.NameType; -import matcher.Util; +import matcher.model.NameType; +import matcher.model.Util; class Analysis { static void analyzeMethod(MethodInstance method, CommonClasses common) { MethodNode asmNode = method.getAsmNode(); if (asmNode == null || (asmNode.access & Opcodes.ACC_ABSTRACT) != 0 || asmNode.instructions.size() == 0) return; - Matcher.LOGGER.debug(method.getDisplayName(NameType.MAPPED_PLAIN, true)); + logger.debug(method.getDisplayName(NameType.MAPPED_PLAIN, true)); dump(asmNode); StateRecorder rec = new StateRecorder(method, common); @@ -1144,12 +1145,12 @@ private static List createLocalVariables(InsnList il, StateRe lvToVar = null; - Matcher.LOGGER.debug("Local vars raw:"); + logger.debug("Local vars raw:"); for (int i = 0; i < varCount; i++) { ExecState state = rec.getState(startIndices[i]); - Matcher.LOGGER.debug(" {}: LV {} @ {} - {}: {}\t\t({})", + logger.debug(" {}: LV {} @ {} - {}: {}\t\t({})", i, varToLv[i], startIndices[i], endIndices[i], state.locals[varToLv[i]].toString(), rec.varSources[state.localVarIds[varToLv[i]] - 1].name()); } @@ -1255,12 +1256,12 @@ private static List createLocalVariables(InsnList il, StateRe } } - Matcher.LOGGER.debug("Local vars:"); + logger.debug("Local vars:"); for (int i = 0; i < varCount; i++) { ExecState state = rec.getState(startIndices[i]); - Matcher.LOGGER.debug(" {}: LV {} @ {} - {}: {}\t\t({})", + logger.debug(" {}: LV {} @ {} - {}: {}\t\t({})", i, varToLv[i], startIndices[i], endIndices[i], state.locals[varToLv[i]].toString(), rec.varSources[state.localVarIds[varToLv[i]] - 1].name()); } @@ -1282,14 +1283,14 @@ private static List createLocalVariables(InsnList il, StateRe } if (!mismatch) { - Matcher.LOGGER.debug("Existing vars matched!"); + logger.debug("Existing vars matched!"); } else { - Matcher.LOGGER.debug("Existing vars mismatch:"); + logger.debug("Existing vars mismatch:"); for (int i = 0; i < orig.size(); i++) { LocalVariableNode lvn = orig.get(i); - Matcher.LOGGER.debug(" {}: LV {} @ {} - {}: {}", + logger.debug(" {}: LV {} @ {} - {}: {}", i, lvn.index, il.indexOf(lvn.start), il.indexOf(lvn.end) - 1, lvn.desc); } } @@ -1861,7 +1862,7 @@ public void dump(InsnList il) { sb.append('\n'); } - Matcher.LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); } private void dumpVars(ClassInstance[] types, int[] ids, StringBuilder sb) { @@ -1896,7 +1897,7 @@ private void dumpVars(ClassInstance[] types, int[] ids, StringBuilder sb) { } sb.append(']'); - Matcher.LOGGER.debug(sb.toString()); + logger.debug(sb.toString()); } final ExecState[] states; // state at the start of every instruction index @@ -1980,7 +1981,7 @@ static void checkInitializer(FieldInstance field, ClassFeatureExtractor context) AbstractInsnNode fieldWrite = null; //dump(method.asmNode); - //Matcher.LOGGER.debug("\n------------------------\n"); + //logger.debug("\n------------------------\n"); for (Iterator it = il.iterator(); it.hasNext(); ) { AbstractInsnNode aInsn = it.next(); @@ -2084,10 +2085,10 @@ static void checkInitializer(FieldInstance field, ClassFeatureExtractor context) in = il.get(pos); initIl.add(in); - /*Matcher.LOGGER.debug(pos+": "); + /*logger.debug(pos+": "); il.get(pos).accept(visitor); - Matcher.LOGGER.debug(textifier.getText().get(0)); + logger.debug(textifier.getText().get(0)); textifier.getText().clear();*/ pos++; @@ -2098,7 +2099,7 @@ static void checkInitializer(FieldInstance field, ClassFeatureExtractor context) /* int pos = fieldWritePos; for (int i = 0; i < 100; i++) { - Matcher.LOGGER.debug(i+" ("+pos+"):"); + logger.debug(i+" ("+pos+"):"); Frame frame = frames[pos]; Frame nextFrame = frames[pos + 1]; @@ -2108,24 +2109,24 @@ static void checkInitializer(FieldInstance field, ClassFeatureExtractor context) SourceValue value = frame.getStack(frame.getStackSize() - 1); if (value.insns.isEmpty()) { - Matcher.LOGGER.debug("empty"); + logger.debug("empty"); break; } for (AbstractInsnNode ain : value.insns) { ain.accept(visitor); - Matcher.LOGGER.debug(textifier.getText().get(0)); + logger.debug(textifier.getText().get(0)); textifier.getText().clear(); } pos = method.asmNode.instructions.indexOf(value.insns.iterator().next()); }*/ - /*Matcher.LOGGER.debug(frame); - Matcher.LOGGER.debug("\n------------------------\n"); + /*logger.debug(frame); + logger.debug("\n------------------------\n"); dump(frame.getStack(frame.getStackSize() - 1).insns);*/ - //Matcher.LOGGER.debug(); + //logger.debug(); } private static int getStackDemand(AbstractInsnNode ain, Frame frame) { @@ -2392,7 +2393,7 @@ private static void dump(MethodNode method) { textifier.print(pw); } - Matcher.LOGGER.debug(writer.toString()); + logger.debug(writer.toString()); } private static void dump(Iterable il) { @@ -2410,6 +2411,8 @@ private static void dump(Iterable il) { textifier.print(pw); } - Matcher.LOGGER.debug(writer.toString()); + logger.debug(writer.toString()); } + + private static final Logger logger = LoggerFactory.getLogger(Analysis.class); } diff --git a/matcher-core/src/main/java/matcher/type/ClassEnv.java b/matcher-model/src/main/java/matcher/model/type/ClassEnv.java similarity index 93% rename from matcher-core/src/main/java/matcher/type/ClassEnv.java rename to matcher-model/src/main/java/matcher/model/type/ClassEnv.java index 2cb20ee3..91a83114 100644 --- a/matcher-core/src/main/java/matcher/type/ClassEnv.java +++ b/matcher-model/src/main/java/matcher/model/type/ClassEnv.java @@ -1,8 +1,8 @@ -package matcher.type; +package matcher.model.type; import java.util.Collection; -import matcher.NameType; +import matcher.model.NameType; public interface ClassEnv { boolean isShared(); diff --git a/matcher-core/src/main/java/matcher/type/ClassEnvironment.java b/matcher-model/src/main/java/matcher/model/type/ClassEnvironment.java similarity index 97% rename from matcher-core/src/main/java/matcher/type/ClassEnvironment.java rename to matcher-model/src/main/java/matcher/model/type/ClassEnvironment.java index 11f705fb..7a6d4cdf 100644 --- a/matcher-core/src/main/java/matcher/type/ClassEnvironment.java +++ b/matcher-model/src/main/java/matcher/model/type/ClassEnvironment.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.io.IOException; import java.io.UncheckedIOException; @@ -32,14 +32,15 @@ import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.InnerClassNode; import org.objectweb.asm.tree.MethodNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import matcher.Matcher; -import matcher.NameType; -import matcher.Util; -import matcher.classifier.ClassifierUtil; -import matcher.classifier.MatchingCache; -import matcher.config.ProjectConfig; -import matcher.type.Signature.ClassSignature; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.classifier.MatchingCache; +import matcher.model.config.ProjectConfig; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.Signature.ClassSignature; public final class ClassEnvironment implements ClassEnv { public void init(ProjectConfig config, DoubleConsumer progressReceiver) { @@ -572,7 +573,7 @@ private static void addOuterClass(ClassInstance cls, String name, boolean create outerClass = cls.getEnv().getCreateClassInstance(ClassInstance.getId(name), createUnknown); if (outerClass == null) { - Matcher.LOGGER.trace("Missing outer cls: {} for {}", name, cls); + logger.error("Missing outer cls: {} for {}", name, cls); return; } } @@ -600,6 +601,7 @@ public MatchingCache getCache() { return cache; } + private static final Logger logger = LoggerFactory.getLogger(ClassEnvironment.class); private final List cpFiles = new ArrayList<>(); private final Map sharedClasses = new HashMap<>(); private final List openFileSystems = new ArrayList<>(); diff --git a/matcher-core/src/main/java/matcher/type/ClassFeatureExtractor.java b/matcher-model/src/main/java/matcher/model/type/ClassFeatureExtractor.java similarity index 97% rename from matcher-core/src/main/java/matcher/type/ClassFeatureExtractor.java rename to matcher-model/src/main/java/matcher/model/type/ClassFeatureExtractor.java index dcafb6f7..43e6e404 100644 --- a/matcher-core/src/main/java/matcher/type/ClassFeatureExtractor.java +++ b/matcher-model/src/main/java/matcher/model/type/ClassFeatureExtractor.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.net.URI; import java.nio.file.FileSystem; @@ -27,11 +27,12 @@ import org.objectweb.asm.tree.InvokeDynamicInsnNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.TypeInsnNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import matcher.Matcher; -import matcher.NameType; -import matcher.Util; -import matcher.type.Analysis.CommonClasses; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.Analysis.CommonClasses; public class ClassFeatureExtractor implements LocalClassEnv { public ClassFeatureExtractor(ClassEnvironment env) { @@ -241,7 +242,7 @@ private void processClassB(ClassInstance cls) { private void processMethodInsns(MethodInstance method) { if (!method.isReal()) { // artificial method to capture calls to types with incomplete/unknown hierarchy/super type method info - Matcher.LOGGER.debug("Skipping empty method {}", method); + logger.debug("Skipping empty method {}", method); return; } @@ -304,7 +305,7 @@ private void processMethodInsns(MethodInstance method) { Util.isCallToInterface(impl), impl.getTag() == Opcodes.H_INVOKESTATIC); break; default: - Matcher.LOGGER.warn("Unexpected impl tag: {}", impl.getTag()); + logger.warn("Unexpected impl tag: {}", impl.getTag()); } break; @@ -329,7 +330,7 @@ private MethodInstance resolveMethod(String owner, String name, String desc, boo MethodInstance ret = cls.resolveMethod(name, desc, toInterface); if (ret == null && create) { - Matcher.LOGGER.trace("Creating synthetic method {}/{}{}", owner, name, desc); + logger.trace("Creating synthetic method {}/{}{}", owner, name, desc); ret = new MethodInstance(cls, name, desc, isStatic); cls.addMethod(ret); @@ -723,6 +724,7 @@ public ClassEnv getOther() { return this == env.getEnvA() ? env.getEnvB() : env.getEnvA(); } + private static final Logger logger = LoggerFactory.getLogger(ClassFeatureExtractor.class); final ClassEnvironment env; private final List inputFiles = new ArrayList<>(); private final List cpFiles = new ArrayList<>(); diff --git a/matcher-core/src/main/java/matcher/type/ClassInstance.java b/matcher-model/src/main/java/matcher/model/type/ClassInstance.java similarity index 99% rename from matcher-core/src/main/java/matcher/type/ClassInstance.java rename to matcher-model/src/main/java/matcher/model/type/ClassInstance.java index 30ce62db..d6cc1973 100644 --- a/matcher-core/src/main/java/matcher/type/ClassInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/ClassInstance.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.net.URI; import java.util.ArrayDeque; @@ -19,13 +19,13 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.ClassNode; -import matcher.NameType; -import matcher.SimilarityChecker; -import matcher.Util; -import matcher.bcremap.AsmClassRemapper; -import matcher.bcremap.AsmRemapper; -import matcher.classifier.ClassifierUtil; -import matcher.type.Signature.ClassSignature; +import matcher.model.bcremap.AsmClassRemapper; +import matcher.model.bcremap.AsmRemapper; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.NameType; +import matcher.model.SimilarityChecker; +import matcher.model.Util; +import matcher.model.type.Signature.ClassSignature; public final class ClassInstance implements ParentInstance, Matchable { /** diff --git a/matcher-core/src/main/java/matcher/type/FieldInstance.java b/matcher-model/src/main/java/matcher/model/type/FieldInstance.java similarity index 95% rename from matcher-core/src/main/java/matcher/type/FieldInstance.java rename to matcher-model/src/main/java/matcher/model/type/FieldInstance.java index 4021042e..bad37d26 100644 --- a/matcher-core/src/main/java/matcher/type/FieldInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/FieldInstance.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.util.List; import java.util.Set; @@ -7,10 +7,10 @@ import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.FieldNode; -import matcher.NameType; -import matcher.Util; -import matcher.classifier.ClassifierUtil; -import matcher.type.Signature.FieldSignature; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.Signature.FieldSignature; public final class FieldInstance extends MemberInstance { /** diff --git a/matcher-core/src/main/java/matcher/type/InputFile.java b/matcher-model/src/main/java/matcher/model/type/InputFile.java similarity index 99% rename from matcher-core/src/main/java/matcher/type/InputFile.java rename to matcher-model/src/main/java/matcher/model/type/InputFile.java index fe445112..ebea5560 100644 --- a/matcher-core/src/main/java/matcher/type/InputFile.java +++ b/matcher-model/src/main/java/matcher/model/type/InputFile.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/matcher-core/src/main/java/matcher/type/InvalidSharedEnvException.java b/matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvException.java similarity index 93% rename from matcher-core/src/main/java/matcher/type/InvalidSharedEnvException.java rename to matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvException.java index cfb0493f..f42dfa76 100644 --- a/matcher-core/src/main/java/matcher/type/InvalidSharedEnvException.java +++ b/matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvException.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; @SuppressWarnings("serial") public final class InvalidSharedEnvException extends RuntimeException { diff --git a/matcher-core/src/main/java/matcher/type/InvalidSharedEnvQueryException.java b/matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvQueryException.java similarity index 95% rename from matcher-core/src/main/java/matcher/type/InvalidSharedEnvQueryException.java rename to matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvQueryException.java index 84191d36..8119e5a4 100644 --- a/matcher-core/src/main/java/matcher/type/InvalidSharedEnvQueryException.java +++ b/matcher-model/src/main/java/matcher/model/type/InvalidSharedEnvQueryException.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; @SuppressWarnings("serial") public final class InvalidSharedEnvQueryException extends RuntimeException { diff --git a/matcher-core/src/main/java/matcher/type/LocalClassEnv.java b/matcher-model/src/main/java/matcher/model/type/LocalClassEnv.java similarity index 65% rename from matcher-core/src/main/java/matcher/type/LocalClassEnv.java rename to matcher-model/src/main/java/matcher/model/type/LocalClassEnv.java index aa4dbc7d..fada78f4 100644 --- a/matcher-core/src/main/java/matcher/type/LocalClassEnv.java +++ b/matcher-model/src/main/java/matcher/model/type/LocalClassEnv.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; public interface LocalClassEnv extends ClassEnv { } diff --git a/matcher-core/src/main/java/matcher/type/MatchType.java b/matcher-model/src/main/java/matcher/model/type/MatchType.java similarity index 68% rename from matcher-core/src/main/java/matcher/type/MatchType.java rename to matcher-model/src/main/java/matcher/model/type/MatchType.java index c7869bc0..e709be3b 100644 --- a/matcher-core/src/main/java/matcher/type/MatchType.java +++ b/matcher-model/src/main/java/matcher/model/type/MatchType.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; public enum MatchType { Class, Method, Field, MethodVar; diff --git a/matcher-core/src/main/java/matcher/type/Matchable.java b/matcher-model/src/main/java/matcher/model/type/Matchable.java similarity index 92% rename from matcher-core/src/main/java/matcher/type/Matchable.java rename to matcher-model/src/main/java/matcher/model/type/Matchable.java index 5171e011..165cb195 100644 --- a/matcher-core/src/main/java/matcher/type/Matchable.java +++ b/matcher-model/src/main/java/matcher/model/type/Matchable.java @@ -1,6 +1,6 @@ -package matcher.type; +package matcher.model.type; -import matcher.NameType; +import matcher.model.NameType; public interface Matchable> { MatchableKind getKind(); diff --git a/matcher-core/src/main/java/matcher/type/MatchableKind.java b/matcher-model/src/main/java/matcher/model/type/MatchableKind.java similarity index 82% rename from matcher-core/src/main/java/matcher/type/MatchableKind.java rename to matcher-model/src/main/java/matcher/model/type/MatchableKind.java index 8e0f6686..bce9dd2d 100644 --- a/matcher-core/src/main/java/matcher/type/MatchableKind.java +++ b/matcher-model/src/main/java/matcher/model/type/MatchableKind.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; public enum MatchableKind { CLASS, FIELD, METHOD, METHOD_ARG, METHOD_VAR; diff --git a/matcher-core/src/main/java/matcher/type/MemberHierarchyData.java b/matcher-model/src/main/java/matcher/model/type/MemberHierarchyData.java similarity index 95% rename from matcher-core/src/main/java/matcher/type/MemberHierarchyData.java rename to matcher-model/src/main/java/matcher/model/type/MemberHierarchyData.java index ecf23f51..534cbb7d 100644 --- a/matcher-core/src/main/java/matcher/type/MemberHierarchyData.java +++ b/matcher-model/src/main/java/matcher/model/type/MemberHierarchyData.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.util.Set; diff --git a/matcher-core/src/main/java/matcher/type/MemberInstance.java b/matcher-model/src/main/java/matcher/model/type/MemberInstance.java similarity index 98% rename from matcher-core/src/main/java/matcher/type/MemberInstance.java rename to matcher-model/src/main/java/matcher/model/type/MemberInstance.java index ca863472..df764ce4 100644 --- a/matcher-core/src/main/java/matcher/type/MemberInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/MemberInstance.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.util.Collections; import java.util.Comparator; @@ -6,9 +6,9 @@ import org.objectweb.asm.Opcodes; -import matcher.NameType; -import matcher.SimilarityChecker; -import matcher.Util; +import matcher.model.NameType; +import matcher.model.SimilarityChecker; +import matcher.model.Util; public abstract class MemberInstance> implements Matchable { @SuppressWarnings("unchecked") diff --git a/matcher-core/src/main/java/matcher/type/MethodInstance.java b/matcher-model/src/main/java/matcher/model/type/MethodInstance.java similarity index 98% rename from matcher-core/src/main/java/matcher/type/MethodInstance.java rename to matcher-model/src/main/java/matcher/model/type/MethodInstance.java index 8b74f04b..69e5d600 100644 --- a/matcher-core/src/main/java/matcher/type/MethodInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/MethodInstance.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; import java.net.URI; import java.util.ArrayList; @@ -15,10 +15,10 @@ import org.objectweb.asm.tree.LocalVariableNode; import org.objectweb.asm.tree.MethodNode; -import matcher.NameType; -import matcher.Util; -import matcher.classifier.ClassifierUtil; -import matcher.type.Signature.MethodSignature; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.NameType; +import matcher.model.Util; +import matcher.model.type.Signature.MethodSignature; public final class MethodInstance extends MemberInstance implements ParentInstance { /** diff --git a/matcher-core/src/main/java/matcher/type/MethodType.java b/matcher-model/src/main/java/matcher/model/type/MethodType.java similarity index 74% rename from matcher-core/src/main/java/matcher/type/MethodType.java rename to matcher-model/src/main/java/matcher/model/type/MethodType.java index 0928cbae..346a4d36 100644 --- a/matcher-core/src/main/java/matcher/type/MethodType.java +++ b/matcher-model/src/main/java/matcher/model/type/MethodType.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; public enum MethodType { UNKNOWN, OTHER, CLASS_INIT, CONSTRUCTOR, LAMBDA_IMPL; diff --git a/matcher-core/src/main/java/matcher/type/MethodVarInstance.java b/matcher-model/src/main/java/matcher/model/type/MethodVarInstance.java similarity index 97% rename from matcher-core/src/main/java/matcher/type/MethodVarInstance.java rename to matcher-model/src/main/java/matcher/model/type/MethodVarInstance.java index 5911789e..d01f07ef 100644 --- a/matcher-core/src/main/java/matcher/type/MethodVarInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/MethodVarInstance.java @@ -1,9 +1,9 @@ -package matcher.type; +package matcher.model.type; -import matcher.NameType; -import matcher.SimilarityChecker; -import matcher.Util; -import matcher.classifier.ClassifierUtil; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.NameType; +import matcher.model.SimilarityChecker; +import matcher.model.Util; public final class MethodVarInstance implements Matchable { MethodVarInstance(MethodInstance method, boolean isArg, int index, int lvIndex, int asmIndex, diff --git a/matcher-core/src/main/java/matcher/type/ParentInstance.java b/matcher-model/src/main/java/matcher/model/type/ParentInstance.java similarity index 70% rename from matcher-core/src/main/java/matcher/type/ParentInstance.java rename to matcher-model/src/main/java/matcher/model/type/ParentInstance.java index ee24eb83..56faaeb0 100644 --- a/matcher-core/src/main/java/matcher/type/ParentInstance.java +++ b/matcher-model/src/main/java/matcher/model/type/ParentInstance.java @@ -1,4 +1,4 @@ -package matcher.type; +package matcher.model.type; public interface ParentInstance { boolean hasMappedChildren(); diff --git a/matcher-core/src/main/java/matcher/type/Signature.java b/matcher-model/src/main/java/matcher/model/type/Signature.java similarity index 99% rename from matcher-core/src/main/java/matcher/type/Signature.java rename to matcher-model/src/main/java/matcher/model/type/Signature.java index d149188d..d3679e4e 100644 --- a/matcher-core/src/main/java/matcher/type/Signature.java +++ b/matcher-model/src/main/java/matcher/model/type/Signature.java @@ -1,11 +1,11 @@ -package matcher.type; +package matcher.model.type; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import matcher.NameType; -import matcher.classifier.ClassifierUtil; +import matcher.model.classifier.ClassifierUtil; +import matcher.model.NameType; public final class Signature { public static final class ClassSignature implements PotentialComparable { diff --git a/matcher-model/src/main/java/module-info.java b/matcher-model/src/main/java/module-info.java new file mode 100644 index 00000000..2c609c46 --- /dev/null +++ b/matcher-model/src/main/java/module-info.java @@ -0,0 +1,17 @@ +module matcher.model { + requires java.prefs; + requires org.objectweb.asm.commons; + requires org.objectweb.asm.tree.analysis; + requires org.objectweb.asm.util; + requires transitive net.fabricmc.mappingio; + requires transitive org.objectweb.asm; + requires transitive org.objectweb.asm.tree; + requires transitive org.slf4j; + + exports matcher.model; + exports matcher.model.bcremap; + exports matcher.model.classifier; + exports matcher.model.config; + exports matcher.model.mapping; + exports matcher.model.type; +} diff --git a/settings.gradle b/settings.gradle index 334e0ca7..6aa5ded3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,6 +12,7 @@ pluginManagement { rootProject.name = 'matcher' +include 'matcher-model' include 'matcher-core' include 'matcher-cli' include 'matcher-gui'