use of org.metaborg.core.language.IComponentCreationConfigRequest in project spoofax by metaborg.
the class LanguageComponentFactory method createConfigs.
@Override
public Collection<ComponentCreationConfig> createConfigs(Iterable<IComponentCreationConfigRequest> requests) throws MetaborgException {
final List<ComponentCreationConfig> configs = Lists.newArrayList();
for (IComponentCreationConfigRequest request : requests) {
final ComponentCreationConfig config = createConfig(request);
configs.add(config);
}
return configs;
}
use of org.metaborg.core.language.IComponentCreationConfigRequest in project spoofax by metaborg.
the class LanguageDiscoveryService method scanComponentsInDirectory.
@Override
public Set<ILanguageComponent> scanComponentsInDirectory(FileObject directory) throws MetaborgException {
final Collection<IComponentCreationConfigRequest> requests = componentFactory.requestAllInDirectory(directory);
final Collection<ComponentCreationConfig> configs = componentFactory.createConfigs(requests);
final Set<ILanguageComponent> components = Sets.newHashSet();
for (ComponentCreationConfig config : configs) {
final ILanguageComponent component = languageService.add(config);
components.add(component);
}
return components;
}
use of org.metaborg.core.language.IComponentCreationConfigRequest in project spoofax by metaborg.
the class LanguageComponentFactory method requestAllInDirectory.
@Override
public Collection<IComponentCreationConfigRequest> requestAllInDirectory(FileObject directory) throws MetaborgException {
final Set<IComponentCreationConfigRequest> requests = Sets.newHashSet();
try {
if (!directory.exists()) {
throw new MetaborgException("Cannot scan directory " + directory + ", it does not exist");
}
if (!directory.isFolder()) {
throw new MetaborgException("Cannot scan " + directory + ", it is not a directory");
}
final Iterable<FileObject> files = ResourceUtils.find(directory, new LanguageFileScanSelector());
for (FileObject file : files) {
final IComponentCreationConfigRequest request;
if (file.isFolder()) {
request = requestFromDirectory(file);
} else {
request = requestFromArchive(file);
}
requests.add(request);
}
} catch (FileSystemException e) {
throw new MetaborgException("Cannot scan " + directory + ", unexpected I/O error", e);
}
return requests;
}
use of org.metaborg.core.language.IComponentCreationConfigRequest in project spoofax by metaborg.
the class LanguageDiscoveryService method request.
@Deprecated
@Override
public Iterable<ILanguageDiscoveryRequest> request(FileObject location) throws MetaborgException {
final Collection<ILanguageDiscoveryRequest> requests = Lists.newLinkedList();
final FileObject[] configFiles;
try {
configFiles = location.findFiles(new FileSelector() {
@Override
public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception {
final String baseName = fileInfo.getFile().getName().getBaseName();
return !baseName.equals("bin") && !baseName.equals("target");
}
@Override
public boolean includeFile(FileSelectInfo fileInfo) throws Exception {
return fileInfo.getFile().getName().getBaseName().equals(MetaborgConstants.FILE_COMPONENT_CONFIG);
}
});
} catch (FileSystemException e) {
throw new MetaborgException("Searching for language components failed unexpectedly", e);
}
if (configFiles == null || configFiles.length == 0) {
return requests;
}
for (FileObject configFile : configFiles) {
try {
final FileObject directory = configFile.getParent().getParent();
final IComponentCreationConfigRequest request = componentFactory.requestFromDirectory(directory);
requests.add(request);
} catch (FileSystemException e) {
logger.error("Could not resolve parent directory of config file {}, skipping", e, configFile);
continue;
}
}
return requests;
}
Aggregations