@@ -233,25 +233,9 @@ public static void completeMappingsFromTr(TrEnvironment trEnvironment) {
233233 }
234234 }
235235
236- int propagated = 0 ;
237-
238- for (Map .Entry <ExtendedClassMember , List <String >> entry : classMembers .entrySet ()) {
239- List <String > toAdd = new ArrayList <>(entry .getValue ());
240-
241- while (!toAdd .isEmpty ()) {
242- TrClass trClass = trEnvironment .getClass (toAdd .remove (0 ));
243- if (trClass == null ) continue ;
244-
245- List <String > children = trClass .getChildren ().stream ().map (TrClass ::getName ).collect (Collectors .toList ());
236+ gatherChildClassCandidates (trEnvironment , classMembers );
246237
247- for (String child : children ) {
248- if (!entry .getValue ().contains (child )) {
249- toAdd .add (child );
250- entry .getValue ().add (child );
251- }
252- }
253- }
254- }
238+ int propagated = 0 ;
255239
256240 for (Map .Entry <ExtendedClassMember , List <String >> entry : classMembers .entrySet ()) {
257241 ExtendedClassMember member = entry .getKey ();
@@ -294,6 +278,26 @@ public static void completeMappingsFromTr(TrEnvironment trEnvironment) {
294278 System .out .println ("Propagated: " + propagated + " methods" );
295279 }
296280
281+ private static void gatherChildClassCandidates (TrEnvironment trEnvironment , Map <ExtendedClassMember , List <String >> classMembers ) {
282+ for (Map .Entry <ExtendedClassMember , List <String >> entry : classMembers .entrySet ()) {
283+ List <String > toAdd = new ArrayList <>(entry .getValue ());
284+
285+ while (!toAdd .isEmpty ()) {
286+ TrClass trClass = trEnvironment .getClass (toAdd .remove (0 ));
287+ if (trClass == null ) continue ;
288+
289+ List <String > children = trClass .getChildren ().stream ().map (TrClass ::getName ).collect (Collectors .toList ());
290+
291+ for (String child : children ) {
292+ if (!entry .getValue ().contains (child )) {
293+ toAdd .add (child );
294+ entry .getValue ().add (child );
295+ }
296+ }
297+ }
298+ }
299+ }
300+
297301 static class ExtendedClassMember extends MappingUtils .ClassMember {
298302 public final String owner ;
299303 public ExtendedClassMember (String name , @ Nullable String desc , String owner ) {
@@ -342,6 +346,11 @@ public static MappingUtils.ClassMember mapMethod(String className, String method
342346
343347 MappingTree .MethodMapping methodMapping = FULL_MAPPINGS .getMethod (className , methodName , methodDesc , srcNamespace );
344348
349+ if (methodMapping == null ) {
350+ MappingTree .ClassMapping classMapping = FULL_MAPPINGS .getClass (className , srcNamespace );
351+ if (classMapping != null ) methodMapping = mapMethodWithPartialDesc (classMapping , methodName , methodDesc , srcNamespace );
352+ }
353+
345354 return mapMember (methodName , methodDesc , targetNamespace , methodMapping );
346355 }
347356
@@ -353,9 +362,25 @@ public static MappingUtils.ClassMember mapMethodFromRemappedClass(String classNa
353362 if (classMapping == null ) return new MappingUtils .ClassMember (methodName , methodDesc );
354363
355364 MappingTree .MethodMapping methodMapping = classMapping .getMethod (methodName , methodDesc , srcNamespace );
365+
366+ if (methodMapping == null ) methodMapping = mapMethodWithPartialDesc (classMapping , methodName , methodDesc , srcNamespace );
367+
356368 return mapMember (methodName , methodDesc , targetNamespace , methodMapping );
357369 }
358370
371+ private static MappingTree .MethodMapping mapMethodWithPartialDesc (MappingTree .ClassMapping classMapping , String methodName , String methodDesc , int namespace ) {
372+ for (MappingTree .MethodMapping methodMapping : classMapping .getMethods ()) {
373+ String name = methodMapping .getName (namespace );
374+ String desc = methodMapping .getDesc (namespace );
375+
376+ if (name != null && name .equals (methodName ) && desc != null && desc .startsWith (methodDesc )) {
377+ return methodMapping ;
378+ }
379+ }
380+
381+ return null ;
382+ }
383+
359384 @ NotNull
360385 private static MappingUtils .ClassMember mapMember (String memberName , @ Nullable String memberDesc , int targetNamespace , MappingTree .MemberMapping memberMapping ) {
361386 if (memberMapping == null ) return new MappingUtils .ClassMember (memberName , memberDesc );
@@ -429,4 +454,11 @@ private static String classTypeToDescriptor(Class<?>[] classTypes) {
429454
430455 return desc + ")" ;
431456 }
457+
458+ public static String mapDescriptor (String desc ) {
459+ int srcNamespace = FULL_MAPPINGS .getNamespaceId ("official" );
460+ int targetNamespace = FULL_MAPPINGS .getNamespaceId (getTargetNamespace ());
461+
462+ return FULL_MAPPINGS .mapDesc (desc , srcNamespace , targetNamespace );
463+ }
432464}
0 commit comments