|
1 | | -/* |
2 | | - * Copyright (c) 2018, 2019 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 | 1 | package com.replaymod.gradle.preprocess |
17 | 2 |
|
18 | | -import net.fabricmc.mappings.Mappings |
| 3 | +import net.fabricmc.mapping.tree.TinyTree |
19 | 4 | import org.cadixdev.lorenz.MappingSet |
20 | 5 | import org.cadixdev.lorenz.io.MappingsReader |
21 | 6 | import java.io.IOException |
22 | 7 |
|
23 | | -class TinyReader(private val m: Mappings, private val from: String, private val to: String, private val appendNone: Boolean) : MappingsReader() { |
24 | | - |
25 | | - private fun procClassName(s: String): String { |
26 | | - return if (appendNone) { |
27 | | - if (s.indexOf('/') < 0) { |
28 | | - "none/$s" |
29 | | - } else { |
30 | | - s |
31 | | - } |
32 | | - } else { |
33 | | - s |
34 | | - } |
35 | | - } |
36 | | - |
| 8 | +class TinyReader(private val m: TinyTree, private val from: String, private val to: String) : MappingsReader() { |
37 | 9 | override fun read(mappings: MappingSet): MappingSet { |
38 | | - for (entry in m.classEntries) { |
39 | | - mappings.getOrCreateClassMapping(entry.get(from)).deobfuscatedName = procClassName(entry.get(to)) |
40 | | - } |
| 10 | + for (cls in m.classes) { |
| 11 | + val clsMapping = mappings.getOrCreateClassMapping(cls.getName(from)) |
| 12 | + clsMapping.deobfuscatedName = cls.getName(to) |
41 | 13 |
|
42 | | - for (entry in m.fieldEntries) { |
43 | | - val fromEntry = entry.get(from) |
44 | | - val toEntry = entry.get(to) |
45 | | - |
46 | | - mappings.getOrCreateClassMapping(fromEntry.owner) |
47 | | - .getOrCreateFieldMapping(fromEntry.name, fromEntry.desc).deobfuscatedName = toEntry.name |
48 | | - } |
49 | | - |
50 | | - for (entry in m.methodEntries) { |
51 | | - val fromEntry = entry.get(from) |
52 | | - val toEntry = entry.get(to) |
| 14 | + for (field in cls.fields) { |
| 15 | + clsMapping.getOrCreateFieldMapping(field.getName(from), field.getDescriptor(from)).deobfuscatedName = field.getName(to) |
| 16 | + } |
53 | 17 |
|
54 | | - mappings.getOrCreateClassMapping(fromEntry.owner) |
55 | | - .getOrCreateMethodMapping(fromEntry.name, fromEntry.desc).deobfuscatedName = toEntry.name |
| 18 | + for (method in cls.methods) { |
| 19 | + clsMapping.getOrCreateMethodMapping(method.getName(from), method.getDescriptor(from)).deobfuscatedName = method.getName(to) |
| 20 | + } |
56 | 21 | } |
57 | | - |
58 | 22 | return mappings |
59 | 23 | } |
60 | 24 |
|
|
0 commit comments