diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 1d538ab38e3..6fa1c6b9148 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -2085,35 +2085,45 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi @Override protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) { String oldLanguage = ""; //$NON-NLS-1$ - if (originalElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) originalElement).getFile(); - if (file != null) { - IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName()); - if (type != null) { - oldLanguage = type.getId(); - } - if (oldLanguage == null) { - return false; - } + IFile originalFile = getEditorInputFile(originalElement); + + if (originalFile != null) { + // if the project of the original input cannot be accessed, + // we do have a project rename scenario and we can handle a move + // see Bug #434852 + if (originalFile.getProject() != null && !originalFile.getProject().isAccessible()) { + return true; + } + IContentType type = CCorePlugin.getContentType(originalFile.getProject(), originalFile.getName()); + if (type != null) { + oldLanguage = type.getId(); + } + if (oldLanguage == null) { + return false; } } String newLanguage = ""; //$NON-NLS-1$ - if (movedElement instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput) movedElement).getFile(); - if (file != null) { - IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName()); - if (type != null) { - newLanguage = type.getId(); - } - if (newLanguage == null) { - return false; - } + IFile movedFile = getEditorInputFile(movedElement); + if (movedFile != null) { + IContentType type = CCorePlugin.getContentType(movedFile.getProject(), movedFile.getName()); + if (type != null) { + newLanguage = type.getId(); + } + if (newLanguage == null) { + return false; } } return oldLanguage.equals(newLanguage); } + private IFile getEditorInputFile(IEditorInput editorInput) { + if (editorInput instanceof IFileEditorInput) { + return ((IFileEditorInput) editorInput).getFile(); + } + return null; + } + @Override protected void createActions() { super.createActions();