use of org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails in project ceylon by eclipse.
the class SmokeTestCase method testCompleteJDKWithPrefix.
@Test
public void testCompleteJDKWithPrefix() throws Exception {
Assume.assumeTrue(JDKUtils.jdk == JDKUtils.JDK.JDK8);
RepositoryManager manager = getJDKRepositoryManager();
ModuleDetails[] expected = new ModuleDetails[] { jdkModule("java.auth", "JDK module java.auth"), jdkModule("java.auth.kerberos", "JDK module java.auth.kerberos"), jdkModule("java.base", "JDK module java.base"), jdkModule("java.compiler", "JDK module java.compiler"), jdkModule("java.corba", "JDK module java.corba"), jdkModule("java.desktop", "JDK module java.desktop"), jdkModule("java.instrument", "JDK module java.instrument"), jdkModule("java.jdbc", "JDK module java.jdbc"), jdkModule("java.jdbc.rowset", "JDK module java.jdbc.rowset"), jdkModule("java.logging", "JDK module java.logging"), jdkModule("java.management", "JDK module java.management"), jdkModule("java.prefs", "JDK module java.prefs"), jdkModule("java.rmi", "JDK module java.rmi"), jdkModule("java.security.acl", "JDK module java.security.acl"), jdkModule("java.tls", "JDK module java.tls"), jdkModule("javafx.base", "JDK module javafx.base"), jdkModule("javafx.controls", "JDK module javafx.controls"), jdkModule("javafx.deploy", "JDK module javafx.deploy"), jdkModule("javafx.fxml", "JDK module javafx.fxml"), jdkModule("javafx.graphics", "JDK module javafx.graphics"), jdkModule("javafx.media", "JDK module javafx.media"), jdkModule("javafx.swing", "JDK module javafx.swing"), jdkModule("javafx.web", "JDK module javafx.web"), jdkModule("javax.annotation", "JDK module javax.annotation"), jdkModule("javax.jaxws", "JDK module javax.jaxws"), jdkModule("javax.naming", "JDK module javax.naming"), jdkModule("javax.script", "JDK module javax.script"), jdkModule("javax.transaction", "JDK module javax.transaction"), jdkModule("javax.xml", "JDK module javax.xml"), jdkModule("javax.xmldsig", "JDK module javax.xmldsig") };
testComplete("java", expected, manager);
expected = new ModuleDetails[] { jdkModule("javax.annotation", "JDK module javax.annotation"), jdkModule("javax.jaxws", "JDK module javax.jaxws"), jdkModule("javax.naming", "JDK module javax.naming"), jdkModule("javax.script", "JDK module javax.script"), jdkModule("javax.transaction", "JDK module javax.transaction"), jdkModule("javax.xml", "JDK module javax.xml"), jdkModule("javax.xmldsig", "JDK module javax.xmldsig") };
testComplete("javax", expected, manager);
}
use of org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails in project ceylon by eclipse.
the class SmokeTestCase method testCompleteOrgBinaryIncompatible.
@Test
public void testCompleteOrgBinaryIncompatible() throws Exception {
RepositoryManager manager = getRepositoryManager();
ModuleDetails[] expected = new ModuleDetails[] {};
testComplete("org", expected, manager, Type.JVM, 1234, 0, 1234, 0);
}
use of org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method searchModules.
@Override
public ModuleSearchResult searchModules(ModuleQuery query) {
if (!query.isPaging()) {
// that's pretty simple
ModuleSearchResult result = new ModuleSearchResult();
for (CmrRepository root : getRepositories()) {
if (query.getNamespace() == null || query.getNamespace().equals(root.getNamespace())) {
root.searchModules(query, result);
}
}
return result;
} else {
// we need to merge manually
List<CmrRepository> repos = getRepositories();
ModuleSearchResult[] results = new ModuleSearchResult[repos.size()];
// keep an overall module name ordering
SortedSet<String> names = new TreeSet<>();
int i = 0;
long[] pagingInfo = query.getPagingInfo();
if (pagingInfo != null) {
// check its length
if (pagingInfo.length != repos.size())
throw new IllegalArgumentException("Paging info is not the same size as roots, it must have come from a different RepositoryManager");
}
Long start = query.getStart();
for (CmrRepository root : repos) {
if (query.getNamespace() == null || query.getNamespace().equals(root.getNamespace())) {
ModuleSearchResult result = new ModuleSearchResult();
// adapt the start index if required
if (pagingInfo != null)
query.setStart(pagingInfo[i]);
root.searchModules(query, result);
results[i++] = result;
names.addAll(result.getModuleNames());
}
}
// restore the query start
query.setStart(start);
// now merge results
ModuleSearchResult result = new ModuleSearchResult();
long[] resultPagingInfo = new long[repos.size()];
// initialise it if we need to
if (pagingInfo != null)
System.arraycopy(pagingInfo, 0, resultPagingInfo, 0, resultPagingInfo.length);
result.setNextPagingInfo(resultPagingInfo);
i = 0;
for (String module : names) {
// stop if we exceeded the count
if (query.getCount() != null && i++ == query.getCount())
break;
// collect every module result for that name from the results
int repo = 0;
for (ModuleSearchResult resultPart : results) {
ModuleDetails details = resultPart.getResult(module);
// did we find anything in that repo?
if (details == null) {
repo++;
continue;
} else {
// count one result for this repo
resultPagingInfo[repo++]++;
}
// merge it
result.addResult(module, details);
}
}
// see if there are any records left in next pages
int repo = 0;
for (ModuleSearchResult resultPart : results) {
// if we had more results in the first place then we must have another page
if (resultPart.getHasMoreResults()) {
result.setHasMoreResults(true);
break;
}
// see how many results we added from this repo
long resultsAddedForThisRepo;
if (pagingInfo != null)
resultsAddedForThisRepo = resultPagingInfo[repo] - pagingInfo[repo];
else
resultsAddedForThisRepo = resultPagingInfo[repo];
// did we have more results than we put in?
if (resultPart.getCount() > resultsAddedForThisRepo) {
result.setHasMoreResults(true);
break;
}
repo++;
}
// record where we started (i is one greater than the number of modules added)
if (query.getStart() != null)
result.setStart(query.getStart());
else
result.setStart(0);
// all done
return result;
}
}
use of org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails in project ceylon by eclipse.
the class LegacyImporter method outputSuggestions.
private void outputSuggestions(String pkg) throws Exception {
ModuleDependencyInfo dep = null;
Set<ModuleDetails> suggestions = findSuggestions(pkg);
if (!suggestions.isEmpty()) {
dep = feedback.suggestions(pkg, suggestions);
if (dep != null) {
expectedDependencies.add(dep);
hasProblems = true;
}
}
}
use of org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails in project ceylon by eclipse.
the class CeylonInfoTool method run.
@Override
public void run() throws Exception {
if (showIncompatible != Incompatible.yes) {
if (queryType.includes(ArtifactContext.CAR)) {
jvmBinaryMajor = Versions.JVM_BINARY_MAJOR_VERSION;
jvmBinaryMinor = Versions.JVM_BINARY_MINOR_VERSION;
}
if (queryType.includes(ArtifactContext.JS)) {
jsBinaryMajor = Versions.JS_BINARY_MAJOR_VERSION;
jsBinaryMinor = Versions.JS_BINARY_MINOR_VERSION;
}
}
String msgkey = showIncompatible == Incompatible.no ? "module.not.found.compat" : "module.not.found";
for (ModuleSpec module : modules) {
String name = module.getName();
if (!module.isVersioned() && (name.startsWith("*") || name.endsWith("*"))) {
Collection<ModuleDetails> modules = getModules(getRepositoryManager(), module.getNamespace(), name, queryType, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
if (modules.isEmpty()) {
String err;
if (name.startsWith("*") || name.endsWith("*")) {
err = CeylonInfoMessages.msg("no.match", name);
} else {
err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
}
errorAppend(err);
errorNewline();
continue;
}
outputModules(module, modules);
} else {
Collection<ModuleVersionDetails> versions = getModuleVersions(getRepositoryManager(), module.getNamespace(), module.getName(), module.getVersion(), false, queryType, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
if (versions.isEmpty()) {
// try from source
ModuleVersionDetails fromSource = getModuleVersionDetailsFromSource(name);
if (fromSource != null) {
// is it the version we're after?
versions = Arrays.asList(fromSource);
} else {
if (showIncompatible == Incompatible.auto && (jvmBinaryMajor != null || jvmBinaryMinor != null || jsBinaryMajor != null || jsBinaryMinor != null)) {
// If we were called with a specific version and we didn't find a "compatible"
// artifact then lets see if we can find an "incompatible" one
versions = getModuleVersions(getRepositoryManager(), module.getNamespace(), module.getName(), module.getVersion(), false, queryType, null, null, null, null);
}
if (versions.isEmpty()) {
String err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
errorAppend(err);
errorNewline();
continue;
}
}
}
if (module.getVersion() == null || module.getVersion().isEmpty() || versions.size() > 1) {
outputVersions(module, versions);
} else {
outputDetails(module, versions.iterator().next());
}
}
}
}
Aggregations