blob: 197b4744fcb5ac85d67c3750ac47c28eeb1226e3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*******************************************************************************
* 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;
}
}
|