本文整理匯總了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);
}