summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahaase2008-02-26 05:51:01 (EST)
committer ahaase2008-02-26 05:51:01 (EST)
commit7c32eb654b09b432c6638533b023e12c67a454c9 (patch)
treec8c098138439f4f2bd53a1aa66f9e983b466045b
parent50c51ce83b405a7bd2bc0b39af85fc4556d88fc8 (diff)
downloadorg.eclipse.xpand-7c32eb654b09b432c6638533b023e12c67a454c9.zip
org.eclipse.xpand-7c32eb654b09b432c6638533b023e12c67a454c9.tar.gz
org.eclipse.xpand-7c32eb654b09b432c6638533b023e12c67a454c9.tar.bz2
finished AOP support and implemented Check middle end
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AdvisedFunction.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AroundAdvice.java2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPoint.java (renamed from plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPoint.java)2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPointStaticPart.java (renamed from plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPointStaticPart.java)2
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/SysLibNames.java1
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldExpressionConverter.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExpressionConverter.java)10
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldHelper.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendHelper.java)4
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldTypeAnalyzer.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldTypeAnalyzer.java)4
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/TypeToBackendType.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/TypeToBackendType.java)12
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldDefinitionConverter.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java)5
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldXpandRegistry.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java)11
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandBackendFacade.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandBackendFacade.java)15
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandComponent.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandComponent.java)2
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandDefinitionName.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandDefinitionName.java)3
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckBackendFacade.java32
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckComponent.java126
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckConverter.java110
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/JavaExtensionFunction.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/JavaExtensionFunction.java)2
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldExtensionConverter.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExtensionConverter.java)4
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldXtendRegistry.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendRegistry.java)20
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendBackendFacade.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendBackendFacade.java)16
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendComponent.java (renamed from plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendComponent.java)2
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java2
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java4
-rw-r--r--tests/org.eclipse.xtend.middleend.old.test/src/org/eclipse/xtend/middleend/old/first/FirstAttempt.java6
26 files changed, 351 insertions, 54 deletions
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AdvisedFunction.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AdvisedFunction.java
index 366440c..ddab16f 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AdvisedFunction.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AdvisedFunction.java
@@ -13,8 +13,6 @@ package org.eclipse.xtend.backend.aop;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.xtend.backend.aop.internal.ThisJoinPoint;
-import org.eclipse.xtend.backend.aop.internal.ThisJoinPointStaticPart;
import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.common.Function;
import org.eclipse.xtend.backend.util.ObjectWrapper;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AroundAdvice.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AroundAdvice.java
index 41013b6..29c9c59 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AroundAdvice.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/AroundAdvice.java
@@ -10,8 +10,6 @@ Contributors:
*/
package org.eclipse.xtend.backend.aop;
-import org.eclipse.xtend.backend.aop.internal.ThisJoinPoint;
-import org.eclipse.xtend.backend.aop.internal.ThisJoinPointStaticPart;
import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.common.ExpressionBase;
import org.eclipse.xtend.backend.common.SyntaxConstants;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPoint.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPoint.java
index f2acddd..1d36a31 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPoint.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPoint.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.backend.aop.internal;
+package org.eclipse.xtend.backend.aop;
import java.util.List;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPointStaticPart.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPointStaticPart.java
index 172ac46..a61f636 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/internal/ThisJoinPointStaticPart.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/aop/ThisJoinPointStaticPart.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.backend.aop.internal;
+package org.eclipse.xtend.backend.aop;
import org.eclipse.xtend.backend.common.Function;
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/SysLibNames.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/SysLibNames.java
index a21f27d..10abd2d 100644
--- a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/SysLibNames.java
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/syslib/SysLibNames.java
@@ -22,6 +22,7 @@ public interface SysLibNames {
String WRITE_TO_FILE = "writeToFile";
String REGISTER_OUTLET = "registerOutlet";
+ String COLLECT = "collect";
String TYPE_SELECT = "typeSelect";
String IMPLIES = "implies";
diff --git a/plugins/org.eclipse.xtend.middleend.old/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtend.middleend.old/META-INF/MANIFEST.MF
index 6d60ffa..f52d9ee 100644
--- a/plugins/org.eclipse.xtend.middleend.old/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.xtend.middleend.old/META-INF/MANIFEST.MF
@@ -12,5 +12,7 @@ Require-Bundle: org.eclipse.xtend.backend,
org.eclipse.xtend.typesystem.emf,
org.eclipse.emf.mwe.core,
org.apache.commons.logging
-Export-Package: org.eclipse.xtend.middleend.old,
- org.eclipse.xtend.middleend.old.internal.xtendlib;x-internal:=true
+Export-Package: org.eclipse.xtend.middleend.old.common,
+ org.eclipse.xtend.middleend.old.internal.xtendlib,
+ org.eclipse.xtend.middleend.old.xpand,
+ org.eclipse.xtend.middleend.old.xtend
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExpressionConverter.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldExpressionConverter.java
index d4b4e1d..099bc00 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExpressionConverter.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldExpressionConverter.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.common;
import java.util.ArrayList;
import java.util.Arrays;
@@ -76,7 +76,7 @@ import org.eclipse.xtend.typesystem.Type;
*
* @author Arno Haase (http://www.haase-consulting.com)
*/
-final class OldExpressionConverter {
+public final class OldExpressionConverter {
private final TypeToBackendType _typeConverter;
private ExecutionContext _ctx;
private final String _extensionName;
@@ -172,7 +172,7 @@ final class OldExpressionConverter {
return false;
final Type target = paramTypes[0];
- return target.getOperation(functionName, CollectionHelper.withoutFirst (paramTypes)) != null;
+ return target.getOperation (functionName, CollectionHelper.withoutFirst (paramTypes)) != null;
}
@@ -318,7 +318,7 @@ final class OldExpressionConverter {
// 3. check for a type literal
try {
- return new LiteralExpression (_typeConverter.convertToBackendType (Arrays.asList (expr.getName().getValue().split(SyntaxConstants.NS_DELIM))), sourcePos);
+ return new LiteralExpression (_typeConverter.convertToBackendType (expr.getName()), sourcePos);
}
catch (IllegalArgumentException exc) {} // do nothing - this means it is not a type literal
@@ -352,7 +352,7 @@ final class OldExpressionConverter {
}
private ExpressionBase convertConstructorCallExpression (ConstructorCallExpression expr) {
- final BackendType t = _typeConverter.convertToBackendType (Arrays.asList(expr.getTypeName()));
+ final BackendType t = _typeConverter.convertToBackendType (expr.getType ());
return new CreateUncachedExpression (t, getSourcePos(expr));
}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendHelper.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldHelper.java
index 9a5f837..0a102d1 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendHelper.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldHelper.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.common;
import java.util.Collection;
@@ -26,7 +26,7 @@ import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel;
*
* @author Arno Haase (http://www.haase-consulting.com)
*/
-final class OldXtendHelper {
+public final class OldHelper {
public static BackendTypesystem guessTypesystem (Collection<MetaModel> mms) {
boolean hasEmf = false;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldTypeAnalyzer.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldTypeAnalyzer.java
index afc0dad..f9b2ab5 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldTypeAnalyzer.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/OldTypeAnalyzer.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.common;
import java.util.Arrays;
import java.util.HashSet;
@@ -62,7 +62,7 @@ import org.eclipse.xtend.typesystem.Type;
*
* @author Arno Haase (http://www.haase-consulting.com)
*/
-public class OldTypeAnalyzer {
+public final class OldTypeAnalyzer {
public Type analyze (ExecutionContext ctx, Extension ext, Type[] paramTypes) {
if (ext instanceof JavaExtensionStatement)
return analyzeJavaExtension (ctx, (JavaExtensionStatement) ext);
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/TypeToBackendType.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/TypeToBackendType.java
index 852dc67..73c06bb 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/TypeToBackendType.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/common/TypeToBackendType.java
@@ -8,14 +8,16 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.common;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.internal.xtend.expression.ast.Identifier;
import org.eclipse.internal.xtend.expression.parser.SyntaxConstants;
import org.eclipse.internal.xtend.type.baseimpl.types.BooleanTypeImpl;
import org.eclipse.internal.xtend.type.baseimpl.types.CollectionTypeImpl;
@@ -59,7 +61,7 @@ import org.eclipse.xtend.typesystem.emf.EObjectType;
*
* @author Arno Haase (http://www.haase-consulting.com)
*/
-final class TypeToBackendType {
+public final class TypeToBackendType {
private final BackendTypesystem _backendTypes;
private final EmfTypesystem _emfTypes;
private final ExecutionContext _ctx;
@@ -77,7 +79,11 @@ final class TypeToBackendType {
_emfTypes = ets;
}
- public BackendType convertToBackendType (List<String> segments) {
+ public BackendType convertToBackendType (Identifier typeName) {
+ return convertToBackendType (Arrays.asList (typeName.getValue().split (SyntaxConstants.NS_DELIM)));
+ }
+
+ private BackendType convertToBackendType (List<String> segments) {
final StringBuilder sb = new StringBuilder();
boolean first = true;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldDefinitionConverter.java
index a2ead0b..f94c1c4 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldDefinitionConverter.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xpand;
import java.util.ArrayList;
import java.util.Arrays;
@@ -59,6 +59,9 @@ import org.eclipse.xtend.backend.types.builtin.ObjectType;
import org.eclipse.xtend.expression.AnalysationIssue;
import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.Variable;
+import org.eclipse.xtend.middleend.old.common.OldExpressionConverter;
+import org.eclipse.xtend.middleend.old.common.OldTypeAnalyzer;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XpandIsDeleteLine;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendIterator;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendLibNames;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldXpandRegistry.java
index 881cb2d..7e126bb 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/OldXpandRegistry.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xpand;
import java.util.ArrayList;
import java.util.Collection;
@@ -27,7 +27,10 @@ import org.eclipse.xtend.backend.common.NamedFunction;
import org.eclipse.xtend.backend.functions.FunctionDefContextFactory;
import org.eclipse.xtend.backend.functions.FunctionDefContextInternal;
import org.eclipse.xtend.backend.util.Cache;
+import org.eclipse.xtend.middleend.old.common.OldHelper;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendLibContributor;
+import org.eclipse.xtend.middleend.old.xtend.OldXtendRegistry;
/**
@@ -61,7 +64,7 @@ final class OldXpandRegistry {
private FunctionDefContextInternal getFunctionDefContext (String xtendName) {
- return _functionDefContexts.get (OldXtendHelper.normalizeXtendResourceName (xtendName));
+ return _functionDefContexts.get (OldHelper.normalizeXtendResourceName (xtendName));
}
@@ -69,12 +72,12 @@ final class OldXpandRegistry {
* parses and converts an Xpand file and all other files it depends on.
*/
public void registerXpandFile (String xpandFile) {
- xpandFile = OldXtendHelper.normalizeXpandResourceName (xpandFile);
+ xpandFile = OldHelper.normalizeXpandResourceName (xpandFile);
if (_functionsByResource.containsKey (xpandFile))
return;
- final String xpandResourceName = OldXtendHelper.xpandFileAsOldResourceName(xpandFile);
+ final String xpandResourceName = OldHelper.xpandFileAsOldResourceName(xpandFile);
final Template file = (Template) _ctx.getResourceManager().loadResource (xpandResourceName, XpandUtil.TEMPLATE_EXTENSION);
if (file == null)
throw new IllegalArgumentException ("could not find Xpand file '" + xpandResourceName + "'");
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandBackendFacade.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandBackendFacade.java
index def5cce..ef21ad2 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandBackendFacade.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandBackendFacade.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xpand;
import java.io.File;
import java.io.StringReader;
@@ -47,6 +47,9 @@ import org.eclipse.xtend.backend.syslib.InMemoryPostprocessor;
import org.eclipse.xtend.backend.syslib.SysLibNames;
import org.eclipse.xtend.backend.syslib.UriBasedPostprocessor;
import org.eclipse.xtend.expression.Variable;
+import org.eclipse.xtend.middleend.old.common.OldHelper;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
+import org.eclipse.xtend.middleend.old.xtend.OldXtendRegistry;
import org.eclipse.xtend.typesystem.MetaModel;
@@ -92,8 +95,8 @@ public final class XpandBackendFacade {
* Both the "variables" and "outlets" parameter may be null.
*/
public static Object executeStatement (String code, String fileEncoding, Collection<MetaModel> mms, Map<String, Object> variables, Collection <Outlet> outlets) {
- fileEncoding = OldXtendHelper.normalizedFileEncoding (fileEncoding);
- final BackendTypesystem ts = OldXtendHelper.guessTypesystem (mms);
+ fileEncoding = OldHelper.normalizedFileEncoding (fileEncoding);
+ final BackendTypesystem ts = OldHelper.guessTypesystem (mms);
if (variables == null)
variables = new HashMap<String, Object> ();
@@ -231,7 +234,7 @@ public final class XpandBackendFacade {
private static XpandExecutionContext createOldExecutionContext (String fileEncoding, Collection<MetaModel> mms, Collection<Outlet> outlets) {
- fileEncoding = OldXtendHelper.normalizedFileEncoding (fileEncoding);
+ fileEncoding = OldHelper.normalizedFileEncoding (fileEncoding);
final Output output = new OutputImpl ();
for (Outlet outlet: outlets)
@@ -247,8 +250,8 @@ public final class XpandBackendFacade {
}
private XpandBackendFacade (String xpandFilename, String fileEncoding, Collection<MetaModel> mms, Collection <Outlet> outlets) {
- _xpandFile = OldXtendHelper.normalizeXpandResourceName (xpandFilename);
- _ts = OldXtendHelper.guessTypesystem (mms);
+ _xpandFile = OldHelper.normalizeXpandResourceName (xpandFilename);
+ _ts = OldHelper.guessTypesystem (mms);
final XpandExecutionContext ctx = createOldExecutionContext (fileEncoding, mms, outlets);
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandComponent.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandComponent.java
index 48244d2..30983fc 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandComponent.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandComponent.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xpand;
import java.io.StringReader;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandDefinitionName.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandDefinitionName.java
index 836b395..c9dcb6f 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XpandDefinitionName.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xpand/XpandDefinitionName.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xpand;
import java.util.List;
@@ -18,6 +18,7 @@ import org.eclipse.internal.xtend.expression.ast.FeatureCall;
import org.eclipse.internal.xtend.expression.ast.Identifier;
import org.eclipse.xpand2.XpandExecutionContext;
import org.eclipse.xtend.expression.ExecutionContext;
+import org.eclipse.xtend.middleend.old.common.OldTypeAnalyzer;
import org.eclipse.xtend.typesystem.Type;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckBackendFacade.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckBackendFacade.java
new file mode 100644
index 0000000..335728c
--- /dev/null
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckBackendFacade.java
@@ -0,0 +1,32 @@
+/*
+Copyright (c) 2008 Arno Haase.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.middleend.old.xtend;
+
+import java.util.Collection;
+
+import org.eclipse.emf.mwe.core.issues.Issues;
+import org.eclipse.xtend.typesystem.MetaModel;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public class CheckBackendFacade {
+
+ public static void checkAll (String xtendFileName, Collection<MetaModel> mms, Issues issues, Collection<?> allObjects) {
+ checkAll (xtendFileName, null, mms, issues, allObjects);
+ }
+
+ public static void checkAll (String xtendFileName, String fileEncoding, Collection<MetaModel> mms, Issues issues, Collection<?> allObjects) {
+ XtendBackendFacade.invokeXtendFunction (xtendFileName, fileEncoding, mms, CheckConverter.ALL_CHECKS_FUNCTION_NAME, issues, allObjects);
+ }
+}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckComponent.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckComponent.java
new file mode 100644
index 0000000..68d23c1
--- /dev/null
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckComponent.java
@@ -0,0 +1,126 @@
+/*
+Copyright (c) 2008 Arno Haase.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.middleend.old.xtend;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.mwe.core.WorkflowContext;
+import org.eclipse.emf.mwe.core.WorkflowInterruptedException;
+import org.eclipse.emf.mwe.core.issues.Issues;
+import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
+import org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent;
+
+
+//TODO test this
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public class CheckComponent extends AbstractExpressionsUsingWorkflowComponent {
+
+ private String _expression = null;
+ private List<String> _checkFiles = new ArrayList<String>();
+ private boolean _abortOnError = true;
+ private boolean _warnIfNothingChecked = false;
+ private String _emfAllChildrenSlot;
+ private String _fileEncoding = null;
+
+ public void setAbortOnError (boolean abortOnError) {
+ _abortOnError = abortOnError;
+ }
+
+ public void addCheckFile (String checkFile) {
+ _checkFiles.add(checkFile);
+ }
+
+ public void setExpression (String expression) {
+ _expression = expression;
+ }
+
+ public void setWarnIfNothingChecked (boolean b) {
+ _warnIfNothingChecked = b;
+ }
+
+ public void setEmfAllChildrenSlot (String childExpression) {
+ _emfAllChildrenSlot = childExpression;
+ }
+
+ public void setFileEncoding (String fileEncoding) {
+ _fileEncoding = fileEncoding;
+ }
+
+ @Override
+ public String getLogMessage() {
+ final StringBuilder result = new StringBuilder ();
+ if ( _emfAllChildrenSlot != null )
+ result.append ("slot " + _emfAllChildrenSlot + " ");
+ else
+ result.append ("expression " + _expression + " ");
+
+ result.append ("check file(s): ");
+ for (String f: _checkFiles)
+ result.append (f + " ");
+
+ return result.toString();
+ }
+
+
+ @Override
+ protected void invokeInternal2 (WorkflowContext wfCtx, ProgressMonitor monitor, Issues issues) {
+ final Collection<?> allObjects = getExpressionResult (wfCtx, _expression);
+
+ for (String checkFile : _checkFiles)
+ CheckBackendFacade.checkAll (checkFile, _fileEncoding, metaModels, issues, allObjects);
+
+ if (_abortOnError && issues.hasErrors())
+ throw new WorkflowInterruptedException ("Errors during validation.");
+ }
+
+
+ @Override
+ public void checkConfiguration (Issues issues) {
+ super.checkConfiguration (issues);
+
+ if (_expression == null && _emfAllChildrenSlot != null)
+ _expression = _emfAllChildrenSlot + ".eAllContents.union ( {" + _emfAllChildrenSlot + "} )";
+ else if (_expression != null && _emfAllChildrenSlot == null) {
+ // ok - do nothing, expression already has a reasonable value
+ }
+ else
+ issues.addError(this, "You have to set one of the properties 'expression' and 'emfAllChildrenSlot'!");
+
+ if (_checkFiles.isEmpty())
+ issues.addError (this, "Property 'checkFile' not set!");
+ }
+
+ private Collection<?> getExpressionResult (WorkflowContext wfCtx, String expression2) {
+ final Map<String, Object> localVars = new HashMap<String, Object>();
+ final String[] names = wfCtx.getSlotNames ();
+ for (int i = 0; i < names.length; i++)
+ localVars.put (names[i], wfCtx.get (names[i]));
+
+ final Object result = XtendBackendFacade.evaluateExpression (expression2, metaModels, localVars);
+
+ if (result instanceof Collection)
+ return (Collection<?>) result;
+
+ if (result == null)
+ return Collections.EMPTY_SET;
+
+ return Collections.singleton (result);
+ }
+}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckConverter.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckConverter.java
new file mode 100644
index 0000000..0fd1fd1
--- /dev/null
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/CheckConverter.java
@@ -0,0 +1,110 @@
+/*
+Copyright (c) 2008 Arno Haase.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Arno Haase - initial API and implementation
+ */
+package org.eclipse.xtend.middleend.old.xtend;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.emf.mwe.core.issues.Issues;
+import org.eclipse.internal.xtend.xtend.ast.Check;
+import org.eclipse.internal.xtend.xtend.ast.ExtensionFile;
+import org.eclipse.xtend.backend.common.BackendType;
+import org.eclipse.xtend.backend.common.BackendTypesystem;
+import org.eclipse.xtend.backend.common.ExpressionBase;
+import org.eclipse.xtend.backend.common.FunctionDefContext;
+import org.eclipse.xtend.backend.common.NamedFunction;
+import org.eclipse.xtend.backend.common.SourcePos;
+import org.eclipse.xtend.backend.common.SyntaxConstants;
+import org.eclipse.xtend.backend.expr.AndExpression;
+import org.eclipse.xtend.backend.expr.IfExpression;
+import org.eclipse.xtend.backend.expr.InitClosureExpression;
+import org.eclipse.xtend.backend.expr.InvocationOnObjectExpression;
+import org.eclipse.xtend.backend.expr.LiteralExpression;
+import org.eclipse.xtend.backend.expr.LocalVarEvalExpression;
+import org.eclipse.xtend.backend.expr.SequenceExpression;
+import org.eclipse.xtend.backend.functions.SourceDefinedFunction;
+import org.eclipse.xtend.backend.syslib.SysLibNames;
+import org.eclipse.xtend.backend.types.builtin.CollectionType;
+import org.eclipse.xtend.backend.types.builtin.ObjectType;
+import org.eclipse.xtend.expression.ExecutionContext;
+import org.eclipse.xtend.middleend.old.common.OldExpressionConverter;
+import org.eclipse.xtend.middleend.old.common.OldHelper;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public final class CheckConverter {
+ public static final String ALL_CHECKS_FUNCTION_NAME = "CheckAllChecks";
+
+ /**
+ * name of the parameter in which the Issues are passed to the check function. This is not intended to
+ * be edited in a source file, so it is chosen not to be a valid identifier to avoid name clashes.
+ */
+ public static final String ISSUES_PARAM_NAME = "$issues";
+ public static final String ALL_OBJECTS_PARAM_NAME = "$allObjects";
+
+ private final TypeToBackendType _typeConverter;
+ private final ExecutionContext _emptyExecutionContext;
+
+ public CheckConverter (ExecutionContext ctx, TypeToBackendType typeConverter) {
+ _emptyExecutionContext = ctx;
+ _typeConverter = typeConverter;
+ }
+
+
+ public NamedFunction createCheckFunction (BackendTypesystem ts, FunctionDefContext fdc, ExtensionFile extensionFile) {
+ final OldExpressionConverter exprConv = new OldExpressionConverter (_emptyExecutionContext.cloneWithResource (extensionFile), _typeConverter, OldHelper.normalizeXtendResourceName (extensionFile.getFullyQualifiedName()));
+ final List<String> paramNames = Arrays.asList (ISSUES_PARAM_NAME, ALL_OBJECTS_PARAM_NAME);
+ final List<BackendType> paramTypes = Arrays.asList (ts.findType (Issues.class), CollectionType.INSTANCE);
+
+ final List<ExpressionBase> allChecks = new ArrayList<ExpressionBase> ();
+ for (Check chk: extensionFile.getChecks())
+ allChecks.add (convertCheck (chk, exprConv));
+
+ final ExpressionBase body = new SequenceExpression (allChecks, exprConv.getSourcePos (extensionFile));
+
+ return new NamedFunction (ALL_CHECKS_FUNCTION_NAME, new SourceDefinedFunction (ALL_CHECKS_FUNCTION_NAME, paramNames, paramTypes, fdc, body, false, null));
+ }
+
+
+ private ExpressionBase convertCheck (Check chk, OldExpressionConverter exprConv) {
+ final SourcePos sourcePos = exprConv.getSourcePos (chk);
+
+ final ExpressionBase preCondExpression = (chk.getGuard() == null) ?
+ exprConv.convert (chk.getConstraint()) :
+ new AndExpression (exprConv.convert (chk.getGuard()), exprConv.convert (chk.getConstraint()), sourcePos);
+
+ final String addIssueMethodName = chk.isErrorCheck() ? "addError" : "addWarning";
+
+ final List<ExpressionBase> failureParams = new ArrayList<ExpressionBase> ();
+ failureParams.add (new LocalVarEvalExpression (ISSUES_PARAM_NAME, sourcePos));
+ failureParams.add (exprConv.convert(chk.getMsg()));
+ failureParams.add (new LocalVarEvalExpression (SyntaxConstants.THIS, sourcePos));
+
+ final ExpressionBase failureExpression = new InvocationOnObjectExpression (addIssueMethodName, failureParams, true, sourcePos);
+
+ final ExpressionBase onEachExpression = new IfExpression (preCondExpression, failureExpression, new LiteralExpression (null, sourcePos), sourcePos);
+
+ final List<ExpressionBase> typeSelectParams = new ArrayList<ExpressionBase> ();
+ typeSelectParams.add (new LocalVarEvalExpression (ALL_OBJECTS_PARAM_NAME, sourcePos));
+ typeSelectParams.add (new LiteralExpression (_typeConverter.convertToBackendType (chk.getType()), sourcePos));
+ final ExpressionBase typeSelectExpression = new InvocationOnObjectExpression (SysLibNames.TYPE_SELECT, typeSelectParams, true, sourcePos);
+
+ final List<ExpressionBase> collectParams = new ArrayList<ExpressionBase> ();
+ collectParams.add (typeSelectExpression);
+ collectParams.add (new InitClosureExpression (Arrays.asList(SyntaxConstants.THIS), Arrays.asList(ObjectType.INSTANCE), onEachExpression, sourcePos));
+ return new InvocationOnObjectExpression (SysLibNames.COLLECT, collectParams, true, sourcePos);
+ }
+}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/JavaExtensionFunction.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/JavaExtensionFunction.java
index 873a524..c71b7e1 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/JavaExtensionFunction.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/JavaExtensionFunction.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xtend;
import java.lang.reflect.Method;
import java.util.List;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExtensionConverter.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldExtensionConverter.java
index d9466bd..d136849 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldExtensionConverter.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldExtensionConverter.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xtend;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -34,6 +34,8 @@ import org.eclipse.xtend.backend.functions.SourceDefinedFunction;
import org.eclipse.xtend.expression.AnalysationIssue;
import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.Variable;
+import org.eclipse.xtend.middleend.old.common.OldExpressionConverter;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
import org.eclipse.xtend.typesystem.Type;
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendRegistry.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldXtendRegistry.java
index e9ad6f9..3583022 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXtendRegistry.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/OldXtendRegistry.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xtend;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,6 +28,8 @@ import org.eclipse.xtend.backend.functions.FunctionDefContextFactory;
import org.eclipse.xtend.backend.functions.FunctionDefContextInternal;
import org.eclipse.xtend.backend.util.Cache;
import org.eclipse.xtend.expression.ExecutionContext;
+import org.eclipse.xtend.middleend.old.common.OldHelper;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendLibContributor;
@@ -36,7 +38,7 @@ import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendLibContributor;
*
* @author Arno Haase (http://www.haase-consulting.com)
*/
-final class OldXtendRegistry {
+public final class OldXtendRegistry {
private final ExecutionContext _ctx;
private final BackendTypesystem _ts;
@@ -72,7 +74,7 @@ final class OldXtendRegistry {
private FunctionDefContextInternal getFunctionDefContext (String xtendName) {
- return _functionDefContexts.get (OldXtendHelper.normalizeXtendResourceName (xtendName));
+ return _functionDefContexts.get (OldHelper.normalizeXtendResourceName (xtendName));
}
@@ -80,12 +82,12 @@ final class OldXtendRegistry {
* parses and converts an Xtend file and all other files it depends on.
*/
public void registerExtension (String xtendFile) {
- xtendFile = OldXtendHelper.normalizeXtendResourceName (xtendFile);
+ xtendFile = OldHelper.normalizeXtendResourceName (xtendFile);
if (_definedFunctionsByResource.containsKey(xtendFile))
return;
- final XtendFile file = (XtendFile) _ctx.getResourceManager().loadResource (xtendFile, XtendFile.FILE_EXTENSION);
+ final ExtensionFile file = (ExtensionFile) _ctx.getResourceManager().loadResource (xtendFile, XtendFile.FILE_EXTENSION);
if (file == null)
throw new IllegalArgumentException ("could not find extension '" + xtendFile + "'");
@@ -105,6 +107,8 @@ final class OldXtendRegistry {
// register the XtendLib. Do this first so the extension can override functions
fdc.register (new XtendLibContributor (_ts).getContributedFunctions());
+ fdc.register (new CheckConverter (ctx, typeConverter).createCheckFunction(_ts, fdc, file));
+
for (Extension ext: file.getExtensions()) {
final NamedFunction f = extensionFactory.create (ext, fdc);
@@ -124,7 +128,7 @@ final class OldXtendRegistry {
// make all imported extensions visible for the scope of this compilation unit
for (String importedResource: file.getImportedExtensions()) {
- for (NamedFunction f: _locallyExportedFunctionsByResource.get (OldXtendHelper.normalizeXtendResourceName (importedResource)))
+ for (NamedFunction f: _locallyExportedFunctionsByResource.get (OldHelper.normalizeXtendResourceName (importedResource)))
fdc.register (f);
}
@@ -140,7 +144,7 @@ final class OldXtendRegistry {
}
private void getReexported (String xtendFile, Collection<NamedFunction> result, Set<String> harvestedCompilationUnits, Set<String> processedCompilationUnits) {
- xtendFile = OldXtendHelper.normalizeXtendResourceName (xtendFile);
+ xtendFile = OldHelper.normalizeXtendResourceName (xtendFile);
if (processedCompilationUnits.contains (xtendFile))
return;
@@ -161,7 +165,7 @@ final class OldXtendRegistry {
}
public Collection<NamedFunction> getContributedFunctions (String xtendFile) {
- return _exportedFunctionsByResource.get (OldXtendHelper.normalizeXtendResourceName(xtendFile));
+ return _exportedFunctionsByResource.get (OldHelper.normalizeXtendResourceName(xtendFile));
}
}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendBackendFacade.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendBackendFacade.java
index cf0d081..23bda27 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendBackendFacade.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendBackendFacade.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xtend;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,6 +29,9 @@ import org.eclipse.xtend.backend.functions.FunctionDefContextInternal;
import org.eclipse.xtend.backend.functions.SourceDefinedFunction;
import org.eclipse.xtend.expression.ExecutionContextImpl;
import org.eclipse.xtend.expression.Variable;
+import org.eclipse.xtend.middleend.old.common.OldExpressionConverter;
+import org.eclipse.xtend.middleend.old.common.OldHelper;
+import org.eclipse.xtend.middleend.old.common.TypeToBackendType;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendGlobalVarOperations;
import org.eclipse.xtend.middleend.old.internal.xtendlib.XtendLibContributor;
import org.eclipse.xtend.typesystem.MetaModel;
@@ -83,7 +86,7 @@ public final class XtendBackendFacade {
for (String varName: localVars.keySet())
ctx = (ExecutionContextImpl) ctx.cloneWithVariable (new Variable (varName, ctx.getType (localVars.get (varName))));
- final BackendTypesystem ts = OldXtendHelper.guessTypesystem (mms);
+ final BackendTypesystem ts = OldHelper.guessTypesystem (mms);
final TypeToBackendType typeConverter = new TypeToBackendType (ts, ctx);
final ExpressionBase newAst = new OldExpressionConverter (ctx, typeConverter, "<no file>").convert(oldAst);
@@ -96,6 +99,7 @@ public final class XtendBackendFacade {
return newAst.evaluate (newCtx);
}
+
private static FunctionDefContext createEmptyFdc (BackendTypesystem ts, String initialXtendFileName, String fileEncoding, Collection<MetaModel> mms) {
if (initialXtendFileName != null)
return createForFile (initialXtendFileName, fileEncoding, mms).getFunctionDefContext();
@@ -113,7 +117,7 @@ public final class XtendBackendFacade {
public static Object invokeXtendFunction (String xtendFileName, String fileEncoding, Collection<MetaModel> mms, String functionName, Object... parameters) {
final XtendBackendFacade xbf = createForFile (xtendFileName, fileEncoding, mms);
final FunctionDefContext fdc = xbf.getFunctionDefContext();
- final ExecutionContext ctx = BackendFacade.createExecutionContext (fdc, OldXtendHelper.guessTypesystem (mms), true); //TODO configure isLogStacktrace
+ final ExecutionContext ctx = BackendFacade.createExecutionContext (fdc, OldHelper.guessTypesystem (mms), true); //TODO configure isLogStacktrace
return fdc.invoke (ctx, functionName, Arrays.asList (parameters));
}
@@ -126,9 +130,9 @@ public final class XtendBackendFacade {
if (mms == null)
mms = new ArrayList<MetaModel> ();
- fileEncoding = OldXtendHelper.normalizedFileEncoding (fileEncoding);
- _xtendFile = OldXtendHelper.normalizeXtendResourceName (xtendFileName);
- _ts = OldXtendHelper.guessTypesystem (mms);
+ fileEncoding = OldHelper.normalizedFileEncoding (fileEncoding);
+ _xtendFile = OldHelper.normalizeXtendResourceName (xtendFileName);
+ _ts = OldHelper.guessTypesystem (mms);
final ExecutionContextImpl ctx = new ExecutionContextImpl ();
for (MetaModel mm: mms)
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendComponent.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendComponent.java
index ca47419..17a4e39 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/XtendComponent.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/xtend/XtendComponent.java
@@ -8,7 +8,7 @@ http://www.eclipse.org/legal/epl-v10.html
Contributors:
Arno Haase - initial API and implementation
*/
-package org.eclipse.xtend.middleend.old;
+package org.eclipse.xtend.middleend.old.xtend;
import java.io.InputStream;
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java
index 8afeb58..e520e78 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java
@@ -31,7 +31,7 @@ import org.eclipse.xtend.expression.ExecutionContext;
import org.eclipse.xtend.expression.ExecutionContextImpl;
import org.eclipse.xtend.expression.Type1;
import org.eclipse.xtend.expression.Variable;
-import org.eclipse.xtend.middleend.old.XtendBackendFacade;
+import org.eclipse.xtend.middleend.old.xtend.XtendBackendFacade;
import org.eclipse.xtend.typesystem.Property;
/**
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
index a3d4045..8ab20d8 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java
@@ -29,6 +29,10 @@ public class ConstructorCallExpression extends Expression {
this.type = type;
}
+ public Identifier getType () {
+ return type;
+ }
+
public String getTypeName () {
return type.getValue();
}
diff --git a/tests/org.eclipse.xtend.middleend.old.test/src/org/eclipse/xtend/middleend/old/first/FirstAttempt.java b/tests/org.eclipse.xtend.middleend.old.test/src/org/eclipse/xtend/middleend/old/first/FirstAttempt.java
index da77609..4d68bd6 100644
--- a/tests/org.eclipse.xtend.middleend.old.test/src/org/eclipse/xtend/middleend/old/first/FirstAttempt.java
+++ b/tests/org.eclipse.xtend.middleend.old.test/src/org/eclipse/xtend/middleend/old/first/FirstAttempt.java
@@ -23,9 +23,9 @@ import org.eclipse.xpand2.output.Outlet;
import org.eclipse.xtend.backend.BackendFacade;
import org.eclipse.xtend.backend.common.ExecutionContext;
import org.eclipse.xtend.backend.types.CompositeTypesystem;
-import org.eclipse.xtend.middleend.old.XpandBackendFacade;
-import org.eclipse.xtend.middleend.old.XpandComponent;
-import org.eclipse.xtend.middleend.old.XtendBackendFacade;
+import org.eclipse.xtend.middleend.old.xpand.XpandBackendFacade;
+import org.eclipse.xtend.middleend.old.xpand.XpandComponent;
+import org.eclipse.xtend.middleend.old.xtend.XtendBackendFacade;
import org.eclipse.xtend.typesystem.MetaModel;