Search in sources :

Example 1 with ScopeContext

use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext in project dsl-devkit by dsldevkit.

the class ScopeLabelProvider method text.

/**
 * Return label text for an ScopeRule.
 *
 * @param rule
 *          The ScopeRule.
 * @return The label text.
 */
@SuppressWarnings("nls")
public String text(final ScopeRule rule) {
    StringBuffer res = new StringBuffer();
    final ScopeContext context = rule.getContext();
    if (context.isGlobal()) {
        res.append("* ");
    } else {
        res.append(context.getContextType().getName());
        res.append(' ');
    }
    if (context.getGuard() != null) {
        String guard = serializer.serialize(context.getGuard());
        // NOPMD
        guard = guard.length() > MAX_GUARD_LABEL_LENGTH ? guard.substring(0, MAX_GUARD_LABEL_LENGTH) + "..." : guard;
        res.append('[').append(guard).append("] ");
    }
    return res.toString();
}
Also used : ScopeContext(com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext)

Example 2 with ScopeContext

use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext in project dsl-devkit by dsldevkit.

the class ScopeJavaValidator method checkGuardDefaultExists.

/**
 * Checks that a guarded scope rule is matched by a unguarded default scope rule.
 *
 * @param context
 *          scope rule to check
 */
@Check
public void checkGuardDefaultExists(final ScopeRule context) {
    if (context.getContext() == null || context.getContext().getGuard() == null) {
        return;
    }
    ScopeDefinition def = EObjectUtil.eContainer(context, ScopeDefinition.class);
    ScopeContext ctx = context.getContext();
    boolean defaultFound = false;
    for (ScopeRule r : def.getRules()) {
        ScopeContext c = r.getContext();
        if (c != null && c.getGuard() == null && c.getContextType() == ctx.getContextType()) {
            defaultFound = true;
            break;
        }
    }
    if (!defaultFound) {
        warning("No matching default scope rule defined", ScopePackage.Literals.SCOPE_RULE__CONTEXT);
    }
}
Also used : ScopeDefinition(com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition) ScopeContext(com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext) ScopeRule(com.avaloq.tools.ddk.xtext.scope.scope.ScopeRule) Check(org.eclipse.xtext.validation.Check)

Example 3 with ScopeContext

use of com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext in project dsl-devkit by dsldevkit.

the class ScopeRuleImpl method basicSetContext.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetContext(ScopeContext newContext, NotificationChain msgs) {
    ScopeContext oldContext = context;
    context = newContext;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ScopePackage.SCOPE_RULE__CONTEXT, oldContext, newContext);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ScopeContext(com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

ScopeContext (com.avaloq.tools.ddk.xtext.scope.scope.ScopeContext)3 ScopeDefinition (com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition)1 ScopeRule (com.avaloq.tools.ddk.xtext.scope.scope.ScopeRule)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Check (org.eclipse.xtext.validation.Check)1