Search in sources :

Example 1 with VersionNumberDescriptor

use of org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor in project n4js by eclipse.

the class SemverConverter method simplifyHyphenRange.

private static List<SimpleVersion> simplifyHyphenRange(HyphenVersionRange hvr) {
    VersionNumberDescriptor vndFrom = SemverUtils.getVersionNumberDescriptor(hvr.getFrom());
    VersionNumberDescriptor vndTo = SemverUtils.getVersionNumberDescriptor(hvr.getTo());
    VersionComparator toComparator = VersionComparator.SMALLER_EQUALS;
    if (vndTo.minor == null || vndTo.patch == null) {
        toComparator = VersionComparator.SMALLER;
    }
    return packRange(vndFrom, VersionComparator.GREATER_EQUALS, vndTo, toComparator);
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionComparator(org.eclipse.n4js.semver.Semver.VersionComparator)

Example 2 with VersionNumberDescriptor

use of org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor in project n4js by eclipse.

the class SemverConverter method simplifyTilde.

private static List<SimpleVersion> simplifyTilde(SimpleVersion sv) {
    VersionNumber caretVN = sv.getNumber();
    VersionNumberDescriptor vnd = SemverUtils.getVersionNumberDescriptor(caretVN);
    VersionNumberDescriptor vndTildeUpper = vnd.getTildeUpperBound();
    return packRange(vnd, VersionComparator.GREATER_EQUALS, vndTildeUpper, VersionComparator.SMALLER);
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 3 with VersionNumberDescriptor

use of org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor in project n4js by eclipse.

the class SemverConverter method simplifySpecific.

private static List<SimpleVersion> simplifySpecific(SimpleVersion sv) {
    if (sv == null || sv.getNumber() == null) {
        return Collections.emptyList();
    }
    VersionNumber vn = sv.getNumber();
    if (vn.getMajor().isWildcard()) {
        VersionNumberDescriptor vnDescr = new VersionNumberDescriptor(0, 0, 0, null, null);
        return pack(vnDescr, VersionComparator.GREATER_EQUALS);
    }
    int major = vn.getMajor().getNumber();
    if (vn.getMinor() == null || vn.getMinor().isWildcard()) {
        VersionNumberDescriptor fromVND = new VersionNumberDescriptor(major, 0, 0, null, null);
        VersionNumberDescriptor toVND = new VersionNumberDescriptor(major + 1, 0, 0, null, null);
        return packRange(fromVND, VersionComparator.GREATER_EQUALS, toVND, VersionComparator.SMALLER);
    }
    int minor = vn.getMinor().getNumber();
    if (vn.getPatch() == null || vn.getPatch().isWildcard()) {
        VersionNumberDescriptor fromVND = new VersionNumberDescriptor(major, minor, 0, null, null);
        VersionNumberDescriptor toVND = new VersionNumberDescriptor(major, minor + 1, 0, null, null);
        return packRange(fromVND, VersionComparator.GREATER_EQUALS, toVND, VersionComparator.SMALLER);
    }
    VersionNumberDescriptor vnDescriptor = SemverUtils.getVersionNumberDescriptor(vn);
    return packRange(vnDescriptor, vnDescriptor);
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber) VersionRangeConstraint(org.eclipse.n4js.semver.Semver.VersionRangeConstraint)

Example 4 with VersionNumberDescriptor

use of org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor in project n4js by eclipse.

the class SemverConverter method copyAndPack.

private static List<SimpleVersion> copyAndPack(SimpleVersion sv) {
    VersionNumberDescriptor verDescr = SemverUtils.getVersionNumberDescriptor(sv.getNumber());
    EList<VersionComparator> vComps = sv.getComparators();
    return pack(verDescr, vComps.toArray(new VersionComparator[vComps.size()]));
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionComparator(org.eclipse.n4js.semver.Semver.VersionComparator)

Example 5 with VersionNumberDescriptor

use of org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor in project n4js by eclipse.

the class SemverConverter method simplifyCaret.

private static List<SimpleVersion> simplifyCaret(SimpleVersion sv) {
    VersionNumber caretVN = sv.getNumber();
    VersionNumberDescriptor vnd = SemverUtils.getVersionNumberDescriptor(caretVN);
    VersionNumberDescriptor vndCaretUpper = vnd.getCaretUpperBound();
    return packRange(vnd, VersionComparator.GREATER_EQUALS, vndCaretUpper, VersionComparator.SMALLER);
}
Also used : VersionNumberDescriptor(org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Aggregations

VersionNumberDescriptor (org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor)5 VersionNumber (org.eclipse.n4js.semver.Semver.VersionNumber)3 VersionComparator (org.eclipse.n4js.semver.Semver.VersionComparator)2 VersionRangeConstraint (org.eclipse.n4js.semver.Semver.VersionRangeConstraint)1