Search in sources :

Example 1 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class JSONIdeContentProposalProvider method proposeVersions.

private void proposeVersions(ContentAssistContext context, IIdeContentProposalAcceptor acceptor, List<String> namePath) {
    if (namePath.size() >= 2) {
        // somewhat poor heuristic: propose all projects that are known in the current workspace
        String devOrDep = namePath.get(namePath.size() - 2);
        if (PackageJsonProperties.DEPENDENCIES.name.equals(devOrDep) || PackageJsonProperties.DEV_DEPENDENCIES.name.equals(devOrDep)) {
            NameValuePair pair = (NameValuePair) context.getCurrentModel();
            N4JSProjectConfigSnapshot project = workspaceAccess.findProjectByName(context.getResource(), pair.getName());
            if (project != null) {
                VersionNumber version = project.getVersion();
                ContentAssistEntry versionEntry = getProposalCreator().createProposal('"' + version.toString() + '"', context, ContentAssistEntry.KIND_VALUE, null);
                acceptor.accept(versionEntry, getProposalPriorities().getDefaultPriority(versionEntry));
            }
            ContentAssistEntry wildcard = getProposalCreator().createProposal("\"*\"", context, ContentAssistEntry.KIND_VALUE, null);
            acceptor.accept(wildcard, getProposalPriorities().getDefaultPriority(wildcard));
        }
    }
}
Also used : NameValuePair(org.eclipse.n4js.json.JSON.NameValuePair) ContentAssistEntry(org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry) N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 2 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class HyphenVersionRangeImpl method basicSetFrom.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetFrom(VersionNumber newFrom, NotificationChain msgs) {
    VersionNumber oldFrom = from;
    from = newFrom;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SemverPackage.HYPHEN_VERSION_RANGE__FROM, oldFrom, newFrom);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 3 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class SimpleVersionImpl method basicSetNumber.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetNumber(VersionNumber newNumber, NotificationChain msgs) {
    VersionNumber oldNumber = number;
    number = newNumber;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SemverPackage.SIMPLE_VERSION__NUMBER, oldNumber, newNumber);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 4 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber in project n4js by eclipse.

the class SemverSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == SemverPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case SemverPackage.GIT_HUB_VERSION_REQUIREMENT:
                sequence_GitHubVersionRequirement(context, (GitHubVersionRequirement) semanticObject);
                return;
            case SemverPackage.HYPHEN_VERSION_RANGE:
                sequence_HyphenVersionRange(context, (HyphenVersionRange) semanticObject);
                return;
            case SemverPackage.LOCAL_PATH_VERSION_REQUIREMENT:
                sequence_LocalPathVersionRequirement(context, (LocalPathVersionRequirement) semanticObject);
                return;
            case SemverPackage.QUALIFIER:
                sequence_Qualifier(context, (Qualifier) semanticObject);
                return;
            case SemverPackage.QUALIFIER_TAG:
                sequence_QualifierTag(context, (QualifierTag) semanticObject);
                return;
            case SemverPackage.SIMPLE_VERSION:
                sequence_SimpleVersion(context, (SimpleVersion) semanticObject);
                return;
            case SemverPackage.TAG_VERSION_REQUIREMENT:
                sequence_TagVersionRequirement(context, (TagVersionRequirement) semanticObject);
                return;
            case SemverPackage.URL_COMMIT_ISH:
                sequence_URLVersionSpecifier(context, (URLCommitISH) semanticObject);
                return;
            case SemverPackage.URL_SEMVER:
                sequence_URLSemver(context, (URLSemver) semanticObject);
                return;
            case SemverPackage.URL_VERSION_REQUIREMENT:
                sequence_URLVersionRequirement(context, (URLVersionRequirement) semanticObject);
                return;
            case SemverPackage.VERSION_NUMBER:
                sequence_VersionNumber(context, (VersionNumber) semanticObject);
                return;
            case SemverPackage.VERSION_PART:
                sequence_VersionPart(context, (VersionPart) semanticObject);
                return;
            case SemverPackage.VERSION_RANGE_CONSTRAINT:
                sequence_VersionRangeContraint(context, (VersionRangeConstraint) semanticObject);
                return;
            case SemverPackage.VERSION_RANGE_SET_REQUIREMENT:
                sequence_VersionRangeSetRequirement(context, (VersionRangeSetRequirement) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : URLSemver(org.eclipse.n4js.semver.Semver.URLSemver) ParserRule(org.eclipse.xtext.ParserRule) GitHubVersionRequirement(org.eclipse.n4js.semver.Semver.GitHubVersionRequirement) Action(org.eclipse.xtext.Action) URLCommitISH(org.eclipse.n4js.semver.Semver.URLCommitISH) QualifierTag(org.eclipse.n4js.semver.Semver.QualifierTag) VersionRangeSetRequirement(org.eclipse.n4js.semver.Semver.VersionRangeSetRequirement) URLVersionRequirement(org.eclipse.n4js.semver.Semver.URLVersionRequirement) TagVersionRequirement(org.eclipse.n4js.semver.Semver.TagVersionRequirement) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber) EPackage(org.eclipse.emf.ecore.EPackage) VersionPart(org.eclipse.n4js.semver.Semver.VersionPart) VersionRangeConstraint(org.eclipse.n4js.semver.Semver.VersionRangeConstraint) HyphenVersionRange(org.eclipse.n4js.semver.Semver.HyphenVersionRange) Parameter(org.eclipse.xtext.Parameter) Qualifier(org.eclipse.n4js.semver.Semver.Qualifier) SimpleVersion(org.eclipse.n4js.semver.Semver.SimpleVersion) LocalPathVersionRequirement(org.eclipse.n4js.semver.Semver.LocalPathVersionRequirement)

Example 5 with VersionNumber

use of org.eclipse.n4js.semver.Semver.VersionNumber 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)

Aggregations

VersionNumber (org.eclipse.n4js.semver.Semver.VersionNumber)19 SimpleVersion (org.eclipse.n4js.semver.Semver.SimpleVersion)4 VersionRangeConstraint (org.eclipse.n4js.semver.Semver.VersionRangeConstraint)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 VersionNumberDescriptor (org.eclipse.n4js.semver.SemverUtils.VersionNumberDescriptor)3 Qualifier (org.eclipse.n4js.semver.Semver.Qualifier)2 QualifierTag (org.eclipse.n4js.semver.Semver.QualifierTag)2 VersionPart (org.eclipse.n4js.semver.Semver.VersionPart)2 VersionRangeSetRequirement (org.eclipse.n4js.semver.Semver.VersionRangeSetRequirement)2 ArrayList (java.util.ArrayList)1 EPackage (org.eclipse.emf.ecore.EPackage)1 NameValuePair (org.eclipse.n4js.json.JSON.NameValuePair)1 ProjectDescription (org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)1 SourceContainerDescription (org.eclipse.n4js.packagejson.projectDescription.SourceContainerDescription)1 GitHubVersionRequirement (org.eclipse.n4js.semver.Semver.GitHubVersionRequirement)1 HyphenVersionRange (org.eclipse.n4js.semver.Semver.HyphenVersionRange)1 LocalPathVersionRequirement (org.eclipse.n4js.semver.Semver.LocalPathVersionRequirement)1 TagVersionRequirement (org.eclipse.n4js.semver.Semver.TagVersionRequirement)1 URLCommitISH (org.eclipse.n4js.semver.Semver.URLCommitISH)1 URLSemver (org.eclipse.n4js.semver.Semver.URLSemver)1