| /** |
| * Copyright (c) 2011 NumberFour AG |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * 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.IRTypeDeclaration; |
| import org.eclipse.dltk.javascript.typeinfo.ITypeSystem; |
| import org.eclipse.dltk.javascript.typeinfo.JSDocTypeParser; |
| import org.eclipse.dltk.javascript.typeinfo.RClassVariable; |
| import org.eclipse.dltk.javascript.typeinfo.RTypes; |
| import org.eclipse.dltk.javascript.typeinfo.model.JSType; |
| import org.eclipse.dltk.javascript.typeinfo.model.TypeInfoModelPackage; |
| import org.eclipse.dltk.javascript.typeinfo.model.TypeVariable; |
| import org.eclipse.dltk.javascript.typeinfo.model.TypeVariableClassType; |
| import org.eclipse.emf.common.notify.Notification; |
| 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>Type Variable Class Type</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.dltk.javascript.typeinfo.model.impl.TypeVariableClassTypeImpl#getVariable <em>Variable</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class TypeVariableClassTypeImpl extends MinimalEObjectImpl implements TypeVariableClassType { |
| /** |
| * The cached value of the '{@link #getVariable() <em>Variable</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getVariable() |
| * @generated |
| * @ordered |
| */ |
| protected TypeVariable variable; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TypeVariableClassTypeImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return TypeInfoModelPackage.Literals.TYPE_VARIABLE_CLASS_TYPE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TypeVariable getVariable() { |
| if (variable != null && variable.eIsProxy()) { |
| InternalEObject oldVariable = (InternalEObject)variable; |
| variable = (TypeVariable)eResolveProxy(oldVariable); |
| if (variable != oldVariable) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, TypeInfoModelPackage.TYPE_VARIABLE_CLASS_TYPE__VARIABLE, oldVariable, variable)); |
| } |
| } |
| return variable; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TypeVariable basicGetVariable() { |
| return variable; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setVariable(TypeVariable newVariable) { |
| TypeVariable oldVariable = variable; |
| variable = newVariable; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, TypeInfoModelPackage.TYPE_VARIABLE_CLASS_TYPE__VARIABLE, oldVariable, variable)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public String getName() { |
| return variable != null ? JSDocTypeParser.CLASS + "<" |
| + variable.getName() + ">" : JSDocTypeParser.CLASS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public IRType toRType(ITypeSystem typeSystem) { |
| if (variable != null) { |
| if (typeSystem != null) { |
| final IRType value = typeSystem.getTypeVariable(variable); |
| if (value != null) { |
| return RTypes.classOf(value); |
| } |
| final JSType bound = variable.getBound(); |
| if (bound != null) { |
| return RTypes.classOf(RTypes.create(typeSystem, bound)); |
| } |
| } |
| return new RClassVariable(variable); |
| } |
| return RTypes.classType((IRTypeDeclaration) null); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case TypeInfoModelPackage.TYPE_VARIABLE_CLASS_TYPE__VARIABLE: |
| if (resolve) return getVariable(); |
| return basicGetVariable(); |
| } |
| 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.TYPE_VARIABLE_CLASS_TYPE__VARIABLE: |
| setVariable((TypeVariable)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.TYPE_VARIABLE_CLASS_TYPE__VARIABLE: |
| setVariable((TypeVariable)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.TYPE_VARIABLE_CLASS_TYPE__VARIABLE: |
| return variable != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } //TypeVariableClassTypeImpl |