Search in sources :

Example 1 with LanguagesFileSelector

use of org.metaborg.core.language.LanguagesFileSelector in project spoofax by metaborg.

the class Builder method clean.

@Override
public void clean(CleanInput input, IProgress progress, ICancel cancel) throws InterruptedException {
    final FileObject location = input.project.location();
    logger.debug("Cleaning {}", location);
    FileSelector selector = new LanguagesFileSelector(languageIdentifier, input.languages);
    if (input.selector != null) {
        selector = FileSelectorUtils.and(selector, input.selector);
    }
    try {
        final FileObject[] resources = location.findFiles(selector);
        if (resources == null) {
            return;
        }
        final Set<IContext> contexts = ContextUtils.getAll(Iterables2.from(resources), input.project, languageIdentifier, contextService);
        for (IContext context : contexts) {
            cancel.throwIfCancelled();
            try {
                context.reset();
            } catch (IOException e) {
                logger.error("Could not clean {}", e, context);
            }
        }
    } catch (FileSystemException e) {
        logger.error("Could not clean contexts at {}", e, location);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) IContext(org.metaborg.core.context.IContext) FileSelector(org.apache.commons.vfs2.FileSelector) LanguagesFileSelector(org.metaborg.core.language.LanguagesFileSelector) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) LanguagesFileSelector(org.metaborg.core.language.LanguagesFileSelector)

Aggregations

IOException (java.io.IOException)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSelector (org.apache.commons.vfs2.FileSelector)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 IContext (org.metaborg.core.context.IContext)1 LanguagesFileSelector (org.metaborg.core.language.LanguagesFileSelector)1