+1
VAJ was doing that. On method save, if an exception would not be handled, a "Correct"
feature allowed to add automatically the exception to the exception spec of the
method.
VERY HANDY!
Have the choice of adding it to the exception spec or handling it in the code would be
even better!
I have a proposal on how to handle the try-catch block location. This can be
generalize to any block construct when appropriate: you can drag and drop block start
to another position in the method. The end would follow automatically to match the
depth level of the start. Same thing would happen if you dragged the end: the start
would move to match.
blabla
for (int i =0; ...) {
MyObject o = ...
try { <- try-catch block begin
o.fctThatThrow();
}
catch (Exception e) {
printState(o);
} <- try-catch block end
}
if I drag the "try {" before the for, I would obtain
blabla
try { <- try-catch block begin
for (int i =0; ...) {
MyObject o = ...
o.fctThatThrow();
}
}
catch (Exception e) {
printState(o);
} <- try-catch block end
Even better, scope resolution of local variables would be handled automatically and
MyObject o =... would automatically move outside of the new try location:
blabla
MyObject o = ...
try { <- try-catch block begin
for (int i =0; ...) {
o.fctThatThrow();
}
}
catch (Exception e) {
printState(o);
} <- try-catch block end
Maybe it is more involved to implement but it would simplify the previous problem. If
the developer wanted to handle the exception inside the body of the method you could
just drop the try-catch around the function itself or around the whole method body.
Let the developer adjust through D&D where the try-catch should be.
When there are multiple catch clauses, the developer can drag one catch clause to move
that one only. IntelliJ could be smart enough to merge try catch block when they are
immediately enclosed like
try {
try {
...
} catch (E1) {}
} catch (E2) {}
to
try {
...
} catch (E1) {
} catch (E2) {}
The problem is when there is a finally clause. I will let you think about this one...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 08, 2002 4:57 AM
To: [EMAIL PROTECTED]
Subject: [Eap-features] Exceptions
Hi
At the moment, I process Exception syntax errors by writing some code, then
compiling, and seeing messages like 'unreported exception x; must be caught
or declared to be thrown', and then having to add a try..catch or a throws
to the method. I think IDEA could do something in this area -- spotting
uncaught exceptions and doing something in response.
The 'light bulb' drop-down being used for the "Coding by Intention" feature
might be useful here -- I use an uncaught Exception, then a light bulb
appears with options to 'add throws to method' or 'add try...catch block'.
If I select the latter, IDEA should then get me to select the block I want
to surround, then press 'OK' to add a try..catch.
Cheers,
Ben.
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features