Search in sources :

Example 1 with MessageInfo

use of mb.nabl2.constraints.messages.MessageInfo 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);
    }
}
Also used : ISourceRegion(org.metaborg.core.source.ISourceRegion) FileObject(org.apache.commons.vfs2.FileObject) TermOrigin(mb.nabl2.stratego.TermOrigin)

Aggregations

TermOrigin (mb.nabl2.stratego.TermOrigin)1 FileObject (org.apache.commons.vfs2.FileObject)1 ISourceRegion (org.metaborg.core.source.ISourceRegion)1