Search in sources :

Example 1 with NamingSection

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

the class ScopingGeneratorUtil method isCaseInsensitive.

/**
 * Determine whether a certain scope expression is case sensitive or not.
 *
 * @param expr
 *          The scope expression.
 * @return true, if the expression is case insensitive; false otherwise.
 */
public static boolean isCaseInsensitive(final NamedScopeExpression expr) {
    Casing casing = null;
    if (expr.isCaseDef()) {
        casing = expr.getCasing();
    } else {
        NamingSection naming = EObjectUtil.eContainer(expr, ScopeModel.class).getNaming();
        casing = naming != null ? naming.getCasing() : Casing.SENSITIVE;
    }
    return casing == Casing.INSENSITIVE;
}
Also used : ScopeModel(com.avaloq.tools.ddk.xtext.scope.scope.ScopeModel) Casing(com.avaloq.tools.ddk.xtext.scope.scope.Casing) NamingSection(com.avaloq.tools.ddk.xtext.scope.scope.NamingSection)

Example 2 with NamingSection

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

the class ScopeModelImpl method basicSetNaming.

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

Example 3 with NamingSection

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

the class ScopeJavaValidator method checkNameFunctionExists.

/**
 * Verifies that a matching default name function exists for scope expressions without explicit name functions.
 *
 * @param expr
 *          scope expression to check
 */
@Check
public void checkNameFunctionExists(final SimpleScopeExpression expr) {
    if (expr.getNaming() != null && !expr.getNaming().getNames().isEmpty()) {
        return;
    }
    ScopeDefinition def = EObjectUtil.eContainer(expr, ScopeDefinition.class);
    ScopeModel model = EObjectUtil.eContainer(expr, ScopeModel.class);
    if (def != null && model != null) {
        EClass scopeType = getType(def);
        NamingSection namingSection = model.getNaming();
        if (namingSection != null) {
            for (NamingDefinition naming : namingSection.getNamings()) {
                if (naming.getType() != null && isLeftMostSuperType(naming.getType(), scopeType)) {
                    return;
                }
            }
        }
        error(NLS.bind(Messages.missingNameFunction, scopeType.getName()), ScopePackage.Literals.SIMPLE_SCOPE_EXPRESSION__EXPR);
    }
}
Also used : ScopeDefinition(com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition) EClass(org.eclipse.emf.ecore.EClass) ScopeModel(com.avaloq.tools.ddk.xtext.scope.scope.ScopeModel) NamingSection(com.avaloq.tools.ddk.xtext.scope.scope.NamingSection) NamingDefinition(com.avaloq.tools.ddk.xtext.scope.scope.NamingDefinition) Check(org.eclipse.xtext.validation.Check)

Aggregations

NamingSection (com.avaloq.tools.ddk.xtext.scope.scope.NamingSection)3 ScopeModel (com.avaloq.tools.ddk.xtext.scope.scope.ScopeModel)2 Casing (com.avaloq.tools.ddk.xtext.scope.scope.Casing)1 NamingDefinition (com.avaloq.tools.ddk.xtext.scope.scope.NamingDefinition)1 ScopeDefinition (com.avaloq.tools.ddk.xtext.scope.scope.ScopeDefinition)1 EClass (org.eclipse.emf.ecore.EClass)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Check (org.eclipse.xtext.validation.Check)1