MCPcopy Create free account
hub / github.com/FabricMC/Matcher / visitDstName

Method visitDstName

src/main/java/matcher/mapping/Mappings.java:197–389  ·  view source on GitHub ↗
(MappedElementKind targetKind, int namespace, String name)

Source from the content-addressed store, hash-verified

195 }
196
197 @Override
198 public void visitDstName(MappedElementKind targetKind, int namespace, String name) {
199 if (namespace != dstNs) return;
200
201 switch (targetKind) {
202 case CLASS:
203 switch (fieldTarget) {
204 case MAPPED:
205 if (!cls.hasMappedName() || replace) {
206 if (ClassInstance.hasOuterName(name)) {
207 name = ClassInstance.getInnerName(name);
208 }
209
210 cls.setMappedName(name);
211 }
212
213 break;
214 case AUX:
215 case AUX2:
216 if (!cls.hasAuxName(fieldTarget.type.getAuxIndex()) || replace) {
217 if (ClassInstance.hasOuterName(name)) {
218 name = ClassInstance.getInnerName(name);
219 }
220
221 cls.setAuxName(fieldTarget.type.getAuxIndex(), name);
222 }
223
224 break;
225 case UID:
226 String prefix = env.getGlobal().classUidPrefix;
227
228 if (!name.startsWith(prefix)) {
229 Matcher.LOGGER.warn("Invalid uid class name {}", name);
230 return;
231 } else {
232 int innerNameStart = name.lastIndexOf('$') + 1;
233 String uidStr;
234
235 if (innerNameStart > 0) {
236 int subPrefixStart = prefix.lastIndexOf('/') + 1;
237
238 if (!name.startsWith(prefix.substring(subPrefixStart), innerNameStart)) {
239 Matcher.LOGGER.warn("Invalid uid class name {}", name);
240 return;
241 } else {
242 uidStr = name.substring(innerNameStart + prefix.length() - subPrefixStart);
243 }
244 } else {
245 uidStr = name.substring(prefix.length());
246 }
247
248 int uid = Integer.parseInt(uidStr);
249
250 if (uid < 0) {
251 Matcher.LOGGER.warn("Invalid class uid {}", uid);
252 return;
253 } else if (cls.getUid() < 0 || cls.getUid() > uid || replace) {
254 cls.setUid(uid);

Callers

nothing calls this directly

Calls 12

hasOuterNameMethod · 0.95
getInnerNameMethod · 0.95
getAuxIndexMethod · 0.80
hasMappedNameMethod · 0.65
hasAuxNameMethod · 0.65
getGlobalMethod · 0.65
getUidMethod · 0.65
getKindMethod · 0.65
setMappedNameMethod · 0.45
setAuxNameMethod · 0.45
setUidMethod · 0.45

Tested by

no test coverage detected