use of org.metaborg.spoofax.core.analysis.SpoofaxAnalyzeResult in project spoofax by metaborg.
the class StrategoAnalyzer method analyze.
@Override
public ISpoofaxAnalyzeResult analyze(ISpoofaxParseUnit input, IContext context, IProgress progress, ICancel cancel) throws AnalysisException, InterruptedException {
cancel.throwIfCancelled();
if (!input.valid()) {
final String message = logger.format("Parse input for {} is invalid, cannot analyze", input.source());
throw new AnalysisException(context, message);
}
final ILanguageImpl language = context.language();
final ITermFactory termFactory = termFactoryService.getGeneric();
final FacetContribution<AnalysisFacet> facetContribution = language.facetContribution(AnalysisFacet.class);
if (facetContribution == null) {
logger.debug("No analysis required for {}", language);
final ISpoofaxAnalyzeUnit emptyUnit = unitService.emptyAnalyzeUnit(input, context);
return new SpoofaxAnalyzeResult(emptyUnit, context);
}
final AnalysisFacet facet = facetContribution.facet;
cancel.throwIfCancelled();
final HybridInterpreter runtime;
try {
runtime = runtimeService.runtime(facetContribution.contributor, context, true);
} catch (MetaborgException e) {
throw new AnalysisException(context, "Failed to get Stratego runtime", e);
}
cancel.throwIfCancelled();
final ISpoofaxAnalyzeUnit result = analyze(input, context, runtime, facet.strategyName, termFactory);
return new SpoofaxAnalyzeResult(result, context);
}
Aggregations