Search in sources :

Example 1 with IResourceRelocationStrategy

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

the class ResourceRelocationProcessor method executeParticipants.

protected void executeParticipants(final ResourceRelocationContext context) {
    final List<? extends IResourceRelocationStrategy> strategies = this.strategyRegistry.getStrategies();
    ResourceRelocationContext.ChangeType _changeType = context.getChangeType();
    boolean _tripleEquals = (_changeType == ResourceRelocationContext.ChangeType.COPY);
    if (_tripleEquals) {
        IChangeSerializer _changeSerializer = context.getChangeSerializer();
        _changeSerializer.setUpdateRelatedFiles(false);
    }
    final Consumer<IResourceRelocationStrategy> _function = (IResourceRelocationStrategy it) -> {
        try {
            it.applyChange(context);
        } catch (final Throwable _t) {
            if (_t instanceof Throwable) {
                final Throwable t = (Throwable) _t;
                this.issues.add(RefactoringIssueAcceptor.Severity.ERROR, "Error applying resource changes", t);
                ResourceRelocationProcessor.LOG.error(t.getMessage(), t);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    };
    strategies.forEach(_function);
}
Also used : IResourceRelocationStrategy(org.eclipse.xtext.ide.refactoring.IResourceRelocationStrategy) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) ResourceRelocationContext(org.eclipse.xtext.ide.refactoring.ResourceRelocationContext)

Example 2 with IResourceRelocationStrategy

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

the class ResourceRelocationProcessor method executeParticipants.

protected void executeParticipants(ResourceRelocationContext context, SubMonitor monitor) {
    List<? extends IResourceRelocationStrategy> strategies = strategyRegistry.getStrategies();
    if (context.getChangeType() == ResourceRelocationContext.ChangeType.COPY) {
        context.getChangeSerializer().setUpdateRelatedFiles(false);
    }
    monitor.setWorkRemaining(strategies.size());
    for (IResourceRelocationStrategy strategy : strategies) {
        try {
            monitor.split(1);
            strategy.applyChange(context);
        } catch (OperationCanceledException t) {
            issues.add(ERROR, "Operation was cancelled while applying resource changes", t);
            LOG.error(t.getMessage(), t);
            break;
        }
    }
}
Also used : IResourceRelocationStrategy(org.eclipse.xtext.ide.refactoring.IResourceRelocationStrategy) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException)

Aggregations

IResourceRelocationStrategy (org.eclipse.xtext.ide.refactoring.IResourceRelocationStrategy)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 ResourceRelocationContext (org.eclipse.xtext.ide.refactoring.ResourceRelocationContext)1 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)1