Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Aguirre2016-05-23 09:54:23 +0000
committerGerrit Code Review @ Eclipse.org2016-09-09 22:56:04 +0000
commit70b6bdb742c504cc4a74ca571a88d8571d3f52dd (patch)
tree2e7840d0a62ada45a98a03173c10c474d63dc9fa
parent02a17afb7c45e09bcd08cc7ae5f0ab0be7a54ead (diff)
downloadorg.eclipse.emf.eson-70b6bdb742c504cc4a74ca571a88d8571d3f52dd.tar.gz
org.eclipse.emf.eson-70b6bdb742c504cc4a74ca571a88d8571d3f52dd.tar.xz
org.eclipse.emf.eson-70b6bdb742c504cc4a74ca571a88d8571d3f52dd.zip
[Fix] new URI mechanism scope management with dots in packages
Change-Id: If84937b89397ffa3497e4366ee95d73ab07b160a Signed-off-by: David Aguirre <daguirre@temenos.com>
-rw-r--r--plugins/org.eclipse.emf.eson/src/org/eclipse/emf/eson/scoping/SimpleEPackageScope.java3
-rw-r--r--tests/org.eclipse.emf.eson.tests/model/TestModel.ecore2
-rw-r--r--tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackage.efactory8
-rw-r--r--tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackageEXPECTED.efactory12
-rw-r--r--tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestModel.java28
-rw-r--r--tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestmodelPackage.java30
-rw-r--r--tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestModelImpl.java67
-rw-r--r--tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestmodelPackageImpl.java11
-rw-r--r--tests/org.eclipse.emf.eson.tests/src/org/eclipse/emf/eson/builder/resync/tests/BuilderResyncTest.java27
9 files changed, 181 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.eson/src/org/eclipse/emf/eson/scoping/SimpleEPackageScope.java b/plugins/org.eclipse.emf.eson/src/org/eclipse/emf/eson/scoping/SimpleEPackageScope.java
index 52a5d42..f9a29cf 100644
--- a/plugins/org.eclipse.emf.eson/src/org/eclipse/emf/eson/scoping/SimpleEPackageScope.java
+++ b/plugins/org.eclipse.emf.eson/src/org/eclipse/emf/eson/scoping/SimpleEPackageScope.java
@@ -43,7 +43,8 @@ public class SimpleEPackageScope extends SimpleScope implements IScope {
result = Iterables.filter(localElements, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
- return input.getQualifiedName().getFirstSegment().equals(ePackage.getNsURI());
+ // NS URI must exactly match for handling subpackages with different namespaces
+ return input.getQualifiedName().toString(".").equals(ePackage.getNsURI());
}
});
}
diff --git a/tests/org.eclipse.emf.eson.tests/model/TestModel.ecore b/tests/org.eclipse.emf.eson.tests/model/TestModel.ecore
index ee15c8b..ec8ed6b 100644
--- a/tests/org.eclipse.emf.eson.tests/model/TestModel.ecore
+++ b/tests/org.eclipse.emf.eson.tests/model/TestModel.ecore
@@ -18,6 +18,8 @@
eType="#//AttributeTestContainer" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="nameAttributeTest" upperBound="-1"
eType="#//NameAttributeContainer" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="sub" eType="#//testsubmodel/TestInnerModel"
+ containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Child">
<eStructuralFeatures xsi:type="ecore:EReference" name="referenceList" upperBound="-1"
diff --git a/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackage.efactory b/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackage.efactory
new file mode 100644
index 0000000..0f223aa
--- /dev/null
+++ b/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackage.efactory
@@ -0,0 +1,8 @@
+use testmodel.*
+use testmodel.testsubmodel.*
+
+TestModel {
+ name: "test"
+ singleRequired: SingleRequired { }
+ sub: TestInnerModel { }
+}
diff --git a/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackageEXPECTED.efactory b/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackageEXPECTED.efactory
new file mode 100644
index 0000000..4d2fb3e
--- /dev/null
+++ b/tests/org.eclipse.emf.eson.tests/res/BuilderResyncTests/4TestModelWithSubPackageEXPECTED.efactory
@@ -0,0 +1,12 @@
+use testmodel
+use testmodel.testsubmodel
+
+TestModel {
+ name: "test"
+ singleRequired: SingleRequired { }
+ sub: TestInnerModel { }
+nameAttributeTest: [
+ {
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestModel.java b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestModel.java
index 7b8f709..ac6c7ad 100644
--- a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestModel.java
+++ b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestModel.java
@@ -5,6 +5,7 @@ package testmodel;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
+import testmodel.testsubmodel.TestInnerModel;
/**
* <!-- begin-user-doc -->
@@ -24,6 +25,7 @@ import org.eclipse.emf.ecore.EObject;
* <li>{@link testmodel.TestModel#getReferenceTestContainer <em>Reference Test Container</em>}</li>
* <li>{@link testmodel.TestModel#getAttributeTest <em>Attribute Test</em>}</li>
* <li>{@link testmodel.TestModel#getNameAttributeTest <em>Name Attribute Test</em>}</li>
+ * <li>{@link testmodel.TestModel#getSub <em>Sub</em>}</li>
* </ul>
*
* @see testmodel.TestmodelPackage#getTestModel()
@@ -225,4 +227,30 @@ public interface TestModel extends EObject {
*/
EList<NameAttributeContainer> getNameAttributeTest();
+ /**
+ * Returns the value of the '<em><b>Sub</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Sub</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Sub</em>' containment reference.
+ * @see #setSub(TestInnerModel)
+ * @see testmodel.TestmodelPackage#getTestModel_Sub()
+ * @model containment="true"
+ * @generated
+ */
+ TestInnerModel getSub();
+
+ /**
+ * Sets the value of the '{@link testmodel.TestModel#getSub <em>Sub</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Sub</em>' containment reference.
+ * @see #getSub()
+ * @generated
+ */
+ void setSub(TestInnerModel value);
+
} // TestModel
diff --git a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestmodelPackage.java b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestmodelPackage.java
index 7a4a247..62b4c5e 100644
--- a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestmodelPackage.java
+++ b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/TestmodelPackage.java
@@ -148,13 +148,22 @@ public interface TestmodelPackage extends EPackage {
int TEST_MODEL__NAME_ATTRIBUTE_TEST = 8;
/**
+ * The feature id for the '<em><b>Sub</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int TEST_MODEL__SUB = 9;
+
+ /**
* The number of structural features of the '<em>Test Model</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int TEST_MODEL_FEATURE_COUNT = 9;
+ int TEST_MODEL_FEATURE_COUNT = 10;
/**
* The meta object id for the '{@link testmodel.impl.ChildImpl <em>Child</em>}' class.
@@ -1040,6 +1049,17 @@ public interface TestmodelPackage extends EPackage {
EReference getTestModel_NameAttributeTest();
/**
+ * Returns the meta object for the containment reference '{@link testmodel.TestModel#getSub <em>Sub</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Sub</em>'.
+ * @see testmodel.TestModel#getSub()
+ * @see #getTestModel()
+ * @generated
+ */
+ EReference getTestModel_Sub();
+
+ /**
* Returns the meta object for class '{@link testmodel.Child <em>Child</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1831,6 +1851,14 @@ public interface TestmodelPackage extends EPackage {
EReference TEST_MODEL__NAME_ATTRIBUTE_TEST = eINSTANCE.getTestModel_NameAttributeTest();
/**
+ * The meta object literal for the '<em><b>Sub</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference TEST_MODEL__SUB = eINSTANCE.getTestModel_Sub();
+
+ /**
* The meta object literal for the '{@link testmodel.impl.ChildImpl <em>Child</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestModelImpl.java b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestModelImpl.java
index 3cc81e6..cd4e9af 100644
--- a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestModelImpl.java
+++ b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestModelImpl.java
@@ -27,6 +27,7 @@ import testmodel.SingleOptional;
import testmodel.SingleRequired;
import testmodel.TestModel;
import testmodel.TestmodelPackage;
+import testmodel.testsubmodel.TestInnerModel;
/**
* <!-- begin-user-doc -->
@@ -45,6 +46,7 @@ import testmodel.TestmodelPackage;
* <li>{@link testmodel.impl.TestModelImpl#getReferenceTestContainer <em>Reference Test Container</em>}</li>
* <li>{@link testmodel.impl.TestModelImpl#getAttributeTest <em>Attribute Test</em>}</li>
* <li>{@link testmodel.impl.TestModelImpl#getNameAttributeTest <em>Name Attribute Test</em>}</li>
+ * <li>{@link testmodel.impl.TestModelImpl#getSub <em>Sub</em>}</li>
* </ul>
*
* @generated
@@ -151,6 +153,16 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
protected EList<NameAttributeContainer> nameAttributeTest;
/**
+ * The cached value of the '{@link #getSub() <em>Sub</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getSub()
+ * @generated
+ * @ordered
+ */
+ protected TestInnerModel sub;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -410,6 +422,49 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
* <!-- end-user-doc -->
* @generated
*/
+ public TestInnerModel getSub() {
+ return sub;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetSub(TestInnerModel newSub, NotificationChain msgs) {
+ TestInnerModel oldSub = sub;
+ sub = newSub;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestmodelPackage.TEST_MODEL__SUB, oldSub, newSub);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSub(TestInnerModel newSub) {
+ if (newSub != sub) {
+ NotificationChain msgs = null;
+ if (sub != null)
+ msgs = ((InternalEObject)sub).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TestmodelPackage.TEST_MODEL__SUB, null, msgs);
+ if (newSub != null)
+ msgs = ((InternalEObject)newSub).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TestmodelPackage.TEST_MODEL__SUB, null, msgs);
+ msgs = basicSetSub(newSub, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelPackage.TEST_MODEL__SUB, newSub, newSub));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -427,6 +482,8 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
return ((InternalEList<?>)getAttributeTest()).basicRemove(otherEnd, msgs);
case TestmodelPackage.TEST_MODEL__NAME_ATTRIBUTE_TEST:
return ((InternalEList<?>)getNameAttributeTest()).basicRemove(otherEnd, msgs);
+ case TestmodelPackage.TEST_MODEL__SUB:
+ return basicSetSub(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -458,6 +515,8 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
return getAttributeTest();
case TestmodelPackage.TEST_MODEL__NAME_ATTRIBUTE_TEST:
return getNameAttributeTest();
+ case TestmodelPackage.TEST_MODEL__SUB:
+ return getSub();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -502,6 +561,9 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
getNameAttributeTest().clear();
getNameAttributeTest().addAll((Collection<? extends NameAttributeContainer>)newValue);
return;
+ case TestmodelPackage.TEST_MODEL__SUB:
+ setSub((TestInnerModel)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -541,6 +603,9 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
case TestmodelPackage.TEST_MODEL__NAME_ATTRIBUTE_TEST:
getNameAttributeTest().clear();
return;
+ case TestmodelPackage.TEST_MODEL__SUB:
+ setSub((TestInnerModel)null);
+ return;
}
super.eUnset(featureID);
}
@@ -571,6 +636,8 @@ public class TestModelImpl extends EObjectImpl implements TestModel {
return attributeTest != null && !attributeTest.isEmpty();
case TestmodelPackage.TEST_MODEL__NAME_ATTRIBUTE_TEST:
return nameAttributeTest != null && !nameAttributeTest.isEmpty();
+ case TestmodelPackage.TEST_MODEL__SUB:
+ return sub != null;
}
return super.eIsSet(featureID);
}
diff --git a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestmodelPackageImpl.java b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestmodelPackageImpl.java
index bf6c509..e6f8b8e 100644
--- a/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestmodelPackageImpl.java
+++ b/tests/org.eclipse.emf.eson.tests/src-emf/testmodel/impl/TestmodelPackageImpl.java
@@ -331,6 +331,15 @@ public class TestmodelPackageImpl extends EPackageImpl implements TestmodelPacka
* <!-- end-user-doc -->
* @generated
*/
+ public EReference getTestModel_Sub() {
+ return (EReference)testModelEClass.getEStructuralFeatures().get(9);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getChild() {
return childEClass;
}
@@ -940,6 +949,7 @@ public class TestmodelPackageImpl extends EPackageImpl implements TestmodelPacka
createEReference(testModelEClass, TEST_MODEL__REFERENCE_TEST_CONTAINER);
createEReference(testModelEClass, TEST_MODEL__ATTRIBUTE_TEST);
createEReference(testModelEClass, TEST_MODEL__NAME_ATTRIBUTE_TEST);
+ createEReference(testModelEClass, TEST_MODEL__SUB);
childEClass = createEClass(CHILD);
createEReference(childEClass, CHILD__REFERENCE_LIST);
@@ -1076,6 +1086,7 @@ public class TestmodelPackageImpl extends EPackageImpl implements TestmodelPacka
initEReference(getTestModel_ReferenceTestContainer(), this.getReferenceTestContainer(), null, "referenceTestContainer", null, 0, -1, TestModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getTestModel_AttributeTest(), this.getAttributeTestContainer(), null, "attributeTest", null, 0, -1, TestModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getTestModel_NameAttributeTest(), this.getNameAttributeContainer(), null, "nameAttributeTest", null, 0, -1, TestModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getTestModel_Sub(), theTestsubmodelPackage.getTestInnerModel(), null, "sub", null, 0, 1, TestModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(childEClass, Child.class, "Child", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getChild_ReferenceList(), this.getSingleRequired(), null, "referenceList", null, 0, -1, Child.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/tests/org.eclipse.emf.eson.tests/src/org/eclipse/emf/eson/builder/resync/tests/BuilderResyncTest.java b/tests/org.eclipse.emf.eson.tests/src/org/eclipse/emf/eson/builder/resync/tests/BuilderResyncTest.java
index 6c7657a..77e91a9 100644
--- a/tests/org.eclipse.emf.eson.tests/src/org/eclipse/emf/eson/builder/resync/tests/BuilderResyncTest.java
+++ b/tests/org.eclipse.emf.eson.tests/src/org/eclipse/emf/eson/builder/resync/tests/BuilderResyncTest.java
@@ -169,19 +169,35 @@ public class BuilderResyncTest {
*/
@Test
public void testAddNewContainerFeature() throws Exception {
+ testLoadCheckAndSerialize("res/BuilderResyncTests/1TestModelWithNameProperty.efactory",
+ "res/BuilderResyncTests/1TestModelWithNamePropertyEXPECTED.efactory");
+ }
+
+ /**
+ * Test package scope when NS URIs are java like packages with dots. Example xxx.yyy.zzz instead of http://xxx.yyy.zzz
+ * <p>Test is done on sub-package to ensure that it does not only work with main package
+ */
+ @Test
+ public void testMultiPackageScoping() throws Exception {
+ testLoadCheckAndSerialize("res/BuilderResyncTests/4TestModelWithSubPackage.efactory",
+ "res/BuilderResyncTests/4TestModelWithSubPackageEXPECTED.efactory");
+ }
+
+ private void testLoadCheckAndSerialize(String eFactoryInput, String expectedDSLFile) throws Exception {
ResourceProvider resourceProvider = rp.get();
- EList<EObject> resourceContents = resourceProvider.load("res/BuilderResyncTests/1TestModelWithNameProperty.efactory", true);
+ EList<EObject> resourceContents = resourceProvider.load(eFactoryInput, true);
// Change the TestModel
TestModel testModel = (TestModel) resourceContents.get(1);
-
+
NameAttributeContainer nameAttributeContainer = TestmodelFactory.eINSTANCE.createNameAttributeContainer();
// nameAttributeContainer.set...
testModel.getNameAttributeTest().add(nameAttributeContainer);
-
+
// Check the EFactory model
Factory eFactory = (Factory) resourceContents.get(0);
- Value efValue = eFactory.getRoot().getFeatures().get(2).getValue();
+ int posLastFeature = eFactory.getRoot().getFeatures().size() - 1;
+ Value efValue = eFactory.getRoot().getFeatures().get(posLastFeature).getValue();
MultiValue multiValue = (MultiValue) efValue;
Value firstValue = multiValue.getValues().get(0);
@@ -200,10 +216,11 @@ public class BuilderResyncTest {
// format it, not in tests and not in real editor UI etc. because one of
// the main points of ESON is that it doesn't have to reformat
// everything.
- String expectedDSL = LineEndingUtil.fixLineEndings(resourceProvider.loadAsString("res/BuilderResyncTests/1TestModelWithNamePropertyEXPECTED.efactory"));
+ String expectedDSL = LineEndingUtil.fixLineEndings(resourceProvider.loadAsString(expectedDSLFile));
assertEquals(expectedDSL, dsl);
checkNodes(eFactory);
}
+
/**
* Tests that the NodeFixer correctly spaces out (indents) new features

Back to the top