Search in sources :

Example 6 with AnalysisFacet

use of org.metaborg.spoofax.core.analysis.AnalysisFacet in project spoofax by metaborg.

the class TaskEngineAnalyzer method analyzeAll.

@Override
public ISpoofaxAnalyzeResults analyzeAll(Iterable<ISpoofaxParseUnit> inputs, IContext context, IProgress progress, ICancel cancel) throws AnalysisException, InterruptedException {
    cancel.throwIfCancelled();
    final ILanguageImpl langImpl = context.language();
    final ITermFactory termFactory = termFactoryService.getGeneric();
    final FacetContribution<AnalysisFacet> facetContribution = langImpl.facetContribution(AnalysisFacet.class);
    if (facetContribution == null) {
        logger.debug("No analysis required for {}", langImpl);
        return new SpoofaxAnalyzeResults(context);
    }
    final AnalysisFacet facet = facetContribution.facet;
    cancel.throwIfCancelled();
    final HybridInterpreter runtime;
    try {
        runtime = runtimeService.runtime(facetContribution.contributor, context, false);
    } catch (MetaborgException e) {
        throw new AnalysisException(context, "Failed to get Stratego runtime", e);
    }
    cancel.throwIfCancelled();
    return analyzeAll(inputs, context, runtime, facet.strategyName, termFactory);
}
Also used : ISpoofaxAnalyzeResults(org.metaborg.spoofax.core.analysis.ISpoofaxAnalyzeResults) SpoofaxAnalyzeResults(org.metaborg.spoofax.core.analysis.SpoofaxAnalyzeResults) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) MetaborgException(org.metaborg.core.MetaborgException) HybridInterpreter(org.strategoxt.HybridInterpreter) AnalysisException(org.metaborg.core.analysis.AnalysisException) AnalysisFacet(org.metaborg.spoofax.core.analysis.AnalysisFacet) ITermFactory(org.spoofax.interpreter.terms.ITermFactory)

Aggregations

AnalysisFacet (org.metaborg.spoofax.core.analysis.AnalysisFacet)6 MetaborgException (org.metaborg.core.MetaborgException)5 ILanguageImpl (org.metaborg.core.language.ILanguageImpl)5 AnalysisException (org.metaborg.core.analysis.AnalysisException)4 HybridInterpreter (org.strategoxt.HybridInterpreter)4 ISpoofaxAnalyzeResults (org.metaborg.spoofax.core.analysis.ISpoofaxAnalyzeResults)3 SpoofaxAnalyzeResults (org.metaborg.spoofax.core.analysis.SpoofaxAnalyzeResults)3 ITermFactory (org.spoofax.interpreter.terms.ITermFactory)3 FileObject (org.apache.commons.vfs2.FileObject)2 IdentificationFacet (org.metaborg.core.language.IdentificationFacet)2 StrategoRuntimeFacet (org.metaborg.spoofax.core.stratego.StrategoRuntimeFacet)2 SyntaxFacet (org.metaborg.spoofax.core.syntax.SyntaxFacet)2 ISpoofaxAnalyzeUnit (org.metaborg.spoofax.core.unit.ISpoofaxAnalyzeUnit)2 ISpoofaxParseUnit (org.metaborg.spoofax.core.unit.ISpoofaxParseUnit)2 Test (org.junit.Test)1 ILanguageComponentConfig (org.metaborg.core.config.ILanguageComponentConfig)1 ContextFacet (org.metaborg.core.context.ContextFacet)1 IContextFactory (org.metaborg.core.context.IContextFactory)1 IContextStrategy (org.metaborg.core.context.IContextStrategy)1 ComponentCreationConfig (org.metaborg.core.language.ComponentCreationConfig)1