Search in sources :

Example 1 with ResourceRelocationChange

use of org.eclipse.xtext.ide.refactoring.ResourceRelocationChange in project xtext-core by eclipse.

the class FileAwareTestLanguageResourceRelocationStrategy method applyChange.

@Override
public void applyChange(final ResourceRelocationContext context) {
    final Function1<ResourceRelocationChange, Boolean> _function = (ResourceRelocationChange it) -> {
        return Boolean.valueOf(this.canHandle(it));
    };
    final Consumer<ResourceRelocationChange> _function_1 = (ResourceRelocationChange change) -> {
        final IChangeSerializer.IModification<Resource> _function_2 = (Resource resource) -> {
            final EObject rootElement = IterableExtensions.<EObject>head(resource.getContents());
            if ((rootElement instanceof PackageDeclaration)) {
                final String newPackage = IterableExtensions.join(IterableExtensions.<String>drop(change.getToURI().trimSegments(1).segmentsList(), 2), ".");
                ((PackageDeclaration) rootElement).setName(newPackage);
            }
        };
        context.addModification(change, _function_2);
    };
    IterableExtensions.<ResourceRelocationChange>filter(context.getChanges(), _function).forEach(_function_1);
}
Also used : ResourceRelocationChange(org.eclipse.xtext.ide.refactoring.ResourceRelocationChange) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) PackageDeclaration(org.eclipse.xtext.testlanguages.fileAware.fileAware.PackageDeclaration)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceRelocationChange (org.eclipse.xtext.ide.refactoring.ResourceRelocationChange)1 PackageDeclaration (org.eclipse.xtext.testlanguages.fileAware.fileAware.PackageDeclaration)1