當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。