Search in sources :

Example 21 with Backends

use of org.eclipse.ceylon.common.Backends in project ceylon by eclipse.

the class Overrides method applyOverrides.

public ModuleInfo applyOverrides(String module, String version, ModuleInfo source) {
    ArtifactOverrides artifactOverrides = getArtifactOverrides(new ArtifactContext(null, module, version));
    Set<ModuleDependencyInfo> result = new HashSet<ModuleDependencyInfo>();
    for (ModuleDependencyInfo dep : source.getDependencies()) {
        String depNamespace = dep.getNamespace();
        String depName = dep.getName();
        String depVersion = dep.getVersion();
        boolean optional = dep.isOptional();
        boolean export = dep.isExport();
        ModuleScope scope = dep.getModuleScope();
        Backends backends = dep.getNativeBackends();
        ArtifactContext ctx = new ArtifactContext(depNamespace, depName, depVersion);
        if ((artifactOverrides != null && artifactOverrides.isRemoved(ctx)) || isRemoved(ctx))
            continue;
        if (artifactOverrides != null && artifactOverrides.isAddedOrUpdated(ctx))
            continue;
        ArtifactContext replacement = replace(ctx);
        if (replacement != null) {
            depNamespace = replacement.getNamespace();
            depName = replacement.getName();
            depVersion = replacement.getVersion();
            ctx = replacement;
        }
        if (isVersionOverridden(ctx))
            depVersion = getVersionOverride(ctx);
        if (artifactOverrides != null) {
            if (artifactOverrides.isShareOverridden(ctx))
                export = artifactOverrides.isShared(ctx);
            if (artifactOverrides.isOptionalOverridden(ctx))
                optional = artifactOverrides.isOptional(ctx);
        }
        result.add(new ModuleDependencyInfo(depNamespace, depName, depVersion, optional, export, backends, scope));
    }
    String filter = source.getFilter();
    if (artifactOverrides != null) {
        if (artifactOverrides.getFilter() != null)
            filter = artifactOverrides.getFilter();
        for (DependencyOverride add : artifactOverrides.getAdd()) {
            ArtifactContext addContext = add.getArtifactContext();
            result.add(new ModuleDependencyInfo(addContext.getNamespace(), addContext.getName(), addContext.getVersion(), add.isOptional(), add.isShared()));
        }
    }
    return new ModuleInfo(source.getNamespace(), module, version, source.getGroupId(), source.getArtifactId(), source.getClassifier(), filter, result);
}
Also used : Backends(org.eclipse.ceylon.common.Backends) ModuleScope(org.eclipse.ceylon.model.cmr.ModuleScope) HashSet(java.util.HashSet)

Aggregations

Backends (org.eclipse.ceylon.common.Backends)21 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)7 Module (org.eclipse.ceylon.model.typechecker.model.Module)7 HashSet (java.util.HashSet)6 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)6 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)6 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)5 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)4 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)3 AnalyzerUtil.getPackageTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration)3 AnalyzerUtil.getTypeDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration)3 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)3 ModelUtil.getNativeDeclaration (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getNativeDeclaration)3 Unit (org.eclipse.ceylon.model.typechecker.model.Unit)3 ModuleInfo (org.eclipse.ceylon.cmr.api.ModuleInfo)2 Backend (org.eclipse.ceylon.common.Backend)2 AnalyzerUtil.getPackageTypedDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypedDeclaration)2