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


Java IContext.location方法代码示例

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


在下文中一共展示了IContext.location方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 FileObject location = context.location();
    final IProject project = projectService.get(location);
    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 name for " + location, e);
    }
    if(languageSpec == null) {
        return null;
    }

    return factory.makeString(languageSpec.config().prettyPrintLanguage());
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:31,代码来源:LanguageSpecPpNamePrimitive.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 FileObject location = context.location();
    final IProject project = projectService.get(location);
    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.debug("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 name for " + location, e);
    }
    if(languageSpec == null) {
        return null;
    }

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

示例3: call

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

    final String path = Tools.asJavaString(current);
    final FileObject resource = resourceService.resolve(path);

    FileObject base = context.location();
    final IProject project = projectService.get(context.location());
    if(project != null) {
        // GTODO: require language identifier instead of language name
        final String languageName = Tools.asJavaString(tvars[0]);
        final Iterable<FileObject> sourceLocations = languagePathService.sourceAndIncludePaths(project, languageName);
        for(FileObject sourceLocation : sourceLocations) {
            if(sourceLocation.getName().isDescendent(resource.getName())) {
                base = sourceLocation;
                break;
            }
        }
    }

    final String relativePath = ResourceUtils.relativeName(resource.getName(), base.getName(), true);
    return factory.makeString(relativePath);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:30,代码来源:RelativeSourceOrIncludePath.java

示例4: call

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

    final String path = Tools.asJavaString(current);
    final FileObject resource = resourceService.resolve(path);

    FileObject base = context.location();
    final IProject project = projectService.get(context.location());
    if(project != null) {
        // GTODO: require language identifier instead of language name
        final String languageName = Tools.asJavaString(tvars[0]);
        final Iterable<FileObject> sourceLocations = languagePathService.sourcePaths(project, languageName);
        for(FileObject sourceLocation : sourceLocations) {
            if(sourceLocation.getName().isDescendent(resource.getName())) {
                base = sourceLocation;
                break;
            }
        }
    }

    final String relativePath = ResourceUtils.relativeName(resource.getName(), base.getName(), true);
    return factory.makeString(relativePath);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:30,代码来源:RelativeSourcePath.java


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