diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 3f1c586f390..5b5f0f99b89 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -84,12 +84,14 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.osgi.util.NLS; /** * @see ITranslationUnit @@ -371,17 +373,20 @@ public class TranslationUnit extends Openable implements ITranslationUnit { @Override public void delete(boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().delete(force, monitor); } @Override public void move(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().move(container, sibling, rename, force, monitor); } @Override public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { + Assert.isTrue(!isReadOnly(), NLS.bind("Translation unit {0} must not be read-only", getElementName())); //$NON-NLS-1$ getSourceManipulationInfo().rename(name, force, monitor); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java index a7502340ae9..737d59a11f1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/changes/RenameTranslationUnitChange.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.refactoring.changes; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -28,7 +27,6 @@ public final class RenameTranslationUnitChange extends AbstractCElementRenameCha public RenameTranslationUnitChange(ITranslationUnit tu, String newName) { this(tu.getResource().getFullPath(), tu.getElementName(), newName, IResource.NULL_STAMP); - Assert.isTrue(!tu.isReadOnly(), "Translation unit must not be read-only"); //$NON-NLS-1$ } private RenameTranslationUnitChange(IPath resourcePath, String oldName, String newName, long stampToRestore) {