Search in sources :

Example 11 with ILanguageImpl

use of org.metaborg.core.language.ILanguageImpl in project spoofax by metaborg.

the class JSGLRParseService method parse.

@Override
public ISpoofaxParseUnit parse(ISpoofaxInputUnit input, IProgress progress, ICancel cancel) throws ParseException {
    final FileObject source = input.source();
    final ILanguageImpl langImpl;
    final ILanguageImpl base;
    if (input.dialect() != null) {
        langImpl = input.dialect();
        base = input.langImpl();
    } else {
        langImpl = input.langImpl();
        base = null;
    }
    final String text = input.text();
    final ITermFactory termFactory = termFactoryService.get(langImpl, null, false);
    final IParserConfig config;
    JSGLRParserConfiguration parserConfig = input.config();
    if (parserConfig == null) {
        parserConfig = defaultParserConfig;
    }
    if (parserConfig.completion) {
        config = getCompletionParserConfig(langImpl, input);
    } else {
        config = getParserConfig(langImpl, input);
    }
    try {
        logger.trace("Parsing {}", source);
        JSGLRVersion version = jsglrVersion(input);
        final JSGLRI<?> parser;
        boolean dataDependentParsing = false;
        for (ILanguageComponent component : langImpl.components()) {
            if (component.config().dataDependent()) {
                dataDependentParsing = true;
            }
        }
        if (version == JSGLRVersion.v2) {
            if (dataDependentParsing) {
                parser = new JSGLR2I(config, termFactory, langImpl, null, source, text, true);
            } else {
                parser = new JSGLR2I(config, termFactory, langImpl, null, source, text, false);
            }
        } else {
            if (base != null) {
                parser = new JSGLR1I(config, termFactory, base, langImpl, source, text);
            } else {
                parser = new JSGLR1I(config, termFactory, langImpl, null, source, text);
            }
        }
        final ParseContrib contrib = parser.parse(parserConfig);
        if (version == JSGLRVersion.v2) {
            if (contrib.valid)
                logger.info("Valid JSGLR2 parse");
            else
                logger.info("Invalid JSGLR2 parse");
        }
        final ISpoofaxParseUnit unit = unitService.parseUnit(input, contrib);
        return unit;
    } catch (IOException | InvalidParseTableException | ParseTableReadException e) {
        throw new ParseException(input, e);
    }
}
Also used : ISpoofaxParseUnit(org.metaborg.spoofax.core.unit.ISpoofaxParseUnit) ParseContrib(org.metaborg.spoofax.core.unit.ParseContrib) JSGLRVersion(org.metaborg.core.config.JSGLRVersion) IOException(java.io.IOException) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) FileObject(org.apache.commons.vfs2.FileObject) ParseException(org.metaborg.core.syntax.ParseException) ITermFactory(org.spoofax.interpreter.terms.ITermFactory) ILanguageComponent(org.metaborg.core.language.ILanguageComponent) InvalidParseTableException(org.spoofax.jsglr.client.InvalidParseTableException) ParseTableReadException(org.spoofax.jsglr2.parsetable.ParseTableReadException)

Example 12 with ILanguageImpl

use of org.metaborg.core.language.ILanguageImpl in project spoofax by metaborg.

the class HoverService method hover.

@Override
public Hover hover(int offset, ISpoofaxParseUnit result) throws MetaborgException {
    if (!result.valid()) {
        return null;
    }
    final FileObject source = result.source();
    final IProject project = projectService.get(source);
    final ILanguageImpl langImpl = result.input().langImpl();
    @Nullable IContext context;
    if (project == null) {
        context = null;
    } else {
        try {
            context = contextService.get(source, project, langImpl);
        } catch (ContextException | MetaborgRuntimeException e) {
            // Failed to get a context, ignore and use the source file to get a stratego runtime later.
            context = null;
        }
    }
    final FacetContribution<HoverFacet> facetContrib = facet(langImpl);
    final HoverFacet facet = facetContrib.facet;
    final ILanguageComponent contributor = facetContrib.contributor;
    final String strategy = facet.strategyName;
    try {
        final ITermFactory termFactory = termFactoryService.get(contributor, project, true);
        final HybridInterpreter interpreter;
        if (context == null) {
            interpreter = strategoRuntimeService.runtime(contributor, source, true);
        } else {
            interpreter = strategoRuntimeService.runtime(contributor, context, true);
        }
        final Iterable<IStrategoTerm> inRegion = tracingService.fragments(result, new SourceRegion(offset));
        final TermWithRegion tuple = common.outputs(termFactory, interpreter, context.location(), source, result.ast(), inRegion, strategy);
        return hover(tuple);
    } catch (MetaborgException e) {
        throw new MetaborgException("Getting hover tooltip information failed unexpectedly", e);
    }
}
Also used : MetaborgRuntimeException(org.metaborg.core.MetaborgRuntimeException) IContext(org.metaborg.core.context.IContext) IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) MetaborgException(org.metaborg.core.MetaborgException) HybridInterpreter(org.strategoxt.HybridInterpreter) ISourceRegion(org.metaborg.core.source.ISourceRegion) SourceRegion(org.metaborg.core.source.SourceRegion) IProject(org.metaborg.core.project.IProject) ContextException(org.metaborg.core.context.ContextException) TermWithRegion(org.metaborg.spoofax.core.tracing.TracingCommon.TermWithRegion) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) FileObject(org.apache.commons.vfs2.FileObject) ILanguageComponent(org.metaborg.core.language.ILanguageComponent) ITermFactory(org.spoofax.interpreter.terms.ITermFactory) Nullable(javax.annotation.Nullable)

Example 13 with ILanguageImpl

use of org.metaborg.core.language.ILanguageImpl in project spoofax by metaborg.

the class ResolverService method resolve.

@Override
public Resolution resolve(int offset, ISpoofaxAnalyzeUnit result) throws MetaborgException {
    if (!result.valid() || !result.hasAst()) {
        return null;
    }
    final FileObject source = result.source();
    final IContext context = result.context();
    final IProject project = context.project();
    final ILanguageImpl language = context.language();
    final FacetContribution<ResolverFacet> facetContrib = facet(language);
    final ResolverFacet facet = facetContrib.facet;
    final String strategy = facet.strategyName;
    try {
        final ITermFactory termFactory = termFactoryService.get(facetContrib.contributor, project, true);
        final HybridInterpreter interpreter = strategoRuntimeService.runtime(facetContrib.contributor, context, true);
        final Iterable<IStrategoTerm> inRegion = tracingService.fragments(result, new SourceRegion(offset));
        final TermWithRegion tuple;
        try (IClosableLock lock = context.read()) {
            tuple = common.outputs(termFactory, interpreter, source, source, result.ast(), inRegion, strategy);
        }
        return resolve(tuple);
    } catch (MetaborgException e) {
        throw new MetaborgException("Reference resolution failed", e);
    }
}
Also used : IContext(org.metaborg.core.context.IContext) IStrategoTerm(org.spoofax.interpreter.terms.IStrategoTerm) MetaborgException(org.metaborg.core.MetaborgException) HybridInterpreter(org.strategoxt.HybridInterpreter) ISourceRegion(org.metaborg.core.source.ISourceRegion) SourceRegion(org.metaborg.core.source.SourceRegion) IProject(org.metaborg.core.project.IProject) TermWithRegion(org.metaborg.spoofax.core.tracing.TracingCommon.TermWithRegion) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) FileObject(org.apache.commons.vfs2.FileObject) IClosableLock(org.metaborg.util.concurrent.IClosableLock) ITermFactory(org.spoofax.interpreter.terms.ITermFactory)

Example 14 with ILanguageImpl

use of org.metaborg.core.language.ILanguageImpl in project spoofax by metaborg.

the class SpoofaxLanguageTest method discoverLanguage.

/**
 * The 'res:' filesystem redirects to resources inside the tests' JAR file or class file location, which are copied
 * to the class file location from src/test/resources by Maven. The binary files of the Entity language are located
 * in the resources to test language discovery.
 */
@Test
public void discoverLanguage() throws Exception {
    final FileObject location = resourceService.resolve("res:");
    final Iterable<ILanguageComponent> languages = languageDiscoveryService.discover(languageDiscoveryService.request(location));
    assertEquals(1, Iterables.size(languages));
    final ILanguageComponent component = Iterables.get(languages, 0);
    final ILanguageImpl impl = Iterables.get(component.contributesTo(), 0);
    final ILanguage language = impl.belongsTo();
    assertEquals("Entity", language.name());
    assertEquals(resourceService.resolve("res:Entity"), component.location());
    final IdentificationFacet identificationFacet = impl.facet(IdentificationFacet.class);
    assertTrue(identificationFacet.identify(resourceService.resolve("ram:///Entity/test.ent")));
    final SyntaxFacet syntaxFacet = impl.facet(SyntaxFacet.class);
    assertEquals(resourceService.resolve("res:Entity/target/metaborg/sdf.tbl"), syntaxFacet.parseTable);
    assertIterableEquals(syntaxFacet.startSymbols, "Start");
    final StrategoRuntimeFacet strategoFacet = impl.facet(StrategoRuntimeFacet.class);
    assertIterableEquals(strategoFacet.ctreeFiles, resourceService.resolve("res:Entity/target/metaborg/stratego.ctree"));
    assertIterableEquals(strategoFacet.jarFiles, resourceService.resolve("res:Entity/target/metaborg/stratego-javastrat.jar"));
    final AnalysisFacet analysisFacet = impl.facet(AnalysisFacet.class);
    assertEquals("editor-analyze", analysisFacet.strategyName);
}
Also used : ILanguage(org.metaborg.core.language.ILanguage) SyntaxFacet(org.metaborg.spoofax.core.syntax.SyntaxFacet) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) IdentificationFacet(org.metaborg.core.language.IdentificationFacet) FileObject(org.apache.commons.vfs2.FileObject) AnalysisFacet(org.metaborg.spoofax.core.analysis.AnalysisFacet) ILanguageComponent(org.metaborg.core.language.ILanguageComponent) StrategoRuntimeFacet(org.metaborg.spoofax.core.stratego.StrategoRuntimeFacet) Test(org.junit.Test) LanguageServiceTest(org.metaborg.core.test.language.LanguageServiceTest)

Example 15 with ILanguageImpl

use of org.metaborg.core.language.ILanguageImpl in project spoofax by metaborg.

the class GenerateSourcesBuilder method build.

@Override
public None build(GenerateSourcesBuilder.Input input) throws IOException {
    final File srcGenSigDir = toFile(paths.syntaxSrcGenSignatureDir());
    final File srcGenSyntaxDir = toFile(paths.syntaxSrcGenDir());
    final File srcGenSyntaxCompletionDir = toFile(paths.syntaxCompletionSrcGenDir());
    final File srcGenPpDir = toFile(paths.syntaxSrcGenPpDir());
    final File targetMetaborgDir = toFile(paths.targetMetaborgDir());
    // SDF
    @Nullable final Origin parenthesizeOrigin;
    @Nullable final Origin javaParenthesizeOrigin;
    @Nullable final Origin sigOrigin;
    if (input.sdfModule != null && input.sdfEnabled) {
        final String sdfModule = input.sdfModule;
        final File sdfFile = input.sdfFile;
        // new parse table generator
        if (input.sdf2tableVersion == Sdf2tableVersion.java || input.sdf2tableVersion == Sdf2tableVersion.dynamic || input.sdf2tableVersion == Sdf2tableVersion.incremental) {
            // Get JSGLR parse table from the normalized SDF aterm
            final boolean dynamicGeneration = (input.sdf2tableVersion == Sdf2tableVersion.dynamic || input.sdf2tableVersion == Sdf2tableVersion.incremental);
            final boolean dataDependent = input.dataDependent;
            final File srcNormDir = toFile(paths.syntaxNormDir());
            final File tableFile = FileUtils.getFile(targetMetaborgDir, "sdf.tbl");
            final File contextualGrammarFile = FileUtils.getFile(targetMetaborgDir, "ctxgrammar.aterm");
            final File persistedTableFile = FileUtils.getFile(targetMetaborgDir, "table.bin");
            final File sdfNormFile = FileUtils.getFile(srcNormDir, "permissive-norm.aterm");
            final List<String> paths = Lists.newLinkedList();
            paths.add(srcGenSyntaxDir.getAbsolutePath());
            for (LanguageIdentifier langId : input.sourceDeps) {
                ILanguageImpl lang = context.languageService().getImpl(langId);
                for (final ILanguageComponent component : lang.components()) {
                    ILanguageComponentConfig config = component.config();
                    Collection<IExportConfig> exports = config.exports();
                    for (IExportConfig exportConfig : exports) {
                        exportConfig.accept(new IExportVisitor() {

                            @Override
                            public void visit(LangDirExport export) {
                                if (export.language.equals(SpoofaxConstants.LANG_ATERM_NAME)) {
                                    try {
                                        paths.add(toFileReplicate(component.location().resolveFile(export.directory)).getAbsolutePath());
                                    } catch (FileSystemException e) {
                                        System.out.println("Failed to locate path");
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void visit(LangFileExport export) {
                            // Ignore file exports
                            }

                            @Override
                            public void visit(ResourceExport export) {
                            // Ignore resource exports
                            }
                        });
                    }
                }
            }
            final Origin sdf2TableJavaOrigin = Sdf2Table.origin(new Sdf2Table.Input(context, sdfNormFile, tableFile, persistedTableFile, contextualGrammarFile, paths, dynamicGeneration, dataDependent));
            requireBuild(sdf2TableJavaOrigin);
            // New parenthesizer
            final File parenthesizerFile = FileUtils.getFile(srcGenPpDir, sdfModule + "-parenthesize.str");
            javaParenthesizeOrigin = Sdf2Parenthesize.origin(new Sdf2Parenthesize.Input(context, persistedTableFile, parenthesizerFile, sdfModule));
            parenthesizeOrigin = null;
            sigOrigin = null;
        } else {
            // Get the SDF def file, either from existing external def, or by running pack SDF on the grammar
            // specification.
            @Nullable final File packSdfFile;
            @Nullable final Origin packSdfOrigin;
            if (input.sdfExternalDef != null) {
                packSdfFile = input.sdfExternalDef;
                packSdfOrigin = null;
            } else if (sdfFile != null) {
                require(sdfFile, FileExistsStamper.instance);
                if (!sdfFile.exists()) {
                    throw new IOException("Main SDF file at " + sdfFile + " does not exist");
                }
                packSdfFile = FileUtils.getFile(srcGenSyntaxDir, sdfModule + ".def");
                packSdfOrigin = PackSdf.origin(new PackSdf.Input(context, sdfModule, sdfFile, packSdfFile, input.packSdfIncludePaths, input.packSdfArgs, null));
            } else {
                packSdfFile = null;
                packSdfOrigin = null;
            }
            if (packSdfFile != null) {
                // file.
                if (input.sdfExternalDef != null || input.sdfVersion == SdfVersion.sdf2) {
                    final File rtgFile = FileUtils.getFile(srcGenSigDir, sdfModule + ".rtg");
                    final Origin rtgOrigin = Sdf2Rtg.origin(new Sdf2Rtg.Input(context, packSdfFile, rtgFile, sdfModule, packSdfOrigin));
                    final File sigFile = FileUtils.getFile(srcGenSigDir, sdfModule + ".str");
                    final String sigModule = "signatures/" + sdfModule;
                    sigOrigin = Rtg2Sig.origin(new Rtg2Sig.Input(context, rtgFile, sigFile, sigModule, rtgOrigin));
                } else {
                    sigOrigin = null;
                }
                // Get Stratego parenthesizer file, from the SDF def file.
                final File parenthesizeFile = FileUtils.getFile(srcGenPpDir, sdfModule + "-parenthesize.str");
                final String parenthesizeModule = "pp/" + sdfModule + "-parenthesize";
                parenthesizeOrigin = Sdf2ParenthesizeLegacy.origin(new Sdf2ParenthesizeLegacy.Input(context, packSdfFile, parenthesizeFile, sdfModule, parenthesizeModule, packSdfOrigin));
                // Get SDF permissive def file, from the SDF def file.
                final File permissiveDefFile = FileUtils.getFile(srcGenSyntaxDir, sdfModule + "-permissive.def");
                final Origin permissiveDefOrigin = MakePermissive.origin(new MakePermissive.Input(context, packSdfFile, permissiveDefFile, sdfModule, packSdfOrigin));
                // Get JSGLR parse table, from the SDF permissive def file.
                final File tableFile = FileUtils.getFile(targetMetaborgDir, "sdf.tbl");
                final Origin sdf2TableOrigin = Sdf2TableLegacy.origin(new Sdf2TableLegacy.Input(context, permissiveDefFile, tableFile, sdfModule, permissiveDefOrigin));
                requireBuild(sdf2TableOrigin);
                javaParenthesizeOrigin = null;
            } else {
                javaParenthesizeOrigin = null;
                parenthesizeOrigin = null;
                sigOrigin = null;
            }
        }
    } else {
        javaParenthesizeOrigin = null;
        parenthesizeOrigin = null;
        sigOrigin = null;
    }
    // SDF completions
    final Origin sdfCompletionOrigin;
    if (input.sdfCompletionFile != null && input.sdfEnabled) {
        final String sdfCompletionsModule = input.sdfCompletionModule;
        final File sdfCompletionsFile = input.sdfCompletionFile;
        if (input.sdf2tableVersion == Sdf2tableVersion.java || input.sdf2tableVersion == Sdf2tableVersion.dynamic || input.sdf2tableVersion == Sdf2tableVersion.incremental) {
            // Get JSGLR parse table, from the normalized SDF aterm
            final boolean dynamicGeneration = (input.sdf2tableVersion == Sdf2tableVersion.dynamic || input.sdf2tableVersion == Sdf2tableVersion.incremental);
            final boolean dataDependent = input.dataDependent;
            final List<String> paths = Lists.newLinkedList();
            paths.add(srcGenSyntaxDir.getAbsolutePath());
            for (LanguageIdentifier langId : input.sourceDeps) {
                ILanguageImpl lang = context.languageService().getImpl(langId);
                for (final ILanguageComponent component : lang.components()) {
                    ILanguageComponentConfig config = component.config();
                    Collection<IExportConfig> exports = config.exports();
                    for (IExportConfig exportConfig : exports) {
                        exportConfig.accept(new IExportVisitor() {

                            @Override
                            public void visit(LangDirExport export) {
                                if (export.language.equals(SpoofaxConstants.LANG_ATERM_NAME)) {
                                    try {
                                        paths.add(toFileReplicate(component.location().resolveFile(export.directory)).getAbsolutePath());
                                    } catch (FileSystemException e) {
                                        System.out.println("Failed to locate path");
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void visit(LangFileExport export) {
                            // Ignore file exports
                            }

                            @Override
                            public void visit(ResourceExport export) {
                            // Ignore resource exports
                            }
                        });
                    }
                }
            }
            final File tableFile = FileUtils.getFile(targetMetaborgDir, "sdf-completions.tbl");
            sdfCompletionOrigin = Sdf2Table.origin(new Sdf2Table.Input(context, sdfCompletionsFile, tableFile, null, null, paths, dynamicGeneration, dataDependent));
            requireBuild(sdfCompletionOrigin);
        } else {
            // Get the SDF def file, either from existing external def, or by running pack SDF on the grammar
            // specification.
            @Nullable final File packSdfCompletionsFile;
            @Nullable final Origin packSdfCompletionsOrigin;
            if (sdfCompletionsFile != null) {
                require(sdfCompletionsFile, FileExistsStamper.instance);
                if (!sdfCompletionsFile.exists()) {
                    throw new IOException("Main SDF completions file at " + sdfCompletionsFile + " does not exist");
                }
                packSdfCompletionsFile = FileUtils.getFile(srcGenSyntaxCompletionDir, sdfCompletionsModule + ".def");
                packSdfCompletionsOrigin = PackSdf.origin(new PackSdf.Input(context, sdfCompletionsModule, sdfCompletionsFile, packSdfCompletionsFile, input.packSdfIncludePaths, input.packSdfArgs, null));
            } else {
                packSdfCompletionsFile = null;
                packSdfCompletionsOrigin = null;
            }
            if (packSdfCompletionsFile != null) {
                // Get SDF permissive def file, from the SDF def file.
                final File permissiveCompletionsDefFile = FileUtils.getFile(srcGenSyntaxCompletionDir, sdfCompletionsModule + "-permissive.def");
                final Origin permissiveCompletionsDefOrigin = MakePermissive.origin(new MakePermissive.Input(context, packSdfCompletionsFile, permissiveCompletionsDefFile, sdfCompletionsModule, packSdfCompletionsOrigin));
                // Get JSGLR parse table, from the SDF permissive def file.
                final File completionsTableFile = FileUtils.getFile(targetMetaborgDir, "sdf-completions.tbl");
                sdfCompletionOrigin = Sdf2TableLegacy.origin(new Sdf2TableLegacy.Input(context, permissiveCompletionsDefFile, completionsTableFile, "completion/" + sdfCompletionsModule, permissiveCompletionsDefOrigin));
                requireBuild(sdfCompletionOrigin);
            } else {
                sdfCompletionOrigin = null;
            }
        }
    } else {
        sdfCompletionOrigin = null;
    }
    // SDF meta-module for creating a Stratego concrete syntax extension parse table
    final File sdfMetaFile = input.sdfMetaFile;
    final Origin sdfMetaOrigin;
    if (sdfMetaFile != null) {
        require(sdfMetaFile, FileExistsStamper.instance);
        if (!sdfMetaFile.exists()) {
            throw new IOException("Main meta-SDF file at " + sdfMetaFile + " does not exist");
        }
        final String sdfMetaModule = input.sdfMetaModule;
        final BuildRequest<PrepareNativeBundle.Input, OutputTransient<PrepareNativeBundle.Output>, PrepareNativeBundle, SpoofaxBuilderFactory<PrepareNativeBundle.Input, OutputTransient<PrepareNativeBundle.Output>, PrepareNativeBundle>> nativeBundleRequest = PrepareNativeBundle.request(new PrepareNativeBundle.Input(context));
        final File strategoMixFile = requireBuild(nativeBundleRequest).val().strategoMixFile;
        final Origin strategoMixOrigin = Origin.from(nativeBundleRequest);
        final Arguments packSdfMetaArgs = new Arguments(input.packSdfArgs);
        packSdfMetaArgs.addFile("-Idef", strategoMixFile);
        final File packSdfFile = FileUtils.getFile(srcGenSyntaxDir, sdfMetaModule + ".def");
        final Origin packSdfOrigin = PackSdf.origin(new PackSdf.Input(context, sdfMetaModule, sdfMetaFile, packSdfFile, input.packSdfIncludePaths, packSdfMetaArgs, strategoMixOrigin));
        final File permissiveDefFile = FileUtils.getFile(srcGenSyntaxDir, sdfMetaModule + "-permissive.def");
        final Origin permissiveDefOrigin = MakePermissive.origin(new MakePermissive.Input(context, packSdfFile, permissiveDefFile, sdfMetaModule, packSdfOrigin));
        final File transDir = toFile(paths.transDir());
        final File tableFile = FileUtils.getFile(transDir, sdfMetaModule + ".tbl");
        sdfMetaOrigin = Sdf2TableLegacy.origin(new Sdf2TableLegacy.Input(context, permissiveDefFile, tableFile, sdfMetaModule, permissiveDefOrigin));
        requireBuild(sdfMetaOrigin);
    } else {
        sdfMetaOrigin = null;
    }
    // Stratego
    final File strFile = input.strFile;
    if (strFile != null) {
        require(strFile, FileExistsStamper.instance);
        if (!strFile.exists()) {
            throw new IOException("Main Stratego file at " + strFile + " does not exist");
        }
        boolean buildStrJavaStrat = input.strJavaStratPackage != null && input.strJavaStratFile != null;
        if (buildStrJavaStrat) {
            require(input.strJavaStratFile, FileExistsStamper.instance);
            if (!input.strJavaStratFile.exists()) {
                throw new IOException("Main Stratego Java strategies file at " + input.strJavaStratFile + " does not exist");
            }
        }
        final Arguments extraArgs = new Arguments();
        extraArgs.addAll(input.strjArgs);
        final File outputFile;
        final File depPath;
        if (input.strFormat == StrategoFormat.ctree) {
            outputFile = FileUtils.getFile(targetMetaborgDir, "stratego.ctree");
            depPath = outputFile;
            extraArgs.add("-F");
        } else {
            depPath = toFile(paths.strSrcGenJavaTransDir(input.languageId));
            outputFile = FileUtils.getFile(depPath, "Main.java");
            extraArgs.add("-la", "java-front");
            if (buildStrJavaStrat) {
                extraArgs.add("-la", input.strJavaStratPackage);
            }
        }
        if (input.strExternalJarFlags != null) {
            extraArgs.addLine(input.strExternalJarFlags);
        }
        // @formatter:off
        final Origin origin;
        if (input.sdf2tableVersion == Sdf2tableVersion.java || input.sdf2tableVersion == Sdf2tableVersion.dynamic) {
            origin = Origin.Builder().add(sigOrigin).add(sdfCompletionOrigin).add(sdfMetaOrigin).add(javaParenthesizeOrigin).get();
        } else {
            origin = Origin.Builder().add(parenthesizeOrigin).add(sigOrigin).add(sdfCompletionOrigin).add(sdfMetaOrigin).get();
        }
        // @formatter:on
        final File cacheDir = toFile(paths.strCacheDir());
        final Strj.Input strjInput = new Strj.Input(context, strFile, outputFile, depPath, input.strJavaPackage, true, true, input.strjIncludeDirs, input.strjIncludeFiles, Lists.newArrayList(), cacheDir, extraArgs, origin);
        final Origin strjOrigin = Strj.origin(strjInput);
        requireBuild(strjOrigin);
        // Typesmart
        final File typesmartExportedFile = toFile(paths.strTypesmartExportedFile());
        final Typesmart.Input typesmartInput = new Typesmart.Input(context, input.strFile, input.strjIncludeDirs, typesmartExportedFile, origin);
        final Origin typesmartOrigin = Typesmart.origin(typesmartInput);
        requireBuild(typesmartOrigin);
    }
    return None.val;
}
Also used : Origin(build.pluto.dependency.Origin) MakePermissive(org.metaborg.spoofax.meta.core.pluto.build.MakePermissive) OutputTransient(build.pluto.output.OutputTransient) IExportConfig(org.metaborg.core.config.IExportConfig) Sdf2Table(org.metaborg.spoofax.meta.core.pluto.build.Sdf2Table) FileSystemException(org.apache.commons.vfs2.FileSystemException) SpoofaxInput(org.metaborg.spoofax.meta.core.pluto.SpoofaxInput) Typesmart(org.metaborg.spoofax.meta.core.pluto.build.Typesmart) IExportVisitor(org.metaborg.core.config.IExportVisitor) LangDirExport(org.metaborg.core.config.LangDirExport) Sdf2Rtg(org.metaborg.spoofax.meta.core.pluto.build.Sdf2Rtg) Strj(org.metaborg.spoofax.meta.core.pluto.build.Strj) ILanguageComponentConfig(org.metaborg.core.config.ILanguageComponentConfig) LangFileExport(org.metaborg.core.config.LangFileExport) PackSdf(org.metaborg.spoofax.meta.core.pluto.build.PackSdf) PrepareNativeBundle(org.metaborg.spoofax.meta.core.pluto.build.misc.PrepareNativeBundle) Arguments(org.metaborg.util.cmd.Arguments) IOException(java.io.IOException) LanguageIdentifier(org.metaborg.core.language.LanguageIdentifier) ILanguageImpl(org.metaborg.core.language.ILanguageImpl) ResourceExport(org.metaborg.core.config.ResourceExport) Sdf2TableLegacy(org.metaborg.spoofax.meta.core.pluto.build.Sdf2TableLegacy) SpoofaxBuilderFactory(org.metaborg.spoofax.meta.core.pluto.SpoofaxBuilderFactory) ILanguageComponent(org.metaborg.core.language.ILanguageComponent) File(java.io.File) Nullable(javax.annotation.Nullable)

Aggregations

ILanguageImpl (org.metaborg.core.language.ILanguageImpl)53 FileObject (org.apache.commons.vfs2.FileObject)32 ILanguageComponent (org.metaborg.core.language.ILanguageComponent)24 MetaborgException (org.metaborg.core.MetaborgException)17 IStrategoTerm (org.spoofax.interpreter.terms.IStrategoTerm)15 ILanguage (org.metaborg.core.language.ILanguage)14 HybridInterpreter (org.strategoxt.HybridInterpreter)13 LanguageIdentifier (org.metaborg.core.language.LanguageIdentifier)11 ITermFactory (org.spoofax.interpreter.terms.ITermFactory)11 Test (org.junit.Test)10 IContext (org.metaborg.core.context.IContext)10 LanguageVersion (org.metaborg.core.language.LanguageVersion)10 MetaborgRuntimeException (org.metaborg.core.MetaborgRuntimeException)9 MetaborgTest (org.metaborg.core.test.MetaborgTest)9 IStrategoString (org.spoofax.interpreter.terms.IStrategoString)9 IProject (org.metaborg.core.project.IProject)8 Nullable (javax.annotation.Nullable)6 ISpoofaxParseUnit (org.metaborg.spoofax.core.unit.ISpoofaxParseUnit)6 IdentifiedResource (org.metaborg.core.language.IdentifiedResource)5 ISourceRegion (org.metaborg.core.source.ISourceRegion)5