summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahaase2008-04-07 13:09:15 (EDT)
committerahaase2008-04-07 13:09:15 (EDT)
commita93fba781c18aff374b00a7646d22d22a02a8baa (patch)
tree9346123214e7c403a563b783f9b008b9e9b0650a
parentc86093c8eb986888ddc87d9e191c9a8fdea3a01e (diff)
downloadorg.eclipse.xpand-a93fba781c18aff374b00a7646d22d22a02a8baa.zip
org.eclipse.xpand-a93fba781c18aff374b00a7646d22d22a02a8baa.tar.gz
org.eclipse.xpand-a93fba781c18aff374b00a7646d22d22a02a8baa.tar.bz2
added support for "synthetic" properties, i.e. properties defined by functions
-rw-r--r--plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/EnumType.java3
-rw-r--r--plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/StereotypeType.java13
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/BackendType.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/FunctionDefContext.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/Property.java3
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/expr/PropertyOnWhateverExpression.java6
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/internal/FunctionDefContextImpl.java4
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/ReflectionOperations.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractProperty.java18
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractType.java166
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/BuiltinProperty.java4
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/CollectionType.java4
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java4
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/ObjectType.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/PropertyType.java5
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StaticPropertyType.java5
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StringType.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/TypeType.java19
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/EObjectType.java10
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/internal/EClassType.java10
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/FunctionBackedProperty.java63
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/SyntheticPropertyExtracter.java126
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansProperty.java4
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansType.java4
-rw-r--r--plugins/org.eclipse.xtend.middleend.xtend/src/org/eclipse/xtend/middleend/xtend/internal/OldExpressionConverter.java21
25 files changed, 345 insertions, 157 deletions
diff --git a/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/EnumType.java b/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/EnumType.java
index 9cc4213..40cddea 100644
--- a/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/EnumType.java
+++ b/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/EnumType.java
@@ -18,7 +18,6 @@ import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.common.StaticProperty;
import org.eclipse.xtend.backend.types.AbstractProperty;
import org.eclipse.xtend.backend.types.AbstractType;
-import org.eclipse.xtend.backend.types.builtin.StringType;
import org.eclipse.xtend.backend.types.emf.EObjectType;
@@ -53,7 +52,7 @@ public final class EnumType extends AbstractType {
}
});
- register (new AbstractProperty (this, StringType.INSTANCE, String.class, "literal", false) {
+ register (new AbstractProperty (this, String.class, "literal", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
if (o == null)
diff --git a/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/StereotypeType.java b/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/StereotypeType.java
index e818b98..8d03251 100644
--- a/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/StereotypeType.java
+++ b/plugins/org.eclipse.xtend.backend.uml2types/src/org/eclipse/xtend/backend/types/uml2/internal/StereotypeType.java
@@ -33,7 +33,6 @@ import org.eclipse.xtend.backend.common.BackendType;
import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.types.AbstractProperty;
import org.eclipse.xtend.backend.types.AbstractType;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
import org.eclipse.xtend.backend.types.uml2.UmlTypesystem;
@@ -48,12 +47,12 @@ public final class StereotypeType extends AbstractType {
super (name, name, superTypes (umlTs, stereoType).toArray (new BackendType[0])); //TODO uniqueRepresentation
_stereoType = stereoType;
- for (StereotypeProperty stp: getProperties(this, stereoType, umlTs))
+ for (StereotypeProperty stp: getProperties(this, stereoType))
register (stp);
}
- private Collection<StereotypeProperty> getProperties (BackendType owningType, Stereotype stereoType, UmlTypesystem umlTs) {
+ private Collection<StereotypeProperty> getProperties (BackendType owningType, Stereotype stereoType) {
final Collection<StereotypeProperty> result = new HashSet<StereotypeProperty> ();
for (Property attrib: stereoType.getAttributes()) {
@@ -68,8 +67,8 @@ public final class StereotypeType extends AbstractType {
continue;
}
- final BackendType backendType = (attrib.isMultivalued()) ? CollectionType.INSTANCE : umlTs.findType (umlType);
- result.add (new StereotypeProperty (backendType, attrib.getName ()));
+// final BackendType backendType = (attrib.isMultivalued()) ? CollectionType.INSTANCE : umlTs.findType (umlType);
+ result.add (new StereotypeProperty (attrib.getName ()));
}
return result;
@@ -133,8 +132,8 @@ public final class StereotypeType extends AbstractType {
private final class StereotypeProperty extends AbstractProperty {
- public StereotypeProperty (BackendType type, String name) {
- super (StereotypeType.this, type, Object.class, name, false);
+ public StereotypeProperty (String name) {
+ super (StereotypeType.this, Object.class, name, true, false);
}
@Override
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/BackendType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/BackendType.java
index fae346d..493fd93 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/BackendType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/BackendType.java
@@ -31,7 +31,7 @@ public interface BackendType {
// stuff required for reflection / meta programming
String getName ();
Collection<? extends BackendType> getSuperTypes ();
- Map<String, ? extends Property> getProperties ();
+ Map<String, ? extends Property> getProperties (ExecutionContext ctx);
Map<String, ? extends StaticProperty> getStaticProperties ();
String getUniqueRepresentation ();
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/FunctionDefContext.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/FunctionDefContext.java
index 8781dc8..9ef69bf 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/FunctionDefContext.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/FunctionDefContext.java
@@ -25,7 +25,7 @@ public interface FunctionDefContext {
Object invoke (ExecutionContext ctx, String functionName, List<? extends Object> params);
/**
- * for reflection. This method returns separately registered functions, not those "built into" the
+ * for reflection. This method returns all functions, both those separately registered and those "built into" the
* type.
*/
Collection<NamedFunction> getByFirstParameterType (BackendType firstParameterType);
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/Property.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/Property.java
index 1966030..79b5f60 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/Property.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/common/Property.java
@@ -19,10 +19,9 @@ public interface Property {
String getName ();
BackendType getOwner ();
- BackendType getType ();
-
Object get (ExecutionContext ctx, Object o);
void set (ExecutionContext ctx, Object o, Object newValue);
+ boolean isReadable ();
boolean isWritable ();
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/expr/PropertyOnWhateverExpression.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/expr/PropertyOnWhateverExpression.java
index b4f55fe..761b81b 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/expr/PropertyOnWhateverExpression.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/expr/PropertyOnWhateverExpression.java
@@ -51,7 +51,7 @@ public final class PropertyOnWhateverExpression extends ExpressionBase {
final BackendType t = ctx.getTypesystem().findType (o);
if (CollectionType.INSTANCE.isAssignableFrom(t)) {
- if (isProperty (t, _propertyName))
+ if (isProperty (ctx, t, _propertyName))
return t.getProperty (ctx, o, _propertyName);
final Collection<Object> result = CollectionOperations.createMatchingCollection ((Collection<?>) o);
@@ -65,7 +65,7 @@ public final class PropertyOnWhateverExpression extends ExpressionBase {
return t.getProperty (ctx, o, _propertyName);
}
- private boolean isProperty (BackendType t, String propName) {
- return t.getProperties().containsKey (propName);
+ private boolean isProperty (ExecutionContext ctx, BackendType t, String propName) {
+ return t.getProperties(ctx).containsKey (propName);
}
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/internal/FunctionDefContextImpl.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/internal/FunctionDefContextImpl.java
index c3f0b2a..6ae114e 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/internal/FunctionDefContextImpl.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/functions/internal/FunctionDefContextImpl.java
@@ -144,8 +144,8 @@ public final class FunctionDefContextImpl implements FunctionDefContextInternal
if (firstParameterType.getBuiltinOperations().isEmpty())
return _byFirstParameterType.get (firstParameterType);
- final List<NamedFunction> result = new ArrayList<NamedFunction> (_byFirstParameterType.get (firstParameterType));
- result.addAll (firstParameterType.getBuiltinOperations());
+ final List<NamedFunction> result = new ArrayList<NamedFunction> (firstParameterType.getBuiltinOperations());
+ result.addAll (_byFirstParameterType.get (firstParameterType));
return result;
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/ReflectionOperations.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/ReflectionOperations.java
index c090b1a..8e118b1 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/ReflectionOperations.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/ReflectionOperations.java
@@ -44,7 +44,7 @@ public final class ReflectionOperations extends AbstractExecutionContextAware {
}
public Property getProperty (BackendType t, String name) {
- return t.getProperties().get (name);
+ return t.getProperties(_ctx).get (name);
}
public StaticProperty getStaticProperty (BackendType t, String name) {
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractProperty.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractProperty.java
index 68dce8c..fde00d5 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractProperty.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractProperty.java
@@ -23,20 +23,18 @@ import org.eclipse.xtend.backend.functions.java.internal.JavaBuiltinConverterFac
*/
public abstract class AbstractProperty implements Property {
protected final BackendType _owner;
- protected final BackendType _type;
protected final String _name;
+ protected final boolean _isReadable;
protected final boolean _isWritable;
- protected final JavaBuiltinConverter _converter;
+ protected final JavaBuiltinConverter _converter; //TODO remove this
- public AbstractProperty (BackendType owner, BackendType type, Class<?> javaType, String name, boolean isWritable) {
+ public AbstractProperty (BackendType owner, Class<?> javaType, String name, boolean isReadable, boolean isWritable) {
if (owner == null)
throw new IllegalArgumentException ();
- if (type == null)
- throw new IllegalArgumentException ();
_owner = owner;
- _type = type;
_name = name;
+ _isReadable = isReadable;
_isWritable = isWritable;
_converter = JavaBuiltinConverterFactory.getConverter (javaType);
@@ -50,10 +48,6 @@ public abstract class AbstractProperty implements Property {
return _owner;
}
- public BackendType getType () {
- return _type;
- }
-
public final Object get (ExecutionContext ctx, Object o) {
return _converter.javaToBackend (getRaw (ctx, o));
}
@@ -69,6 +63,10 @@ public abstract class AbstractProperty implements Property {
public void setRaw (ExecutionContext ctx, Object o, Object newValue) {
throw new IllegalStateException ("property " + _name + " of type " + _owner.getName() + " can not be set");
}
+
+ public boolean isReadable () {
+ return _isReadable;
+ }
public boolean isWritable () {
return _isWritable;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractType.java
index 31466da..f11aa4e 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/AbstractType.java
@@ -21,15 +21,13 @@ import java.util.Map;
import org.eclipse.xtend.backend.common.BackendType;
import org.eclipse.xtend.backend.common.ExecutionContext;
-import org.eclipse.xtend.backend.common.ExpressionBase;
import org.eclipse.xtend.backend.common.Function;
-import org.eclipse.xtend.backend.common.FunctionDefContext;
import org.eclipse.xtend.backend.common.NamedFunction;
import org.eclipse.xtend.backend.common.Property;
import org.eclipse.xtend.backend.common.StaticProperty;
import org.eclipse.xtend.backend.types.builtin.ObjectType;
import org.eclipse.xtend.backend.types.builtin.VoidType;
-import org.eclipse.xtend.backend.util.StringHelper;
+import org.eclipse.xtend.backend.types.internal.SyntheticPropertyExtracter;
/**
@@ -57,7 +55,6 @@ public abstract class AbstractType implements BackendType {
for (BackendType superType: superTypes) {
_builtinOperations.addAll (superType.getBuiltinOperations());
- _properties.putAll (superType.getProperties());
_staticProperties.putAll (superType.getStaticProperties());
}
}
@@ -71,9 +68,9 @@ public abstract class AbstractType implements BackendType {
protected void register (Property p) {
_properties.put (p.getName(), p);
- register ("get" + StringHelper.firstUpper (p.getName()), new GetterOperation (p));
- if (p.isWritable())
- register ("set" + StringHelper.firstUpper (p.getName()), new SetterOperation (p));
+// register ("get" + StringHelper.firstUpper (p.getName()), new GetterOperation (p));
+// if (p.isWritable())
+// register ("set" + StringHelper.firstUpper (p.getName()), new SetterOperation (p));
}
protected void register (StaticProperty p) {
@@ -93,7 +90,7 @@ public abstract class AbstractType implements BackendType {
}
public final Object getProperty (ExecutionContext ctx, Object o, String name) {
- final Property p = getProperties().get (name);
+ final Property p = getProperties(ctx).get (name);
if (p == null)
throw new IllegalArgumentException ("no property " + name + " in type " + getName());
@@ -101,7 +98,7 @@ public abstract class AbstractType implements BackendType {
}
public final void setProperty (ExecutionContext ctx, Object o, String name, Object value) {
- final Property p = getProperties().get (name);
+ final Property p = getProperties(ctx).get (name);
if (p == null)
throw new IllegalArgumentException ("no property " + name + " in type " + getName());
@@ -117,18 +114,23 @@ public abstract class AbstractType implements BackendType {
throw new UnsupportedOperationException ("Type " + getName() + " can not be instantiated reflectively.");
}
- public final Map<String, ? extends Property> getProperties () {
+ public final Map<String, ? extends Property> getProperties (ExecutionContext ctx) {
//this could be statically initialized in the constructor, but is intentionally done dynamically to prepare for
// "dynamic properties" that are attached at runtime
final Map<String, Property> result = new HashMap<String, Property> ();
for (BackendType t: _superTypes)
- result.putAll (t.getProperties());
-
+ result.putAll (t.getProperties (ctx));
+
+ //TODO caching / optimization?
+ result.putAll (new SyntheticPropertyExtracter (ctx, this).getProperties());
result.putAll (_properties);
+
return result;
}
+ //TODO remove "getter / setter to property" support for Java Beans type system
+
public final Map<String, ? extends StaticProperty> getStaticProperties () {
return _staticProperties;
}
@@ -156,76 +158,78 @@ public abstract class AbstractType implements BackendType {
return _name;
}
- private class SetterOperation implements Function {
- private final List<BackendType> _paramTypes = new ArrayList<BackendType> ();
- private final Property _property;
-
- public SetterOperation (Property property) {
- _property = property;
-
- _paramTypes.add (AbstractType.this);
- _paramTypes.add (property.getType ());
- }
-
- public ExpressionBase getGuard () {
- return null;
- }
-
- public List<? extends BackendType> getParameterTypes () {
- return _paramTypes;
- }
-
- public Object invoke (ExecutionContext ctx, Object[] params) {
- _property.set (ctx, params[0], params[1]);
- return null;
- }
-
- public boolean isCached () {
- return false;
- }
-
- public FunctionDefContext getFunctionDefContext () {
- return null;
- }
-
- public void setFunctionDefContext (FunctionDefContext fdc) {
- throw new UnsupportedOperationException ();
- }
- }
+ //TODO synthetic setter operation --> middle end (requires knowledge of the property type!)
- private class GetterOperation implements Function {
- private final List<BackendType> _paramTypes = new ArrayList<BackendType> ();
- private final Property _property;
-
- public GetterOperation (Property property) {
- _property = property;
- _paramTypes.add (AbstractType.this);
- }
-
- public ExpressionBase getGuard () {
- return null;
- }
-
- public List<? extends BackendType> getParameterTypes () {
- return _paramTypes;
- }
-
- public Object invoke (ExecutionContext ctx, Object[] params) {
- return _property.get (ctx, params[0]);
- }
-
- public boolean isCached () {
- return false;
- }
-
- public FunctionDefContext getFunctionDefContext () {
- return null;
- }
-
- public void setFunctionDefContext (FunctionDefContext fdc) {
- throw new UnsupportedOperationException ();
- }
- }
+// private class SetterOperation implements Function {
+// private final List<BackendType> _paramTypes = new ArrayList<BackendType> ();
+// private final Property _property;
+//
+// public SetterOperation (Property property) {
+// _property = property;
+//
+// _paramTypes.add (AbstractType.this);
+// _paramTypes.add (property.getType ());
+// }
+//
+// public ExpressionBase getGuard () {
+// return null;
+// }
+//
+// public List<? extends BackendType> getParameterTypes () {
+// return _paramTypes;
+// }
+//
+// public Object invoke (ExecutionContext ctx, Object[] params) {
+// _property.set (ctx, params[0], params[1]);
+// return null;
+// }
+//
+// public boolean isCached () {
+// return false;
+// }
+//
+// public FunctionDefContext getFunctionDefContext () {
+// return null;
+// }
+//
+// public void setFunctionDefContext (FunctionDefContext fdc) {
+// throw new UnsupportedOperationException ();
+// }
+// }
+//
+// private class GetterOperation implements Function {
+// private final List<BackendType> _paramTypes = new ArrayList<BackendType> ();
+// private final Property _property;
+//
+// public GetterOperation (Property property) {
+// _property = property;
+// _paramTypes.add (AbstractType.this);
+// }
+//
+// public ExpressionBase getGuard () {
+// return null;
+// }
+//
+// public List<? extends BackendType> getParameterTypes () {
+// return _paramTypes;
+// }
+//
+// public Object invoke (ExecutionContext ctx, Object[] params) {
+// return _property.get (ctx, params[0]);
+// }
+//
+// public boolean isCached () {
+// return false;
+// }
+//
+// public FunctionDefContext getFunctionDefContext () {
+// return null;
+// }
+//
+// public void setFunctionDefContext (FunctionDefContext fdc) {
+// throw new UnsupportedOperationException ();
+// }
+// }
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/BuiltinProperty.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/BuiltinProperty.java
index 37a3224..ad8b043 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/BuiltinProperty.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/BuiltinProperty.java
@@ -26,8 +26,8 @@ public final class BuiltinProperty extends AbstractProperty {
private final Method _getter;
private final Method _setter;
- public BuiltinProperty (BackendType owner, BackendType type, String name, Method getter, Method setter) {
- super (owner, type, getJavaClassForProperty(getter, setter), name, setter != null);
+ public BuiltinProperty (BackendType owner, String name, Method getter, Method setter) {
+ super (owner, getJavaClassForProperty(getter, setter), name, getter != null, setter != null);
_getter = getter;
_setter = setter;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/CollectionType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/CollectionType.java
index cf8c7d6..5536bf7 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/CollectionType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/CollectionType.java
@@ -26,8 +26,8 @@ public final class CollectionType extends AbstractType {
private CollectionType() {
super ("Collection", "{builtin}Collection");
- register (new BuiltinProperty (this, LongType.INSTANCE, "size", ReflectionHelper.getKnownMethod(Collection.class, "size"), null));
- register (new BuiltinProperty (this, BooleanType.INSTANCE, "isEmpty", ReflectionHelper.getKnownMethod(Collection.class, "isEmpty"), null));
+ register (new BuiltinProperty (this, "size", ReflectionHelper.getKnownMethod(Collection.class, "size"), null));
+ register (new BuiltinProperty (this, "isEmpty", ReflectionHelper.getKnownMethod(Collection.class, "isEmpty"), null));
}
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java
index 8b319a2..e40cfbb 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/MapType.java
@@ -25,8 +25,8 @@ public final class MapType extends AbstractType {
private MapType () {
super ("Map", "{builtin}Map");
- register (new BuiltinProperty (CollectionType.INSTANCE, LongType.INSTANCE, "size", ReflectionHelper.getKnownMethod(Collection.class, "size"), null));
- register (new BuiltinProperty (CollectionType.INSTANCE, BooleanType.INSTANCE, "isEmpty", ReflectionHelper.getKnownMethod(Collection.class, "isEmpty"), null));
+ register (new BuiltinProperty (CollectionType.INSTANCE, "size", ReflectionHelper.getKnownMethod(Collection.class, "size"), null));
+ register (new BuiltinProperty (CollectionType.INSTANCE, "isEmpty", ReflectionHelper.getKnownMethod(Collection.class, "isEmpty"), null));
}
public static final MapType INSTANCE = new MapType ();
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/ObjectType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/ObjectType.java
index e62be49..9c72f88 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/ObjectType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/ObjectType.java
@@ -50,7 +50,7 @@ public final class ObjectType implements BackendType {
return "{builtin}Object";
}
- public Map<String, ? extends Property> getProperties () {
+ public Map<String, ? extends Property> getProperties (ExecutionContext ctx) {
return Collections.emptyMap();
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/PropertyType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/PropertyType.java
index c105304..4062991 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/PropertyType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/PropertyType.java
@@ -26,9 +26,8 @@ public final class PropertyType extends AbstractType {
private PropertyType () {
super ("Property", "{builtin}Property");
- register (new BuiltinProperty (this, StringType.INSTANCE, "name", ReflectionHelper.getKnownMethod(Property.class, "getName"), null));
- register (new BuiltinProperty (this, TypeType.INSTANCE, "returnType", ReflectionHelper.getKnownMethod(Property.class, "getType"), null));
- register (new BuiltinProperty (this, TypeType.INSTANCE, "owner", ReflectionHelper.getKnownMethod(Property.class, "getOwner"), null));
+ register (new BuiltinProperty (this, "name", ReflectionHelper.getKnownMethod(Property.class, "getName"), null));
+ register (new BuiltinProperty (this, "owner", ReflectionHelper.getKnownMethod(Property.class, "getOwner"), null));
}
@Override
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StaticPropertyType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StaticPropertyType.java
index 790efbf..3dda641 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StaticPropertyType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StaticPropertyType.java
@@ -26,9 +26,8 @@ public final class StaticPropertyType extends AbstractType {
private StaticPropertyType () {
super ("StaticProperty", "{builtin}StaticProperty");
- register (new BuiltinProperty (this, StringType.INSTANCE, "name", ReflectionHelper.getKnownMethod(Property.class, "getName"), null));
- register (new BuiltinProperty (this, TypeType.INSTANCE, "returnType", ReflectionHelper.getKnownMethod(Property.class, "getType"), null));
- register (new BuiltinProperty (this, TypeType.INSTANCE, "owner", ReflectionHelper.getKnownMethod(Property.class, "getOwner"), null));
+ register (new BuiltinProperty (this, "name", ReflectionHelper.getKnownMethod(Property.class, "getName"), null));
+ register (new BuiltinProperty (this, "owner", ReflectionHelper.getKnownMethod(Property.class, "getOwner"), null));
}
@Override
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StringType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StringType.java
index 07575bd..4ba664d 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StringType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/StringType.java
@@ -31,7 +31,7 @@ public final class StringType extends AbstractType {
private StringType () {
super ("String", "{builtin}String");
- register (new BuiltinProperty (this, this, "length", ReflectionHelper.getKnownMethod (CharSequence.class, "length"), null));
+ register (new BuiltinProperty (this, "length", ReflectionHelper.getKnownMethod (CharSequence.class, "length"), null));
}
@Override
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/TypeType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/TypeType.java
index 773fd06..a95d5df 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/TypeType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/builtin/TypeType.java
@@ -35,12 +35,19 @@ public final class TypeType extends AbstractType {
private TypeType () {
super ("Type", "{builtin}Type");
- register (new BuiltinProperty (this, StringType.INSTANCE, "name", ReflectionHelper.getKnownMethod (BackendType.class, "getName"), null));
- register (new BuiltinProperty (this, ListType.INSTANCE, "superTypes", ReflectionHelper.getKnownMethod (BackendType.class, "getSuperTypes"), null));
- register (new BuiltinProperty (this, ListType.INSTANCE, "allProperties", ReflectionHelper.getKnownMethod (BackendType.class, "getProperties"), null));
- register (new BuiltinProperty (this, ListType.INSTANCE, "allStaticProperties", ReflectionHelper.getKnownMethod (BackendType.class, "getStaticProperties"), null));
+ register (new BuiltinProperty (this, "name", ReflectionHelper.getKnownMethod (BackendType.class, "getName"), null));
+ register (new BuiltinProperty (this, "superTypes", ReflectionHelper.getKnownMethod (BackendType.class, "getSuperTypes"), null));
+ register (new BuiltinProperty (this, "allStaticProperties", ReflectionHelper.getKnownMethod (BackendType.class, "getStaticProperties"), null));
- register (new AbstractProperty (this, ListType.INSTANCE, java.util.List.class, "allOperations", false) {
+ register (new AbstractProperty (this, java.util.Map.class, "allProperties", true, false) {
+
+ @Override
+ protected Object getRaw (ExecutionContext ctx, Object o) {
+ return ((BackendType) o).getProperties (ctx);
+ }
+ });
+
+ register (new AbstractProperty (this, java.util.List.class, "allOperations", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
final BackendType t = (BackendType) o;
@@ -66,7 +73,7 @@ public final class TypeType extends AbstractType {
final BackendType t = (BackendType) params[0];
final String propname = (String) params[1];
- return t.getProperties().get(propname);
+ return t.getProperties(ctx).get(propname);
}
public boolean isCached () {
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/EObjectType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/EObjectType.java
index f237735..3a051e8 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/EObjectType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/EObjectType.java
@@ -21,8 +21,6 @@ import org.eclipse.xtend.backend.common.BackendType;
import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.types.AbstractProperty;
import org.eclipse.xtend.backend.types.AbstractType;
-import org.eclipse.xtend.backend.types.builtin.ListType;
-import org.eclipse.xtend.backend.types.builtin.SetType;
import org.eclipse.xtend.backend.types.builtin.VoidType;
@@ -36,25 +34,25 @@ public final class EObjectType extends AbstractType {
private EObjectType () {
super ("emf::EObject", EmfTypesystem.getUniqueIdentifier (EcorePackage.eINSTANCE.getEObject()));
- register (new AbstractProperty (INSTANCE, INSTANCE, EObject.class, "eContainer", false) {
+ register (new AbstractProperty (INSTANCE, EObject.class, "eContainer", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
return ((EObject) o).eContainer();
}
});
- register (new AbstractProperty (INSTANCE, ListType.INSTANCE, java.util.List.class, "eContents", false) {
+ register (new AbstractProperty (INSTANCE, java.util.List.class, "eContents", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
return ((EObject) o).eContents();
}
});
- register (new AbstractProperty (INSTANCE, INSTANCE, EObject.class, "eRootContainer", false) {
+ register (new AbstractProperty (INSTANCE, EObject.class, "eRootContainer", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
return EcoreUtil.getRootContainer((EObject) o);
}
});
- register (new AbstractProperty (INSTANCE, SetType.INSTANCE, java.util.Set.class, "eAllContents", false) {
+ register (new AbstractProperty (INSTANCE, java.util.Set.class, "eAllContents", true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
final Set<Object> result = new HashSet<Object>();
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/internal/EClassType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/internal/EClassType.java
index 8a337e8..9be4432 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/internal/EClassType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/emf/internal/EClassType.java
@@ -52,16 +52,16 @@ public final class EClassType extends AbstractType {
* operations that reference itself
*/
public void init (EmfTypesystem ts) {
- initProperties (ts);
+ initProperties ();
initOperations (ts);
}
- private void initProperties (EmfTypesystem ts) {
+ private void initProperties () {
for (final EStructuralFeature feature: _cls.getEStructuralFeatures()) {
- final BackendType t = ts.getTypeForETypedElement(feature);
+// final BackendType t = ts.getTypeForETypedElement(feature);
if (feature.isChangeable() && !feature.isUnsettable() && !feature.isDerived()) {
- register (new AbstractProperty (this, t, feature.getEType().getInstanceClass(), feature.getName(), true) {
+ register (new AbstractProperty (this, feature.getEType().getInstanceClass(), feature.getName(), true, true) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
return ((EObject) o).eGet(feature);
@@ -74,7 +74,7 @@ public final class EClassType extends AbstractType {
});
}
else {
- register (new AbstractProperty (this, t, feature.getEType().getInstanceClass(), feature.getName(), false) {
+ register (new AbstractProperty (this, feature.getEType().getInstanceClass(), feature.getName(), true, false) {
@Override
public Object getRaw (ExecutionContext ctx, Object o) {
return ((EObject) o).eGet(feature);
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/FunctionBackedProperty.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/FunctionBackedProperty.java
new file mode 100644
index 0000000..d0d5d40
--- /dev/null
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/FunctionBackedProperty.java
@@ -0,0 +1,63 @@
+/*
+Copyright (c) 2008 Arno Haase.
+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
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.backend.types.internal;
+
+import java.util.Arrays;
+
+import org.eclipse.xtend.backend.common.BackendType;
+import org.eclipse.xtend.backend.common.ExecutionContext;
+import org.eclipse.xtend.backend.common.Property;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public final class FunctionBackedProperty implements Property {
+ private final String _name;
+ private final BackendType _owner;
+ private final String _getterName;
+ private final String _setterName;
+
+ //TODO inherit from AbstractProperty once the JavaConversion stuff is factored to a more generic place
+
+ public FunctionBackedProperty (String name, String getterName, String setterName, BackendType owner) {
+ _name = name;
+ _owner = owner;
+ _getterName = getterName;
+ _setterName = setterName;
+ }
+
+
+ public Object get (ExecutionContext ctx, Object o) {
+ return ctx.getFunctionDefContext().invoke (ctx, _getterName, Arrays.asList (o));
+ }
+
+ public void set (ExecutionContext ctx, Object o, Object newValue) {
+ ctx.getFunctionDefContext().invoke (ctx, _setterName, Arrays.asList (o, newValue));
+ }
+
+ public String getName () {
+ return _name;
+ }
+
+ public BackendType getOwner () {
+ return _owner;
+ }
+
+ public boolean isReadable () {
+ return _getterName != null;
+ }
+
+ public boolean isWritable () {
+ return _setterName != null;
+ }
+}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/SyntheticPropertyExtracter.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/SyntheticPropertyExtracter.java
new file mode 100644
index 0000000..99deded
--- /dev/null
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/internal/SyntheticPropertyExtracter.java
@@ -0,0 +1,126 @@
+/*
+Copyright (c) 2008 Arno Haase.
+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
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.backend.types.internal;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.xtend.backend.common.BackendType;
+import org.eclipse.xtend.backend.common.ExecutionContext;
+import org.eclipse.xtend.backend.common.NamedFunction;
+import org.eclipse.xtend.backend.common.Property;
+import org.eclipse.xtend.backend.util.Cache;
+import org.eclipse.xtend.backend.util.Pair;
+
+
+//TODO inherit from AbstractProperty after JavaConverter is removed from it
+
+/**
+ * This class creates properties from the functions of a given type by matching
+ * against Java Bean naming conventions.
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public final class SyntheticPropertyExtracter {
+ private final Cache<String, AccessorPair> _accessorPairs = new Cache<String, AccessorPair> () {
+
+ @Override
+ protected AccessorPair create (String key) {
+ return new AccessorPair ();
+ }
+ };
+
+ private final BackendType _owner;
+
+ public SyntheticPropertyExtracter (ExecutionContext ctx, BackendType type) {
+ _owner = type;
+
+ final Collection<NamedFunction> _allFunctions = ctx.getFunctionDefContext().getByFirstParameterType (type);
+
+ for (NamedFunction f: _allFunctions) {
+ final Pair<Boolean, String> propAcc = getPropertyAccessorDetails (f);
+
+ if (propAcc == null)
+ continue;
+
+
+ final AccessorPair ap = _accessorPairs.get (refinePropertyName (propAcc.getSecond()));
+
+ final boolean isSetter = propAcc.getFirst();
+ if (isSetter)
+ ap._setterName = f.getName();
+ else
+ ap._getterName = f.getName();
+ }
+ }
+
+ public Map<String, Property> getProperties () {
+ final Map<String, Property> result = new HashMap<String, Property> ();
+
+ for (String propName: _accessorPairs.getMap().keySet()) {
+ final AccessorPair ap = _accessorPairs.get (propName);
+ result.put (propName, new FunctionBackedProperty (propName, ap._getterName, ap._setterName, _owner));
+ }
+
+ return result;
+ }
+
+
+ /**
+ * This method implements the Java Beans conventions for property accessors, but on NamedFunctions
+ * rather then Methods
+ */
+ private static Pair<Boolean, String> getPropertyAccessorDetails (NamedFunction f) {
+ if (f.getFunction().getGuard() != null)
+ return null;
+
+ if (hasPrefix (f.getName(), "set")) {
+ if (f.getFunction().getParameterTypes().size() != 2)
+ return null;
+
+ return new Pair<Boolean, String> (true, f.getName().substring (3));
+ }
+
+ if (f.getFunction().getParameterTypes().size() != 1)
+ return null;
+
+ if (hasPrefix (f.getName(), "get") || hasPrefix (f.getName(), "has"))
+ return new Pair<Boolean, String> (false, f.getName().substring (3));
+
+ if (hasPrefix (f.getName(), "is"))
+ return new Pair<Boolean, String> (false, f.getName().substring (2));
+
+ return null;
+ }
+
+ private static boolean hasPrefix (String functionName, String prefix) {
+ if (! functionName.startsWith (prefix))
+ return false;
+
+ if (functionName.length() < prefix.length() + 1)
+ return false;
+
+ return Character.isUpperCase (functionName.charAt(prefix.length()));
+ }
+
+ private static String refinePropertyName (String rawName) {
+ if (rawName.length() >= 2 && Character.isUpperCase (rawName.charAt (1)))
+ return rawName;
+
+ return Character.toLowerCase(rawName.charAt (0)) + rawName.substring (1);
+ }
+
+ private static class AccessorPair {
+ public String _getterName;
+ public String _setterName;
+ }
+}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansProperty.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansProperty.java
index 11430a4..073fb53 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansProperty.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansProperty.java
@@ -26,8 +26,8 @@ public final class JavaBeansProperty extends AbstractProperty {
private final PropertyDescriptor _pd;
- public JavaBeansProperty (PropertyDescriptor pd, BackendType owner, BackendType type) {
- super (owner, type, pd.getPropertyType(), pd.getName(), pd.getWriteMethod() != null);
+ public JavaBeansProperty (PropertyDescriptor pd, BackendType owner) {
+ super (owner, pd.getPropertyType(), pd.getName(), pd.getReadMethod() != null, pd.getWriteMethod() != null);
_pd = pd;
}
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansType.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansType.java
index 94b678a..71ed9eb 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansType.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/types/java/internal/JavaBeansType.java
@@ -75,7 +75,7 @@ public final class JavaBeansType implements BackendType {
if (getDeclaringClass (pd) == Object.class)
continue;
- _properties.put (pd.getName(), new JavaBeansProperty (pd, this, ts.getRootTypesystem().findType (pd.getPropertyType()))); //TODO apply primitive type conversion!
+ _properties.put (pd.getName(), new JavaBeansProperty (pd, this)); //TODO apply primitive type conversion!
}
// static properties
@@ -155,7 +155,7 @@ public final class JavaBeansType implements BackendType {
return AbstractJavaBeansTypesystem.UNIQUE_REPRESENTATION_PREFIX + _javaClass.getName();
}
- public Map<String, ? extends Property> getProperties () {
+ public Map<String, ? extends Property> getProperties (ExecutionContext ctx) {
return _properties;
}
diff --git a/plugins/org.eclipse.xtend.middleend.xtend/src/org/eclipse/xtend/middleend/xtend/internal/OldExpressionConverter.java b/plugins/org.eclipse.xtend.middleend.xtend/src/org/eclipse/xtend/middleend/xtend/internal/OldExpressionConverter.java
index 43e4d70..35893d3 100644
--- a/plugins/org.eclipse.xtend.middleend.xtend/src/org/eclipse/xtend/middleend/xtend/internal/OldExpressionConverter.java
+++ b/plugins/org.eclipse.xtend.middleend.xtend/src/org/eclipse/xtend/middleend/xtend/internal/OldExpressionConverter.java
@@ -60,12 +60,9 @@ import org.eclipse.xtend.backend.expr.LiteralExpression;
import org.eclipse.xtend.backend.expr.LocalVarEvalExpression;
import org.eclipse.xtend.backend.expr.NewLocalVarDefExpression;
import org.eclipse.xtend.backend.expr.OrExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnCollectionExpression;
-import org.eclipse.xtend.backend.expr.PropertyOnObjectExpression;
import org.eclipse.xtend.backend.expr.PropertyOnWhateverExpression;
import org.eclipse.xtend.backend.expr.SequenceExpression;
import org.eclipse.xtend.backend.syslib.SysLibNames;
-import org.eclipse.xtend.backend.types.builtin.CollectionType;
import org.eclipse.xtend.backend.types.builtin.ObjectType;
import org.eclipse.xtend.backend.util.CollectionHelper;
import org.eclipse.xtend.backend.util.Pair;
@@ -366,17 +363,17 @@ public final class OldExpressionConverter {
}
private ExpressionBase createPropertyExpression (ExpressionBase target, Type type, String varName, SourcePos sourcePos) {
- if (isCollectionType (type)) {
- if (CollectionType.INSTANCE.getProperties().keySet().contains (varName))
- return new PropertyOnObjectExpression (target, varName, sourcePos);
- else
- return new PropertyOnCollectionExpression (target, varName, sourcePos);
- }
-
- if (isObjectType (type))
+// if (isCollectionType (type)) {
+// if (CollectionType.INSTANCE.getProperties().keySet().contains (varName))
+// return new PropertyOnObjectExpression (target, varName, sourcePos);
+// else
+// return new PropertyOnCollectionExpression (target, varName, sourcePos);
+// }
+//
+// if (isObjectType (type))
return new PropertyOnWhateverExpression (target, varName, sourcePos);
- return new PropertyOnObjectExpression (target, varName, sourcePos);
+// return new PropertyOnObjectExpression (target, varName, sourcePos);
}
private ExpressionBase convertConstructorCallExpression (ConstructorCallExpression expr) {