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;
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
add a comment |
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
add a comment |
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
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
intellij-idea keyboard-shortcuts
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Great question!
Yes, this is possible using the combination of Extract parameter
and Inline variable
.
Starting point
Over
getA()
,right click > Refactor > Extract > Parameter
(or ctrl + alt + p on Windows).
The result is
Do the same withgetB()
.Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)
Admire the result and rename accordingly
I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Great question!
Yes, this is possible using the combination of Extract parameter
and Inline variable
.
Starting point
Over
getA()
,right click > Refactor > Extract > Parameter
(or ctrl + alt + p on Windows).
The result is
Do the same withgetB()
.Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)
Admire the result and rename accordingly
I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)
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
add a comment |
Great question!
Yes, this is possible using the combination of Extract parameter
and Inline variable
.
Starting point
Over
getA()
,right click > Refactor > Extract > Parameter
(or ctrl + alt + p on Windows).
The result is
Do the same withgetB()
.Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)
Admire the result and rename accordingly
I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)
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
add a comment |
Great question!
Yes, this is possible using the combination of Extract parameter
and Inline variable
.
Starting point
Over
getA()
,right click > Refactor > Extract > Parameter
(or ctrl + alt + p on Windows).
The result is
Do the same withgetB()
.Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)
Admire the result and rename accordingly
I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)
Great question!
Yes, this is possible using the combination of Extract parameter
and Inline variable
.
Starting point
Over
getA()
,right click > Refactor > Extract > Parameter
(or ctrl + alt + p on Windows).
The result is
Do the same withgetB()
.Invoke the Inline variable quick-fix/refactoring on the local variables (ctrl + alt + n on Windows)
Admire the result and rename accordingly
I can do all of that in a matter of 5 seconds using shortcuts and quick-fixes navigation ;)
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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