| /******************************************************************************* |
| * Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others. |
| * 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 |
| *******************************************************************************/ |
| package org.eclipse.osbp.xtext.oxtype.imports; |
| |
| import org.eclipse.emf.ecore.EClassifier; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.EReference; |
| import org.eclipse.xtext.common.types.JvmType; |
| import org.eclipse.xtext.common.types.TypesPackage; |
| import org.eclipse.xtext.naming.QualifiedName; |
| import org.eclipse.xtext.util.ITextRegion; |
| |
| public class EObjectJvmLinkUsage { |
| |
| private EObjectUsage parent; |
| private String crossRefString; |
| private ITextRegion textRegion; |
| private EObject context; |
| private JvmType resolvedJvmType; |
| |
| public EObjectJvmLinkUsage(EObjectUsage parent, String crossRefString, |
| ITextRegion textRegion, EObject context) { |
| this.parent = parent; |
| this.crossRefString = crossRefString; |
| this.textRegion = textRegion; |
| this.context = context; |
| } |
| |
| public EObjectJvmLinkUsage(EObjectUsage parent, JvmType jvmType, |
| ITextRegion textRegion, EObject context) { |
| this.parent = parent; |
| this.resolvedJvmType = jvmType; |
| this.textRegion = textRegion; |
| this.context = context; |
| } |
| |
| public EObjectUsage getParent() { |
| return parent; |
| } |
| |
| public JvmType getUsedType() { |
| return resolvedJvmType; |
| } |
| |
| public String getCrossReferenceString() { |
| return crossRefString; |
| } |
| |
| /** |
| * Only works, if parent {@link EObjectUsage} was resolved properly. |
| * |
| * @return |
| */ |
| public QualifiedName getTypeQualifiedName() { |
| |
| return parent.isResolved() ? parent.getTypeQualifiedName().skipLast(1) |
| .append(crossRefString) : null; |
| } |
| |
| public ITextRegion getTextRegion() { |
| return textRegion; |
| } |
| |
| public EObject getContext() { |
| return context; |
| } |
| |
| public String getContextPackageName() { |
| return getPackageName(context); |
| } |
| |
| public EClassifier getType() { |
| return TypesPackage.Literals.JVM_TYPE; |
| } |
| |
| public EReference getReference() { |
| return TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE; |
| } |
| |
| protected String getPackageName(EObject context) { |
| return null; |
| } |
| |
| } |