本文整理汇总了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);
}
示例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);
}