Project: JDT
Bug 322331 [introduce parameter] IntroduceParameterRefactoring wrong assurance ICompilationUnit => IMethod
Reported: 2010-08-11 06:17:54 | Status: verified fixed

Build Identifier: M20090917-0800 I'm trying to create a refactoring using RefactoringDescriptor class. I'm generate the necessary arguments of the argument Map<String, String> to get an instance of the class "RefactoringDescriptor". Then a create refactoring object, that already parametrezed. Here I land in the method "private RefactoringStatus initialize(JavaRefactoringArguments arguments) of the class org.eclipse.jdt.internal.corext.refactoring.code.IntroduceParameterRefactoring. In this method, at line 564 is the wrong test, see Source: if (element == null | |! element.exists () | | element.getElementType ()! = IJavaElement.COMPILATION_UNIT) JavaRefactoringDescriptorUtil.createInputFatalStatus return (element getName (), IJavaRefactorings.INTRODUCE_PARAMETER); else fSourceCU = ((IMethods) element). getCompilationUnit (); In the "if" question is assured that variable is to be "element" ICompilationUnit type. Is expected, but IMethods! Reproducible: Always Steps to Reproduce: 1.Try to create an Refactoring using LTK API. Something like that! 2. public Refactoring createRefactoring(String project, String description, String comment) throws CoreException { final JavaRefactoringDescriptor descriptor = (JavaRefactoringDescriptor) RefactoringCore .getRefactoringContribution( IJavaRefactorings.INTRODUCE_PARAMETER) .createDescriptor(IJavaRefactorings.INTRODUCE_PARAMETER, project, description, comment, getAttributes(), getFlags()); Assert.isNotNull(descriptor); return descriptor.createRefactoring(descriptor.validateDescriptor()); } 3.

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java