Search in sources :

Example 6 with PropertyNameKind

use of org.eclipse.n4js.n4JS.PropertyNameKind in project n4js by eclipse.

the class LiteralOrComputedPropertyNameImpl method setKind.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setKind(PropertyNameKind newKind) {
    PropertyNameKind oldKind = kind;
    kind = newKind == null ? KIND_EDEFAULT : newKind;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.LITERAL_OR_COMPUTED_PROPERTY_NAME__KIND, oldKind, kind));
}
Also used : PropertyNameKind(org.eclipse.n4js.n4JS.PropertyNameKind) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 7 with PropertyNameKind

use of org.eclipse.n4js.n4JS.PropertyNameKind in project n4js by eclipse.

the class PrettyPrinterSwitch method processPropertyName.

private void processPropertyName(PropertyNameOwner owner) {
    final LiteralOrComputedPropertyName name = owner.getDeclaredName();
    final PropertyNameKind kind = name.getKind();
    if (kind == PropertyNameKind.COMPUTED) {
        // computed property names:
        write('[');
        process(name.getExpression());
        write(']');
    } else {
        // all other cases than computed property names: IDENTIFIER, STRING, NUMBER
        final String propName = name.getName();
        if (propName.startsWith(N4JSLanguageUtils.SYMBOL_IDENTIFIER_PREFIX)) {
            // we have a name like "#iterator" that represents a Symbol --> emit as: "[Symbol.iterator]"
            // (note: we have to do this special handling here in the pretty printer because there is, at the
            // moment, no way to represent a property assignment with a Symbol as name other than using a name
            // starting with the SYMBOL_IDENTIFIER_PREFIX)
            write("[Symbol.");
            write(propName.substring(1));
            write(']');
        } else {
            // standard case:
            writeQuotedIfNonIdentifier(propName);
        }
    }
}
Also used : PropertyNameKind(org.eclipse.n4js.n4JS.PropertyNameKind) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Example 8 with PropertyNameKind

use of org.eclipse.n4js.n4JS.PropertyNameKind in project n4js by eclipse.

the class N4MethodDeclarationImpl method isValidName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean isValidName() {
    String _name = this.getName();
    boolean _equals = Objects.equal("prototype", _name);
    if (_equals) {
        return false;
    }
    boolean _and = false;
    if (!(Objects.equal("constructor", this.getName()) && this.isGenerator())) {
        _and = false;
    } else {
        LiteralOrComputedPropertyName _declaredName = this.getDeclaredName();
        PropertyNameKind _kind = null;
        if (_declaredName != null) {
            _kind = _declaredName.getKind();
        }
        boolean _tripleNotEquals = (_kind != PropertyNameKind.COMPUTED);
        _and = _tripleNotEquals;
    }
    if (_and) {
        return false;
    }
    return true;
}
Also used : PropertyNameKind(org.eclipse.n4js.n4JS.PropertyNameKind) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Aggregations

PropertyNameKind (org.eclipse.n4js.n4JS.PropertyNameKind)8 LiteralOrComputedPropertyName (org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1