summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2009-03-05 05:25:36 (EST)
committer sefftinge2009-03-05 05:25:36 (EST)
commit404d34a35d927cb4b90a58ebb8f5ec9e1805f95b (patch)
treeea27099da2808852bc51d54b5fe123cfbb52ad4e
parent27242f3885096fddba4c2cd78d469362f8ad669b (diff)
downloadorg.eclipse.xpand-404d34a35d927cb4b90a58ebb8f5ec9e1805f95b.zip
org.eclipse.xpand-404d34a35d927cb4b90a58ebb8f5ec9e1805f95b.tar.gz
org.eclipse.xpand-404d34a35d927cb4b90a58ebb8f5ec9e1805f95b.tar.bz2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=267033
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java2
-rw-r--r--tests/org.eclipse.xtend.typesystem.emf.tests/src/org/eclipse/xtend/typesystem/emf/EmfMetaModelTest.java43
2 files changed, 44 insertions, 1 deletions
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
index 341c28b..8fe1665 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java
@@ -142,7 +142,7 @@ public class EClassType extends AbstractTypeImpl {
log.warn("Couldn't resolve type for " + getTypeName(feature.getEType()));
}
else {
- if (feature.isChangeable() && !feature.isDerived()) { // !feature.isUnsettable()
+ if (feature.isChangeable() && !feature.isDerived() && !feature.isMany()) { // !feature.isUnsettable()
// &&
result.add(new OperationImpl(this, "set" + StringHelper.firstUpper(feature.getName()), this,
new Type[] { t }) {
diff --git a/tests/org.eclipse.xtend.typesystem.emf.tests/src/org/eclipse/xtend/typesystem/emf/EmfMetaModelTest.java b/tests/org.eclipse.xtend.typesystem.emf.tests/src/org/eclipse/xtend/typesystem/emf/EmfMetaModelTest.java
index 6a6458a..826bddb 100644
--- a/tests/org.eclipse.xtend.typesystem.emf.tests/src/org/eclipse/xtend/typesystem/emf/EmfMetaModelTest.java
+++ b/tests/org.eclipse.xtend.typesystem.emf.tests/src/org/eclipse/xtend/typesystem/emf/EmfMetaModelTest.java
@@ -21,8 +21,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.mwe.utils.StandaloneSetup;
import org.eclipse.xtend.expression.ExecutionContextImpl;
+import org.eclipse.xtend.expression.ExpressionFacade;
+import org.eclipse.xtend.expression.Variable;
import org.eclipse.xtend.typesystem.Operation;
import org.eclipse.xtend.typesystem.ParameterizedType;
import org.eclipse.xtend.typesystem.Property;
@@ -57,6 +60,46 @@ public class EmfMetaModelTest extends TestCase {
assertEquals(mm.getTypeForName("ecore::EStructuralFeature"), op
.getReturnType());
}
+
+
+ public void testSettingMultiValueDataType() throws Exception {
+ EcoreFactory f = EcoreFactory.eINSTANCE;
+ final EPackage pack = f.createEPackage();
+ pack.setName("test");
+
+ EClass clazz = f.createEClass();
+ clazz.setName("AClass");
+ pack.getEClassifiers().add(clazz);
+
+ EAttribute attr = f.createEAttribute();
+ attr.setName("multiString");
+ attr.setEType(EcorePackage.eINSTANCE.getEString());
+ attr.setUpperBound(-1);
+ clazz.getEStructuralFeatures().add(attr);
+
+ final ExecutionContextImpl ctx = new ExecutionContextImpl();
+ final EmfRegistryMetaModel mm = new EmfRegistryMetaModel() {
+ @Override
+ protected EPackage[] allPackages() {
+ return new EPackage[]{pack};
+ }
+ };
+ ctx.registerMetaModel(mm);
+
+ Type aClassType = mm.getTypeForName("test::AClass");
+ assertNotNull(aClassType);
+ Operation op = aClassType.getOperation("setMultiString", new Type[] {ctx.getListType(ctx.getStringType()) });
+ assertNull(op);
+
+ EObject aClassInstance = EcoreUtil.create(clazz);
+ ExpressionFacade facade = new ExpressionFacade(ctx);
+ facade = facade.cloneWithVariable(new Variable("aClassInstance", aClassInstance));
+ assertEquals("0", "" + facade.evaluate("aClassInstance.multiString.size"));
+ facade.evaluate("aClassInstance.multiString.add('foo')");
+ assertEquals("1", "" + facade.evaluate("aClassInstance.multiString.size"));
+ assertEquals("foo", "" + facade.evaluate("aClassInstance.multiString.first()"));
+ }
+
public final void testEEnumType() {
final ExecutionContextImpl ctx = new ExecutionContextImpl();