Skip to content

Commit

Permalink
Move Tiny properties to separate class
Browse files Browse the repository at this point in the history
  • Loading branch information
NebelNidas committed May 13, 2023
1 parent a6de335 commit 420e73c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,18 @@ public void visitNamespaces(String srcNamespace, List<String> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 420e73c

Please sign in to comment.