Ability to refactor boolean expressions
What would you think about the ability to refactor boolean expressions?
For instance:
- extract !
(value <= 1) => !(value > 1)
- inline !
!(value == null) => (value != null)
- change && to ||
(a && b) => !(!a || !b)
- change || to &&
(a || b) => !(!a && !b)
I can imagine, that the most intuitive solution would be intentions.
Tom
请先登录再写评论。
Dmitry,
You know my position on OpenAPI (more is good! even more is better!) and this is great that you are willing to open it up even unsupported. (now you just need to open up the refactorings ;)
As we have done with PSI, the community has been very good at supporting itself after the initial learning has occured.
I like the idea of having the community creating the documentation. We could do as we go. With a little more discipline we could document on wiki the things that people are asking (we kind have started this already).
Or is it unrealistic to think that the community could result in good documentation? Open Source software has always suffer from the lact of good documentation.
Somebody could also compile the discussions from the OpenApi forums.
Jacques
Excellent! (this goes to all others who reply of course)
We will open API for intentions (on the same terms as PSI) in the build
after the one we all are waiting for :)
Cheers,
Dmitry
Timur Zambalayev wrote:
>> Hi all,
>>
>> Supposing we open an interface for intention actions
>> on the same terms as
>> PSI, will there be undertakers for such a plugin?
>> We think it is rather a good opportunity for testing
>> PSI interfaces and
>> figuring out the state of PSI w.r.t. its becoming an
>> official OpenAPI,
>>
>> Friendly,
>> Dmitry
--
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Outstanding! With a bit of luck and a good tail wind, I'll whomp up those intentions I listed in short order.
Here's a few more I'm planning on getting to:
Replace multiply/divide with shift-left/shift-right.
x = y*8; -> x = y<<3;
x *=8; -> x<<=3;
Replace assignment and operation with assignment operator x = x + 3; -> x += 3;
Simplify boolean literal equality
if(x == true) -> if(x)
if(x == false) -> if(!x)
if(x != false) -> if(x)
Convert int literal to hex/octal/decimal
15 -> 0xf;
15 -> 017;
017 -> 0xf;
etc.
I've got one more:
com.company.product.Clazz clazz = ...
==>
import com.company.product.Clazz;
...
Clazz clazz = ...
Tom
FYI: There's an SCR for this:
http://www.intellij.net/tracker/idea/viewSCR?publicId=9563
But, if we can get the functionality sooner via the OpenAPI, then great! :D
Few more:
assertTrue("", exp) <=> assertEquals("", true, exp);
assertFalse("", exp) <=> assertEquals("", false, exp);
Jacques Morel wrote:
Why bidirectional? Why not:
assertEquals("", true, exp) => assertTrue("", exp)
assertEquals("", false, exp) => assertFalse("", exp)
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919
Gordon Tyler wrote:
>> Few more:
>> assertTrue("", exp) <=> assertEquals("", true, exp);
>> assertFalse("", exp) <=> assertEquals("", false, exp);
Because sometimes it's more suitable to do it in other direction in
order to extract then common part of test in separate method and pass
expected value of comparison
Friendly.
Sergey
When you are extracting a higher level assert from a bunch of hard coded asserts (to remove duplication usually) you usually have to take into account both false and true cases.
So come to think of it we have the other 2
assertNull("somthing", o) <=> assertEquals("someting", null, o);
assertNotNull("somthing", o) <=> assertFalse("someting", null != o);
Jacques
This functionality is now available in the Intention Power-Pack plugin, available at http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack. Requires Aurora build 816 or greater