当前位置: 首页>>代码示例>>Java>>正文


Java IContext.project方法代码示例

本文整理汇总了Java中org.metaborg.core.context.IContext.project方法的典型用法代码示例。如果您正苦于以下问题:Java IContext.project方法的具体用法?Java IContext.project怎么用?Java IContext.project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.metaborg.core.context.IContext的用法示例。


在下文中一共展示了IContext.project方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import org.metaborg.core.context.IContext; //导入方法依赖的package包/类
@Override protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars,
        ITermFactory factory, IContext context) throws MetaborgException {
    final IProject project = context.project();
    if(project == null) {
        return null;
    }
    final CommonPaths paths = new CommonPaths(project.location());

    if(languageSpecServiceProvider == null) {
        // Indicates that meta-Spoofax is not available (ISpoofaxLanguageSpecService cannot be injected), but this
        // should never happen because this primitive is inside meta-Spoofax. Check for null just in case.
        logger.error("Language specification service is not available; static injection failed");
        return null;
    }

    if(!Tools.isTermString(current)) {
        throw new MetaborgException("Expect a string as argument term, got " + current);
    }
    String name = Tools.asJavaString(current);

    final String srcGenDir;
    try {
        srcGenDir = ResourceUtils.relativeName(paths.srcGenDir().resolveFile(name).getName(),
                project.location().getName(), true);
    } catch(FileSystemException e) {
        return null;
    }

    return factory.makeString(srcGenDir);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:31,代码来源:LanguageSpecSrcGenDirectory.java

示例2: call

import org.metaborg.core.context.IContext; //导入方法依赖的package包/类
@Override protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars,
    ITermFactory factory, IContext context) throws MetaborgException {
    final IProject project = context.project();
    if(project == null) {
        return null;
    }

    if(languageSpecServiceProvider == null) {
        // Indicates that meta-Spoofax is not available (ISpoofaxLanguageSpecService cannot be injected), but this
        // should never happen because this primitive is inside meta-Spoofax. Check for null just in case.
        logger.error("Language specification service is not available; static injection failed");
        return null;
    }
    final ISpoofaxLanguageSpecService languageSpecService = languageSpecServiceProvider.get();
    if(!languageSpecService.available(project)) {
        return null;
    }
    final ISpoofaxLanguageSpec languageSpec;
    try {
        languageSpec = languageSpecService.get(project);
    } catch(ConfigException e) {
        throw new MetaborgException("Unable to get language specification configuration for " + project, e);
    }
    if(languageSpec == null) {
        return null;
    }

    final IStrategoString nameTerm = factory.makeString(languageSpec.config().name());
    final LanguageIdentifier id = languageSpec.config().identifier();
    final IStrategoString groupIdTerm = factory.makeString(id.groupId);
    final IStrategoString idTerm = factory.makeString(id.id);
    final IStrategoString versionTerm = factory.makeString(id.version.toString());
    final IStrategoString locationTerm = factory.makeString(languageSpec.location().getName().getURI());
    return factory.makeTuple(nameTerm, groupIdTerm, idTerm, versionTerm, locationTerm);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:36,代码来源:LanguageSpecificationPrimitive.java


注:本文中的org.metaborg.core.context.IContext.project方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。