IntelliJ: Refactor signature to use parameters propertiesHow can I permanently enable line numbers in IntelliJ?What are the most useful Intellij IDEA keyboard shortcuts?Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA projectLocate current file in IntelliJIntelliJ: Never use wildcard importsWhat is the shortcut in IntelliJ IDEA to find method / functions?IntelliJ shortcut to show a popup of methods in a class that can be searchedIntellij shortcut to convert code to upper or lower case?IntelliJ show JavaDocs tooltip on mouse overKeyboard shortcut for Jump to Previous View Location (Navigate back/forward) in IntelliJ IDEA

Why does FFmpeg choose 10+20+20 ms instead of an even 16 ms for 60 fps GIF images?

What details should I consider before agreeing for part of my salary to be 'retained' by employer?

Was Jacobi the first to notice the ambiguity in the partial derivatives notation? And did anyone object to his fix?

Did Voldemort kill his father before finding out about Horcruxes?

Pi 3 B+ no audio device found

Can you perfectly wrap a cube with this blocky shape?

Create Array from list of indices/values

Why did Steve Rogers choose this character in Endgame?

Optimising the Selection of MaxValue in Association

Generating a PIN from cryptographic bytes

Is passive Investigation essentially truesight against illusions?

Why does "git status" show I'm on the master branch and "git branch" does not in a newly created repository?

Cauchy reals and Dedekind reals satisfy "the same mathematical theorems"

DC Series motor and its starting

Why do space operations use "nominal" to mean "working correctly"?

What is the difference between a Hosaka, Ono-Sendai, and a "deck"?

Is this artwork (used in a video game) real?

Using SPID in DB Tables (instead of Table Variable)

Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?

Why doesn't philosophy have higher standards for its arguments?

How could a medieval fortress manage large groups of migrants and travelers?

Is the purpose of sheet music to be played along to? Or a guide for learning and reference during playing?

Do dragons smell of lilacs?

Is there a typesafe way to get a Database.QueryLocator?



IntelliJ: Refactor signature to use parameters properties


How can I permanently enable line numbers in IntelliJ?What are the most useful Intellij IDEA keyboard shortcuts?Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA projectLocate current file in IntelliJIntelliJ: Never use wildcard importsWhat is the shortcut in IntelliJ IDEA to find method / functions?IntelliJ shortcut to show a popup of methods in a class that can be searchedIntellij shortcut to convert code to upper or lower case?IntelliJ show JavaDocs tooltip on mouse overKeyboard shortcut for Jump to Previous View Location (Navigate back/forward) in IntelliJ IDEA






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Is it possible in IntelliJ to do this kind of refactoring



public class Demo 

public long sum(Model model)
int a = model.getA();
int b = model.getB();
System.out.println(model.getA());
System.out.println(model.getB());
return (long) a + b;


//refactor to

public long sum(int a, int b)
System.out.println(a);
System.out.println(b);
return (long) a + b;


private static class Model
private int a;
private int b;
private int c;

//getter & boilerplate




would be quite nice IMHO to reduce complexity in certain cases.



Googled around for a while and tried various refactoring dialogues- couldn't find anything better than "Change Signature" yet.



EDIT: refined Example to have multiple usages per parameter










share|improve this question






























    1















    Is it possible in IntelliJ to do this kind of refactoring



    public class Demo 

    public long sum(Model model)
    int a = model.getA();
    int b = model.getB();
    System.out.println(model.getA());
    System.out.println(model.getB());
    return (long) a + b;


    //refactor to

    public long sum(int a, int b)
    System.out.println(a);
    System.out.println(b);
    return (long) a + b;


    private static class Model
    private int a;
    private int b;
    private int c;

    //getter & boilerplate




    would be quite nice IMHO to reduce complexity in certain cases.



    Googled around for a while and tried various refactoring dialogues- couldn't find anything better than "Change Signature" yet.



    EDIT: refined Example to have multiple usages per parameter










    share|improve this question


























      1












      1








      1








      Is it possible in IntelliJ to do this kind of refactoring



      public class Demo 

      public long sum(Model model)
      int a = model.getA();
      int b = model.getB();
      System.out.println(model.getA());
      System.out.println(model.getB());
      return (long) a + b;


      //refactor to

      public long sum(int a, int b)
      System.out.println(a);
      System.out.println(b);
      return (long) a + b;


      private static class Model
      private int a;
      private int b;
      private int c;

      //getter & boilerplate




      would be quite nice IMHO to reduce complexity in certain cases.



      Googled around for a while and tried various refactoring dialogues- couldn't find anything better than "Change Signature" yet.



      EDIT: refined Example to have multiple usages per parameter










      share|improve this question
















      Is it possible in IntelliJ to do this kind of refactoring



      public class Demo 

      public long sum(Model model)
      int a = model.getA();
      int b = model.getB();
      System.out.println(model.getA());
      System.out.println(model.getB());
      return (long) a + b;


      //refactor to

      public long sum(int a, int b)
      System.out.println(a);
      System.out.println(b);
      return (long) a + b;


      private static class Model
      private int a;
      private int b;
      private int c;

      //getter & boilerplate




      would be quite nice IMHO to reduce complexity in certain cases.



      Googled around for a while and tried various refactoring dialogues- couldn't find anything better than "Change Signature" yet.



      EDIT: refined Example to have multiple usages per parameter







      intellij-idea keyboard-shortcuts






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 7:56







      Franz Ebner

















      asked Mar 26 at 9:15









      Franz EbnerFranz Ebner

      2,6983 gold badges23 silver badges53 bronze badges




      2,6983 gold badges23 silver badges53 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Great question!

          Yes, this is possible using the combination of Extract parameter and Inline variable.



          1. Starting point

            enter image description here


          2. Over getA(), right click > Refactor > Extract > Parameter (or ctrl + alt + p on Windows).
            The result is

            enter image description here

            Do the same with getB().


          3. Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)

            enter image description here


          4. Admire the result and rename accordingly

            enter image description here



          I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)






          share|improve this answer

























          • Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

            – Franz Ebner
            Mar 27 at 7:32






          • 1





            @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

            – LppEdd
            Mar 27 at 7:37











          • @FranzEbner btw, even with multiple usages this works fine

            – LppEdd
            Mar 27 at 10:20











          • @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

            – LppEdd
            Mar 29 at 8:53











          • really seems to be the single best option currently, thanks for the feature request

            – Franz Ebner
            Mar 29 at 10:51











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353440%2fintellij-refactor-signature-to-use-parameters-properties%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Great question!

          Yes, this is possible using the combination of Extract parameter and Inline variable.



          1. Starting point

            enter image description here


          2. Over getA(), right click > Refactor > Extract > Parameter (or ctrl + alt + p on Windows).
            The result is

            enter image description here

            Do the same with getB().


          3. Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)

            enter image description here


          4. Admire the result and rename accordingly

            enter image description here



          I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)






          share|improve this answer

























          • Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

            – Franz Ebner
            Mar 27 at 7:32






          • 1





            @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

            – LppEdd
            Mar 27 at 7:37











          • @FranzEbner btw, even with multiple usages this works fine

            – LppEdd
            Mar 27 at 10:20











          • @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

            – LppEdd
            Mar 29 at 8:53











          • really seems to be the single best option currently, thanks for the feature request

            – Franz Ebner
            Mar 29 at 10:51
















          1














          Great question!

          Yes, this is possible using the combination of Extract parameter and Inline variable.



          1. Starting point

            enter image description here


          2. Over getA(), right click > Refactor > Extract > Parameter (or ctrl + alt + p on Windows).
            The result is

            enter image description here

            Do the same with getB().


          3. Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)

            enter image description here


          4. Admire the result and rename accordingly

            enter image description here



          I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)






          share|improve this answer

























          • Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

            – Franz Ebner
            Mar 27 at 7:32






          • 1





            @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

            – LppEdd
            Mar 27 at 7:37











          • @FranzEbner btw, even with multiple usages this works fine

            – LppEdd
            Mar 27 at 10:20











          • @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

            – LppEdd
            Mar 29 at 8:53











          • really seems to be the single best option currently, thanks for the feature request

            – Franz Ebner
            Mar 29 at 10:51














          1












          1








          1







          Great question!

          Yes, this is possible using the combination of Extract parameter and Inline variable.



          1. Starting point

            enter image description here


          2. Over getA(), right click > Refactor > Extract > Parameter (or ctrl + alt + p on Windows).
            The result is

            enter image description here

            Do the same with getB().


          3. Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)

            enter image description here


          4. Admire the result and rename accordingly

            enter image description here



          I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)






          share|improve this answer















          Great question!

          Yes, this is possible using the combination of Extract parameter and Inline variable.



          1. Starting point

            enter image description here


          2. Over getA(), right click > Refactor > Extract > Parameter (or ctrl + alt + p on Windows).
            The result is

            enter image description here

            Do the same with getB().


          3. Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)

            enter image description here


          4. Admire the result and rename accordingly

            enter image description here



          I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 1 at 8:15









          Morteza Asadi

          1,3472 gold badges9 silver badges28 bronze badges




          1,3472 gold badges9 silver badges28 bronze badges










          answered Mar 26 at 22:12









          LppEddLppEdd

          10.4k3 gold badges19 silver badges52 bronze badges




          10.4k3 gold badges19 silver badges52 bronze badges












          • Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

            – Franz Ebner
            Mar 27 at 7:32






          • 1





            @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

            – LppEdd
            Mar 27 at 7:37











          • @FranzEbner btw, even with multiple usages this works fine

            – LppEdd
            Mar 27 at 10:20











          • @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

            – LppEdd
            Mar 29 at 8:53











          • really seems to be the single best option currently, thanks for the feature request

            – Franz Ebner
            Mar 29 at 10:51


















          • Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

            – Franz Ebner
            Mar 27 at 7:32






          • 1





            @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

            – LppEdd
            Mar 27 at 7:37











          • @FranzEbner btw, even with multiple usages this works fine

            – LppEdd
            Mar 27 at 10:20











          • @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

            – LppEdd
            Mar 29 at 8:53











          • really seems to be the single best option currently, thanks for the feature request

            – Franz Ebner
            Mar 29 at 10:51

















          Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

          – Franz Ebner
          Mar 27 at 7:32





          Thanks for your reply! While 'Extract Variable' offers to replace multiple occurrences, this seems not to be the case for 'Extract Parameter'.. still curious if there is any even faster alternative ;)

          – Franz Ebner
          Mar 27 at 7:32




          1




          1





          @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

          – LppEdd
          Mar 27 at 7:37





          @FranzEbner unfortunately there is no alternative as of now. You can still open a feature request on Youtrack, I'll upvote.

          – LppEdd
          Mar 27 at 7:37













          @FranzEbner btw, even with multiple usages this works fine

          – LppEdd
          Mar 27 at 10:20





          @FranzEbner btw, even with multiple usages this works fine

          – LppEdd
          Mar 27 at 10:20













          @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

          – LppEdd
          Mar 29 at 8:53





          @FranzEbner created youtrack.jetbrains.com/issue/IDEA-209968

          – LppEdd
          Mar 29 at 8:53













          really seems to be the single best option currently, thanks for the feature request

          – Franz Ebner
          Mar 29 at 10:51






          really seems to be the single best option currently, thanks for the feature request

          – Franz Ebner
          Mar 29 at 10:51







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353440%2fintellij-refactor-signature-to-use-parameters-properties%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript