added qualified names support
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
index eb29b3b..6f4f131 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.compiler/src/org/eclipse/mylyn/docs/intent/client/compiler/generator/modellinking/ModelingUnitLinkResolver.java
@@ -180,26 +180,54 @@
*/
private EClassifier resolveEClassifierUsingPackage(UnitInstruction instruction, String nsURI, String href)
throws PackageNotFoundResolveException {
-
+
EPackage ePackage = this.packageRegistry.getEPackage(nsURI);
-
+
if (ePackage == null) {
throw new PackageNotFoundResolveException(instruction, "The package with nsURI \"" + nsURI
+ "\" cannot be found. ");
}
+
+ // resolving ePackage from qualified name if necessary
+ String classifierName = href;
+ if (href.contains(".")) {
+ classifierName = href.substring(href.lastIndexOf('.') + 1);
+ String packageQualifiedName = href.substring(0, href.lastIndexOf('.'));
+ if (!getQualifiedName(ePackage).equals(packageQualifiedName)) {
+ return null;
+ }
+ }
+
EClassifier resolvedClass = null;
- EClassifier foundClassifier = ePackage.getEClassifier(href);
+ EClassifier foundClassifier = ePackage.getEClassifier(classifierName);
if (foundClassifier != null) {
resolvedClass = foundClassifier;
if (instruction instanceof ReferenceValueForStructuralFeature) {
((ReferenceValueForStructuralFeature)instruction).setReferencedMetaType(resolvedClass);
}
}
-
+
return resolvedClass;
}
/**
+ * Returns the qualified name of the ePackage.
+ *
+ * @param ePackage
+ * the ePackage
+ * @return the qualified name of the ePackage
+ */
+ private String getQualifiedName(EPackage ePackage) {
+ String res = ePackage.getName();
+ EPackage tmp = (EPackage)ePackage.eContainer();
+ while (tmp != null) {
+ res = tmp.getName() + '.' + res;
+ tmp = (EPackage)tmp.eContainer();
+ }
+ return res;
+ }
+
+ /**
* Resolve an unresolved reference using the informationHolder's informations.
*
* @param instruction
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedName.intent b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedName.intent
new file mode 100644
index 0000000..4b0efc8
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedName.intent
@@ -0,0 +1,9 @@
+@M
+Resource R {
+ content += p;
+}
+new ecore.EPackage p {
+ nsURI = "p";
+ nsPrefix = "p";
+}
+M@
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedNameNewInstance.intent b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedNameNewInstance.intent
new file mode 100644
index 0000000..ff38c15
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/dataTests/resources/qualifiedNameNewInstance.intent
@@ -0,0 +1,45 @@
+@M
+Resource R1 {
+ content += p1;
+ content += p2;
+}
+new EPackage p1 {
+ nsURI = "p1URI";
+ nsPrefix = "p1Prefix";
+ eSubpackages += sub1;
+}
+new EPackage sub1 {
+ nsURI = "sub1URI";
+ nsPrefix = "sub1Prefix";
+ eClassifiers += new EClass Type {
+ eStructuralFeatures += new EAttribute {
+ name = "sub1attr";
+ eType = EString;
+ changeable = "true";
+ ordered = "true";
+ };
+ };
+}
+new EPackage p2 {
+ nsURI = "p2URI";
+ nsPrefix = "p2Prefix";
+ eClassifiers += new EClass Type {
+ eStructuralFeatures += new EAttribute {
+ name = "p2attr";
+ eType = EString;
+ changeable = "true";
+ ordered = "true";
+ };
+ };
+}
+Resource R2 {
+ content += instance1;
+ content += instance2;
+}
+new p1.sub1.Type instance1 {
+ sub1attr = "instance1";
+}
+new p2.Type instance2 {
+ p2attr = "instance2";
+}
+M@
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedName.intent.R.xmi b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedName.intent.R.xmi
new file mode 100644
index 0000000..6aaa96a
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedName.intent.R.xmi
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ASCII"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="p" nsURI="p" nsPrefix="p"/>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R1.xmi b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R1.xmi
new file mode 100644
index 0000000..f48a1e5
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R1.xmi
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
+ <ecore:EPackage name="p1" nsURI="p1URI" nsPrefix="p1Prefix">
+ <eSubpackages name="sub1" nsURI="sub1URI" nsPrefix="sub1Prefix">
+ <eClassifiers xsi:type="ecore:EClass" name="Type">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="sub1attr">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eStructuralFeatures>
+ </eClassifiers>
+ </eSubpackages>
+ </ecore:EPackage>
+ <ecore:EPackage name="p2" nsURI="p2URI" nsPrefix="p2Prefix">
+ <eClassifiers xsi:type="ecore:EClass" name="Type">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="p2attr">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eStructuralFeatures>
+ </eClassifiers>
+ </ecore:EPackage>
+</xmi:XMI>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R2.xmi b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R2.xmi
new file mode 100644
index 0000000..d84fcae
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/expectedResults/resources/qualifiedNameNewInstance.intent.R2.xmi
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:p2Prefix="p2URI" xmlns:sub1Prefix="sub1URI">
+ <sub1Prefix:Type sub1attr="instance1"/>
+ <p2Prefix:Type p2attr="instance2"/>
+</xmi:XMI>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/unit/GeneratedResourcesTest.java b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/unit/GeneratedResourcesTest.java
index 329f911..63f207e 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/unit/GeneratedResourcesTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.compiler.test/src/org/eclipse/mylyn/docs/intent/client/compiler/test/unit/GeneratedResourcesTest.java
@@ -40,4 +40,13 @@
compile("dataTests/resources/dataType.intent");
}
+ @Test
+ public void testQualifiedName() {
+ compile("dataTests/resources/qualifiedName.intent");
+ }
+
+ @Test
+ public void testQualifiedNameNewInstance() {
+ compile("dataTests/resources/qualifiedNameNewInstance.intent");
+ }
}
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedName.intent b/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedName.intent
new file mode 100644
index 0000000..4b0efc8
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedName.intent
@@ -0,0 +1,9 @@
+@M
+Resource R {
+ content += p;
+}
+new ecore.EPackage p {
+ nsURI = "p";
+ nsPrefix = "p";
+}
+M@
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedNameNewInstance.intent b/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedNameNewInstance.intent
new file mode 100644
index 0000000..ff38c15
--- /dev/null
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/dataTests/modelingUnits/qualifiedNames/qualifiedNameNewInstance.intent
@@ -0,0 +1,45 @@
+@M
+Resource R1 {
+ content += p1;
+ content += p2;
+}
+new EPackage p1 {
+ nsURI = "p1URI";
+ nsPrefix = "p1Prefix";
+ eSubpackages += sub1;
+}
+new EPackage sub1 {
+ nsURI = "sub1URI";
+ nsPrefix = "sub1Prefix";
+ eClassifiers += new EClass Type {
+ eStructuralFeatures += new EAttribute {
+ name = "sub1attr";
+ eType = EString;
+ changeable = "true";
+ ordered = "true";
+ };
+ };
+}
+new EPackage p2 {
+ nsURI = "p2URI";
+ nsPrefix = "p2Prefix";
+ eClassifiers += new EClass Type {
+ eStructuralFeatures += new EAttribute {
+ name = "p2attr";
+ eType = EString;
+ changeable = "true";
+ ordered = "true";
+ };
+ };
+}
+Resource R2 {
+ content += instance1;
+ content += instance2;
+}
+new p1.sub1.Type instance1 {
+ sub1attr = "instance1";
+}
+new p2.Type instance2 {
+ p2attr = "instance2";
+}
+M@
\ No newline at end of file
diff --git a/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/test/TestModelingUnitSerialization.java b/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/test/TestModelingUnitSerialization.java
index 31ba511..61816d4 100644
--- a/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/test/TestModelingUnitSerialization.java
+++ b/tests/org.eclipse.mylyn.docs.intent.parser.test/src/org/eclipse/mylyn/docs/intent/parser/modelingunit/test/TestModelingUnitSerialization.java
@@ -109,4 +109,9 @@
parseAndCompareSerializationToExpected("resourcesRelatedTest/resourceReference", true);
}
+ @Test
+ public void testQualifiedNamesSerialization() {
+ parseAndCompareSerializationToExpected("qualifiedNames/qualifiedName", true);
+ parseAndCompareSerializationToExpected("qualifiedNames/qualifiedNameNewInstance", true);
+ }
}