Community
Participate
Working Groups
I20070503-1400 Given: package test; public class E1 { public void foo(int x, int y) {} public static void main(String[] args) { new E1().foo(1, 2); } } 1. Select 'foo' in body of 'main' 2. Introduce Parameter Object... Is: A parameter object is introduced to 'main' Should: Introduce it to the selected method, like change method signature does
Created attachment 68093 [details] Better check of selection
This leads to a NPE easily=>Whenever getSingleSelectedMethod(*) returns null... Also code style: 1. Do not comment in method body what method does, if you really feel the need to do that then refactor the method such that it is clear what it does. The code is the doc. 2. Use the pattern if (expr) return null; if (expr) return null; return validElement; 3. There is commented code, why do you not set the tooltip/help/description?
Created attachment 68357 [details] Updated version 2.1 Comments describing the general problem are not too bad. This code section is "inherited" from Markus. Sometimes it simple is hard to write meaningful code. 2.2 I clearly prefer if (elementAt instanceof IMethod) return (IMethod) elementAt; return null; over if (!(elementAt instanceof IMethod)) return null; return (IMethod) elementAt; because it shows that when elementAt is an instance of IMethod I simply return it. Otherwise the assumptions about the result are deferred until the last line. 2.3 I'm not sure where this would be shown, but I updated it. NPEs resulting from getSingleMethod are now handled correctly
patch is good I would change the following: - remove the added 'tab' in 'ExceptionHandler.handle(e....' - move the null check out of run(IMethod)
Created attachment 68553 [details] fix - Don't even THINK about catching java.lang.Exception! - I can't parse this, a project tries to keep a certain code style, it is not that important what a single comitter thinks is better, consistency is more important. - 'private run' can throw CoreException
please release.
fixed > I20070524-0010
verified in I20070527-0010