use of org.metaborg.core.messages.IMessagePrinter in project spoofax by metaborg.
the class Builder method printMessages.
private boolean printMessages(Iterable<IMessage> messages, String phase, BuildInput input, boolean pardoned) {
final IMessagePrinter printer = input.messagePrinter;
if (printer != null) {
for (IMessage message : messages) {
printer.print(message, pardoned);
}
}
final boolean failed = !pardoned && MessageUtils.containsSeverity(messages, MessageSeverity.ERROR);
if (input.throwOnErrors && failed) {
throw new MetaborgRuntimeException(phase + " produced errors");
}
return !failed;
}
use of org.metaborg.core.messages.IMessagePrinter in project spoofax by metaborg.
the class Builder method build.
@Override
public IBuildOutput<P, A, AU, T> build(BuildInput input, IProgress progress, ICancel cancel) throws InterruptedException {
cancel.throwIfCancelled();
final Multimap<ILanguageImpl, IdentifiedResourceChange> changes = ArrayListMultimap.create();
identifyResources(input.sourceChanges, input, changes, cancel);
if (changes.size() == 0) {
// When there are no source changes, keep the old state and skip building.
final IBuildOutputInternal<P, A, AU, T> buildOutput = buildOutputProvider.get();
buildOutput.setState(input.state);
return buildOutput;
}
cancel.throwIfCancelled();
logger.info("Building " + input.project.location());
final BuildState newState = new BuildState();
final IBuildOutputInternal<P, A, AU, T> buildOutput = buildOutputProvider.get();
buildOutput.setState(newState);
final Iterable<ILanguageImpl> buildOrder = input.buildOrder.buildOrder();
progress.setWorkRemaining(Iterables.size(buildOrder));
for (ILanguageImpl language : buildOrder) {
cancel.throwIfCancelled();
final LanguageBuildState languageState = input.state.get(resourceService, languageIdentifier, language);
final Collection<IdentifiedResourceChange> sourceChanges = changes.get(language);
if (sourceChanges.size() == 0) {
// When there are no source changes for this language, keep the old state and don't build.
newState.add(language, languageState);
continue;
}
final Iterable<FileObject> includePaths = input.includePaths.get(language);
final Iterable<IdentifiedResource> includeFiles = languagePathService.toFiles(includePaths, language);
final LanguageBuildDiff diff = languageState.diff(changes.get(language), includeFiles);
final boolean pardoned = input.pardonedLanguages.contains(language);
final Collection<FileObject> newResources = updateLanguageResources(input, language, diff, buildOutput, pardoned, progress.subProgress(1), cancel);
final Iterable<ResourceChange> newResourceChanges = ResourceUtils.toChanges(newResources, ResourceChangeKind.Create);
identifyResources(newResourceChanges, input, changes, cancel);
newState.add(language, diff.newState);
}
final IMessagePrinter printer = input.messagePrinter;
if (printer != null) {
printer.printSummary();
}
return buildOutput;
}
Aggregations