summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-03 10:37:47 (EST)
committersefftinge2008-03-03 10:37:47 (EST)
commit3a9cb61162669da98df050531ac2f1d0a8185eb5 (patch)
treeb7cf29ba20406e5fac77fdfea60278fb41bfb372
parent2991cad35d9f06071d79ce42ec6729f6241ff5f3 (diff)
downloadorg.eclipse.xpand-3a9cb61162669da98df050531ac2f1d0a8185eb5.zip
org.eclipse.xpand-3a9cb61162669da98df050531ac2f1d0a8185eb5.tar.gz
org.eclipse.xpand-3a9cb61162669da98df050531ac2f1d0a8185eb5.tar.bz2
static typesystem (third draft)
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java)6
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java2
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java6
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java9
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java2
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java6
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java62
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java21
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java74
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java327
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java90
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java271
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java128
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java148
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java72
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java68
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java190
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java58
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java62
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java330
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java187
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java60
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java27
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFeature.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java)4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFunction.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java)9
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredOperation.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java)8
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredProperty.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java)4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredStaticProperty.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java)4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredType.java35
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredTypeParameter.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java)17
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/Type.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java)11
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeMirror.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java)2
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeVariable.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java)4
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/VoidType.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java)2
-rw-r--r--plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/WildcardType.java (renamed from plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java)2
35 files changed, 2275 insertions, 33 deletions
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java
index e2d3af1..e1f5b52 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredTypeParameter.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/AnalyzeContext.java
@@ -13,12 +13,12 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation;
/**
* @author Sven Efftinge
*
*/
-public interface DeclaredTypeParameter extends AbstractNamed {
- Type[] getUpperBounds();
+public interface AnalyzeContext {
+
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
index 558e7f0..6202356 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Feature.java
@@ -15,6 +15,8 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
+
/**
* @author Sven Efftinge
*
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java
index 43b0952..53a324a 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Function.java
@@ -15,11 +15,15 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
+
/**
* @author Sven Efftinge
*
*/
public interface Function extends AbstractNamed {
TypeMirror getReturnType();
- TypeMirror[] getParameterTypes();
+ List<TypeMirror> getParameterTypes();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
index 2b41500..ed76df3 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Operation.java
@@ -15,11 +15,16 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
+
/**
* @author Sven Efftinge
*
*/
public interface Operation extends Feature {
- Type[] getParameterTypes();
- Type getReturnType();
+ List<Type> getParameterTypes();
+ TypeMirror getReturnType();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
index 788ff06..f7a5427 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Property.java
@@ -15,6 +15,8 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
+
/**
* @author Sven Efftinge
*
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
index 1b0ae00..db052c9 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeSystemFacade.java
@@ -15,6 +15,12 @@
*/
package org.eclipse.xand3.analyzation.typesystem;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredFunction;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
+import org.eclipse.xand3.analyzation.typesystem.type.WildcardType;
+
/**
* @author Sven Efftinge
*
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java
new file mode 100644
index 0000000..f1a432c
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BooleanTypeImpl.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+public final class BooleanTypeImpl extends BuiltinBaseType implements Type {
+ public BooleanTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Boolean;
+ }
+
+ @Override
+ public Object convert(final Object src, final Class targetType) {
+ if (targetType == Boolean.class || targetType == Boolean.TYPE)
+ return src;
+ return super.convert(src, targetType);
+ }
+
+ public Object newInstance() {
+ return Boolean.FALSE;
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "!",BooleanTypeImpl.this) {
+ @Override
+ public Object evaluateInternal(final Object target,
+ final Object[] params) {
+ return target == null ? null : new Boolean(!((Boolean) target)
+ .booleanValue());
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java
new file mode 100644
index 0000000..ff656aa
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinBaseType.java
@@ -0,0 +1,21 @@
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredFeature;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
+
+public abstract class BuiltinBaseType implements DeclaredType {
+
+ private String name;
+
+ public BuiltinBaseType(final String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclaredType#getDeclaredFeatures()
+ */
+ public DeclaredFeature[] getDeclaredFeatures() {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
new file mode 100644
index 0000000..a9d44a8
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/BuiltinDeclarationsContributor.java
@@ -0,0 +1,74 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG 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
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclarationsContributor;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredFunction;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public class BuiltinDeclarationsContributor implements DeclarationsContributor {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#functionsForName(java.lang.String)
+ */
+ public DeclaredFunction[] functionsForName(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.xand3.analyzation.typesystem.DeclarationsContributor#typeForName(java.lang.String)
+ */
+ public DeclaredType typeForName(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public static final String OBJECT = "Object";
+
+ // Datatypes
+ public final static String STRING = "String";
+
+ public final static String BOOLEAN = "Boolean";
+
+ public final static String INTEGER = "Integer";
+
+ public final static String REAL = "Real";
+
+ // Collection types
+ public final static String COLLECTION = "Collection";
+
+ public final static String SET = "Set";
+
+ public final static String LIST = "List";
+
+ // reflection layer types
+ public static final String TYPE = "Type";
+
+ public static final String FEATURE = "Feature";
+
+ public static final String PROPERTY = "Property";
+
+ public static final String OPERATION = "Operation";
+
+ public static final String STATIC_PROPERTY = "StaticProperty";
+
+ public static final String VOID = "Void";
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java
new file mode 100644
index 0000000..5bca95c
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/CollectionTypeImpl.java
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.ParameterizedType;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class CollectionTypeImpl extends BuiltinBaseType implements ParameterizedType {
+ private Type innerType;
+
+ public CollectionTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
+ super(ts, name);
+ this.innerType = innerType;
+ }
+
+ public Type getInnerType() {
+ return innerType;
+ }
+
+ public ParameterizedType cloneWithInnerType(final Type innerType) {
+ return (ParameterizedType) getTypeSystem().getCollectionType(innerType);
+ }
+
+ @Override
+ protected boolean internalIsAssignableFrom(final Type t) {
+ return super.internalIsAssignableFrom(t);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Collection;
+ }
+
+ public Object newInstance() {
+ return new ArrayList<Object>();
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "toList", getTypeSystem().getListType(getInnerType())) {
+
+ @Override
+ public String getDocumentation() {
+ return "converts this collection to List";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new ArrayList<Object>(((Collection<?>) target));
+ }
+
+ @Override
+ public Type getReturnType(final Type targetType, final Type[] paramTypes) {
+ if (!(targetType instanceof ParameterizedType))
+ return getReturnType();
+ final TypeSystem ts = getTypeSystem();
+ return ts.getListType(((ParameterizedType) targetType).getInnerType());
+ }
+ },
+
+ new OperationImpl(this, "toSet", getTypeSystem().getSetType(getInnerType())) {
+
+ @Override
+ public String getDocumentation() {
+ return "converts this collection to Set";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new java.util.HashSet<Object>((Collection<?>) target);
+ }
+
+ @Override
+ public Type getReturnType(final Type targetType, final Type[] paramTypes) {
+ if (!(targetType instanceof ParameterizedType))
+ return getReturnType();
+ final TypeSystem ts = getTypeSystem();
+ return ts.getSetType(((ParameterizedType) targetType).getInnerType());
+ }
+ },
+
+ new OperationImpl(this, "toString", getTypeSystem().getStringType(), getTypeSystem()
+ .getStringType() ) {
+
+ @Override
+ public String getDocumentation() {
+ return "concatenates each contained element (using toString()), separated by the specified String.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final StringBuffer buff = new StringBuffer();
+ for (final Iterator<?> iter = ((Collection<?>) target).iterator(); iter.hasNext();) {
+ buff.append(iter.next().toString());
+ if (iter.hasNext()) {
+ buff.append(params[0].toString());
+ }
+ }
+ return buff.toString();
+ }
+ },
+
+ new PropertyImpl(this, "size", getTypeSystem().getIntegerType()) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns the size of this Collection";
+ }
+
+ public Object get(final Object target) {
+ return new Long(((Collection<?>) target).size());
+ }
+ },
+
+ new PropertyImpl(this, "isEmpty", getTypeSystem().getBooleanType()) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns true if this Collection is empty";
+ }
+
+ public Object get(final Object target) {
+ return new Boolean(((Collection<?>) target).size() == 0);
+ }
+ },
+
+ new OperationImpl(this, "add", this, getInnerType() ) {
+
+ @Override
+ public String getDocumentation() {
+ return "adds an element to the Collection (modifies it!). returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ ((Collection<Object>) target).add(params[0]);
+ return target;
+ }
+ },
+
+ new OperationImpl(this, "addAll", this, getTypeSystem().getCollectionType(
+ getInnerType()) ) {
+
+ @Override
+ public String getDocumentation() {
+ return "adds all elements to the Collection (modifies it!). returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ ((Collection<?>) target).addAll((Collection) params[0]);
+ return target;
+ }
+ },
+
+ new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), getTypeSystem()
+ .getObjectType() ) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns true if this collection contains the specified object. otherwise false. returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return Boolean.valueOf(((Collection) target).contains(params[0]));
+ }
+ },
+
+ new OperationImpl(this, "containsAll", getTypeSystem().getBooleanType(), getTypeSystem()
+ .getCollectionType(getTypeSystem().getObjectType()) ) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns true if this collection contains each element contained in the specified collection. otherwise false. returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return Boolean.valueOf(((Collection) target).containsAll((Collection) params[0]));
+ }
+ },
+
+ new OperationImpl(this, "remove", this, getTypeSystem().getObjectType() ) {
+
+ @Override
+ public String getDocumentation() {
+ return "removes the specified element from this Collection if contained (modifies it!). returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ ((Collection) target).remove(params[0]);
+ return target;
+ }
+ },
+
+ new OperationImpl(this, "removeAll", this, getTypeSystem().getObjectType() ) {
+
+ @Override
+ public String getDocumentation() {
+ return "removes all elements contained in the specified collection from this Collection if contained (modifies it!). returns this Collection.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ ((Collection) target).removeAll((Collection) params[0]);
+ return target;
+ }
+ },
+
+ new OperationImpl(this, "union", getTypeSystem().getSetType(getInnerType()),
+ getTypeSystem().getCollectionType(getTypeSystem().getObjectType())) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a new Set, containing all elements from this and the specified Collection";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final Set r = new HashSet((Collection) target);
+ r.addAll((Collection) params[0]);
+ return r;
+ }
+ },
+
+ new OperationImpl(this, "without", getTypeSystem().getSetType(getInnerType()),
+ getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a new Set, containing all elements from this Collection without the elements from specified Collection";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final Set r = new HashSet((Collection) target);
+ r.removeAll((Collection) params[0]);
+ return r;
+ }
+ },
+
+ new OperationImpl(this, "intersect", getTypeSystem().getSetType(getInnerType()),
+ getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a new Set, containing only the elements contained in this and the specified Collection";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final Set r = new HashSet((Collection) target);
+ r.retainAll((Collection) params[0]);
+ return r;
+ }
+ },
+
+ new OperationImpl(this, "flatten", getTypeSystem().getListType(getTypeSystem().getObjectType()),
+ new Type[0]) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a flatten List.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return flattenRec((Collection) target);
+ }
+
+ public List<Object> flattenRec(final Collection col) {
+ final List<Object> result = new ArrayList<Object>();
+ for (final Object element : col) {
+ if (element instanceof Collection) {
+ result.addAll(flattenRec((Collection) element));
+ } else {
+ result.add(element);
+ }
+ }
+ return result;
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ @Override
+ public String toString() {
+ String s = getName();
+ if (innerType != null) {
+ s += "[" + innerType + "]";
+ }
+ return s;
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java
new file mode 100644
index 0000000..115f66f
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/FeatureTypeImpl.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class FeatureTypeImpl extends BuiltinBaseType implements Type {
+
+ public FeatureTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Feature;
+ }
+
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] { new PropertyImpl(this, "name", getTypeSystem().getStringType()) {
+ public Object get(final Object target) {
+ return ((Feature) target).getName();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("property name is unsettable!");
+ }
+
+ }, new PropertyImpl(this, "returnType", getTypeSystem().getTypeType()) {
+ public Object get(final Object target) {
+ return ((Feature) target).getReturnType();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("property name is unsettable!");
+ }
+
+ }, new PropertyImpl(this, "owner", getTypeSystem().getTypeType()) {
+ public Object get(final Object target) {
+ return ((Feature) target).getOwner();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("property name is unsettable!");
+ }
+
+ }, new PropertyImpl(this, "documentation", getTypeSystem().getStringType()) {
+
+ public Object get(final Object target) {
+ return ((Feature) target).getDocumentation();
+ }
+ } };
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java
new file mode 100644
index 0000000..dfc0c2d
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/IntegerTypeImpl.java
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+public final class IntegerTypeImpl extends BuiltinBaseType implements Type {
+
+ public IntegerTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Integer || o instanceof BigInteger || o instanceof Byte || o instanceof Long
+ || o instanceof Short;
+ }
+
+ public Object newInstance() {
+ return new Long(-1);
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "+", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+ return new Long(((Number) target).longValue() + ((Number) params[0]).longValue());
+ }
+ },
+ new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+ return new Long(((Number) target).longValue() - ((Number) params[0]).longValue());
+ }
+ },
+ new OperationImpl(this, "-", IntegerTypeImpl.this, new Type[] {}) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new Long(((Number) target).longValue() * -1l);
+ }
+ },
+ new OperationImpl(this, "*", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Long(((Number) target).longValue() * ((Number) params[0]).longValue());
+ }
+ },
+ new OperationImpl(this, "/", IntegerTypeImpl.this, new Type[] { IntegerTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Long(((Number) target).longValue() / ((Number) params[0]).longValue());
+ }
+ },
+ new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return new Boolean(target == params[0]);
+
+ try {
+ return toLong(target).equals(toLong(params[0]));
+ }
+ catch (Exception exc) {
+ if (target instanceof Number && params[0] instanceof Number)
+ return ((Number) target).doubleValue() == ((Number) params[0]).doubleValue();
+
+ return false;
+ }
+ }
+
+ },
+ new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] != null;
+
+ try {
+ return ! toLong(target).equals(toLong(params[0]));
+ }
+ catch (Exception exc) {
+ if (target instanceof Number && params[0] instanceof Number)
+ return ((Number) target).doubleValue() != ((Number) params[0]).doubleValue();
+
+ return true;
+ }
+ }
+ },
+ new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+
+ try {
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) > 0;
+ }
+ catch (Exception exc) {
+ return ((Number) target).doubleValue() > ((Number) params[0]).doubleValue();
+ }
+ }
+ },
+ new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+
+ try {
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) >= 0;
+ }
+ catch (Exception exc) {
+ return ((Number) target).doubleValue() >= ((Number) params[0]).doubleValue();
+ }
+ }
+ },
+ new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+
+ try {
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) < 0;
+ }
+ catch (Exception exc) {
+ return ((Number) target).doubleValue() < ((Number) params[0]).doubleValue();
+ }
+ }
+ },
+ new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+
+ try {
+ return ((Comparable<Long>) toLong(target)).compareTo(toLong(params[0])) <= 0;
+ }
+ catch (Exception exc) {
+ return ((Number) target).doubleValue() <= ((Number) params[0]).doubleValue();
+ }
+ }
+ }, new OperationImpl(this, "upTo", getTypeSystem().getListType(this), new Type[] { this }) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a List of Integers starting with the value of the target expression, up to "
+ + "the value of the specified Integer, incremented by one."
+ + "e.g. '1.upTo(5)' evaluates to {1,2,3,4,5}";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final List<Long> result = new ArrayList<Long>();
+ long l1 = toLong(target).longValue();
+ final long l2 = toLong(params[0]).longValue();
+
+ while (l1 <= l2) {
+ result.add(new Long(l1));
+ l1++;
+ }
+ return result;
+ }
+ }, new OperationImpl(this, "upTo", getTypeSystem().getListType(this), new Type[] { this, this }) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns a List of Integers starting with the value of the target expression, up to "
+ + "the value of the first paramter, incremented by the second parameter."
+ + "e.g. '1.upTo(10, 2)' evaluates to {1,3,5,7,9}";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final List<Long> result = new ArrayList<Long>();
+ long l1 = toLong(target).longValue();
+ final long l2 = toLong(params[0]).longValue();
+ final long l3 = toLong(params[1]).longValue();
+
+ while (l1 <= l2) {
+ result.add(new Long(l1));
+ l1 = l1 + l3;
+ }
+ return result;
+ }
+ } };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getRealType());
+ }
+
+ Long toLong(final Object o) {
+ if (o == null)
+ return null;
+
+ if (o instanceof Integer)
+ return new Long(((Integer) o).longValue());
+ else if (o instanceof BigInteger)
+ return new Long(((BigInteger) o).longValue());
+ else if (o instanceof Byte)
+ return new Long(((Byte) o).longValue());
+ else if (o instanceof Long)
+ return (Long) o;
+ else if (o instanceof Short)
+ return new Long(((Short) o).longValue());
+ throw new IllegalArgumentException(o.getClass().getName() + " not supported");
+ }
+
+ @Override
+ public Object convert(final Object src, final Class<?> targetType) {
+ final Long l = toLong(src);
+ if (targetType.isAssignableFrom(Integer.class) || targetType.isAssignableFrom(Integer.TYPE))
+ return new Integer(l.intValue());
+ else if (targetType.isAssignableFrom(BigInteger.class))
+ return BigInteger.valueOf(l.longValue());
+ else if (targetType.isAssignableFrom(Byte.class) || targetType.isAssignableFrom(Byte.TYPE))
+ return new Byte(l.byteValue());
+ else if (targetType.isAssignableFrom(Long.class) || targetType.isAssignableFrom(Long.TYPE))
+ return src;
+ else if (targetType.isAssignableFrom(Short.class) || targetType.isAssignableFrom(Short.TYPE))
+ return new Short(l.shortValue());
+ return super.convert(src, targetType);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java
new file mode 100644
index 0000000..e4299ab
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ListTypeImpl.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.ParameterizedType;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class ListTypeImpl extends CollectionTypeImpl implements Type {
+
+ public ListTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
+ super(innerType, ts, name);
+ }
+
+ @Override
+ public boolean isInstance(final Object o) {
+ return o instanceof List;
+ }
+
+ @Override
+ public Object newInstance() {
+ return new ArrayList<Object>();
+ }
+
+ @Override
+ public ParameterizedType cloneWithInnerType(final Type innerType) {
+ return (ParameterizedType) getTypeSystem().getListType(innerType);
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] { new OperationImpl(this, "get", getInnerType(), new Type[] { getTypeSystem().getIntegerType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((List<?>) target).get(((Number) params[0]).intValue());
+ }
+ }, new OperationImpl(this, "indexOf", getTypeSystem().getIntegerType(), new Type[] { getTypeSystem().getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new Long(((List<?>) target).indexOf(params[0]));
+ }
+ }, new OperationImpl(this, "first", getInnerType(), new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target instanceof List) {
+ List<?> l = (List<?>) target;
+ if (l.size() > 0)
+ return l.get(0);
+ }
+ return null;
+ }
+ }, new OperationImpl(this, "reverse", getInnerType(), new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target instanceof List) {
+ List<?> l = new ArrayList ((List<?>) target);
+ Collections.reverse(l);
+ return l;
+ }
+ return null;
+ }
+ }, new OperationImpl(this, "last", getInnerType(), new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target instanceof List) {
+ List<?> l = (List<?>) target;
+ if (l.size() > 0)
+ return l.get(l.size() - 1);
+ }
+ return null;
+ }
+ }, new OperationImpl(this, "withoutFirst", this, new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target instanceof List) {
+ List l = (List) target;
+ List r = new ArrayList();
+ for (int i = 1; i < l.size(); i++) {
+ r.add(l.get(i));
+ }
+ return r;
+ }
+ return null;
+ }
+ }, new OperationImpl(this, "withoutLast", this, new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target instanceof List) {
+ List l = (List) target;
+ List r = new ArrayList();
+ for (int i = 0; i < l.size() - 1; i++) {
+ r.add(l.get(i));
+ }
+ return r;
+ }
+ return null;
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getCollectionType(getInnerType()));
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java
new file mode 100644
index 0000000..c39fcaf
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/ObjectTypeImpl.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Operation;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class ObjectTypeImpl extends BuiltinBaseType implements Type {
+
+ public ObjectTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return new Boolean(target == params[0]);
+ return new Boolean(target.equals(params[0]));
+ }
+ }, new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return new Boolean(target != params[0]);
+ return new Boolean(!target.equals(params[0]));
+ }
+ }, new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Object>) target).compareTo(params[0]) > 0);
+ }
+ }, new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Object>) target).compareTo(params[0]) >= 0);
+ }
+ }, new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Object>) target).compareTo(params[0]) < 0);
+ }
+ }, new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { ObjectTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Object>) target).compareTo(params[0]) <= 0);
+ }
+ }, new PropertyImpl(this, "metaType", getTypeSystem().getTypeType()) {
+ @Override
+ public String getDocumentation() {
+ return "returns this object's meta type.";
+ }
+
+ public Object get(final Object target) {
+ return getTypeSystem().getType(target);
+ }
+ }, new OperationImpl(this, "toString", getTypeSystem().getStringType()) {
+ @Override
+ public String getDocumentation() {
+ return "returns the String representation of this object. (Calling Java's toString() method)";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target != null ? target.toString() : "null";
+ }
+ }, new OperationImpl(this, "compareTo", getTypeSystem().getIntegerType(), new Type[] { this }) {
+ @Override
+ public String getDocumentation() {
+ return "Compares this object with the specified object for order. Returns a negative "
+ + "integer, zero, or a positive integer as this object is less than, equal to, "
+ + "or greater than the specified object.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? new Long(0) : new Long(-1);
+ if (params[0] == null)
+ return new Long(1);
+ if (target instanceof Comparable)
+ return new Long(((Comparable<Object>) target).compareTo(params[0]));
+ else {
+ final TypeSystem ts = getTypeSystem();
+ Operation op = ts.findOperation("toString", target, null);
+ final String s1 = (String) op.evaluate(target, null);
+ op = ts.findOperation("toString", params[0], null);
+ final String s2 = (String) op.evaluate(params[0], null);
+ ;
+ return new Long(s1.compareTo(s2));
+ }
+ }
+ } };
+ }
+
+ public boolean isInstance(final Object o) {
+ return true;
+ }
+
+ public Object newInstance() {
+ return new Object();
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.EMPTY_SET;
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java
new file mode 100644
index 0000000..e49d372
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/OperationTypeImpl.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Operation;
+import org.eclipse.xtend.typesystem.Type;
+
+public final class OperationTypeImpl extends FeatureTypeImpl implements Type {
+
+ public OperationTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ @Override
+ public boolean isInstance(final Object o) {
+ return o instanceof Operation;
+ }
+
+ @Override
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getFeatureType());
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "evaluate", getTypeSystem().getObjectType(),
+ getTypeSystem().getObjectType(), getTypeSystem().getListType(null)) {
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Operation) target).evaluate(target, ((List<?>) params[0]).toArray());
+ }
+
+ },
+ new OperationImpl(this, "getParameterTypes",
+ getTypeSystem().getListType(getTypeSystem().getTypeType())) {
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Operation) target).getParameterTypes();
+ }
+
+ } };
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java
new file mode 100644
index 0000000..9286b89
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/PropertyTypeImpl.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Property;
+import org.eclipse.xtend.typesystem.Type;
+
+public final class PropertyTypeImpl extends BuiltinBaseType {
+
+ public PropertyTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Property;
+ }
+
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getFeatureType());
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "get", getTypeSystem().getObjectType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Property) target).get(params[0]);
+ }
+ },
+ new OperationImpl(this, "set", getTypeSystem().getVoidType(), new Type[] {
+ getTypeSystem().getObjectType(), getTypeSystem().getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ ((Property) target).set(params[0], params[1]);
+ return null;
+ }
+ }
+
+ };
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java
new file mode 100644
index 0000000..e961596
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/RealTypeImpl.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class RealTypeImpl extends BuiltinBaseType implements Type {
+
+ public RealTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new OperationImpl(this, "+", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Double(((Number) target).doubleValue() + ((Number) params[0]).doubleValue());
+ }
+ },
+ new OperationImpl(this, "-", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Double(((Number) target).doubleValue() - ((Number) params[0]).doubleValue());
+ }
+ },
+ new OperationImpl(this, "-", RealTypeImpl.this, new Type[] {}) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new Double(((Number) target).doubleValue() * -1.0d);
+ }
+ },
+ new OperationImpl(this, "*", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Double(((Number) target).doubleValue() * ((Number) params[0]).doubleValue());
+ }
+ },
+ new OperationImpl(this, "/", RealTypeImpl.this, new Type[] { RealTypeImpl.this }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (params[0] == null)
+ return null;
+
+ return new Double(((Number) target).doubleValue() / ((Number) params[0]).doubleValue());
+ }
+ },
+ new OperationImpl(this, "==", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return new Boolean(target == params[0]);
+
+ try {
+ return toDouble(target).equals(toDouble(params[0]));
+ }
+ catch (Exception exc) {
+ return false;
+ }
+ }
+
+ },
+ new OperationImpl(this, "!=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return new Boolean(target != params[0]);
+
+ try {
+ return !toDouble(target).equals(toDouble(params[0]));
+ }
+ catch (Exception exc) {
+ return true;
+ }
+ }
+ },
+ new OperationImpl(this, ">", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) > 0);
+ }
+ },
+ new OperationImpl(this, ">=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) >= 0);
+ }
+ },
+ new OperationImpl(this, "<", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) < 0);
+ }
+ },
+ new OperationImpl(this, "<=", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ if (target == null)
+ return params[0] == null ? Boolean.TRUE : Boolean.FALSE;
+ if (params[0] == null)
+ return Boolean.FALSE;
+ return new Boolean(((Comparable<Double>) toDouble(target)).compareTo(toDouble(params[0])) <= 0);
+ }
+ } };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Double || o instanceof Float || o instanceof BigDecimal;
+ }
+
+ public Object newInstance() {
+ return new Double(1);
+ }
+
+ private Double toDouble(final Object o) {
+ if (o == null)
+ return null;
+
+ if (o instanceof Number)
+ return ((Number) o).doubleValue();
+
+ throw new IllegalArgumentException(o.getClass().getName() + " not supported");
+ }
+
+ @Override
+ public Object convert(final Object src, final Class<?> targetType) {
+ final Double l = toDouble(src);
+ if (targetType.isAssignableFrom(Double.class) || targetType.isAssignableFrom(Double.TYPE))
+ return l;
+ else if (targetType.isAssignableFrom(Float.class) || targetType.isAssignableFrom(Float.TYPE))
+ return new Float(l.doubleValue());
+ else if (targetType.isAssignableFrom(BigDecimal.class))
+ return new BigDecimal(l.doubleValue());
+ return super.convert(src, targetType);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java
new file mode 100644
index 0000000..a905407
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/SetTypeImpl.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.ParameterizedType;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class SetTypeImpl extends CollectionTypeImpl {
+
+ public SetTypeImpl(final Type innerType, final TypeSystem ts, final String name) {
+ super(innerType, ts, name);
+ }
+
+ @Override
+ public boolean isInstance(final Object o) {
+ return o instanceof Set;
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {};
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getCollectionType(getInnerType()));
+ }
+
+ @Override
+ public Object newInstance() {
+ return new HashSet<Object>();
+ }
+
+ @Override
+ public ParameterizedType cloneWithInnerType(final Type innerType) {
+ return (ParameterizedType) getTypeSystem().getSetType(innerType);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java
new file mode 100644
index 0000000..1ef725f
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StaticPropertyTypeImpl.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.StaticProperty;
+import org.eclipse.xtend.typesystem.Type;
+
+public final class StaticPropertyTypeImpl extends BuiltinBaseType {
+
+ public StaticPropertyTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof StaticProperty;
+ }
+
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getFeatureType());
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] { new OperationImpl(this, "get", getTypeSystem().getObjectType(), new Type[] {}) {
+
+ @Override
+ public String getDocumentation() {
+ return "returns the static value";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((StaticProperty) target).get();
+ }
+ } };
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java
new file mode 100644
index 0000000..0c790bf
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/StringTypeImpl.java
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
+import org.eclipse.internal.xtend.util.StringHelper;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class StringTypeImpl extends BuiltinBaseType implements Type {
+ final Log log = LogFactory.getLog(getClass());
+
+ public StringTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof String || o instanceof StringBuffer || o instanceof Character;
+ }
+
+ public Object newInstance() {
+ return "";
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new PropertyImpl(this, "length", getTypeSystem().getIntegerType()) {
+
+ @Override
+ public String getDocumentation() {
+ return "the length of this string";
+ }
+
+ public Object get(final Object target) {
+ return new Long(target.toString().length());
+ }
+ },
+
+ new OperationImpl(this, "+", getTypeSystem().getStringType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "concatenates two strings";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target.toString() + params[0];
+ }
+ },
+
+ new OperationImpl(this, "startsWith", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Tests if this string starts with the specified prefix.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final String token = (String) params[0];
+ return new Boolean(target.toString().startsWith(token));
+ }
+ },
+ new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Tests if this string contains substring.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final String token = (String) params[0];
+ return new Boolean(target.toString().indexOf(token) >= 0);
+ }
+ },
+ new OperationImpl(this, "endsWith", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Tests if this string ends with the specified prefix.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final String token = (String) params[0];
+ return new Boolean(target.toString().endsWith(token));
+ }
+ },
+ new OperationImpl(this, "subString", getTypeSystem().getStringType(), new Type[] { getTypeSystem()
+ .getIntegerType(),getTypeSystem().getIntegerType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Tests if this string ends with the specified prefix.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final Number from = (Number) params[0];
+ final Number to = (Number) params[1];
+ return target.toString().substring(from.intValue(),to.intValue());
+ }
+ },
+
+ new OperationImpl(this, "toUpperCase", getTypeSystem().getStringType(), new Type[] {}) {
+
+ @Override
+ public String getDocumentation() {
+ return "Converts all of the characters in this String to upper"
+ + " case using the rules of the default locale (from Java)";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target.toString().toUpperCase();
+ }
+ },
+
+ new OperationImpl(this, "toLowerCase", getTypeSystem().getStringType(), new Type[] {}) {
+ @Override
+ public String getDocumentation() {
+ return "Converts all of the characters in this String to lower"
+ + " case using the rules of the default locale (from Java)";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target.toString().toLowerCase();
+ }
+ },
+
+ new OperationImpl(this, "toFirstUpper", getTypeSystem().getStringType(), new Type[] {}) {
+ @Override
+ public String getDocumentation() {
+ return "Converts the first character in this String to upper"
+ + " case using the rules of the default locale (from Java)";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return StringHelper.firstUpper(target.toString());
+ }
+ },
+
+ new OperationImpl(this, "toFirstLower", getTypeSystem().getStringType(), new Type[] {}) {
+ @Override
+ public String getDocumentation() {
+ return "Converts the first character in this String to lower"
+ + " case using the rules of the default locale (from Java)";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return StringHelper.firstLower(target.toString());
+ }
+ },
+
+ new OperationImpl(this, "toCharList", getTypeSystem().getListType(getTypeSystem().getStringType()),
+ new Type[] {}) {
+
+ @Override
+ public String getDocumentation() {
+ return "splits this String into a List[String] containing Strings of length 1";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final String txt = target.toString();
+ final List<String> result = new ArrayList<String>();
+ final char[] chars = txt.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ result.add(String.valueOf(chars[i]));
+ }
+ return result;
+ }
+ },
+
+ new OperationImpl(this, "replaceAll", getTypeSystem().getStringType(), new Type[] {
+ getTypeSystem().getStringType(), getTypeSystem().getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Replaces each substring of this string that matches the given "
+ + "regular expression with the given replacement.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target.toString().replaceAll(params[0].toString(), params[1].toString());
+ }
+ },
+
+ new OperationImpl(this, "replaceFirst", getTypeSystem().getStringType(), new Type[] {
+ getTypeSystem().getStringType(), getTypeSystem().getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Replaces the first substring of this string that matches the given"
+ + " regular expression with the given replacement.";
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return target.toString().replaceFirst(params[0].toString(), params[1].toString());
+ }
+ },
+
+ new OperationImpl(this, "split", getTypeSystem().getListType(getTypeSystem().getStringType()),
+ new Type[] { getTypeSystem().getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Splits this string around matches of the given regular expression (from Java 1.4)";
+
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new ArrayList<String>(Arrays.asList(target.toString().split(params[0].toString())));
+ }
+ },
+
+ new OperationImpl(this, "matches", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getStringType() }) {
+
+ @Override
+ public String getDocumentation() {
+ return "Tells whether or not this string matches the given regular expression. (from Java 1.4)";
+
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return Boolean.valueOf(((String) target).matches((String) params[0]));
+ }
+ },
+
+ new OperationImpl(this, "trim", getTypeSystem().getStringType(), new Type[] {}) {
+
+ @Override
+ public String getDocumentation() {
+ return "Returns a copy of the string, with leading and trailing whitespace omitted. (from Java 1.4)";
+
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((String) target).trim();
+ }
+ },
+
+ new OperationImpl(this, "asInteger", getTypeSystem().getIntegerType(), new Type[] {}) {
+
+ @Override
+ public String getDocumentation() {
+ return "Returns an Integer object holding the value of the specified String (from Java 1.5)";
+
+ }
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ try {
+ return Integer.valueOf((String) target);
+ } catch (NumberFormatException nfe) {
+ log.error("'asInteger' on '"+target+"' returned null!");
+ return null;
+ }
+ }
+ }
+
+ };
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ private String toString(final Object o) {
+ if (o == null)
+ return null;
+ if (isInstance(o))
+ return o.toString();
+ throw new IllegalArgumentException(o.getClass().getName() + " not supported");
+ }
+
+ @Override
+ public Object convert(final Object src, final Class targetType) {
+ final String s = toString(src);
+ if (targetType.isAssignableFrom(String.class))
+ return s;
+ else if (targetType.isAssignableFrom(Character.class) || targetType.isAssignableFrom(Character.TYPE)) {
+ if (s.length() == 1)
+ return new Character(s.charAt(0));
+ } else if (targetType.isAssignableFrom(StringBuffer.class))
+ return new StringBuffer(s);
+ return super.convert(src, targetType);
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java
new file mode 100644
index 0000000..7ac8383
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/TypeTypeImpl.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.internal.xtend.type.baseimpl.OperationImpl;
+import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl;
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class TypeTypeImpl extends BuiltinBaseType {
+
+ public TypeTypeImpl(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ public boolean isInstance(final Object o) {
+ return o instanceof Type;
+ }
+
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[] {
+ new PropertyImpl(this, "name", getTypeSystem().getStringType()) {
+ public Object get(final Object target) {
+ final Type t = (Type) target;
+ return t.getName();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+
+ },
+
+ new PropertyImpl(this, "superTypes", getTypeSystem().getSetType(getTypeSystem().getTypeType())) {
+ public Object get(final Object target) {
+ return ((Type) target).getSuperTypes();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+ },
+
+ new PropertyImpl(this, "allFeatures", getTypeSystem().getSetType(getTypeSystem().getFeatureType())) {
+ public Object get(final Object target) {
+ return ((Type) target).getAllFeatures();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+ },
+
+ new PropertyImpl(this, "allProperties", getTypeSystem().getSetType(getTypeSystem().getPropertyType())) {
+ public Object get(final Object target) {
+ return ((Type) target).getAllProperties();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+ },
+ new PropertyImpl(this, "allOperations", getTypeSystem().getSetType(getTypeSystem().getOperationType())) {
+ public Object get(final Object target) {
+ return ((Type) target).getAllOperations();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+ },
+
+ new PropertyImpl(this, "allStaticProperties", getTypeSystem().getSetType(
+ getTypeSystem().getStaticPropertyType())) {
+ public Object get(final Object target) {
+ return ((Type) target).getAllStaticProperties();
+ }
+
+ @Override
+ public void set(final Object target, final Object val) {
+ throw new UnsupportedOperationException("unsettable!");
+ }
+ },
+ new OperationImpl(this, "getFeature", getTypeSystem().getFeatureType(), new Type[] {
+ getTypeSystem().getStringType(), getTypeSystem().getListType(null) }) {
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final List l = (List) params[1];
+ final Type[] ta = (Type[]) l.toArray(new Type[l.size()]);
+ return ((Type) target).getFeature((String) params[0], ta);
+ }
+ },
+
+ new OperationImpl(this, "getProperty", getTypeSystem().getPropertyType(), new Type[] { getTypeSystem()
+ .getStringType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Type) target).getProperty((String) params[0]);
+ }
+ },
+
+ new OperationImpl(this, "getOperation", getTypeSystem().getOperationType(), new Type[] {
+ getTypeSystem().getStringType(), getTypeSystem().getListType(null) }) {
+
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ final List l = (List) params[1];
+ final Type[] ta = (Type[]) l.toArray(new Type[l.size()]);
+ return ((Type) target).getOperation((String) params[0], ta);
+ }
+ },
+
+ new OperationImpl(this, "getStaticProperty", getTypeSystem().getStaticPropertyType(),
+ new Type[] { getTypeSystem().getStringType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Type) target).getStaticProperty((String) params[0]);
+ }
+ },
+
+ new OperationImpl(this, "newInstance", getTypeSystem().getObjectType(), new Type[0]) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Type) target).newInstance();
+ }
+ },
+ new OperationImpl(this, "isInstance", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getObjectType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return new Boolean(((Type) target).isInstance(params[0]));
+ }
+ }, new OperationImpl(this, "isAssignableFrom", getTypeSystem().getBooleanType(), new Type[] { getTypeSystem()
+ .getTypeType() }) {
+ @Override
+ public Object evaluateInternal(final Object target, final Object[] params) {
+ return ((Type) target).isAssignableFrom((Type) params[0]);
+ }
+ }, new PropertyImpl(this, "documentation", getTypeSystem().getStringType()) {
+
+ public Object get(final Object target) {
+ return ((Type) target).getDocumentation();
+ }
+ }
+
+ };
+ }
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java
new file mode 100644
index 0000000..f320de1
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/builtin/VoidType.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 committers of openArchitectureWare 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
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.xand3.analyzation.typesystem.builtin;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.xtend.expression.TypeSystem;
+import org.eclipse.xtend.typesystem.AbstractTypeImpl;
+import org.eclipse.xtend.typesystem.Feature;
+import org.eclipse.xtend.typesystem.Type;
+
+/**
+ * @author Sven Efftinge (http://www.efftinge.de)
+ * @author Arno Haase
+ */
+public class VoidType extends AbstractTypeImpl implements Type {
+
+ public VoidType(final TypeSystem ts, final String name) {
+ super(ts, name);
+ }
+
+ @Override
+ public Feature[] getContributedFeatures() {
+ return new Feature[0];
+ }
+
+ public boolean isInstance(final Object o) {
+ return o == null;
+ }
+
+ public Object newInstance() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isAbstract() {
+ return true;
+ }
+
+ @Override
+ public Set<Type> getSuperTypes() {
+ return Collections.singleton(getTypeSystem().getObjectType());
+ }
+
+ @Override
+ public String getDocumentation() {
+ return "Void is used as an undefined type. It's only instance is the null reference.";
+ }
+
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java
new file mode 100644
index 0000000..8f9be02
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclarationsContributor.java
@@ -0,0 +1,27 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG 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
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import java.util.List;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclarationsContributor {
+ DeclaredType typeForName(String name);
+ List<DeclaredFunction> functionsForName(String name);
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFeature.java
index d7d3590..584b9a6 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFeature.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFeature.java
@@ -13,7 +13,9 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import org.eclipse.xand3.analyzation.typesystem.AbstractNamed;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFunction.java
index f03b8db..fc16d44 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredFunction.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredFunction.java
@@ -13,7 +13,12 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.typesystem.AbstractNamed;
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
/**
* @author Sven Efftinge
@@ -22,5 +27,5 @@ package org.eclipse.xand3.analyzation.typesystem;
public interface DeclaredFunction extends AbstractNamed {
DeclaredTypeParameter[] getTypeParameters();
TypeMirror getReturnType();
- TypeMirror[] getParameterTypes();
+ List<TypeMirror> getParameterTypes();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredOperation.java
index 953d26d..ebe9e31 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredOperation.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredOperation.java
@@ -13,7 +13,11 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import java.util.List;
+
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
/**
* @author Sven Efftinge
@@ -21,5 +25,5 @@ package org.eclipse.xand3.analyzation.typesystem;
*/
public interface DeclaredOperation extends DeclaredFeature {
TypeMirror getReturnType();
- TypeMirror[] getParameterTypes();
+ List<TypeMirror> getParameterTypes();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredProperty.java
index c4372b6..55fba93 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredProperty.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredProperty.java
@@ -13,7 +13,9 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import org.eclipse.xand3.analyzation.typesystem.type.TypeMirror;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredStaticProperty.java
index e9a45cb..ae49dc8 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredStaticProperty.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredStaticProperty.java
@@ -13,7 +13,9 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredType.java
new file mode 100644
index 0000000..30ad26b
--- /dev/null
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredType.java
@@ -0,0 +1,35 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2002-2007 itemis AG 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
+ *
+ * Contributors:
+ * itemis AG - Initial API and implementation
+ *
+ * </copyright>
+ *
+ */
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
+
+/**
+ * @author Sven Efftinge
+ *
+ */
+public interface DeclaredType {
+ Set<Type> getSuperTypes();
+
+ Set<DeclaredFeature> getDeclaredFeatures();
+ Set<DeclaredProperty> getDeclaredProperties();
+ Set<DeclaredOperation> getDeclaredOperations();
+
+ List<DeclaredTypeParameter> getTypeParameters();
+}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredTypeParameter.java
index 28d52af..4bf2f54 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/DeclaredType.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/declaration/DeclaredTypeParameter.java
@@ -13,18 +13,17 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.declaration;
+
+import java.util.Set;
+
+import org.eclipse.xand3.analyzation.typesystem.AbstractNamed;
+import org.eclipse.xand3.analyzation.typesystem.type.Type;
/**
* @author Sven Efftinge
*
*/
-public interface DeclaredType {
- Type[] getSuperTypes();
-
- DeclaredFeature[] getDeclaredFeatures();
- DeclaredProperty[] getDeclaredProperties();
- DeclaredOperation[] getDeclaredOperations();
-
- DeclaredTypeParameter[] getTypeParameters();
+public interface DeclaredTypeParameter extends AbstractNamed {
+ Set<Type> getUpperBounds();
}
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/Type.java
index be59cbc..2552e93 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/Type.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/Type.java
@@ -13,15 +13,12 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.type;
-public interface Type extends AbstractNamed, TypeMirror {
- Type[] getSuperTypes();
+import org.eclipse.xand3.analyzation.typesystem.AbstractNamed;
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredType;
- Feature[] getFeatures();
- Property[] getProperties();
- Operation[] getOperations();
-
+public interface Type extends AbstractNamed, TypeMirror {
/**
* @return returns either the type this type is a bound instance of or just <code>this</code>, if the originally declared type wasn't generic
*/
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeMirror.java
index 03755e3..8218ed9 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeMirror.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeMirror.java
@@ -13,7 +13,7 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.type;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeVariable.java
index a923951..bf7a98a 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/TypeVariable.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/TypeVariable.java
@@ -13,7 +13,9 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.type;
+
+import org.eclipse.xand3.analyzation.typesystem.declaration.DeclaredTypeParameter;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/VoidType.java
index 5f0acab..d75be9a 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/VoidType.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/VoidType.java
@@ -13,7 +13,7 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.type;
/**
* @author Sven Efftinge
diff --git a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/WildcardType.java
index 78abeb2..04791c4 100644
--- a/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/WildcardType.java
+++ b/plugins/org.eclipse.xpand3/src/org/eclipse/xand3/analyzation/typesystem/type/WildcardType.java
@@ -13,7 +13,7 @@
* </copyright>
*
*/
-package org.eclipse.xand3.analyzation.typesystem;
+package org.eclipse.xand3.analyzation.typesystem.type;
/**
* @author Sven Efftinge