use of org.metaborg.core.build.CommonPaths in project spoofax by metaborg.
the class LanguageSpecSrcGenDirectory method call.
@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);
}
Aggregations