| /** |
| * 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.ITypeSystem; |
| import org.eclipse.dltk.javascript.typeinfo.JSDocTypeParser; |
| import org.eclipse.dltk.javascript.typeinfo.RTypes; |
| import org.eclipse.dltk.javascript.typeinfo.model.ClassType; |
| import org.eclipse.dltk.javascript.typeinfo.model.Type; |
| import org.eclipse.dltk.javascript.typeinfo.model.TypeInfoModelPackage; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.util.URI; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| 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>Class Type</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.dltk.javascript.typeinfo.model.impl.ClassTypeImpl#getTarget <em>Target</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class ClassTypeImpl extends MinimalEObjectImpl implements ClassType { |
| /** |
| * The cached value of the '{@link #getTarget() <em>Target</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTarget() |
| * @generated |
| * @ordered |
| */ |
| protected Type target; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ClassTypeImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return TypeInfoModelPackage.Literals.CLASS_TYPE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Type getTarget() { |
| if (target != null && target.eIsProxy()) { |
| InternalEObject oldTarget = (InternalEObject)target; |
| target = (Type)eResolveProxy(oldTarget); |
| if (target != oldTarget) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, TypeInfoModelPackage.CLASS_TYPE__TARGET, oldTarget, target)); |
| } |
| } |
| return target; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Type basicGetTarget() { |
| return target; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTarget(Type newTarget) { |
| Type oldTarget = target; |
| target = newTarget; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, TypeInfoModelPackage.CLASS_TYPE__TARGET, oldTarget, target)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public String getRawName() { |
| if (target != null) { |
| if (((EObject) target).eIsProxy()) { |
| final URI uri = ((InternalEObject) target).eProxyURI(); |
| if (uri != null) { |
| return URI.decode(uri.fragment()); |
| } |
| } else { |
| return target.getName(); |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public String getName() { |
| final String rawName = getRawName(); |
| return rawName != null ? JSDocTypeParser.CLASS + "<" + rawName + ">" |
| : JSDocTypeParser.CLASS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| public IRType toRType(ITypeSystem typeSystem) { |
| Type t = getTarget(); |
| if (t != null && t.isProxy() && typeSystem != null) { |
| t = typeSystem.resolveType(t); |
| } |
| return RTypes.classType(typeSystem, t); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case TypeInfoModelPackage.CLASS_TYPE__TARGET: |
| if (resolve) return getTarget(); |
| return basicGetTarget(); |
| } |
| 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.CLASS_TYPE__TARGET: |
| setTarget((Type)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.CLASS_TYPE__TARGET: |
| setTarget((Type)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case TypeInfoModelPackage.CLASS_TYPE__TARGET: |
| return target != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } //ClassTypeImpl |