Apex code generation

Issue #25 new
Scott Wells repo owner created an issue

Add code generation options for:

  • Constructors
  • Field accessors
  • Implement/override methods from base class/implemented interfaces - DONE

Comments (18)

  1. Piotr Kożuchowski

    Bump - I really miss generator for constructors and I was on verge of submitting enhancement number of times already.

    Thanks!

  2. Scott Wells reporter

    This will be coming relatively soon. I need to wrap up some LWC enhancements and then will be moving back to more refactorings, code inspections/intentions, and code generation.

  3. Scott Wells reporter

    Piotr (and anyone else), is there a specific subset of this that you were looking for? The main one I'd heard about from people was implement/override so I knocked that one out. I'm happy to revisit high priority subsets of this.

  4. Piotr Kożuchowski

    I think the constructor generation is the main one on my mind - to be able to select class fields for a constructor.

  5. Scott Wells reporter

    Gotcha. Anyone else have a favorite code generation aspect that's not yet implemented?

  6. Justin Julicher

    In addition to Piotr’s request when a constructor already exists add a field to the constructor(s) and assign it?

    In the example below you would have an option in the context menu of the field to “add to Constructor(s)”

    Ideally it would give you the method dialog with the ability to change the order of the current parameters and then open the refactor dialog to inspect the references? Not sure how this should be handled but I seem to remember this functionality existing in IntelliJ Idea for Java?

    e.g.

    public class TestClass {
    private String myField;
    
      public TestClass(){
        System.debug('Some line in class');
      }
    }
    

    would go to

    public class TestClass {
    
      private String myField;
    
      public TestClass(String myField){
        System.debug('Some line in class');
        this.myField = myField;
      }
    }
    

  7. Matt Simonis

    Some additional improvements currently supported by Java that would be nice:

    • Getter
    • Setter
    • Getter and Setter
    • equals() and hashCode()

    Thanks!

  8. Log in to comment