Skip to content

Commit c87e3ba

Browse files
committed
Move Tiny properties to separate class
1 parent f92f89c commit c87e3ba

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
@@ -134,7 +134,7 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws
134134
}
135135
} else {
136136
String line = reader.nextCol();
137-
final String prefix = "# INTERMEDIARY-COUNTER ";
137+
final String prefix = TinyProperties.intermediaryCounter + " ";
138138
String[] parts;
139139

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

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

@@ -179,8 +179,4 @@ private static void readDstNames(ColumnFileReader reader, MappedElementKind subj
179179
if (!name.isEmpty()) visitor.visitDstName(subjectKind, dstNs, name);
180180
}
181181
}
182-
183-
static final String nextIntermediaryClassProperty = "next-intermediary-class";
184-
static final String nextIntermediaryFieldProperty = "next-intermediary-field";
185-
static final String nextIntermediaryMethodProperty = "next-intermediary-method";
186182
}

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)