use of mb.nabl2.stratego.TermOrigin in project spoofax by metaborg.
the class AbstractConstraintAnalyzer method message.
private IMessage message(ITerm originatingTerm, IMessageInfo messageInfo, MessageSeverity severity, IUnifier unifier, C context, FileObject defaultLocation) {
Optional<TermOrigin> maybeOrigin = TermOrigin.get(originatingTerm);
if (maybeOrigin.isPresent()) {
TermOrigin origin = maybeOrigin.get();
ISourceRegion region = JSGLRSourceRegionFactory.fromTokens(origin.getLeftToken(), origin.getRightToken());
FileObject resource = resourceService.resolve(context.location(), origin.getResource());
String message = messageInfo.getContent().apply(unifier::findRecursive).toString(prettyprint(context, resource(resource, context)));
return MessageFactory.newAnalysisMessage(resource, region, message, severity, null);
} else {
String message = messageInfo.getContent().apply(unifier::findRecursive).toString(prettyprint(context, null));
return MessageFactory.newAnalysisMessageAtTop(defaultLocation, message, severity, null);
}
}
use of mb.nabl2.stratego.TermOrigin in project nabl by metaborg.
the class Actions method sourceTerm.
public static ITerm sourceTerm(String resource, ITerm term) {
TermIndex index = ImmutableTermIndex.of(resource, 0);
TermOrigin origin = ImmutableTermOrigin.of(resource);
ImmutableClassToInstanceMap<Object> attachments = ImmutableClassToInstanceMap.builder().put(TermIndex.class, index).put(TermOrigin.class, origin).build();
return term.withAttachments(attachments);
}
Aggregations