[refactoring] introduced default method in 'IResourceRelocationStrategy' allowing an implementation to explicitly demand for live scope resource indexing during refactorings

updated implementation of 'FileAwareTestLanguage'

Signed-off-by: Christian Schneider <christian.schneider@typefox.io>
This commit is contained in:
Christian Schneider 2019-04-17 15:24:30 +02:00
parent dc5c0c6ff7
commit 265e4c97e3
4 changed files with 31 additions and 1 deletions

View file

@ -29,6 +29,16 @@ interface IResourceRelocationStrategy {
def void applyChange(ResourceRelocationContext context)
/**
* If possible refactoring operations may rely on persisted index data for reduced memory consumption,
* which is the case in the Eclipse IDE. By overloading this method client implementations may
* explicitly demand for live scope resource indexing.
*
* @since 2.18
*/
def boolean requiresLiveScopeResourceIndexing(ResourceRelocationContext context) {
return false;
}
}

View file

@ -30,4 +30,15 @@ import org.eclipse.xtext.ide.refactoring.ResourceRelocationContext;
@SuppressWarnings("all")
public interface IResourceRelocationStrategy {
public abstract void applyChange(final ResourceRelocationContext context);
/**
* If possible refactoring operations may rely on persisted index data for reduced memory consumption,
* which is the case in the Eclipse IDE. By overloading this method client implementations may
* explicitly demand for live scope resource indexing.
*
* @since 2.18
*/
public default boolean requiresLiveScopeResourceIndexing(final ResourceRelocationContext context) {
return false;
}
}

View file

@ -14,7 +14,11 @@ class FileAwareTestLanguageResourceRelocationStrategy implements IResourceReloca
def boolean canHandle(ResourceRelocationChange change) {
resourceServiceProvider.canHandle(change.fromURI)
}
override requiresLiveScopeResourceIndexing(ResourceRelocationContext context) {
true
}
override applyChange(ResourceRelocationContext context) {
context.changes.filter[ canHandle ].forEach [ change |
context.addModification(change) [ resource |

View file

@ -22,6 +22,11 @@ public class FileAwareTestLanguageResourceRelocationStrategy implements IResourc
return this.resourceServiceProvider.canHandle(change.getFromURI());
}
@Override
public boolean requiresLiveScopeResourceIndexing(final ResourceRelocationContext context) {
return true;
}
@Override
public void applyChange(final ResourceRelocationContext context) {
final Function1<ResourceRelocationChange, Boolean> _function = (ResourceRelocationChange it) -> {