[ANN] Intention Power-Pack 0.2 released


Intention Power-Pack 0.2 is now available at http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack.

Changes since version 0.1
--Many new intentions added, including "Replace fully-qualified name with import", "Replace switch with if-then-else", "Remove unnecessary parentheses", "Merge nested if statements", "Replace if-then-else with conditional expression", and bunches more.

--Works with Aurora build 818, rather than 816
--Automatically reformats any code that it creates
--Many intentions work over larger areas of code (e.g. if the caret is anywhere in an expression, rather than just
on an operator)
--"Replace && with ||" and "Replace || with &&" now work with chains of || or &&.
--Clearer intention names (hopefully)
--Many bug fixes
--Much code cleanup

Full details on the Wiki site.

Enjoy.

--Dave Griffith

12 comments
Comment actions Permalink

Cool. I'm wondering, is it possible, when using while/for/if wrapping
intention, your plugin would honor the currently installed code style?

For example, my code style of "indent and braces" has the following
preference:
while(..) {
}

By using your plugin "Wrap 'while' branches', I get:
while(..)
{
}

/kesh

Dave Griffith wrote:

Intention Power-Pack 0.2 is now available at http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack.

Changes since version 0.1
--Many new intentions added, including "Replace fully-qualified name with import", "Replace switch with if-then-else", "Remove unnecessary parentheses", "Merge nested if statements", "Replace if-then-else with conditional expression", and bunches more.

--Works with Aurora build 818, rather than 816
--Automatically reformats any code that it creates
--Many intentions work over larger areas of code (e.g. if the caret is anywhere in an expression, rather than just
on an operator)
--"Replace && with ||" and "Replace || with &&" now work with chains of || or &&.
--Clearer intention names (hopefully)
--Many bug fixes
--Much code cleanup

Full details on the Wiki site.

Enjoy.

--Dave Griffith


0
Comment actions Permalink

"Replace qualified name with import" intention should not be available
on package declaration.

/kesh

Dave Griffith wrote:

Intention Power-Pack 0.2 is now available at http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack.


0
Comment actions Permalink

It shouldn't be available on import declations as well.

/kesh

kesh wrote:

"Replace qualified name with import" intention should not be available
on package declaration.

/kesh

Dave Griffith wrote:

>> Intention Power-Pack 0.2 is now available at
>> http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack.



0
Comment actions Permalink

>For example, my code style of "indent and braces" has >the following preference:


Heretic! The one true braces style is



But seriously, every intention in IPP ends by calling on IDEA to do the reformatting on the code it creates, so presumably it follows your selected style options (it certainly has been following mine when I'm testing).

0
Comment actions Permalink


I've got a fix, and it will be in 0.3. Thanks.

0
Comment actions Permalink

Unfortunately, it doesn't. I've just tested that if I have



I apply your plugin's intention:



then Ctrl-Alt-L:



Dave Griffith wrote:

>>For example, my code style of "indent and braces" has >the following preference:


while(..) { > } > ]]>

Heretic! The one true braces style is

while(..) > { > } > ]]>

But seriously, every intention in IPP ends by calling on IDEA to do the reformatting on the code it creates, so presumably it follows your selected style options (it certainly has been following mine when I'm testing).


0
Comment actions Permalink

Wild. I haven't the foggiest. I'd look in the docs, but there aren't any. Any Psi gurus care to spread some enlightenment?

--Dave

0
Comment actions Permalink

Dave Griffith wrote:

Wild. I haven't the foggiest. I'd look in the docs, but there aren't any. Any Psi gurus care to spread some enlightenment?

--Dave


I've looked at your code and I think I have found the problem. Let's
take a look at WrapIfBranchesIntention.wrapIfStatementBranches method.
There you call replaceStatement method and pass it one of the branches
of if statement. But what replaceStatement method does it reformat this
branch only instead of reformatting the whole if statement, which
basically doesn't have any effect at all.

/kesh

0
Comment actions Permalink

Dave Griffith wrote:

Intention Power-Pack 0.2 is now available at http://www.intellij.org/twiki/bin/view/Main/IntentionPowerPack.


Thanks! Lots of nice intentions to play with :)

But it seems like there might be a problem with the IPP when trying to
parse large files and/or malformed files.

I'm getting considerable delays on this 1.2 GHz P3 laptop which I didn't
use to get before. This in itself is not proof that IPP is the culprit
since I haven't used Aurora on this computer before, but Aurora does
work much faster on my other computer (without IPP installed).

A while ago I opened a rather large source file (a parser with over 5000
lines of code) and started deleting a few lines of code that were no
longer necessary. Unfortunately I started by deleting the first line of
an "if" statement which meant that brackets were no longer balanced.

This resulted in what seemed like a complete hang. I took a couple of
thread dumps and IPP seemed to be the likely cause, because it was one
of the few runnable threads that seemed to be actually doing something.

Five minutes later I got back control of IDEA long enough to move the
cursor around for a couple of seconds until the next hang.

I've now stopped IDEA (took about five more minutes before it actually
did stop), and I'm about to restart it without IPP to see whether it
will work correctly then.

Here is a full thread dump taken when IDEA was unresponsive. I have
several other thread dumps but they all look basically the same, with
Intentions.java calling exactly the same methods.

Full thread dump Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode):

"EditorCaretThread" prio=7 tid=0x03D48A38 nid=0x8d4 waiting on condition
[47ff00
0..47ffd8c]
at java.lang.Thread.sleep(Native Method)
at com.intellij.openapi.editor.c.df.run(df.java:15)

"AWT-EventQueue-1" prio=7 tid=0x03DA1EB8 nid=0x8fc runnable

at com.intellij.psi.impl.source.g.q.getLength(q.java:32)
- waiting to lock (a java.lang.Object) at com.intellij.psi.impl.source.g.p.n(p.java:60) - locked <115FCE20> (a java.lang.Object) at com.intellij.psi.impl.source.g.p.getTextRange(p.java:17) at com.intellij.psi.impl.source.g.q.getTextRange(q.java:82) - locked <115FCE20>]]> (a java.lang.Object)
at com.siyeh.ipp.Intention.findMatchingElement(Intention.java:103)
at com.siyeh.ipp.Intention.findMatchingElement(Intention.java:92)
at com.siyeh.ipp.Intention.isAvailable(Intention.java:124)
at com.intellij.codeInsight.h.a.ce.c(ce.java:20)
at com.intellij.codeInsight.h.a.ce.b(ce.java:119)
at com.intellij.codeInsight.h.a.cn.run(cn.java:0)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.intellij.ide.t.a(t.java:86)
at com.intellij.ide.t.dispatchEvent(t.java:117)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

"com.jniwrapper.NativeResourceCollector" daemon prio=7 tid=0x03D08498
nid=0xc1c
in Object.wait()
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked ]]> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at
com.jniwrapper.NativeResourceCollector$1.run(NativeResourceCollector.
java:56)

"TimerQueue" daemon prio=5 tid=0x03ABBE20 nid=0xf08 runnable

at java.lang.Object.wait(Native Method)
at javax.swing.TimerQueue.postExpiredTimers(Unknown Source)
- locked (a javax.swing.TimerQueue) at javax.swing.TimerQueue.run(Unknown Source) - locked <11695CB0>]]> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Unknown Source)

"StoreRefreshStatusThread" prio=2 tid=0x03C3EE10 nid=0xaa0 waiting on
condition

at java.lang.Thread.sleep(Native Method)
at com.intellij.openapi.vfs.a.b.bk.run(bk.java:0)

"WatchForChangesThread" prio=7 tid=0x03C439B0 nid=0xbac runnable
[4e5f000..4e5fd
8c]
at
com.intellij.vfs.local.win32.FileWatcher.waitForChangeImpl(Native Met
hod)
at com.intellij.vfs.local.win32.FileWatcher.b(FileWatcher.java:7)
at com.intellij.openapi.vfs.a.b.bl.run(bl.java:13)

"AlarmThread" prio=5 tid=0x03C73418 nid=0xfa8 in Object.wait()
[4c2f000..4c2fd8c
]
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at com.intellij.util.Alarm$MyThread.run(Alarm.java:69)
- locked (a java.lang.Object) "AlarmThread" prio=7 tid=0x03C7B268 nid=0xc74 in Object.wait() [4b2f000..4b2fd8c ] at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Unknown Source) at com.intellij.util.Alarm$MyThread.run(Alarm.java:69) - locked <115AD088> (a java.lang.Object) "AWT-Shutdown" prio=7 tid=0x03BA7E68 nid=0x5a0 in Object.wait() [46ff000..46ffd8 c] at java.lang.Object.wait(Native Method) - waiting on <11475C68> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at sun.awt.AWTAutoShutdown.run(Unknown Source) - locked <11475C68>]]> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"License checker" prio=5 tid=0x03AC0AC8 nid=0x548 runnable

at java.net.PlainDatagramSocketImpl.receive(Native Method)
- locked (a java.net.PlainDatagramSocketImpl) at java.net.DatagramSocket.receive(Unknown Source) - locked <11503440> (a java.net.DatagramPacket) - locked <11503460> (a java.net.MulticastSocket) at com.intellij.ide.p.g.d(g.java:8) at com.intellij.idea.g.run(g.java:1) at java.lang.Thread.run(Unknown Source) "Java2D Disposer" daemon prio=10 tid=0x039B7E28 nid=0x324 in Object.wait() [44ef 000..44efd8c] at java.lang.Object.wait(Native Method) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <11503500>]]> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"AWT-Windows" daemon prio=7 tid=0x03D0EB08 nid=0x2c8 runnable


at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

"Lock thread" prio=5 tid=0x03D08AB8 nid=0xefc runnable
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
- locked ]]> (a java.net.PlainSocketImpl)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at com.intellij.idea.o.run(o.java:2)
at java.lang.Thread.run(Unknown Source)

"Signal Dispatcher" daemon prio=10 tid=0x010BEB20 nid=0x2f0 waiting on
condition


"Finalizer" daemon prio=9 tid=0x010BAEB0 nid=0xd0 in Object.wait()
[359f000..359
fd8c]
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) "Reference Handler" daemon prio=10 tid=0x010B9A80 nid=0x228 in Object.wait() [34 9f000..349fd8c] at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Unknown Source) at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) - locked <11412518>]]> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x003E48D0 nid=0xfe0 waiting on condition

"VM Thread" prio=5 tid=0x011006D0 nid=0x790 runnable

"VM Periodic Task Thread" prio=10 tid=0x010BD048 nid=0xaf8 waiting on
condition

"Suspend Checker Thread" prio=10 tid=0x010BE160 nid=0x698 runnable

0
Comment actions Permalink

Gotcha. This, and the other bugs you reported with "Replace fully qualified name with import" are fixed in 0.21, now available on the Wiki.

Thanks again.

--Dave

0
Comment actions Permalink

Jonas Kvarnstr?m wrote:

I've now stopped IDEA (took about five more minutes before it actually
did stop), and I'm about to restart it without IPP to see whether it
will work correctly then.


I've verified it: With IPP active IDEA will hang between five or six
minutes for this particular file; with IPP inactive, performance is as
usual.

0
Comment actions Permalink


Hurm. Yup, it looks like my problem, and it's gonna take a bit to figure out what to do about it. I'm betting it's a case of malformed files, rather than simply large ones (I went to a bit of effort to keep things scalable), but I'm unsure about the locking protocols on Psi elements as editing occurs. Any thoughts from the mass mind?

0

Please sign in to leave a comment.