Java Code Examples for org.eclipse.xtext.ui.refactoring.IChangeRedirector#Aware
The following examples show how to use
org.eclipse.xtext.ui.refactoring.IChangeRedirector#Aware .
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: RefactoringUpdateAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IChangeRedirector getChangeRedirector() { if(refactoringDocumentProvider instanceof IChangeRedirector.Aware) return ((IChangeRedirector.Aware) refactoringDocumentProvider).getChangeRedirector(); else return IChangeRedirector.NULL; }
Example 2
Source File: XtendFileRenameParticipant.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) { if(super.getNewName().endsWith(".xtend")) { IFile file = (IFile) element; final IPath filePath = file.getFullPath(); final IPath newPath = file.getFullPath().removeLastSegments(1).append(getNewName() + ".xtend"); String className = trimFileExtension(file.getName()); if(className != null) { ResourceSet resourceSet = resourceSetProvider.get(file.getProject()); URI resourceURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); Resource resource = resourceSet.getResource(resourceURI, true); if (resource != null && !resource.getContents().isEmpty()) { for (XtendTypeDeclaration type : EcoreUtil2.eAllOfType(resource.getContents().get(0), XtendTypeDeclaration.class)) { if (equal(className, type.getName())) { IRenameElementContext renameElementContext = renameContextFactory.createRenameElementContext(type, null, null, (XtextResource) resource); if(renameElementContext instanceof IChangeRedirector.Aware) ((IChangeRedirector.Aware) renameElementContext).setChangeRedirector(new IChangeRedirector() { @Override public IPath getRedirectedPath(IPath source) { return source.equals(filePath) ? newPath : source; } }); return singletonList(renameElementContext); } } } } } return super.createRenameElementContexts(element); }
Example 3
Source File: XtendRenameStrategy.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
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 4
Source File: RenameElementProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void transferChangeRedirector(IRefactoringUpdateAcceptor currentUpdateAcceptor2) { if(currentUpdateAcceptor instanceof IChangeRedirector.Aware && renameElementContext instanceof IChangeRedirector.Aware) ((IChangeRedirector.Aware) currentUpdateAcceptor).setChangeRedirector( ((IChangeRedirector.Aware)getRenameElementContext()).getChangeRedirector()); }
Example 5
Source File: RefactoringUpdateAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public void setChangeRedirector(IChangeRedirector changeRedirector) { if(refactoringDocumentProvider instanceof IChangeRedirector.Aware) ((IChangeRedirector.Aware) refactoringDocumentProvider).setChangeRedirector(changeRedirector); }