use of org.eclipse.ceylon.cmr.spi.Node in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method getLeafNode.
protected Node getLeafNode(ArtifactContext context) {
final Node node = getFromAllRoots(context, true);
if (node == null) {
if (context.isThrowErrorIfMissing())
throw new IllegalArgumentException("No such artifact: " + context);
return null;
}
// save the context info
context.toNode(node);
return node;
}
use of org.eclipse.ceylon.cmr.spi.Node in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method fromRepositories.
/**
* Cache is only used for remote repos; see issue #47.
*/
private Node fromRepositories(Iterable<CmrRepository> repositories, ArtifactContext context, boolean addLeaf) {
log.debug("Looking for " + context);
for (CmrRepository repository : repositories) {
log.debug(" Looking in " + repository);
if (!repository.supportsNamespace(context.getNamespace())) {
log.debug(" -> does not support namespace " + context.getNamespace());
continue;
}
Node child = fromRepository(repository, context, addLeaf);
if (child != null) {
log.debug(" -> Found");
return child;
}
log.debug(" -> Not Found");
}
log.debug(" -> Artifact " + context + " not found in any repository");
return null;
}
use of org.eclipse.ceylon.cmr.spi.Node in project ceylon by eclipse.
the class AbstractOpenNode method getChildren.
@Override
public Iterable<? extends Node> getChildren() {
if (!children.containsKey(NODE_MARKER)) {
// add marker
children.put(NODE_MARKER, new MarkerNode());
ConcurrentMap<String, OpenNode> tmp = new ConcurrentHashMap<>();
for (OpenNode on : findService(StructureBuilder.class).find(this)) put(tmp, on.getLabel(), on);
children.putAll(tmp);
return tmp.values();
} else {
List<Node> nodes = new ArrayList<>();
for (Node on : children.values()) {
if (on instanceof MarkerNode == false)
nodes.add(on);
}
return nodes;
}
}
use of org.eclipse.ceylon.cmr.spi.Node in project ceylon by eclipse.
the class AbstractRepository method getBestInfoArtifact.
private Node getBestInfoArtifact(Node versionNode) {
String moduleName = toModuleName(NodeUtils.firstParent(versionNode));
String version = versionNode.getLabel();
String artifactName = getArtifactName(moduleName, version, ArtifactContext.CAR);
Node artifact = versionNode.getChild(artifactName);
if (artifact == null) {
artifactName = getArtifactName(moduleName, version, ArtifactContext.NPM_DESCRIPTOR);
artifact = versionNode.getChild(artifactName);
if (artifact == null) {
artifactName = getArtifactName(moduleName, version, ArtifactContext.JS);
artifact = versionNode.getChild(artifactName);
if (artifact == null) {
artifactName = getArtifactName(moduleName, version, ArtifactContext.JAR);
artifact = versionNode.getChild(artifactName);
}
}
}
return artifact;
}
use of org.eclipse.ceylon.cmr.spi.Node in project ceylon by eclipse.
the class AbstractRepository method matchesSearch.
private boolean matchesSearch(String name, Node artifact, Node versionNode, ModuleQuery query) {
// match on the module name first
Node moduleNode = NodeUtils.firstParent(versionNode);
// can't happen but hey
if (moduleNode == null)
return false;
String moduleName = toModuleName(moduleNode);
if (moduleName.toLowerCase().contains(query.getName()))
return true;
// now search on the metadata
Node infoArtifact = getBestInfoArtifact(versionNode);
return matchFromCar(infoArtifact, moduleName, versionNode.getLabel(), query.getName());
}
Aggregations