Search in sources :

Example 41 with IReferenceDescription

use of org.eclipse.xtext.resource.IReferenceDescription in project xtext-eclipse by eclipse.

the class AbstractReferenceUpdater method createReferenceUpdates.

protected void createReferenceUpdates(ElementRenameArguments elementRenameArguments, Iterable<IReferenceDescription> referenceDescriptions, IRefactoringUpdateAcceptor updateAcceptor, RefactoringResourceSetProvider resourceSetProvider, IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, 100);
    progress.beginTask("Sort references by project", 1);
    Multimap<IProject, IReferenceDescription> project2references = sorter.sortByProject(referenceDescriptions);
    SubMonitor allProjectsProgress = progress.newChild(98).setWorkRemaining(project2references.keySet().size());
    for (IProject project : project2references.keySet()) {
        if (allProjectsProgress.isCanceled()) {
            throw new OperationCanceledException();
        }
        Multimap<URI, IReferenceDescription> resource2references = sorter.sortByResource(project2references.get(project));
        ResourceSet resourceSet = resourceSetProvider.get(project);
        StatusWrapper status = updateAcceptor.getRefactoringStatus();
        createClusteredReferenceUpdates(elementRenameArguments, resource2references, resourceSet, updateAcceptor, status, allProjectsProgress.newChild(1));
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription)

Example 42 with IReferenceDescription

use of org.eclipse.xtext.resource.IReferenceDescription in project xtext-eclipse by eclipse.

the class XbaseReferenceUpdater method processReferringResource.

@Override
protected void processReferringResource(Resource referringResource, Iterable<IReferenceDescription> referenceDescriptions, ElementRenameArguments elementRenameArguments, IRefactoringUpdateAcceptor updateAcceptor, IProgressMonitor monitor) {
    ImportAwareUpdateAcceptor importAwareUpdateAcceptor = createUpdateAcceptor(referringResource, updateAcceptor);
    Iterable<IReferenceDescription> importTypeReferences = getImportTypeReferences(referenceDescriptions);
    super.processReferringResource(referringResource, importTypeReferences, elementRenameArguments, importAwareUpdateAcceptor, monitor);
    importAwareUpdateAcceptor.getImportSection().update();
    Iterable<IReferenceDescription> notImportTypeReferences = getNotImportTypeReferences(referenceDescriptions);
    super.processReferringResource(referringResource, notImportTypeReferences, elementRenameArguments, importAwareUpdateAcceptor, monitor);
    List<ReplaceRegion> importChanges = importAwareUpdateAcceptor.getImportSection().rewrite();
    TextEdit importChangeEdit = replaceConverter.convertToTextEdit(importChanges);
    if (importChangeEdit != null)
        updateAcceptor.accept(referringResource.getURI(), importChangeEdit);
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) TextEdit(org.eclipse.text.edits.TextEdit) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription)

Aggregations

IReferenceDescription (org.eclipse.xtext.resource.IReferenceDescription)42 URI (org.eclipse.emf.common.util.URI)18 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)17 EObject (org.eclipse.emf.ecore.EObject)12 Test (org.junit.Test)11 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)9 SubMonitor (org.eclipse.core.runtime.SubMonitor)7 EReference (org.eclipse.emf.ecore.EReference)6 Resource (org.eclipse.emf.ecore.resource.Resource)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)6 XtextResource (org.eclipse.xtext.resource.XtextResource)6 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)5 IFile (org.eclipse.core.resources.IFile)3 IProject (org.eclipse.core.resources.IProject)3 EClass (org.eclipse.emf.ecore.EClass)3 EPackage (org.eclipse.emf.ecore.EPackage)3 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 Main (org.eclipse.xtext.linking.langATestLanguage.Main)3