Search in sources :

Example 1 with ValueStamp

use of build.pluto.stamp.ValueStamp in project spoofax by metaborg.

the class DirectoryModifiedStamper method stampOf.

@Override
public Stamp stampOf(File directory) {
    if (!directory.exists()) {
        return new ValueStamp<>(this, -1L);
    } else if (!directory.isDirectory()) {
        throw new RuntimeException("Directory stamper cannot stamp " + directory + ", it is not a directory");
    } else if (filter != null && fileStamper != null) {
        final Map<File, Stamp> stamps = Maps.newHashMap();
        final Collection<File> files = FileUtils.listFiles(directory, filter, FalseFileFilter.INSTANCE);
        for (File file : files) {
            stamps.put(file, fileStamper.stampOf(file));
        }
        return new ValueStamp<>(this, stamps);
    } else {
        return new ValueStamp<>(this, directory.lastModified());
    }
}
Also used : ValueStamp(build.pluto.stamp.ValueStamp) ValueStamp(build.pluto.stamp.ValueStamp) Stamp(build.pluto.stamp.Stamp) File(java.io.File)

Example 2 with ValueStamp

use of build.pluto.stamp.ValueStamp in project spoofax by metaborg.

the class Sdf2RtgStamper method stampOf.

@Override
public Stamp stampOf(File file) {
    if (!FileCommands.exists(file)) {
        return new ValueStamp<>(this, null);
    }
    final IStrategoTerm term;
    try {
        term = context.parse(file);
    } catch (ParseException | IOException e) {
        return LastModifiedStamper.instance.stampOf(file);
    }
    if (term == null) {
        return LastModifiedStamper.instance.stampOf(file);
    }
    final Deliteralize deliteralize = new Deliteralize(context.termFactory(), false);
    final IStrategoTerm delit = deliteralize.transform(term);
    return new ValueStamp<>(this, delit);
}
Also used : ValueStamp(build.pluto.stamp.ValueStamp) IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) ParseException(org.metaborg.core.syntax.ParseException) IOException(java.io.IOException)

Example 3 with ValueStamp

use of build.pluto.stamp.ValueStamp in project spoofax by metaborg.

the class Sdf2ParenthesizeStamper method stampOf.

@Override
public Stamp stampOf(File file) {
    if (!FileCommands.exists(file)) {
        return new ValueStamp<>(this, null);
    }
    final IStrategoTerm term;
    try {
        term = context.parse(file);
    } catch (ParseException | IOException e) {
        return LastModifiedStamper.instance.stampOf(file);
    }
    if (term == null) {
        return LastModifiedStamper.instance.stampOf(file);
    }
    final ParenExtractor parenExtractor = new ParenExtractor(context.termFactory());
    parenExtractor.visit(term);
    return new ValueStamp<>(this, Pair.create(parenExtractor.getRelevantProds(), parenExtractor.getPriorities()));
}
Also used : ValueStamp(build.pluto.stamp.ValueStamp) IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) ParseException(org.metaborg.core.syntax.ParseException) IOException(java.io.IOException)

Aggregations

ValueStamp (build.pluto.stamp.ValueStamp)3 IOException (java.io.IOException)2 ParseException (org.metaborg.core.syntax.ParseException)2 IStrategoTerm (org.spoofax.interpreter.terms.IStrategoTerm)2 Stamp (build.pluto.stamp.Stamp)1 File (java.io.File)1