Search in sources :

Example 11 with IMessage

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);
}
Also used : MessageBuilder(org.metaborg.core.messages.MessageBuilder) IMessage(org.metaborg.core.messages.IMessage)

Example 12 with IMessage

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);
}
Also used : IMessage(org.metaborg.core.messages.IMessage) FileObject(org.apache.commons.vfs2.FileObject) AnalyzeContrib(org.metaborg.spoofax.core.unit.AnalyzeContrib)

Example 13 with IMessage

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);
}
Also used : MetaborgRuntimeException(org.metaborg.core.MetaborgRuntimeException) AnalyzeUpdateData(org.metaborg.spoofax.core.unit.AnalyzeUpdateData) IMessage(org.metaborg.core.messages.IMessage) IStrategoString(org.spoofax.interpreter.terms.IStrategoString) FileObject(org.apache.commons.vfs2.FileObject)

Example 14 with IMessage

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);
}
Also used : MessageBuilder(org.metaborg.core.messages.MessageBuilder) ConfigRequest(org.metaborg.core.config.ConfigRequest) IMessage(org.metaborg.core.messages.IMessage)

Example 15 with IMessage

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;
}
Also used : IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) IMessage(org.metaborg.core.messages.IMessage) ISourceRegion(org.metaborg.core.source.ISourceRegion) IStrategoString(org.spoofax.interpreter.terms.IStrategoString) ISourceLocation(org.metaborg.core.source.ISourceLocation)

Aggregations

IMessage (org.metaborg.core.messages.IMessage)19 FileObject (org.apache.commons.vfs2.FileObject)8 IStrategoTerm (org.spoofax.interpreter.terms.IStrategoTerm)8 AnalyzeContrib (org.metaborg.spoofax.core.unit.AnalyzeContrib)6 MessageBuilder (org.metaborg.core.messages.MessageBuilder)5 MetaborgException (org.metaborg.core.MetaborgException)3 MetaborgRuntimeException (org.metaborg.core.MetaborgRuntimeException)3 ISpoofaxParseUnit (org.metaborg.spoofax.core.unit.ISpoofaxParseUnit)3 IStrategoString (org.spoofax.interpreter.terms.IStrategoString)3 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 Inject (com.google.inject.Inject)2 Collection (java.util.Collection)2 Map (java.util.Map)2 Optional (java.util.Optional)2 FixedPoint (mb.flowspec.runtime.solver.FixedPoint)2 NaBL2DebugConfig (mb.nabl2.config.NaBL2DebugConfig)2 ISolution (mb.nabl2.solver.ISolution)2 SolverException (mb.nabl2.solver.SolverException)2 IMessages (mb.nabl2.solver.messages.IMessages)2