Community
Participate
Working Groups
I20060228-1207 Steps to reproduce: - Create new Java project, default settings - Create new source folder, check to update exclusion filters in other source folders - Invoke rename refactoring on source folder -> JME because of a wrong classpath (renamed source folder is incorrectly nested in the new classpath)
Moving to JDT/Core. We're calling PackageFragmentRoot#move(..) with all updateModelFlags enabled. Stacktrace: Java Model Exception: Java Model Status [Cannot nest 'Ja/src2' inside 'Ja'. To enable the nesting exclude 'src2/' from 'Ja'] at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:775) at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3007) at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3023) at org.eclipse.jdt.internal.core.MovePackageFragmentRootOperation.renameEntryInClasspath(MovePackageFragmentRootOperation.java:57) at org.eclipse.jdt.internal.core.MovePackageFragmentRootOperation.executeOperation(MovePackageFragmentRootOperation.java:99) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1736) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:784) at org.eclipse.jdt.internal.core.PackageFragmentRoot.move(PackageFragmentRoot.java:807) at org.eclipse.jdt.internal.corext.refactoring.changes.RenameSourceFolderChange.doRename(RenameSourceFolderChange.java) at org.eclipse.jdt.internal.corext.refactoring.AbstractJavaElementRenameChange.perform(AbstractJavaElementRenameChange.java:71) at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:92) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1736) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3997) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3954) at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:95) at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278) at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:232) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1736) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1718) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:280) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.access$1(UIPerformChangeOperation.java:1) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$1.run(UIPerformChangeOperation.java:66) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$2.run(UIPerformChangeOperation.java:84) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3305) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2951) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:158) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:326) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:304) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:545) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:154) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:611) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:433) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:500) at org.eclipse.jface.dialogs.Dialog$3.widgetSelected(Dialog.java:652) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3328) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2948) at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) at org.eclipse.jface.window.Window.open(Window.java:796) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:132) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:145) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:113) at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:114) at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startRenameRefactoring(RefactoringExecutionStarter.java:362) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:171) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:102) at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:108) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:267) ...
We would need to walk the project classpath and update exclusion and inclusion filters if they match the old entry. This can become hard if the inclusion/exclusion pattern is not straightforward. E.g. if we have [-]"src*2/**/p/A*.java", if the user renames src12 into src34, how do we update the exclusion pattern ? I would tend to say it is the responsability of the client since the exclusion/inclusion pattern is controled by the client. Markus, Tobias, what do you think ?
It's correct that the inclusion/exclusion filters are controlled by the client. However, we are calling IPackageFragmentRoot#move(..) with the following flags DESTINATION_PROJECT_CLASSPATH | ORIGINATING_PROJECT_CLASSPATH | OTHER_REFERRING_PROJECTS_CLASSPATH The spec of #move does not mention JavaModelExceptions for inconsistent classpaths in setups like the one above, so I would exspect the API to work without exceptions given the above flags.
If clients of PackageFragmentRoot#move(..) would have to do these corrections, then the method would become rather useless. To ensure that the move works, we would have to - remove all in/exclusion filters from the class path - move - add the modified filters I agree that the updating code will not be trivial in general, but I think it would be enough to just update the common cases like an exclusion filter for the full path of a source folder.
Changed MovePackageFragmentRootOperation#renameEntryInClasspath(...) to also rename the exclusion/inclusion patterns that match exactly the root being renamed, and to not change the classpath if his would result in a JavaModelException. Added regression tests RootManipulationsTests#testRenameSourceFolder3() and testRenameSourceFolder4().
Repne to assign
Still fixed.
Verified for 3.2M6 using build I20060327-0010.