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());
}
}
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);
}
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()));
}
Aggregations