diff --git a/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileReader.java b/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileReader.java index 18acbd8c..fa5a9294 100644 --- a/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileReader.java +++ b/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileReader.java @@ -131,7 +131,7 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws } } else { String line = reader.nextCol(); - final String prefix = "# INTERMEDIARY-COUNTER "; + final String prefix = TinyProperties.intermediaryCounter + " "; String[] parts; if (line.startsWith(prefix) @@ -140,13 +140,13 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws switch (parts[0]) { case "class": - property = nextIntermediaryClassProperty; + property = TinyProperties.NEXT_INTERMEDIARY_CLASS; break; case "field": - property = nextIntermediaryFieldProperty; + property = TinyProperties.NEXT_INTERMEDIARY_FIELD; break; case "method": - property = nextIntermediaryMethodProperty; + property = TinyProperties.NEXT_INTERMEDIARY_METHOD; break; } @@ -176,8 +176,4 @@ private static void readDstNames(ColumnFileReader reader, MappedElementKind subj if (!name.isEmpty()) visitor.visitDstName(subjectKind, dstNs, name); } } - - static final String nextIntermediaryClassProperty = "next-intermediary-class"; - static final String nextIntermediaryFieldProperty = "next-intermediary-field"; - static final String nextIntermediaryMethodProperty = "next-intermediary-method"; } diff --git a/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileWriter.java b/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileWriter.java index 501df402..eeabcf26 100644 --- a/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileWriter.java +++ b/src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileWriter.java @@ -60,20 +60,18 @@ public void visitNamespaces(String srcNamespace, List dstNamespaces) thr @Override public void visitMetadata(String key, String value) throws IOException { switch (key) { - case Tiny1FileReader.nextIntermediaryClassProperty: - case Tiny1FileReader.nextIntermediaryFieldProperty: - case Tiny1FileReader.nextIntermediaryMethodProperty: - write("# INTERMEDIARY-COUNTER "); - + case TinyProperties.NEXT_INTERMEDIARY_CLASS: + case TinyProperties.NEXT_INTERMEDIARY_FIELD: + case TinyProperties.NEXT_INTERMEDIARY_METHOD: switch (key) { - case Tiny1FileReader.nextIntermediaryClassProperty: - write("class"); + case TinyProperties.NEXT_INTERMEDIARY_CLASS: + write(TinyProperties.NEXT_INTERMEDIARY_CLASS); break; - case Tiny1FileReader.nextIntermediaryFieldProperty: - write("field"); + case TinyProperties.NEXT_INTERMEDIARY_FIELD: + write(TinyProperties.NEXT_INTERMEDIARY_FIELD); break; - case Tiny1FileReader.nextIntermediaryMethodProperty: - write("method"); + case TinyProperties.NEXT_INTERMEDIARY_METHOD: + write(TinyProperties.NEXT_INTERMEDIARY_METHOD); break; default: throw new IllegalStateException(); diff --git a/src/main/java/net/fabricmc/mappingio/format/tiny/TinyProperties.java b/src/main/java/net/fabricmc/mappingio/format/tiny/TinyProperties.java new file mode 100644 index 00000000..38051d34 --- /dev/null +++ b/src/main/java/net/fabricmc/mappingio/format/tiny/TinyProperties.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 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.tiny; + +/** + * All standard properties of the Tiny format. + * Internally, trees use the lowest common denominator. + */ +public final class TinyProperties { + // Tiny v1 + static final String intermediaryCounter = "# INTERMEDIARY COUNTER"; + public static final String NEXT_INTERMEDIARY_CLASS = intermediaryCounter + " class"; + public static final String NEXT_INTERMEDIARY_FIELD = intermediaryCounter + " field"; + public static final String NEXT_INTERMEDIARY_METHOD = intermediaryCounter + " method"; + + // Tiny v2 + public static final String NEXT_INTERMEDIARY_CLASS_TINY_2 = "next-intermediary-class"; + public static final String NEXT_INTERMEDIARY_FIELD_TINY_2 = "next-intermediary-field"; + public static final String NEXT_INTERMEDIARY_METHOD_TINY_2 = "next-intermediary-method"; + public static final String MISSING_LVT_INDICES = "missing-lvt-indices"; + public static final String ESCAPED_NAMES = "escaped-names"; +}