use of org.metaborg.core.messages.IMessage in project spoofax by metaborg.
the class LanguageComponentConfigService method toConfig.
@Override
protected ConfigRequest<ILanguageComponentConfig> toConfig(HierarchicalConfiguration<ImmutableNode> config, FileObject configFile) {
final ProjectConfig projectConfig = new ProjectConfig(config);
final LanguageComponentConfig languageComponentConfig = new LanguageComponentConfig(config, projectConfig);
final MessageBuilder mb = MessageBuilder.create().asError().asInternal().withSource(configFile);
final Collection<IMessage> messages = languageComponentConfig.validate(mb);
return new ConfigRequest<ILanguageComponentConfig>(languageComponentConfig, messages);
}
use of org.metaborg.core.messages.IMessage in project spoofax by metaborg.
the class StrategoAnalyzer method result.
private ISpoofaxAnalyzeUnit result(String error, ISpoofaxParseUnit input, IContext context, Throwable e, long duration) {
final FileObject source = input.source();
final IMessage message = MessageFactory.newAnalysisErrorAtTop(source, error, e);
return unitService.analyzeUnit(input, new AnalyzeContrib(false, false, true, null, Iterables2.singleton(message), duration), context);
}
use of org.metaborg.core.messages.IMessage in project spoofax by metaborg.
the class TaskEngineAnalyzer method updateResult.
private ISpoofaxAnalyzeUnitUpdate updateResult(IStrategoTerm result, IContext context) {
final String sourceString = Tools.asJavaString(result.getSubterm(0));
final FileObject source;
try {
source = resourceService.resolve(sourceString);
} catch (MetaborgRuntimeException e) {
logger.error("Cannot find original source for {}, skipping update result", e, sourceString);
return null;
}
final Collection<IMessage> errors = analysisCommon.messages(source, MessageSeverity.ERROR, result.getSubterm(1));
final Collection<IMessage> warnings = analysisCommon.messages(source, MessageSeverity.WARNING, result.getSubterm(2));
final Collection<IMessage> notes = analysisCommon.messages(source, MessageSeverity.NOTE, result.getSubterm(3));
final Collection<IMessage> messages = Lists.newArrayListWithCapacity(errors.size() + warnings.size() + notes.size());
messages.addAll(errors);
messages.addAll(warnings);
messages.addAll(notes);
return unitService.analyzeUnitUpdate(source, new AnalyzeUpdateData(messages), context);
}
use of org.metaborg.core.messages.IMessage in project spoofax by metaborg.
the class SpoofaxProjectConfigService method toConfig.
@Override
protected ConfigRequest<ISpoofaxProjectConfig> toConfig(HierarchicalConfiguration<ImmutableNode> config, FileObject configFile) {
final SpoofaxProjectConfig projectConfig = new SpoofaxProjectConfig(config);
final MessageBuilder mb = MessageBuilder.create().asError().asInternal().withSource(configFile);
final Collection<IMessage> messages = projectConfig.validate(mb);
return new ConfigRequest<>(projectConfig, messages);
}
use of org.metaborg.core.messages.IMessage in project spoofax by metaborg.
the class AnalysisCommon method messages.
public Collection<IMessage> messages(FileObject resource, MessageSeverity severity, IStrategoTerm messagesTerm) {
final Collection<IMessage> messages = Lists.newArrayListWithExpectedSize(messagesTerm.getSubtermCount());
for (IStrategoTerm term : messagesTerm.getAllSubterms()) {
final IStrategoTerm originTerm;
final String message;
if (term.getSubtermCount() == 2) {
originTerm = term.getSubterm(0);
message = toString(term.getSubterm(1));
} else {
originTerm = term;
message = toString(term) + " (no tree node indicated)";
}
if (originTerm != null) {
final ISourceLocation location = tracingService.location(originTerm);
if (location != null) {
final ISourceRegion region = location.region();
messages.add(message(resource, region, message, severity));
} else {
messages.add(message(resource, message, severity));
}
} else {
messages.add(message(resource, message, severity));
}
}
return messages;
}
Aggregations