blob: e27ebb428f9ce7804c0f5f7e46b20cb9971ee72f [file] [log] [blame]
/**
* Copyright (c) 2011 NumberFour AG
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* NumberFour AG - initial API and Implementation (Alex Panchenko)
*/
package org.eclipse.dltk.javascript.typeinfo.model.impl;
import org.eclipse.dltk.javascript.typeinfo.IRType;
import org.eclipse.dltk.javascript.typeinfo.ITypeNames;
import org.eclipse.dltk.javascript.typeinfo.ITypeSystem;
import org.eclipse.dltk.javascript.typeinfo.RTypes;
import org.eclipse.dltk.javascript.typeinfo.model.ArrayType;
import org.eclipse.dltk.javascript.typeinfo.model.JSType;
import org.eclipse.dltk.javascript.typeinfo.model.TypeInfoModelPackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Array Type</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.dltk.javascript.typeinfo.model.impl.ArrayTypeImpl#getItemType <em>Item Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ArrayTypeImpl extends MinimalEObjectImpl implements ArrayType {
/**
* The cached value of the '{@link #getItemType() <em>Item Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getItemType()
* @generated
* @ordered
*/
protected JSType itemType;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ArrayTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return TypeInfoModelPackage.Literals.ARRAY_TYPE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public JSType getItemType() {
return itemType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetItemType(JSType newItemType, NotificationChain msgs) {
JSType oldItemType = itemType;
itemType = newItemType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE, oldItemType, newItemType);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setItemType(JSType newItemType) {
if (newItemType != itemType) {
NotificationChain msgs = null;
if (itemType != null)
msgs = ((InternalEObject)itemType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE, null, msgs);
if (newItemType != null)
msgs = ((InternalEObject)newItemType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE, null, msgs);
msgs = basicSetItemType(newItemType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE, newItemType, newItemType));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public String getName() {
return itemType != null ? ITypeNames.ARRAY + '<' + itemType.getName()
+ '>' : ITypeNames.ARRAY;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public IRType toRType(ITypeSystem typeSystem) {
return RTypes.arrayOf(typeSystem,
RTypes.create(typeSystem, itemType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE:
return basicSetItemType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE:
return getItemType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE:
setItemType((JSType)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE:
setItemType((JSType)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case TypeInfoModelPackage.ARRAY_TYPE__ITEM_TYPE:
return itemType != null;
}
return super.eIsSet(featureID);
}
@Override
public String toString() {
return getName();
}
} //ArrayTypeImpl