use of org.metaborg.core.config.IProjectConfig in project spoofax by metaborg.
the class DefaultDependencyService method checkDependencies.
@Override
public MissingDependencies checkDependencies(IProject project) {
final IProjectConfig config = project.config();
final Collection<LanguageIdentifier> compileDeps = config.compileDeps();
final Collection<LanguageIdentifier> missingCompile = Lists.newLinkedList();
for (LanguageIdentifier identifier : compileDeps) {
if (languageService.getComponent(identifier) == null) {
missingCompile.add(identifier);
}
}
final Collection<LanguageIdentifier> sourceDeps = config.sourceDeps();
final Collection<LanguageIdentifier> missingSource = Lists.newLinkedList();
for (LanguageIdentifier identifier : sourceDeps) {
if (languageService.getComponent(identifier) == null) {
missingSource.add(identifier);
}
}
return new MissingDependencies(missingCompile, missingSource);
}
use of org.metaborg.core.config.IProjectConfig in project spoofax by metaborg.
the class ConfigBasedProjectService method findProject.
private IProject findProject(FileObject resource) {
try {
FileObject dir = (resource.isFolder() ? resource : resource.getParent());
while (dir != null) {
FileName name = dir.getName();
if (projectConfigService.available(dir)) {
final ConfigRequest<? extends IProjectConfig> configRequest = projectConfigService.get(dir);
if (!configRequest.valid()) {
logger.error("Errors occurred when retrieving project configuration from project directory {}", dir);
configRequest.reportErrors(new StreamMessagePrinter(sourceTextService, false, false, logger));
}
final IProjectConfig config = configRequest.config();
if (config == null) {
logger.error("Could not retrieve project configuration from project directory {}", dir);
return null;
}
final IProject project = new Project(dir, config);
IProject prevProject;
if ((prevProject = projects.putIfAbsent(name, project)) != null) {
logger.warn("Project with location {} already exists", name);
return prevProject;
}
return project;
}
dir = dir.getParent();
}
} catch (FileSystemException e) {
logger.error("Error while searching for project configuration.", e);
}
logger.warn("No project configuration file was found for {}.", resource);
return null;
}
use of org.metaborg.core.config.IProjectConfig in project spoofax by metaborg.
the class SimpleProjectService method create.
@Override
public IProject create(FileObject location) throws MetaborgException {
final FileName name = location.getName();
for (FileName projectName : projects.keySet()) {
if (name.equals(projectName) || name.isAncestor(projectName)) {
final String message = String.format("Location %s is equal to or nested in project %s", name, projectName);
throw new MetaborgException(message);
}
}
final ConfigRequest<? extends IProjectConfig> configRequest = projectConfigService.get(location);
if (!configRequest.valid()) {
logger.error("Errors occurred when retrieving project configuration from project directory {}", location);
configRequest.reportErrors(new StreamMessagePrinter(sourceTextService, false, false, logger));
}
final IProjectConfig config;
if (configRequest.config() != null) {
config = configRequest.config();
} else {
logger.debug("Using default configuration for project at {}", location);
config = projectConfigService.defaultConfig(location);
}
final IProject project = new Project(location, config);
if (projects.putIfAbsent(name, project) != null) {
final String message = String.format("Project with location %s already exists", name);
throw new MetaborgException(message);
}
return project;
}
use of org.metaborg.core.config.IProjectConfig in project spoofax by metaborg.
the class SingleFileProjectService method get.
@Override
public IProject get(FileObject resource) {
FileObject rootFolder = resource;
try {
// project location should be a directory (otherwise building gave errors), so take parent dir (if possible)
if (resource.isFile()) {
rootFolder = resource.getParent();
}
} catch (FileSystemException e) {
// ignore
}
final IProjectConfig config = projectConfigService.defaultConfig(rootFolder);
return new Project(rootFolder, config);
}
Aggregations