Community
Participate
Working Groups
1. Added new code to JavaBrowsingPerspectiveFactory 2. Selected some of that code (no save) 3. Extract method java.lang.NullPointerException at org.eclipse.jdt.core.dom.DefaultBindingResolver.returnBindingForQualifiedNamePart(DefaultBindingResolver.java:618) at org.eclipse.jdt.core.dom.DefaultBindingResolver.internalResolveNameForSimpleName(DefaultBindingResolver.java:660) at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveName(DefaultBindingResolver.java:146) at org.eclipse.jdt.core.dom.Name.resolveBinding(Name.java:75) at org.eclipse.jdt.internal.corext.refactoring.code.LocalTypeAnalyzer.visit(LocalTypeAnalyzer.java:45) at org.eclipse.jdt.core.dom.SimpleName.accept0(SimpleName.java:88) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:957) at org.eclipse.jdt.core.dom.QualifiedName.accept0(QualifiedName.java:81) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:986) at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:87) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:957) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:73) 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.IfStatement.accept0(IfStatement.java:93) 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.accept(ASTNode.java:906) at org.eclipse.jdt.internal.corext.refactoring.code.LocalTypeAnalyzer.perform(LocalTypeAnalyzer.java:34) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodAnalyzer.endVisit(ExtractMethodAnalyzer.java:418) at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:140) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:906) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring.checkActivation(ExtractMethodRefactoring.java:166) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:74) at org.eclipse.jdt.internal.ui.refactoring.actions.TextSelectionBasedRefactoringAction.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:738) 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:190) at org.eclipse.core.launcher.Main.run(Main.java:549) at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
This is a AST problem. Moving to JCore
I would need a test case. Without this, it can be really long to fix the bug. Could you please provide the code you selected to "extract method"?
Please provide a test case if you want this PR to be fixed.
no problem here it is: 1. Self-hosting workspace 2. Open JavaBrowsingPerspectiveFactory.java (revision 1.3) 3. Under the method declaration of "createInitialLayout" add: if (fgJavaElementFromAction == null) return true; int type= fgJavaElementFromAction.getElementType(); return type == IJavaElement.JAVA_MODEL || type == IJavaElement.JAVA_PROJECT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT; 4. Select the code which you just added 5. Refactor -> Extract Method
And this revision corresponds to which build? JavaBrowsingPerspectiveFactory.java (revision 1.3)
Build where the problem appears: 20020409 The revision of the file is not part of a build (no tag). Simply use the current build (20020409) and get the correct revision from dev.eclipse.org
I tried to reproduce this problem without success. Could you please tell me exactly where in the source of JavaBrowsingPerspectiveFactory you add the code. The method createInitialLayout returns void. So adding code that returns a boolean is invalid. I tried but I could not reproduce.
Reproduced with latest code sent by email. I am working on it.
The problem comes from the fact that IJavaElement.JAVA_MODEL cannot be resolved properly, because IJavaElement cannot be resolved. So in this case when trying to resolve the name "IJavaElement" or "JAVA_MODEL", I expect null to be returned instead of a NPE. In this case the extracted method doesn't return the proper type. This might be a bug in this code. It returns void instead of boolean. I will fix the name resolution code to return null instead of failing with a NPE. I am expecting you to fix the other part (return type is void instead of boolean).
Another bug is to generate after the extract method a return statement like: return test(); if "test" is the name of the extracted method where the return type of the method is void. This is invalid and I would expect the extraction of the method to fail instead of generating invalid code. The initial problem is fixed and released in HEAD.