[ANN] Rearranger plugin - new version 1.1 released

The rearranger plugin rearranges (reorders) class definitions within a Java file according to rules specified by the user.

Version 1.1 adds two new capabilities:

- Ability to select methods by matching their return type to a regular expression pattern
- Ability to select fields by matching their type to a regular expression pattern

Constructors return a type of 'void'. Initializer methods probably do as well.

Some minor formatting bugs in configuration descriptions were fixed.

N.B. - Configuration file format changed; current settings for matching by name will lose their patterns. (I try to avoid this. Sorry.) You'll have to reenter the patterns.

-Dave

8 comments

Forgot to mention, version 1.1 also renames "static initializer" to "initializer", and those settings will also be lost.

-Dave

0

Idea locked while doing a reformat of a xml file. What is your opinion,
is this a rearranger bug or should I post a tracker request?


Full thread dump Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode):

"EditorCaretThread" prio=7 tid=0x3036bdd0 nid=0x51c waiting on
condition
at java.lang.Thread.sleep(Native Method)
at com.intellij.openapi.editor.a.m$bh_.run(m$bh_.java:30)

"AWT-EventQueue-1" prio=7 tid=0x2ffcca18 nid=0x2f0 in Object.wait()

at java.lang.Object.wait(Native Method)
- waiting on (a com.wrq.rearranger.WaitableBoolean) at java.lang.Object.wait(Unknown Source) at com.wrq.rearranger.WaitableBoolean.whenTrue(WaitableBoolean.java:57) - locked <0x101fec70>]]> (a com.wrq.rearranger.WaitableBoolean)
at
com.wrq.rearranger.RearrangerActionHandler.runWriteActionRearrangement(R
earrangerActionHandler.java:92)
at
com.wrq.rearranger.RearrangerActionHandler$1.run(RearrangerActionHandler
.java:58)
at com.intellij.openapi.application.a.b.runWriteAction(b.java:7)
at
com.wrq.rearranger.RearrangerActionHandler.execute(RearrangerActionHandl
er.java:54)
at
org.intellij.psi.codeStyle.RearrangerUtility$1.psiElementReformatted(Rea
rrangerUtility.java:43)
at
org.intellij.psi.codeStyle.ReformatManager.fireReformatEvent(ReformatMan
ager.java:29)
at
tzambalayev.ideaplugins.reformat.ReformatHandler.fireReformatEvent(Refor
matHandler.java:56)
at
tzambalayev.ideaplugins.reformat.ReformatHandler.reformatFile(ReformatHa
ndler.java:68)
at
tzambalayev.ideaplugins.reformat.ReformatAndOptimizeHandler.executeWrite
Action(ReformatAndOptimizeHandler.jav
a:15)
at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(
EditorWriteActionHandler.java:2)
at com.intellij.openapi.application.a.b.runWriteAction(b.java:7)
at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execut
e(EditorWriteActionHandler.java:5)
at
com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction
.java:2)
at com.intellij.openapi.command.b.a.executeCommand(a.java:88)
at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(Ed
itorAction.java:21)
at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(Ed
itorAction.java:25)
at com.intellij.openapi.a.c.d.a(d.java:118)
at com.intellij.openapi.a.c.d.b(d.java:9)
at com.intellij.openapi.a.c.d.a(d.java:134)
at com.intellij.ide.s.dispatchEvent(s.java:57)
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=0x2fed4bf8
nid=0x4d0 in Object.wait()
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10a67a80>]]> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at
com.jniwrapper.NativeResourceCollector$1.run(NativeResourceCollector.jav
a:56)

"Thread-1" prio=7 tid=0x30227de0 nid=0x6a8 waiting on condition

at java.lang.Thread.sleep(Native Method)
at com.intellij.progress.c$1.run(c$1.java:3)

"TimerQueue" daemon prio=5 tid=0x3610a220 nid=0x3b0 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 <0x1078a208>]]> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Unknown Source)

"StoreRefreshStatusThread" prio=2 tid=0x360de400 nid=0x584 in
Object.wait()
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at com.intellij.util.i.j$b_.a(j$b_.java:12)
- locked ]]> (a com.intellij.util.i.j$b_)
at
com.intellij.openapi.application.a.b.runReadAction(b.java:171)
at com.intellij.openapi.vfs.a.a.f.f(f.java:262)
at com.intellij.openapi.vfs.a.a.f.access$300(f.java:121)
at com.intellij.openapi.vfs.a.a.f$a_.run(f$a_.java:4)

"WatchForChangesThread" prio=7 tid=0x3040ed20 nid=0x4e8 runnable

at
com.intellij.vfs.local.win32.FileWatcher.waitForChangeImpl(Native
Method)
at
com.intellij.vfs.local.win32.FileWatcher.b(FileWatcher.java:25)
at com.intellij.openapi.vfs.a.a.f$b_.run(f$b_.java:25)

"AlarmThread" prio=7 tid=0x301d2ef0 nid=0x528 in Object.wait()

at java.lang.Object.wait(Native Method)
at com.intellij.util.Alarm$MyThread.run(Alarm.java:49)
- locked ]]> (a java.lang.Object)

"AlarmThread" prio=7 tid=0x301d49c0 nid=0x66c in Object.wait()

at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at com.intellij.util.Alarm$MyThread.run(Alarm.java:4)
- locked ]]> (a java.lang.Object)

"License checker" prio=5 tid=0x300d9f90 nid=0x564 runnable

at java.net.PlainDatagramSocketImpl.receive(Native Method)
- locked (a java.net.PlainDatagramSocketImpl) at java.net.DatagramSocket.receive(Unknown Source) - locked <0x104c1c98> (a java.net.DatagramPacket) - locked <0x1048a5c0>]]> (a java.net.MulticastSocket)
at com.intellij.ide.i.d.d(d.java:24)
at com.intellij.idea.Main$1.run(Main$1.java:2)
at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x300d6e28 nid=0x52c in
Object.wait()
at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10488108>]]> (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=0x30062bc8 nid=0x4d4 runnable

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

"AWT-Shutdown" prio=5 tid=0x3001dac0 nid=0x554 in Object.wait()

at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at sun.awt.AWTAutoShutdown.run(Unknown Source) - locked <0x10488128>]]> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)

"Lock thread" prio=5 tid=0x2ff18100 nid=0x414 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.d$b_.run(d$b_.java:2)
at java.lang.Thread.run(Unknown Source)

"Signal Dispatcher" daemon prio=10 tid=0x00a2fca8 nid=0x6ac waiting on
condition

"Surrogate Locker Thread (CMS)" daemon prio=5 tid=0x0086f808 nid=0x388
waiting on condition

"Finalizer" daemon prio=9 tid=0x009ee980 nid=0x590 in Object.wait()

at java.lang.Object.wait(Native Method)
- waiting on (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x10410eb0>]]> (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=0x009edd10 nid=0x4b8 in
Object.wait()
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked ]]> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x00865118 nid=0x55c waiting on condition

"VM Thread" prio=5 tid=0x00a2e2d0 nid=0x3a4 runnable

"VM Periodic Task Thread" prio=10 tid=0x00a326b0 nid=0x430 waiting on
condition
"Suspend Checker Thread" prio=10 tid=0x0086fe58 nid=0x4c0 runnable


0

Restarted idea, tried again, lock again. Seems repeatable :)

0

I'm pretty sure it's my fault. :) Was there an exception that preceded this? I suspect that the rearranger plugin threw an exception and never set the flag to free the lock. (I'm missing a try-catch.) I will fix my code but I think an exception will continue to occur.

If there is an exception, it would be great if you could send (by email or attachment here) your source file and the configuration element from your ]]>/config/options/other.xml file.

Thanks,
-Dave

0

No exception either in the console or the log.

Looking at the log while idea is blocked, there's a dozen lines with:

2003-11-11 15:06:12,506 INFO -
pl.DocumentEditingUndoProvider - Creating NonUndoableAction for file
FolhaRemuneracoes.xml (document was modified in other project)

Attached idea.log for your reference.



Attachment(s):
idea.log.zip
0

Hi Carlos,

Give Rearranger version 1.2 a try and let me know if you still have any trouble. I am waiting for some clarification from JetBrains on some threading issues that may clean up those additional Info messages. Please let me know if your file isn't rearranged properly; I'm still concerned that somehow I am swallowing but not handling an exception. But if everything works, well, great!

-Dave

0

Thanks, testing...

No change :(

But maybe I should (aready) have made a few obervations:

1. I haven't yet touched the rearranger settings in IDE Options ->
everything is clean (have yet to really test rearranger).

2. Reformatting java files works.

3 And most important: the deadlock only happens while reformatting xml
files. What is rearranger doing in special with xml files?

Carlos

0

Hmm, the rearranger shouldn't be doing anything with XML files. It only operates on Java syntax. I thought I had a check to make sure it was a Java file..will make sure.

That's a relief! And it will be easy to test. I'll fix it up so it won't hang IDEA. But in the meantime, the workaround is easy..don't rearrange XML files! :)

Thanks,
-Dave

0

Please sign in to leave a comment.