org.eclipse.xtext.ui.refactoring.impl.RefactoringException Java Examples

The following examples show how to use org.eclipse.xtext.ui.refactoring.impl.RefactoringException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DotRenameStrategy.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected EObject setName(URI targetElementURI, String newName,
		ResourceSet resourceSet) {
	EObject targetElement = resourceSet.getEObject(targetElementURI, false);
	if (targetElement == null) {
		throw new RefactoringException("Target element not loaded."); //$NON-NLS-1$
	}
	targetElement.eSet(getNameAttribute(), ID.fromString(newName));
	return targetElement;
}
 
Example #2
Source File: XtendRenameStrategy.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: EcorePackageRenameStrategy.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Change the package name.
 *
 * @param newName the new name.
 * @param resourceSet the set of resource to use.
 */
protected void setPackageName(String newName, ResourceSet resourceSet) {
	final EObject object = resourceSet.getEObject(this.uriProvider.apply(resourceSet), true);
	if (object instanceof SarlScript) {
		((SarlScript) object).setPackage(newName);
	} else {
		throw new RefactoringException("SARL script not loaded."); //$NON-NLS-1$
	}
}
 
Example #4
Source File: EcorePackageRenameStrategy.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the text update for the rename.
 *
 * @param newName the new package name.
 * @param resourceSet the set of resources.
 * @return the text update.
 */
protected TextEdit getDeclarationTextEdit(String newName, ResourceSet resourceSet) {
	final EObject object = resourceSet.getEObject(this.uriProvider.apply(resourceSet), true);
	if (object instanceof SarlScript) {
		final ITextRegion region = getOriginalPackageRegion((SarlScript) object);
		if (region != null) {
			return new ReplaceEdit(region.getOffset(), region.getLength(), newName);
		}
	}
	throw new RefactoringException("SARL script not loaded."); //$NON-NLS-1$
}