Bug 12525 NPE in extract method
in junit.awtui.TestRunner in the method createUI try to extract the following range: Panel numbersPanel= <START>new Panel(new FlowLayout()); numbersPanel.add(new Label("Runs:")); numbersPanel.add(fNumberOfRuns); numbersPanel.add(new Label(" Errors:")); numbersPanel.add(fNumberOfErrors); numbersPanel.add(new Label(" Failures:")); numbersPanel.add (fNumberOfFailures); <END> You get a walkback: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.SelectionAnalyzer.handleNextSelectedNode (SelectionAnalyzer.java:97) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodAnalyzer.handleNex tSelectedNode(ExtractMethodAnalyzer.java:384) at org.eclipse.jdt.internal.corext.dom.SelectionAnalyzer.visitNode (SelectionAnalyzer.java:73) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit (GenericVisitor.java:83) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0 (ExpressionStatement.java:71) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:986) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:73) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:957) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0 (MethodDeclaration.java:173) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:986) at org.eclipse.jdt.core.dom.TypeDeclaration.accept0 (TypeDeclaration.java:153) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:986) at org.eclipse.jdt.core.dom.CompilationUnit.accept0 (CompilationUnit.java:138) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:906) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring.checkA ctivation(ExtractMethodRefactoring.java:161) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:74) at org.eclipse.jdt.internal.ui.refactoring.actions.TextSelectionBasedRefactoringAct ion.run(TextSelectionBasedRefactoringAction.java:28) at org.eclipse.jdt.internal.ui.refactoring.actions.TextSelectionAction.run (TextSelectionAction.java:80) at org.eclipse.ui.internal.PluginAction.runWithEvent (PluginAction.java:204) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:705) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:196) at org.eclipse.core.launcher.Main.run(Main.java:555) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/JavaBrowsingPart.java
* Answers if the given <code>element</code> is a valid
	 * input for this part.
	 * 
	 * @param 	element	the object to test
	 * @return	<true> if the given element is a valid input
	 */
	abstract protected boolean isValidInput(Object element);
	/**
	 * Answers if the given <code>element</code> is a valid
	 * element for this part.
	 * 
	 * @param 	element	the object to test
	 * @return	<true> if the given element is a valid element
	 */
	protected boolean isValidElement(Object element) {
		if (element == null)
			return false;
		element= getSuitableJavaElement(element);
		if (element == null)
			return false;
		Object input= getViewer().getInput();
		if (input == null)
			return false;
		if (input instanceof Collection)
			return ((Collection)input).contains(element);
		else
			return input.equals(element);
	}
	private boolean isInputResetBy(Object newInput, Object input, IWorkbenchPart part) {
		if (newInput == null)