Search in sources :

Example 6 with IdentifiedResourceChange

use of org.metaborg.core.resource.IdentifiedResourceChange in project spoofax by metaborg.

the class FilesBuildState method sourceDiff.

private void sourceDiff(LanguageBuildState newState, Iterable<IdentifiedResourceChange> changes) {
    for (IdentifiedResourceChange identifiedChange : changes) {
        final ResourceChange change = identifiedChange.change;
        switch(change.kind) {
            case Create:
                newState.source.add(change.resource);
                break;
            case Delete:
                newState.source.remove(change.resource.getName());
                break;
            case Rename:
                final FileObject from = change.from;
                if (from != null) {
                    newState.source.remove(from.getName());
                }
                newState.source.add(change.to);
                break;
            case Copy:
                newState.source.add(change.to);
                break;
            default:
                break;
        }
    }
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) IdentifiedResourceChange(org.metaborg.core.resource.IdentifiedResourceChange) IdentifiedResourceChange(org.metaborg.core.resource.IdentifiedResourceChange) ResourceChange(org.metaborg.core.resource.ResourceChange)

Aggregations

FileObject (org.apache.commons.vfs2.FileObject)6 IdentifiedResourceChange (org.metaborg.core.resource.IdentifiedResourceChange)6 ResourceChange (org.metaborg.core.resource.ResourceChange)5 ILanguageImpl (org.metaborg.core.language.ILanguageImpl)4 IdentifiedResource (org.metaborg.core.language.IdentifiedResource)3 FileName (org.apache.commons.vfs2.FileName)2 IOException (java.io.IOException)1 FileSelector (org.apache.commons.vfs2.FileSelector)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 ContextException (org.metaborg.core.context.ContextException)1 IContext (org.metaborg.core.context.IContext)1 LanguagesFileSelector (org.metaborg.core.language.LanguagesFileSelector)1 IMessage (org.metaborg.core.messages.IMessage)1 IMessagePrinter (org.metaborg.core.messages.IMessagePrinter)1 ResourceChangeKind (org.metaborg.core.resource.ResourceChangeKind)1 ParseException (org.metaborg.core.syntax.ParseException)1 ITransformOutput (org.metaborg.core.transform.ITransformOutput)1 RefBool (org.metaborg.util.RefBool)1