|
|
|
[
Permlink
| « Hide
]
Dmitry Jemerov - 19 Jul 07 20:53
You can use Structural Search and Replace to find where instances of the class are used as monitors in the "synchronized()" block. Is that what you need?
Noop - the structural search is of little help here...
'synchronized' keyword is used in Java for synchronization of blocks of code (have explicit monitor), for synchronization of instance's methods (on instance itself), and for synchronization of static methods (on instance's class). Only in the first case structural search could be of some help. synchronized(getLock()) { // ... } The 'synchronized' search I meant is something similar to 'Find Usages...'. It's something like 'Find Usages for Synchronization...' - the search returns all usages of the specified instance used as a synchronization monitor over the specified project scope - whole project, a module, or a directory. Unfortunately this requires global data flow analysis of the level of sophistication that IntelliJ IDEA is not yet capable of.
It seems like the sophistication of the problem is greatly exaggerated - it is not such a sophisticated and unresolvable problem at all. What's more, it looks like JIDEA already is capable of and has almost everything it needs to provide such a service: tracing of instance and instance's class usage for synchronization is pretty much the same as tracing of usages of the class methods with exclusion of not synchronized methods have to be excluded. The only challenge would be in tracing of synchronized block monitor usage which could be done in a manner similar to tracing of an object usage as a method parameter...
Please note that when done, JIDEA would be the FIRST EVER IDE offering such an extremely useful service. |
|||||||||||||||||||||||||||||||||||||||||||||||