Search in sources :

Example 26 with ModuleDependencyInfo

use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo 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;
        }
    }
}
Also used : ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo) ModuleDetails(org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)

Example 27 with ModuleDependencyInfo

use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.

the class AbstractCeylonArtifactResult method getOrderedDependencies.

/**
 * {@code ModuleInfo} has dependencies as a {@code Set} (actually a
 * {@code HashSet}), but {@link #dependencies()} needs to return a list.
 * The order matter much except when several dependencies can't be found.
 * That happens, in particular, when trying to run a module compiled with a
 * more recent (but still BC) version of Ceylon. So for consistency
 * on that case we will already return ceylon.language first.
 */
private List<ModuleDependencyInfo> getOrderedDependencies(ModuleInfo infos) {
    List<ModuleDependencyInfo> dependencies = new ArrayList<ModuleDependencyInfo>(infos.getDependencies());
    for (int index = 0; index < dependencies.size(); index++) {
        ModuleDependencyInfo dep = dependencies.get(index);
        if ("ceylon.language".equals(dep.getName())) {
            if (index != 0) {
                dependencies.remove(index);
                dependencies.add(0, dep);
            }
            break;
        }
    }
    return dependencies;
}
Also used : ArrayList(java.util.ArrayList) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)

Example 28 with ModuleDependencyInfo

use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.

the class JSUtils method getModuleInfo.

private ModuleInfo getModuleInfo(Object obj, String moduleName, String version, Overrides overrides) {
    if (obj == null) {
        return new ModuleInfo(null, moduleName, version, null, null, null, null, Collections.<ModuleDependencyInfo>emptySet());
    }
    if (!(obj instanceof Iterable)) {
        throw new RuntimeException("Expected something Iterable");
    }
    @SuppressWarnings("unchecked") Iterable<Object> array = (Iterable<Object>) obj;
    Set<ModuleDependencyInfo> deps = new HashSet<ModuleDependencyInfo>();
    for (Object o : array) {
        String module;
        boolean optional = false;
        boolean exported = false;
        if (o instanceof String) {
            module = asString(o);
        } else {
            @SuppressWarnings("unchecked") Map<String, Object> m = (Map<String, Object>) o;
            module = m.get("path").toString();
            optional = m.containsKey("opt");
            exported = m.containsKey("exp");
        }
        String depUri = ModuleUtil.moduleName(module);
        String namespace = ModuleUtil.getNamespaceFromUri(depUri);
        String modName = ModuleUtil.getModuleNameFromUri(depUri);
        deps.add(new ModuleDependencyInfo(namespace, modName, ModuleUtil.moduleVersion(module), optional, exported, Backends.JS));
    }
    ModuleInfo result = new ModuleInfo(null, moduleName, version, null, null, null, null, deps);
    if (overrides != null)
        result = overrides.applyOverrides(moduleName, version, result);
    return result;
}
Also used : ModuleInfo(org.eclipse.ceylon.cmr.api.ModuleInfo) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo) Map(java.util.Map) HashSet(java.util.HashSet)

Example 29 with ModuleDependencyInfo

use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.

the class CeylonInfoTool method outputVersions.

private void outputVersions(String namespace, String moduleName, Collection<ModuleVersionDetails> versions, String prefix) throws IOException {
    String namePrefix = (formatting == Formatting.fancy) ? prefix + "    " : "";
    for (ModuleVersionDetails version : versions) {
        if (formatting == Formatting.fancy || (!showDependencies && !showNames)) {
            append(prefix);
            if (formatting == Formatting.simple) {
                if (namespace != null) {
                    append(namespace).append(":");
                }
                append(moduleName).append("/");
            }
            append(version.getVersion());
            if (formatting == Formatting.fancy) {
                append(" - ").append(version.getOrigin());
                if (hasOnlyIncompatibleBinaries(version)) {
                    append(" ");
                    msg("label.incompatible.version");
                }
                if (version.isRemote()) {
                    append(" ");
                    msg("label.remote");
                }
            }
            newline();
        }
        if (showDependencies) {
            if (formatting == Formatting.fancy || !version.getDependencies().isEmpty()) {
                for (ModuleDependencyInfo dep : version.getDependencies()) {
                    if (dep.getModuleScope() == ModuleScope.TEST)
                        continue;
                    if (formatting == Formatting.fancy) {
                        append(prefix).append("    ").append(dep);
                    } else {
                        if (namespace != null) {
                            append(namespace).append(":");
                        }
                        append(moduleName).append("/").append(version.getVersion()).append(" ").append(dep.getModuleName());
                    }
                    newline();
                }
            } else {
                if (namespace != null) {
                    append(namespace).append(":");
                }
                append(moduleName).append("/").append(version.getVersion()).newline();
            }
        }
        if (showNames) {
            outputNames(namespace, moduleName, version, namePrefix);
        }
    }
}
Also used : ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)

Aggregations

ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)29 ModuleInfo (org.eclipse.ceylon.cmr.api.ModuleInfo)12 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)10 HashSet (java.util.HashSet)9 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ModuleVersionArtifact (org.eclipse.ceylon.cmr.api.ModuleVersionArtifact)5 IOException (java.io.IOException)3 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)3 Backends (org.eclipse.ceylon.common.Backends)3 Annotation (org.eclipse.ceylon.langtools.classfile.Annotation)3 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)3 File (java.io.File)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 Properties (java.util.Properties)2 TreeSet (java.util.TreeSet)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 DependencyDescriptor (org.eclipse.ceylon.cmr.resolver.aether.DependencyDescriptor)2 ClassFile (org.eclipse.ceylon.langtools.classfile.ClassFile)2