Search in sources :

Example 1 with RefactoringException

use of org.eclipse.xtext.ui.refactoring.impl.RefactoringException in project xtext-xtend by eclipse.

the class XtendRenameStrategy method getPathToRename.

protected IPath getPathToRename(URI elementURI, ResourceSet resourceSet) {
    EObject targetObject = resourceSet.getEObject(elementURI, false);
    if (targetObject instanceof XtendTypeDeclaration) {
        URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(targetObject).trimFragment();
        if (!resourceURI.isPlatformResource())
            throw new RefactoringException("Renamed type does not reside in the workspace");
        IPath path = new Path(resourceURI.toPlatformString(true));
        if (context instanceof IChangeRedirector.Aware) {
            if (((IChangeRedirector.Aware) context).getChangeRedirector().getRedirectedPath(path) != path)
                return null;
        }
        return path;
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) EObject(org.eclipse.emf.ecore.EObject) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) RefactoringException(org.eclipse.xtext.ui.refactoring.impl.RefactoringException) URI(org.eclipse.emf.common.util.URI)

Aggregations

IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)1 RefactoringException (org.eclipse.xtext.ui.refactoring.impl.RefactoringException)1