Skip to content

Commit 420e73c

Browse files
committed
Move Tiny properties to separate class
1 parent a6de335 commit 420e73c

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileReader.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws
131131
}
132132
} else {
133133
String line = reader.nextCol();
134-
final String prefix = "# INTERMEDIARY-COUNTER ";
134+
final String prefix = TinyProperties.intermediaryCounter + " ";
135135
String[] parts;
136136

137137
if (line.startsWith(prefix)
@@ -140,13 +140,13 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws
140140

141141
switch (parts[0]) {
142142
case "class":
143-
property = nextIntermediaryClassProperty;
143+
property = TinyProperties.NEXT_INTERMEDIARY_CLASS;
144144
break;
145145
case "field":
146-
property = nextIntermediaryFieldProperty;
146+
property = TinyProperties.NEXT_INTERMEDIARY_FIELD;
147147
break;
148148
case "method":
149-
property = nextIntermediaryMethodProperty;
149+
property = TinyProperties.NEXT_INTERMEDIARY_METHOD;
150150
break;
151151
}
152152

@@ -176,8 +176,4 @@ private static void readDstNames(ColumnFileReader reader, MappedElementKind subj
176176
if (!name.isEmpty()) visitor.visitDstName(subjectKind, dstNs, name);
177177
}
178178
}
179-
180-
static final String nextIntermediaryClassProperty = "next-intermediary-class";
181-
static final String nextIntermediaryFieldProperty = "next-intermediary-field";
182-
static final String nextIntermediaryMethodProperty = "next-intermediary-method";
183179
}

src/main/java/net/fabricmc/mappingio/format/tiny/Tiny1FileWriter.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,18 @@ public void visitNamespaces(String srcNamespace, List<String> dstNamespaces) thr
6060
@Override
6161
public void visitMetadata(String key, String value) throws IOException {
6262
switch (key) {
63-
case Tiny1FileReader.nextIntermediaryClassProperty:
64-
case Tiny1FileReader.nextIntermediaryFieldProperty:
65-
case Tiny1FileReader.nextIntermediaryMethodProperty:
66-
write("# INTERMEDIARY-COUNTER ");
67-
63+
case TinyProperties.NEXT_INTERMEDIARY_CLASS:
64+
case TinyProperties.NEXT_INTERMEDIARY_FIELD:
65+
case TinyProperties.NEXT_INTERMEDIARY_METHOD:
6866
switch (key) {
69-
case Tiny1FileReader.nextIntermediaryClassProperty:
70-
write("class");
67+
case TinyProperties.NEXT_INTERMEDIARY_CLASS:
68+
write(TinyProperties.NEXT_INTERMEDIARY_CLASS);
7169
break;
72-
case Tiny1FileReader.nextIntermediaryFieldProperty:
73-
write("field");
70+
case TinyProperties.NEXT_INTERMEDIARY_FIELD:
71+
write(TinyProperties.NEXT_INTERMEDIARY_FIELD);
7472
break;
75-
case Tiny1FileReader.nextIntermediaryMethodProperty:
76-
write("method");
73+
case TinyProperties.NEXT_INTERMEDIARY_METHOD:
74+
write(TinyProperties.NEXT_INTERMEDIARY_METHOD);
7775
break;
7876
default:
7977
throw new IllegalStateException();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2021 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.mappingio.format.tiny;
18+
19+
/**
20+
* All standard properties of the Tiny format.
21+
* Internally, trees use the lowest common denominator.
22+
*/
23+
public final class TinyProperties {
24+
// Tiny v1
25+
static final String intermediaryCounter = "# INTERMEDIARY COUNTER";
26+
public static final String NEXT_INTERMEDIARY_CLASS = intermediaryCounter + " class";
27+
public static final String NEXT_INTERMEDIARY_FIELD = intermediaryCounter + " field";
28+
public static final String NEXT_INTERMEDIARY_METHOD = intermediaryCounter + " method";
29+
30+
// Tiny v2
31+
public static final String NEXT_INTERMEDIARY_CLASS_TINY_2 = "next-intermediary-class";
32+
public static final String NEXT_INTERMEDIARY_FIELD_TINY_2 = "next-intermediary-field";
33+
public static final String NEXT_INTERMEDIARY_METHOD_TINY_2 = "next-intermediary-method";
34+
public static final String MISSING_LVT_INDICES = "missing-lvt-indices";
35+
public static final String ESCAPED_NAMES = "escaped-names";
36+
}

0 commit comments

Comments
 (0)