summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpschonbac2009-02-21 19:29:26 (EST)
committerpschonbac2009-02-21 19:29:26 (EST)
commit057a329f4d886986a23928c322981b51c4fbb946 (patch)
tree908fb08bd2890f64222a13b2d502cf531722a998
parente9216b5ff47a1ebdee1f4f69a0aae89b30aa30cd (diff)
downloadorg.eclipse.xpand-057a329f4d886986a23928c322981b51c4fbb946.zip
org.eclipse.xpand-057a329f4d886986a23928c322981b51c4fbb946.tar.gz
org.eclipse.xpand-057a329f4d886986a23928c322981b51c4fbb946.tar.bz2
Broken code fixed
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java20
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java8
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java1
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java20
4 files changed, 43 insertions, 6 deletions
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
index 860df8a..f1c2b3d 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
@@ -36,16 +36,24 @@ public class XpandFacade {
/**
* @deprecated use XpandFacade.create instead
*/
+ @Deprecated
public XpandFacade(final XpandExecutionContext ctx) {
this.ctx = ctx;
}
public void evaluate(final String definitionName, final Object targetObject, Object... params) {
- params = params == null ? new Object[0] : params;
+ evaluate2(definitionName, targetObject, params != null ? Arrays.asList(params) : null);
+ }
+
+ public void evaluate2(final String definitionName, final Object targetObject, List<Object> paramList) {
+ if (paramList == null) {
+ paramList = Collections.emptyList();
+ }
final Type targetType = ctx.getType(targetObject);
- final Type[] paramTypes = new Type[params.length];
+ final Type[] paramTypes = new Type[paramList.size()];
for (int i = 0; i < paramTypes.length; i++) {
- paramTypes[i] = ctx.getType(params[i]);
+ Object obj = paramList.get(i);
+ paramTypes[i] = ctx.getType(obj);
}
final XpandDefinition def = ctx.findDefinition(definitionName, targetType, paramTypes);
@@ -55,8 +63,8 @@ public class XpandFacade {
ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE,
targetObject));
- for (int i = 0; i < params.length; i++) {
- final Variable v = new Variable(def.getParams()[i].getName().getValue(), params[i]);
+ for (int i = 0; i < paramList.size(); i++) {
+ final Variable v = new Variable(def.getParams()[i].getName().getValue(), paramList.get(i));
ctx = (XpandExecutionContext) ctx.cloneWithVariable(v);
}
ctx = (XpandExecutionContext) ctx.cloneWithResource(def.getOwner());
@@ -85,7 +93,7 @@ public class XpandFacade {
return issues.toArray(new AnalysationIssue[issues.size()]);
}
- public static XpandFacade create(XpandExecutionContextImpl execCtx) {
+ public static XpandFacade create(XpandExecutionContext execCtx) {
return new XpandFacade(execCtx);
}
}
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
index 492db4a..9f1148a 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java
@@ -146,6 +146,14 @@ public class Outlet {
public Outlet() {
}
+ public Outlet (boolean append, String encoding, String name, boolean overwrite, String path) {
+ this.append = append;
+ this.fileEncoding = encoding;
+ this.name = name;
+ this.overwrite = overwrite;
+ this.path = path;
+ }
+
public boolean shouldWrite(FileHandleImpl fileHandleImpl) {
for (VetoStrategy vs : vetoStrategies) {
if (vs.hasVeto(fileHandleImpl))
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
index 1dac2cb..83f633a 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java
@@ -30,4 +30,5 @@ public interface Output {
public void addOutlet(Outlet outlet);
+ public Outlet getOutlet (String name);
}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
index 5e659fa..3d36a8d 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java
@@ -84,6 +84,26 @@ public class XtendFacade {
return extension.evaluate(params, ctx);
}
+ public Object call(final String ext, List<?> params) {
+ Object[] paramsArray = new Object[params.size()];
+ paramsArray = params.toArray(paramsArray);
+ final Extension extension = ctx.getExtension(ext, paramsArray);
+ if (extension == null)
+ throw new IllegalArgumentException("Couldn't find extension " + ext);
+ return extension.evaluate(paramsArray, ctx);
+ }
+
+ public boolean hasExtension(final String ext, Object[] paramsArray) {
+ final Extension extension = ctx.getExtension(ext, paramsArray);
+ return extension != null;
+ }
+
+ public boolean hasExtension(final String ext, List<?> params) {
+ Object[] paramsArray = new Object[params.size()];
+ paramsArray = params.toArray(paramsArray);
+ return hasExtension(ext, paramsArray);
+ }
+
public Type analyze(final String string, Object[] objects, final Set<AnalysationIssue> issues) {
if (objects == null) {
objects = new Object[0];