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