Community
Participate
Working Groups
Build F2 I selected three lines of code in a .java file and chose 'Refactor'->'Extract Method'. The following IllegalArgumentException was recorded in my .log file: java.lang.IllegalArgumentException Stack trace: java/lang/Throwable.<init>()V org/eclipse/jdt/core/dom/ASTNode.setSourceRange(II)V org/eclipse/jdt/core/dom/ASTConverter.checkAndAddMultipleFieldDeclaration ([Lorg/eclipse/jdt/internal/compiler/ast/FieldDeclaration;ILjava/util/List;)V org/eclipse/jdt/core/dom/ASTConverter.buildBodyDeclarations (Lorg/eclipse/jdt/internal/compiler/ast/TypeDeclaration;Lorg/eclipse/jdt/core/d om/TypeDeclaration;)V org/eclipse/jdt/core/dom/ASTConverter.convert (Lorg/eclipse/jdt/internal/compiler/ast/TypeDeclaration;) Lorg/eclipse/jdt/core/dom/TypeDeclaration; org/eclipse/jdt/core/dom/ASTConverter.convert (Lorg/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration;[C) Lorg/eclipse/jdt/core/dom/CompilationUnit; org/eclipse/jdt/core/dom/AST.parseCompilationUnit (Lorg/eclipse/jdt/core/ICompilationUnit;Z) Lorg/eclipse/jdt/core/dom/CompilationUnit; org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.check Activation(Lorg/eclipse/core/runtime/IProgressMonitor;) Lorg/eclipse/jdt/internal/corext/refactoring/base/RefactoringStatus; org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringStarter.activate (Lorg/eclipse/jdt/internal/corext/refactoring/base/Refactoring;Lorg/eclipse/jdt /internal/ui/refactoring/RefactoringWizard;Ljava/lang/String;Z) Ljava/lang/Object; org/eclipse/jdt/ui/actions/ExtractMethodAction.run (Lorg/eclipse/jface/text/ITextSelection;)V org/eclipse/jdt/ui/actions/SelectionDispatchAction.dispatchRun (Lorg/eclipse/jface/viewers/ISelection;)V org/eclipse/jdt/ui/actions/SelectionDispatchAction.run()V org/eclipse/jface/action/Action.runWithEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/ui/actions/RetargetAction.runWithEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/ui/internal/WWinPluginAction.runWithEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetSelection (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.handleWidgetEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/jface/action/ActionContributionItem.access$0 (Lorg/eclipse/jface/action/ActionContributionItem;Lorg/eclipse/swt/widgets/Even t;)V org/eclipse/jface/action/ActionContributionItem$ActionListener.handleEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/EventTable.sendEvent (Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Widget.sendEvent(Lorg/eclipse/swt/widgets/Event;)V org/eclipse/swt/widgets/Display.runDeferredEvents()Z org/eclipse/swt/widgets/Display.readAndDispatch()Z org/eclipse/ui/internal/Workbench.runEventLoop()V org/eclipse/ui/internal/Workbench.run(Ljava/lang/Object;)Ljava/lang/Object; org/eclipse/core/internal/boot/InternalBootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String; [Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object; org/eclipse/core/boot/BootLoader.run (Ljava/lang/String;Ljava/net/URL;Ljava/lang/String; [Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object; java/lang/reflect/AccessibleObject.invokeL(Ljava/lang/Object; [Ljava/lang/Object;)Ljava/lang/Object; java/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;) Ljava/lang/Object; org/eclipse/core/launcher/Main.basicRun([Ljava/lang/String;) Ljava/lang/Object; org/eclipse/core/launcher/Main.run([Ljava/lang/String;)Ljava/lang/Object; org/eclipse/core/launcher/Main.main([Ljava/lang/String;)V I was able to repeat the problem with a stripped down version of the class. Enter the following class into a Java editor: public class Foo { protected void primExecute() { this.toString(); } if (image != null) { Object loc = null; } } Select the 'this.toString()' line. Choose 'Refactor'->'Extract Method'
i think the problem is on our (refactoring) side this class is so messed up that cu.isStructureKnown() returns false we should guard our code against it
more actions fail: OrganizeImport SurroundWithTryCatch Rename (when you select sth in the file) SelfEncapsulateField (add a field, select and invoke the action) i suggest moving to the ui land and putting guards in the ui actions
I don't agree with this. As we can see from the walkback there is an old AST which somehow can't be converted into a new AST. Even if the CU is totally broken creating an AST for it should not result in an IllegalArgumentException. What I would expect to get is an AST containing only a CompilationUnitNode.
Pls investigate - internal calls should never result in invalid argument exceptions.
I cannot reproduce in latest. This seems to be a duplicate of bug 18708. I got the following cu after applying refact -> extract method on the selected line: public class Foo { protected void primExecute() { test(); } private String test() { return this.toString(); } if (image != null) { Object loc = null; } }
I could reproduce in F2, but not in latest. So this is a duplicate of bug 18708. *** This bug has been marked as a duplicate of 18708 ***