| /** |
| * |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * 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: |
| * Florian Pirchner - Initial implementation |
| * |
| * This copyright notice shows up in the generated Java code |
| * |
| */ |
| package org.eclipse.osbp.xtext.oxtype.scoping |
| |
| import com.google.inject.Inject |
| import javax.xml.stream.events.EntityReference |
| import org.eclipse.emf.ecore.EClass |
| import org.eclipse.emf.ecore.EObject |
| import org.eclipse.emf.ecore.EReference |
| import org.eclipse.osbp.xtext.oxtype.scoping.eobject.OXEObjectImportSectionNamespaceScopeProvider |
| import org.eclipse.osbp.xtext.oxtype.scoping.jvmtype.OXJvmTypesImportSectionNamespaceScopeProvider |
| import org.eclipse.xtext.common.types.TypesPackage |
| import org.eclipse.xtext.scoping.IScopeProvider |
| import org.eclipse.xtext.scoping.impl.IScopeWrapper |
| |
| /** |
| * Delegates between JvmTypeScoping and EObjectScoping. |
| */ |
| class OXDelegatingNamespaceScopeProvider implements IScopeProvider { |
| |
| @Inject |
| OXJvmTypesImportSectionNamespaceScopeProvider jvmTypesDelegate; |
| |
| @Inject |
| OXEObjectImportSectionNamespaceScopeProvider eObjectDelegate; |
| |
| override getScope(EObject context, EReference reference) { |
| val EClass referenceType = reference.getEReferenceType(); |
| if (TypesPackage.Literals.JVM_TYPE.isSuperTypeOf(referenceType)) { |
| return jvmTypesDelegate.getScope(context, reference) |
| }else{ |
| return eObjectDelegate.getScope(context, reference) |
| } |
| } |
| |
| def void setWrapper(IScopeWrapper wrapper, EReference reference){ |
| val EClass referenceType = reference.getEReferenceType(); |
| if (TypesPackage.Literals.JVM_TYPE.isSuperTypeOf(referenceType)) { |
| jvmTypesDelegate.wrapper = wrapper |
| }else{ |
| eObjectDelegate.wrapper = wrapper |
| } |
| } |
| |
| } |