@@ -415,64 +415,74 @@ public void writeClass(ClassNode node, TextBuffer buffer, int indent) {
415415 hasContent .set (true );
416416 };
417417
418+ String methodToDecompile = (String ) DecompilerContext .getProperty (IFernflowerPreferences .METHOD_TO_DECOMPILE );
419+
418420 // fields
419- List <StructRecordComponent > components = cl .getRecordComponents ();
421+ if (methodToDecompile .isEmpty ()) {
422+ List <StructRecordComponent > components = cl .getRecordComponents ();
420423
421- List <StructField > enumFields = new ArrayList <>();
422- List <StructField > nonEnumFields = new ArrayList <>();
424+ List <StructField > enumFields = new ArrayList <>();
425+ List <StructField > nonEnumFields = new ArrayList <>();
423426
424- for (StructField fd : cl .getFields ()) {
425- boolean isEnum = fd .hasModifier (CodeConstants .ACC_ENUM ) && DecompilerContext .getOption (IFernflowerPreferences .DECOMPILE_ENUM );
426- if (isEnum ) {
427- enumFields .add (fd );
428- } else {
429- nonEnumFields .add (fd );
427+ for (StructField fd : cl .getFields ()) {
428+ boolean isEnum = fd .hasModifier (CodeConstants .ACC_ENUM ) && DecompilerContext .getOption (IFernflowerPreferences .DECOMPILE_ENUM );
429+ if (isEnum ) {
430+ enumFields .add (fd );
431+ } else {
432+ nonEnumFields .add (fd );
433+ }
430434 }
431- }
432435
433- boolean enums = false ;
434- for (StructField fd : enumFields ) {
435- if (enums ) {
436- buffer .append (',' ).appendLineSeparator ();
437- }
438- enums = true ;
436+ boolean enums = false ;
437+ for (StructField fd : enumFields ) {
438+ if (enums ) {
439+ buffer .append (',' ).appendLineSeparator ();
440+ }
441+ enums = true ;
439442
440- haveContent .run ();
441- writeField (buffer , indent , fd , wrapper );
442- }
443+ haveContent .run ();
444+ writeField (buffer , indent , fd , wrapper );
445+ }
443446
444- if (enums ) {
445- buffer .append (';' ).appendLineSeparator ();
446- }
447+ if (enums ) {
448+ buffer .append (';' ).appendLineSeparator ();
449+ }
447450
448- for (StructField fd : nonEnumFields ) {
449- boolean hide = fd .isSynthetic () && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
450- wrapper .getHiddenMembers ().contains (InterpreterUtil .makeUniqueKey (fd .getName (), fd .getDescriptor ()));
451- if (hide ) continue ;
451+ for (StructField fd : nonEnumFields ) {
452+ boolean hide = fd .isSynthetic () && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
453+ wrapper .getHiddenMembers ().contains (InterpreterUtil .makeUniqueKey (fd .getName (), fd .getDescriptor ()));
454+ if (hide ) continue ;
452455
453- if (components != null && fd .getAccessFlags () == (CodeConstants .ACC_FINAL | CodeConstants .ACC_PRIVATE ) &&
456+ if (components != null && fd .getAccessFlags () == (CodeConstants .ACC_FINAL | CodeConstants .ACC_PRIVATE ) &&
454457 components .stream ().anyMatch (c -> c .getName ().equals (fd .getName ()) && c .getDescriptor ().equals (fd .getDescriptor ()))) {
455- // Record component field: skip it
456- continue ;
457- }
458+ // Record component field: skip it
459+ continue ;
460+ }
458461
459- if (enums ) {
460- // Add an extra line break between enums and non-enum fields
461- buffer .appendLineSeparator ();
462- enums = false ;
463- }
462+ if (enums ) {
463+ // Add an extra line break between enums and non-enum fields
464+ buffer .appendLineSeparator ();
465+ enums = false ;
466+ }
464467
465- haveContent .run ();
466- writeField (buffer , indent , fd , wrapper );
468+ haveContent .run ();
469+ writeField (buffer , indent , fd , wrapper );
470+ }
467471 }
468472
469473 // methods
470474 VBStyleCollection <StructMethod , String > methods = cl .getMethods ();
471475 for (int i = 0 ; i < methods .size (); i ++) {
472476 StructMethod mt = methods .get (i );
473- boolean hide = mt .isSynthetic () && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
474- mt .hasModifier (CodeConstants .ACC_BRIDGE ) && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_BRIDGE ) ||
475- wrapper .getHiddenMembers ().contains (InterpreterUtil .makeUniqueKey (mt .getName (), mt .getDescriptor ()));
477+ boolean hide ;
478+ if (methodToDecompile .isEmpty () || (node .type != ClassNode .Type .ROOT && node .type != ClassNode .Type .MEMBER )) {
479+ hide = mt .isSynthetic () && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
480+ mt .hasModifier (CodeConstants .ACC_BRIDGE ) && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_BRIDGE ) ||
481+ wrapper .getHiddenMembers ().contains (InterpreterUtil .makeUniqueKey (mt .getName (), mt .getDescriptor ()));
482+ } else {
483+ hide = !methodToDecompile .equals (cl .qualifiedName + "." + mt .getName () + mt .getDescriptor ()) &&
484+ (node .type != ClassNode .Type .ROOT || !methodToDecompile .equals (mt .getName () + mt .getDescriptor ()));
485+ }
476486 if (hide ) continue ;
477487
478488 TextBuffer methodBuffer = new TextBuffer ();
@@ -490,9 +500,14 @@ public void writeClass(ClassNode node, TextBuffer buffer, int indent) {
490500 for (ClassNode inner : node .nested ) {
491501 if (inner .type == ClassNode .Type .MEMBER ) {
492502 StructClass innerCl = inner .classStruct ;
493- boolean isSynthetic = (inner .access & CodeConstants .ACC_SYNTHETIC ) != 0 || innerCl .isSynthetic ();
494- boolean hide = isSynthetic && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
495- wrapper .getHiddenMembers ().contains (innerCl .qualifiedName );
503+ boolean hide ;
504+ if (methodToDecompile .isEmpty ()) {
505+ boolean isSynthetic = (inner .access & CodeConstants .ACC_SYNTHETIC ) != 0 || innerCl .isSynthetic ();
506+ hide = isSynthetic && DecompilerContext .getOption (IFernflowerPreferences .REMOVE_SYNTHETIC ) ||
507+ wrapper .getHiddenMembers ().contains (innerCl .qualifiedName );
508+ } else {
509+ hide = !methodToDecompile .startsWith (innerCl .qualifiedName + "." );
510+ }
496511 if (hide ) continue ;
497512
498513 if (hasContent .get ()) {
0 commit comments