can not extract method or variable 1 + "string"
I was having problems extracting metfod (see below) but after some tinkering
realized that expression like 1 + "text" can not be extracted as method or
variable
==========
I might be missing something but I cant extract neither method or variable
from following expression
System.out.println("TOTAL TIME = " + ((System.currentTimeMillis() - t1) /
1000) +
" mem = " + (Runtime.getRuntime().freeMemory() /1000)
+ " / " + (Runtime.getRuntime().totalMemory() / 1000));
I am trying to extract:
" mem = " + (Runtime.getRuntime().freeMemory() /1000) + " / " +
(Runtime.getRuntime().totalMemory() / 1000)
selected block should represent set of statements or expression
Please sign in to leave a comment.
You can only extract portions of an expression if they form an expression themselves. With string concatenation, this would mean you could extract concatenations from the beginning or middle, but not the end. It has to do with the associativity of the "+" operator. Yes, it's very jarring. There are any number of feature requests for being able to extract from the middle or end of a concatenation, or you can use the SmartIntroduce plugin, which does just that (as well as a bunch of other stuff).
--Dave Griffith
Yes, that's true. Idea cannot make virtual modifications to PSI. One could
of course use brutal force to parenthesize the selection, but I'm not sure
we want to go this way.
BTW, does anyone know what does SmartIntroduce perform to make it work?
Eugene.
"Dave Griffith" <dave.griffith@cnn.com> wrote in message
news:30762185.1112754188134.JavaMail.itn@is.intellij.net...
themselves. With string concatenation, this would mean you could extract
concatenations from the beginning or middle, but not the end. It has to do
with the associativity of the "+" operator. Yes, it's very jarring. There
are any number of feature requests for being able to extract from the middle
or end of a concatenation, or you can use the SmartIntroduce plugin, which
does just that (as well as a bunch of other stuff).
>
I'm pretty sure it does brute force parenthesization, does that extraction, and then removes the parentheses.
--Dave Griffith
Dave Griffith wrote:
Correct, that's how it works. The good part is that IDEA removes the inserted parentheses automatically ;)
Sascha
The bad part is probably that it does not remove them if the user cancels
refactoring...
Eugene.
"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:d311lf$6hv$1@is.intellij.net...
extraction, and then removes the parentheses.
>
inserted parentheses automatically ;)
>
Eugene Vigdorchik (JetBrains) wrote:
Hmm, is that just a guess or did you experience that yourself? I'm asking
because this has been taken care of and should not happen. I'd be curious
to know under what conditions it happens, if it does.
Sascha
Sascha,
no it was just a guess.
Sorry for false alarm.
Eugene.
"Sascha Weinreuter" <sascha.weinreuter@NOSPAM-cit.de> wrote in message
news:d32pvr$fpf$1@is.intellij.net...
cancels
>
>