Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/net/fabricmc/mappingio/MappingReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.fabricmc.mappingio.format.EnigmaReader;
import net.fabricmc.mappingio.format.MappingFormat;
import net.fabricmc.mappingio.format.ProGuardReader;
import net.fabricmc.mappingio.format.SimpleReader;
import net.fabricmc.mappingio.format.SrgReader;
import net.fabricmc.mappingio.format.Tiny1Reader;
import net.fabricmc.mappingio.format.Tiny2Reader;
Expand Down Expand Up @@ -187,6 +188,9 @@ public static void read(Reader reader, MappingFormat format, MappingVisitor visi
case PROGUARD:
ProGuardReader.read(reader, visitor);
break;
case SIMPLE:
SimpleReader.read(reader, visitor);
break;
default:
throw new IllegalStateException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public enum MappingFormat {
SRG("SRG", "srg", false, false, false, false, false),
TSRG("TSRG", "tsrg", false, false, false, false, false),
TSRG2("TSRG2", "tsrg", true, false, false, true, false),
PROGUARD("ProGuard", "map", false, true, false, false, false);
PROGUARD("ProGuard", "map", false, true, false, false, false),
SIMPLE("Simple", "txt", false, false, false, false, false);

MappingFormat(String name, String fileExt,
boolean hasNamespaces, boolean hasFieldDescriptors,
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/net/fabricmc/mappingio/format/SimpleReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.mappingio.format;

import net.fabricmc.mappingio.MappedElementKind;
import net.fabricmc.mappingio.MappingVisitor;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;

public final class SimpleReader {

public static void read(Reader reader, MappingVisitor visitor) throws IOException {
BufferedReader br = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
read(br, visitor);
}

public static void read(BufferedReader reader, MappingVisitor visitor) throws IOException {
String line;
while ((line = reader.readLine()) != null) {

String[] split = line.split(" ");
String obf = split[0];
String deobf = split[1];

if (!(line.contains(".") || line.contains("("))) {
if (visitor.visitClass(obf)) {
visitor.visitDstName(MappedElementKind.CLASS, 0, deobf);
visitor.visitElementContent(MappedElementKind.CLASS);
}
} else if (line.contains(".") && !line.contains("(")) {
if (visitor.visitField(obf.substring(obf.lastIndexOf(".") + 1), null)) {
visitor.visitDstName(MappedElementKind.FIELD, 0, deobf);
visitor.visitElementContent(MappedElementKind.FIELD);
}
} else if (line.contains(".") && line.contains("(")) {
if (visitor.visitMethod(obf.substring(obf.lastIndexOf(".") + 1, obf.lastIndexOf("(")), obf.substring(obf.lastIndexOf("(")))) {
visitor.visitDstName(MappedElementKind.METHOD, 0, deobf);
visitor.visitElementContent(MappedElementKind.METHOD);
}
}
}
}
}