Project: JDT
Bug 95928 Generalize Type throws exceptions / is not available on certain types
Reported: 2005-05-19 08:37:02 | Status: verified fixed

N20050519-0010 With unparameterized types, generalize type can be activated by placing the caret anywhere inside an unqualified type. With parameterized types, the whole type must be selected. The refactoring should automatically detect the generalizable type around the caret location Sometimes, not even selecting the whole type works (e.g. selecting the type "List<Object>" (second parameter of method test2(..))). And with qualified type names (even unparameterized), the refactoring spits: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: assertion failed;No constraint variable matches the selected ASTNode. at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:139) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.findConstraintVariableForSelectedNode(ChangeTypeRefactoring.java:880) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.computeValidTypes(ChangeTypeRefactoring.java:416) at org.eclipse.jdt.internal.ui.refactoring.ChangeTypeWizard$1.run(ChangeTypeWizard.java:195) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113) Here's an example class to play around: public class Dummy { String fValue2 = "Eclipse"; List<String> fValue = Arrays.asList("Eclipse"); String test(String arg) { return null;} List<String> test2(java.util.List<Object> aList, List<Object> l){ return null; } }

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/negative/A_testQualifiedFieldRef_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/negative/A_testQualifiedFieldRef_out.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricEmptySelection_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricEmptySelection_out.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricLocalVar_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricLocalVar_out.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricParameter_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testParametricParameter_out.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testQualifiedNameEmptySelection_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testQualifiedNameEmptySelection_out.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java