Search in sources :

Example 1 with VersionConstraint

use of org.eclipse.osgi.service.resolver.VersionConstraint in project rt.equinox.framework by eclipse.

the class ResolverBundle method hasUnresolvedConstraint.

private boolean hasUnresolvedConstraint(ResolverConstraint reason, ResolverBundle detachedFragment, ResolverBundle remainingFragment, ResolverImport[] oldImports, BundleConstraint[] oldRequires, List<ResolverImport> additionalImports, List<BundleConstraint> additionalRequires) {
    ImportPackageSpecification[] remainingFragImports = remainingFragment.getBundleDescription().getImportPackages();
    BundleSpecification[] remainingFragRequires = remainingFragment.getBundleDescription().getRequiredBundles();
    VersionConstraint[] constraints;
    if (reason instanceof ResolverImport)
        constraints = remainingFragImports;
    else
        constraints = remainingFragRequires;
    for (int i = 0; i < constraints.length; i++) if (reason.getName().equals(constraints[i].getName())) {
        detachFragment(remainingFragment, reason);
        return true;
    }
    for (int i = 0; i < oldImports.length; i++) {
        if (oldImports[i].getVersionConstraint().getBundle() != detachedFragment.getBundleDescription())
            // the constraint is not from the detached fragment
            continue;
        for (int j = 0; j < remainingFragImports.length; j++) {
            if (oldImports[i].getName().equals(remainingFragImports[j].getName())) {
                // same constraint, must reuse the constraint object but swap out the fragment info
                additionalImports.add(oldImports[i]);
                oldImports[i].setVersionConstraint(remainingFragImports[j]);
                break;
            }
        }
    }
    for (int i = 0; i < oldRequires.length; i++) {
        if (oldRequires[i].getVersionConstraint().getBundle() != detachedFragment.getBundleDescription())
            // the constraint is not from the detached fragment
            continue;
        for (int j = 0; j < remainingFragRequires.length; j++) {
            if (oldRequires[i].getName().equals(remainingFragRequires[j].getName())) {
                // same constraint, must reuse the constraint object but swap out the fragment info
                additionalRequires.add(oldRequires[i]);
                oldRequires[i].setVersionConstraint(remainingFragRequires[j]);
                break;
            }
        }
    }
    return false;
}
Also used : VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint) ImportPackageSpecification(org.eclipse.osgi.service.resolver.ImportPackageSpecification) BundleSpecification(org.eclipse.osgi.service.resolver.BundleSpecification) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Example 2 with VersionConstraint

use of org.eclipse.osgi.service.resolver.VersionConstraint in project tycho by eclipse.

the class Activator method getRelevantErrors.

private static void getRelevantErrors(State state, Set<ResolverError> errors, BundleDescription bundle) {
    ResolverError[] bundleErrors = state.getResolverErrors(bundle);
    for (int j = 0; j < bundleErrors.length; j++) {
        ResolverError error = bundleErrors[j];
        errors.add(error);
        VersionConstraint constraint = error.getUnsatisfiedConstraint();
        if (constraint instanceof BundleSpecification || constraint instanceof HostSpecification) {
            BundleDescription[] requiredBundles = state.getBundles(constraint.getName());
            for (int i = 0; i < requiredBundles.length; i++) {
                getRelevantErrors(state, errors, requiredBundles[i]);
            }
        }
    }
}
Also used : VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint) HostSpecification(org.eclipse.osgi.service.resolver.HostSpecification) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError) BundleSpecification(org.eclipse.osgi.service.resolver.BundleSpecification) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Example 3 with VersionConstraint

use of org.eclipse.osgi.service.resolver.VersionConstraint in project tycho by eclipse.

the class EquinoxResolver method getRelevantErrors.

private void getRelevantErrors(State state, Set<ResolverError> errors, BundleDescription bundle) {
    ResolverError[] bundleErrors = state.getResolverErrors(bundle);
    for (int j = 0; j < bundleErrors.length; j++) {
        ResolverError error = bundleErrors[j];
        errors.add(error);
        VersionConstraint constraint = error.getUnsatisfiedConstraint();
        if (constraint instanceof BundleSpecification || constraint instanceof HostSpecification) {
            BundleDescription[] requiredBundles = state.getBundles(constraint.getName());
            for (int i = 0; i < requiredBundles.length; i++) {
                // do not handle that bundle (again). See bug 442594.
                if (bundle.equals(requiredBundles[i])) {
                    continue;
                }
                getRelevantErrors(state, errors, requiredBundles[i]);
            }
        }
    }
}
Also used : VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint) HostSpecification(org.eclipse.osgi.service.resolver.HostSpecification) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError) BundleSpecification(org.eclipse.osgi.service.resolver.BundleSpecification) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Aggregations

BundleSpecification (org.eclipse.osgi.service.resolver.BundleSpecification)3 VersionConstraint (org.eclipse.osgi.service.resolver.VersionConstraint)3 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)2 HostSpecification (org.eclipse.osgi.service.resolver.HostSpecification)2 ResolverError (org.eclipse.osgi.service.resolver.ResolverError)2 ImportPackageSpecification (org.eclipse.osgi.service.resolver.ImportPackageSpecification)1