diff options
author | pschonbac | 2009-01-10 00:59:01 +0000 |
---|---|---|
committer | pschonbac | 2009-01-10 00:59:01 +0000 |
commit | b652f86b31c9d2facb70bdda51704ae1f95a7358 (patch) | |
tree | 059d4728f639b9d1d7b840227cc91ed5dc8bd768 /plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend | |
parent | d5312a4578669fe68e5f34fd672a395746089c8b (diff) | |
download | org.eclipse.xpand-b652f86b31c9d2facb70bdda51704ae1f95a7358.tar.gz org.eclipse.xpand-b652f86b31c9d2facb70bdda51704ae1f95a7358.tar.xz org.eclipse.xpand-b652f86b31c9d2facb70bdda51704ae1f95a7358.zip |
- Updated M2T Xpand to be in sync with version 4.3.1
- The previous step required some additions to the MWE core
- Updated all license headers
Diffstat (limited to 'plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend')
134 files changed, 1742 insertions, 1106 deletions
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java index 62a7db13..6c130efd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.check.codeassist; @@ -33,7 +31,7 @@ import org.eclipse.xtend.typesystem.Type; public class CheckFastAnalyzer { private final static Pattern VALIDATE_PATTERN = Pattern - .compile("context\\s+([\\[\\]:\\w\\]]+)(#|\\s+)[^;]*\\z"); + .compile("context\\s+([\\[\\]:\\w\\]]+)\\s+[^;]*\\z"); private final static Pattern TYPEDECL_PATTERN = Pattern.compile("context\\s+[\\[\\]:\\w\\]]*\\z"); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html new file mode 100644 index 00000000..3d4c5ae8 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Codeassist implementation for the Check component +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java new file mode 100644 index 00000000..4dd0c5b1 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java @@ -0,0 +1,208 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ +package org.eclipse.internal.xtend.expression.ast; + +public abstract class AbstractExpressionVisitor extends AbstractVisitor { + + @Override + public final Object visit(final ISyntaxElement ele) { + Object result = null; + if (result == null && ele instanceof BooleanOperation) { + result = visitBooleanOperation((BooleanOperation) ele); + } + if (result == null && ele instanceof Cast) { + result = visitCast((Cast) ele); + } + if (result == null && ele instanceof ConstructorCallExpression) { + result = visitConstructorCallExpression((ConstructorCallExpression) ele); + } + if (result == null && ele instanceof GlobalVarExpression) { + result = visitGlobalVarExpression((GlobalVarExpression) ele); + } + if (result == null && ele instanceof ChainExpression) { + result = visitChainExpression((ChainExpression) ele); + } + if (result == null && ele instanceof CollectionExpression) { + result = visitCollectionExpression((CollectionExpression) ele); + } + if (result == null && ele instanceof OperationCall) { + result = visitOperationCall((OperationCall) ele); + } + if (result == null && ele instanceof TypeSelectExpression) { + result = visitTypeSelectExpression((TypeSelectExpression) ele); + } + if (result == null && ele instanceof FeatureCall) { + result = visitFeatureCall((FeatureCall) ele); + } + if (result == null && ele instanceof IfExpression) { + result = visitIfExpression((IfExpression) ele); + } + if (result == null && ele instanceof LetExpression) { + result = visitLetExpression((LetExpression) ele); + } + if (result == null && ele instanceof SwitchExpression) { + result = visitSwitchExpression((SwitchExpression) ele); + } + if (result == null && ele instanceof ListLiteral) { + result = visitListLiteral((ListLiteral) ele); + } + if (result == null && ele instanceof BooleanLiteral) { + result = visitBooleanLiteral((BooleanLiteral) ele); + } + if (result == null && ele instanceof IntegerLiteral) { + result = visitIntegerLiteral((IntegerLiteral) ele); + } + if (result == null && ele instanceof NullLiteral) { + result = visitNullLiteral((NullLiteral) ele); + } + if (result == null && ele instanceof RealLiteral) { + result = visitRealLiteral((RealLiteral) ele); + } + if (result == null && ele instanceof StringLiteral) { + result = visitStringLiteral((StringLiteral) ele); + } + return result; + } + + protected Object visitBooleanOperation(BooleanOperation node) { + if (node.getLeft() != null) { + node.getLeft().accept(this); + } + if (node.getRight() != null) { + node.getRight().accept(this); + } + return node; + } + + protected Object visitCast(Cast node) { + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitConstructorCallExpression(ConstructorCallExpression node) { + return node; + } + + protected Object visitGlobalVarExpression(GlobalVarExpression node) { + return node; + } + + protected Object visitChainExpression(ChainExpression ce) { + if (ce.getFirst() != null) { + ce.getFirst().accept(this); + } + if (ce.getNext() != null) { + ce.getNext().accept(this); + } + return ce; + } + + protected Object visitFeatureCall(FeatureCall fc) { + if (fc.getTarget() != null) { + fc.getTarget().accept(this); + } + return fc; + } + + protected Object visitCollectionExpression(CollectionExpression node) { + if (node.getClosure() != null) { + node.getClosure().accept(this); + } + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitOperationCall(OperationCall oc) { + if (oc.getTarget() != null) { + oc.getTarget().accept(this); + } + if (oc.getParamsAsList() != null) { + for (Expression expr : oc.getParamsAsList()) { + expr.accept(this); + } + } + return oc; + } + + protected Object visitTypeSelectExpression(TypeSelectExpression node) { + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitIfExpression(IfExpression node) { + if (node.getCondition() != null) { + node.getCondition().accept(this); + } + if (node.getThenPart() != null) { + node.getThenPart().accept(this); + } + if (node.getElsePart() != null) { + node.getElsePart().accept(this); + } + return node; + } + + protected Object visitLetExpression(LetExpression node) { + if (node.getTargetExpression() != null) { + node.getTargetExpression().accept(this); + } + if (node.getVarExpression() != null) { + node.getVarExpression().accept(this); + } + return node; + } + + protected Object visitSwitchExpression(SwitchExpression node) { + for (Case caze : node.getCases()) { + if (caze.getCondition() != null) { + caze.getCondition().accept(this); + } + if (caze.getThenPart() != null) { + caze.getThenPart().accept(this); + } + } + if (node.getSwitchExpr() != null) { + node.getSwitchExpr().accept(this); + } + if (node.getDefaultExpr() != null) { + node.getDefaultExpr().accept(this); + } + return node; + } + + protected Object visitListLiteral(ListLiteral node) { + return node; + } + + protected Object visitBooleanLiteral(BooleanLiteral node) { + return node; + } + + protected Object visitIntegerLiteral(IntegerLiteral node) { + return node; + } + + protected Object visitNullLiteral(NullLiteral node) { + return node; + } + + protected Object visitRealLiteral(RealLiteral node) { + return node; + } + + protected Object visitStringLiteral(StringLiteral node) { + return node; + } +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java new file mode 100644 index 00000000..51230c1b --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ +package org.eclipse.internal.xtend.expression.ast; + +public abstract class AbstractVisitor { + abstract public Object visit(final ISyntaxElement ele); +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java index f4a6d340..61dbf0df 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -23,16 +21,17 @@ import org.eclipse.xtend.typesystem.Type; */ public class BooleanLiteral extends Literal { - public BooleanLiteral( final Identifier literalValue) { - super(literalValue); - } + public BooleanLiteral(final Identifier literalValue) { + super(literalValue); + } - @Override - public Object evaluateInternal(final ExecutionContext ctx) { - return new Boolean(getLiteralValue().getValue()); - } + @Override + public Object evaluateInternal(final ExecutionContext ctx) { + return new Boolean(getLiteralValue().getValue()); + } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - return ctx.getBooleanType(); - } + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + return ctx.getBooleanType(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java index f43febbc..a01ba3fa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -81,7 +79,7 @@ public class BooleanOperation extends Expression { return ctx.handleNullEvaluation(this); return b; } else - throw new EvaluationException("Unkown Boolean operator " + operator.getValue(), this, ctx); + throw new EvaluationException("Unknown Boolean operator " + operator.getValue(), this, ctx); } private Boolean evaluateToBoolean(final Expression expr, final ExecutionContext ctx) { @@ -96,7 +94,8 @@ public class BooleanOperation extends Expression { return result; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type l = left.analyze(ctx, issues); final Type r = right.analyze(ctx, issues); if (l == null || r == null) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java index b752592f..29312ed1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java index 3bf6c4e4..dc4813f8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -48,7 +46,7 @@ public class Cast extends Expression { return getTarget().evaluate(ctx); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type t = getTarget().analyze(ctx, issues); final Type toCast = findType(getType(), ctx, issues); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java index 325aa716..2e412b92 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -39,9 +37,9 @@ public class ChainExpression extends Expression { return getNext().evaluate(ctx); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { getFirst().analyze(ctx, issues); - return getNext().analyze(ctx, issues); + return getNext()!=null ? getNext().analyze(ctx, issues) : null; } public Expression getFirst() { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java index 0ffc7432..2157d07b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -33,222 +31,237 @@ import org.eclipse.xtend.typesystem.Type; * @author Arno Haase * @author Bernd Kolb */ +@SuppressWarnings("unchecked") public class CollectionExpression extends FeatureCall { - private Expression closure; + private Expression closure; - private Identifier eleName; + private Identifier eleName; - public CollectionExpression(final Identifier name, final Identifier eleName, final Expression closure) { - super(name,null); - this.eleName = eleName; - this.closure = closure; - } + public CollectionExpression(final Identifier name, final Identifier eleName, final Expression closure) { + super(name, null); + this.eleName = eleName; + this.closure = closure; + } - @Override + @Override protected String toStringInternal() { - return super.toStringInternal() + "(" + (eleName != null ? eleName.getValue() + "|" : "") + closure + ")"; - } + return super.toStringInternal() + "(" + (eleName != null ? eleName.getValue() + "|" : "") + closure + ")"; + } + + public Expression getClosure() { + return closure; + } - public Expression getClosure () { - return closure; - } - @Override - public Object evaluateInternal(final ExecutionContext ctx) { - Object targetObj = null; - if (getTarget() == null) { - final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (v != null) { - targetObj = v.getValue(); - } - } else { - targetObj = getTarget().evaluate(ctx); - } - if (targetObj == null) - return ctx.handleNullEvaluation(this); - if (!(targetObj instanceof Collection)) { - throw new EvaluationException("Couldn't call '"+this.toString()+"' on an object of java type "+targetObj.getClass().getName(),this, ctx); - } - - if (getName().getValue().equals(SyntaxConstants.COLLECT)) - return executeCollect((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SELECT)) - return executeSelect((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) - return executeSelectFirst((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.REJECT)) - return executeReject((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.EXISTS)) - return executeExists((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.NOT_EXISTS)) - return executeNotExists((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.FOR_ALL)) - return executeForAll((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) - return executeSortBy((Collection) targetObj, ctx); - else - throw new EvaluationException("Unkown collection operation : " + getName().getValue(), this, ctx); - - } + public Object evaluateInternal(final ExecutionContext ctx) { + Object targetObj = null; + if (getTarget() == null) { + final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); + if (v != null) { + targetObj = v.getValue(); + } + } + else { + targetObj = getTarget().evaluate(ctx); + } + if (targetObj == null) + return ctx.handleNullEvaluation(this); + if (!(targetObj instanceof Collection)) + throw new EvaluationException("Couldn't call '" + toString() + "' on an object of java type " + + targetObj.getClass().getName(), this, ctx); + + if (getName().getValue().equals(SyntaxConstants.COLLECT)) + return executeCollect((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SELECT)) + return executeSelect((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) + return executeSelectFirst((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.REJECT)) + return executeReject((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.EXISTS)) + return executeExists((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.NOT_EXISTS)) + return executeNotExists((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.FOR_ALL)) + return executeForAll((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) + return executeSortBy((Collection) targetObj, ctx); + else + throw new EvaluationException("Unknown collection operation : " + getName().getValue(), this, ctx); + + } + @SuppressWarnings("unchecked") private Object executeSortBy(Collection collection, final ExecutionContext ctx) { List<Object> result = new ArrayList<Object>(); result.addAll(collection); - Collections.sort(result, new Comparator<Object> () { + Collections.sort(result, new Comparator<Object>() { + @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { final Object a = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o1))); final Object b = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o2))); - if (a==b) - return 0; - if (a==null) - return -1; - if (b==null) - return 1; - if (a instanceof Comparable) - return ((Comparable)a).compareTo(b); + if (a == b) + return 0; + if (a == null) + return -1; + if (b == null) + return 1; + if (a instanceof Comparable) + return ((Comparable) a).compareTo(b); return a.toString().compareTo(b.toString()); - }}); + } + }); return result; } private Object executeForAll(final Collection collection, ExecutionContext ctx) { - if ( collection.size()== 0) return Boolean.FALSE; - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); - final Object result = closure.evaluate(ctx); - if (!(result instanceof Boolean) || !((Boolean) result).booleanValue()) - return Boolean.FALSE; - } - return Boolean.TRUE; - } - - private Object executeExists(final Collection collection, ExecutionContext ctx) { - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - private Object executeNotExists(final Collection collection, ExecutionContext ctx) { - Boolean bool = (Boolean) executeExists(collection, ctx); - return Boolean.valueOf(!bool); - } + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (!(result instanceof Boolean) || !((Boolean) result).booleanValue()) + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + private Object executeExists(final Collection collection, ExecutionContext ctx) { + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) + return Boolean.TRUE; + } + return Boolean.FALSE; + } + private Object executeNotExists(final Collection collection, ExecutionContext ctx) { + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @SuppressWarnings("unchecked") private Object executeReject(final Collection collection, ExecutionContext ctx) { - final Collection resultCol = new ArrayList(collection); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.remove(ele); - } - } - return resultCol; - } - - private Object executeSelect(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.add(ele); - } - } - return resultCol; - } - - private Object executeSelectFirst(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.add(ele); - } - } - if ( resultCol.size() == 0 ) return null; - return resultCol.iterator().next(); - } + final Collection resultCol = new ArrayList(collection); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.remove(ele); + } + } + return resultCol; + } + private Object executeSelect(final Collection collection, ExecutionContext ctx) { + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.add(ele); + } + } + return resultCol; + } + + private Object executeSelectFirst(final Collection collection, ExecutionContext ctx) { + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.add(ele); + } + } + if (resultCol.size() == 0) + return null; + return resultCol.iterator().next(); + } + + @SuppressWarnings("unchecked") private Object executeCollect(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = Collections.unmodifiableCollection(collection).iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - resultCol.add(closure.evaluate(ctx)); - } - return resultCol; - } - - @Override - public Type analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) { - Type targetType = null; - if (getTarget() == null) { - final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (v != null) { - targetType = (Type) v.getValue(); - } - } else { - targetType = getTarget().analyze(ctx, issues); - } - if (targetType == null) - return null; - - if (!(targetType instanceof ParameterizedType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Collection type expected! was : " - + targetType, getTarget())); - return null; - } - - final Type innerType = ((ParameterizedType) targetType).getInnerType(); - Type result = null; - ctx = ctx.cloneWithVariable(new Variable(getElementName(), innerType)); - final Type closureType = closure.analyze(ctx, issues); - if (getName().getValue().equals(SyntaxConstants.COLLECT)) { - if (targetType.getName().startsWith(BuiltinMetaModel.SET)) - return ctx.getSetType(closureType); - else if (targetType.getName().startsWith(BuiltinMetaModel.LIST)) - return ctx.getListType(closureType); - else - return ctx.getCollectionType(closureType); - } else if (getName().getValue().equals(SyntaxConstants.SELECT) - || getName().getValue().equals(SyntaxConstants.REJECT) - ) { - return targetType; - } else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) { - return innerType; - } else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) { - return ctx.getListType(innerType); - }else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) { - if (closureType == null) - return null; - return ctx.getListType(closureType); - } else if (getName().getValue().equals(SyntaxConstants.EXISTS) - || getName().getValue().equals(SyntaxConstants.NOT_EXISTS) - || getName().getValue().equals(SyntaxConstants.FOR_ALL)) { - if (!ctx.getBooleanType().isAssignableFrom(closureType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean type expected! was : " - + closureType, closure)); - } - result = ctx.getBooleanType(); - } else { - issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Unknown operation : " - + getName().getValue(), this)); - } - return result; - } - - public String getElementName() { - return eleName != null ? eleName.getValue() : SyntaxConstants.DEFAULT_ELE_NAME; - } + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = Collections.unmodifiableCollection(collection).iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + resultCol.add(closure.evaluate(ctx)); + } + return resultCol; + } + + @Override + public Type analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) { + Type targetType = null; + if (getTarget() == null) { + final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); + if (v != null) { + targetType = (Type) v.getValue(); + } + } + else { + targetType = getTarget().analyze(ctx, issues); + } + if (targetType == null) + return null; + + if (!(targetType instanceof ParameterizedType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Collection type expected! was : " + + targetType, getTarget())); + return null; + } + + final Type innerType = ((ParameterizedType) targetType).getInnerType(); + Type result = null; + ctx = ctx.cloneWithVariable(new Variable(getElementName(), innerType)); + final Type closureType = closure.analyze(ctx, issues); + if (getName().getValue().equals(SyntaxConstants.COLLECT)) { + if (targetType.getName().startsWith(BuiltinMetaModel.SET)) + return ctx.getSetType(closureType); + else if (targetType.getName().startsWith(BuiltinMetaModel.LIST)) + return ctx.getListType(closureType); + else + return ctx.getCollectionType(closureType); + } + else if (getName().getValue().equals(SyntaxConstants.SELECT) + || getName().getValue().equals(SyntaxConstants.REJECT)) + return targetType; + else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) + return innerType; + else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) + return ctx.getListType(innerType); + else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) { + if (closureType == null) + return null; + return ctx.getListType(closureType); + } + else if (getName().getValue().equals(SyntaxConstants.EXISTS) + || getName().getValue().equals(SyntaxConstants.NOT_EXISTS) + || getName().getValue().equals(SyntaxConstants.FOR_ALL)) { + if (!ctx.getBooleanType().isAssignableFrom(closureType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean type expected! was : " + + closureType, closure)); + } + result = ctx.getBooleanType(); + } + else { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Unknown operation : " + + getName().getValue(), this)); + } + return result; + } + + public String getElementName() { + return eleName != null ? eleName.getValue() : SyntaxConstants.DEFAULT_ELE_NAME; + } } 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 8ab20d88..f018f6f4 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 @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -19,45 +17,46 @@ import org.eclipse.xtend.typesystem.Type; /** * @author Bernd Kolb - * + * */ public class ConstructorCallExpression extends Expression { - private Identifier type; - - public ConstructorCallExpression(final Identifier type) { - this.type = type; - } - - public Identifier getType () { - return type; - } - - public String getTypeName () { - return type.getValue(); - } - - @Override - protected Object evaluateInternal(final ExecutionContext ctx) { - final Type t = ctx.getTypeForName(type.getValue()); - if (t != null) - return t.newInstance(); - else - throw new EvaluationException("Couldn't find type " + type, this, ctx); - } - - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - final Type t = ctx.getTypeForName(type.getValue()); - if (t == null) { - issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found : " + type, type)); - } - // TODO add isAbstract to Type and check it here! - return t; - } - - @Override + private Identifier type; + + public ConstructorCallExpression(final Identifier type) { + this.type = type; + } + + public Identifier getType() { + return type; + } + + public String getTypeName() { + return type.getValue(); + } + + @Override + protected Object evaluateInternal(final ExecutionContext ctx) { + final Type t = ctx.getTypeForName(type.getValue()); + if (t != null) + return t.newInstance(); + else + throw new EvaluationException("Couldn't find type " + type, this, ctx); + } + + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + final Type t = ctx.getTypeForName(type.getValue()); + if (t == null) { + issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found : " + type, type)); + } + // TODO add isAbstract to Type and check it here! + return t; + } + + @Override protected String toStringInternal() { - return "new " + getTypeName(); - } + return "new " + getTypeName(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java index 7c01076c..21cbe18c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -21,8 +19,7 @@ public class DeclaredParameter extends SyntaxElement { private Identifier name; - public DeclaredParameter(final Identifier type, - final Identifier name) { + public DeclaredParameter(final Identifier type, final Identifier name) { this.type = type; this.name = name; } @@ -39,4 +36,43 @@ public class DeclaredParameter extends SyntaxElement { public String toString() { return type.getValue() + " " + name.getValue(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null) + return false; + + if (getClass() != obj.getClass()) + return false; + + DeclaredParameter other = (DeclaredParameter) obj; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + + if (type == null) { + if (other.type != null) + return false; + } + else if (!type.equals(other.type)) + return false; + + return true; + } + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java index 984368eb..271d45b7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; import java.util.Set; +import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; import org.eclipse.xtend.expression.AnalysationIssue; import org.eclipse.xtend.expression.Analyzable; import org.eclipse.xtend.expression.Evaluatable; @@ -22,11 +21,10 @@ import org.eclipse.xtend.typesystem.Type; /** * @author Bernd Kolb - * + * */ public abstract class Expression extends SyntaxElement implements Analyzable, Evaluatable { - protected Type findType(final Identifier type, final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type toCast = ctx.getTypeForName(type.getValue()); if (toCast == null) { @@ -36,24 +34,61 @@ public abstract class Expression extends SyntaxElement implements Analyzable, Ev } public final Object evaluate(final ExecutionContext ctx) { + Object evaluateInternal = null; try { - Object evaluateInternal = evaluateInternal(ctx); + ProgressMonitor monitor = ctx.getMonitor(); + if (monitor != null && monitor.isCanceled()) + return null; + + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + evaluateInternal = evaluateInternal(ctx); return evaluateInternal; - } catch (final EvaluationException ex) { + } + catch (final EvaluationException ex) { ctx.handleRuntimeException(ex, this, null); return null; - } catch (final RuntimeException ex) { - EvaluationException evalex = new EvaluationException(ex.getMessage(),this, ctx); + } + catch (final RuntimeException ex) { + EvaluationException evalex = new EvaluationException(ex.getMessage(), this, ctx); ctx.handleRuntimeException(evalex, this, null); return null; } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(evaluateInternal); + } + } + } + + public Type analyze(ExecutionContext ctx, Set<AnalysationIssue> issues) { + Type val = null; + try { + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + val = analyzeInternal(ctx, issues); + return val; + } + catch (final RuntimeException ex) { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, ex.getMessage(), this)); + return null; + } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(val); + } + } } - + + protected abstract Type analyzeInternal(ExecutionContext ctx, Set<AnalysationIssue> issues); + @Override public final String toString() { return toStringInternal(); } - + protected abstract String toStringInternal(); protected abstract Object evaluateInternal(ExecutionContext ctx); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java index 88c8f0cb..ff1981aa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -32,6 +30,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Arno Haase * @author Bernd Kolb */ +@SuppressWarnings("unchecked") public class FeatureCall extends Expression { private Expression target; @@ -176,7 +175,8 @@ public class FeatureCall extends Expression { * * otherwise it's a property */ - public Type analyze(final ExecutionContext ctx, + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type targetType = null; if (target == null) { @@ -257,7 +257,7 @@ public class FeatureCall extends Expression { protected Type findType(final Object value, final ExecutionContext ctx) { final Type t = ctx.getType(value); if (t == null) - throw new EvaluationException("Unkown object type : " + throw new EvaluationException("Unknown object type : " + value.getClass().getName(), this, ctx); return t; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java index a57a5b2f..bc4cf1aa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -47,7 +45,7 @@ public class GlobalVarExpression extends Expression { return o.getValue(); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getObjectType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java index 33033c8b..7e3c8242 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -23,4 +21,5 @@ public interface ISyntaxElement { public String getNameString(ExecutionContext context); + public Object accept(final AbstractVisitor visitor); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java index 622f78b0..7465dd11 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -61,4 +59,28 @@ public class Identifier extends SyntaxElement { public String toString() { return getValue(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getValue() == null) ? 0 : getValue().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null) + return false; + + if (getClass() != obj.getClass()) + return false; + + Identifier other = (Identifier) obj; + return getValue().equals(other.getValue()); + } + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java index c8c975c6..ae14f64f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -68,7 +66,7 @@ public class IfExpression extends Expression { } } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type conditionType = getCondition().analyze(ctx, issues); if (conditionType != null && !conditionType.equals(ctx.getBooleanType())) { issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean expected", getCondition())); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java index 2510b5ff..d2ed30b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class IntegerLiteral extends Literal { return new Long(getLiteralValue().getValue()); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getIntegerType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java index da20027d..76d9ec25 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -57,7 +55,7 @@ public class LetExpression extends Expression { return targetExpression.evaluate(ctx); } - public Type analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type t = varExpression.analyze(ctx, issues); if (t == null) return null; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java index d4fd48da..22de5f83 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -51,7 +49,7 @@ public class ListLiteral extends Expression { return col; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type t = null; for (int i = 0; i < elements.length; i++) { final Expression element = elements[i]; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java index 96da0c5f..48ae5018 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java index 4af6fa8a..a166302f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class NullLiteral extends Literal { return null; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getVoidType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java index 6979bd18..34111eb4 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -171,7 +169,7 @@ public class OperationCall extends FeatureCall { } @Override - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type[] paramTypes = new Type[getParams().length]; if (getParams().length > 0) { for (int i = 0; i < getParams().length; i++) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java index 8ccf87b0..6e28f9b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class RealLiteral extends Literal { return new Double(getLiteralValue().getValue()); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getRealType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java index d7401574..3648f2ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -33,7 +31,7 @@ public class StringLiteral extends Literal { return getValue(); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getStringType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java index 570bcb70..269a6b9a 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java @@ -1,22 +1,23 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.eclipse.xtend.expression.AnalysationIssue; import org.eclipse.xtend.expression.ExecutionContext; +import org.eclipse.xtend.expression.ExpressionFacade; import org.eclipse.xtend.typesystem.Type; /** @@ -26,79 +27,90 @@ import org.eclipse.xtend.typesystem.Type; */ public class SwitchExpression extends Expression { - private Expression switchExpr = null; - - private Expression defaultExpr = null; - - private List<Case> cases = null; - - public SwitchExpression(final Expression switchExpr, - final List<Case> cases, final Expression defaultExpr) { - this.switchExpr = switchExpr; - this.cases = cases; - this.defaultExpr = defaultExpr; - } - - @Override - protected Object evaluateInternal(final ExecutionContext ctx) { - Object switchVal = Boolean.TRUE; - if (switchExpr != null) - switchVal = switchExpr.evaluate(ctx); - for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { - final Case c = iter.next(); - final Object caseCondVal = c.getCondition().evaluate(ctx); - if ((switchVal != null && switchVal.equals(caseCondVal)) || switchVal == caseCondVal) - return c.getThenPart().evaluate(ctx); - } - return defaultExpr.evaluate(ctx); - } - - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - Type condType = ctx.getBooleanType(); - if (switchExpr != null) - condType = switchExpr.analyze(ctx, issues); - if (condType == null) - return null; - Type returnType = defaultExpr.analyze(ctx, issues); - if (returnType == null) - return null; - for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { - final Case c = iter.next(); - final Type caseCondType = c.getCondition().analyze(ctx, issues); - if (caseCondType != null) { - if (!condType.isAssignableFrom(caseCondType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, condType.getName() - + " expected!", c.getCondition())); - } - } - final Type caseThenType = c.getThenPart().analyze(ctx, issues); - if (caseThenType != null) { - if (!returnType.isAssignableFrom(caseThenType)) { - if (caseThenType.isAssignableFrom(returnType)) { - returnType = caseThenType; - } else { - returnType = ctx.getObjectType(); - } - } - } - } - return returnType; - } - - public List<Case> getCases() { - return cases; - } - - public Expression getDefaultExpr() { - return defaultExpr; - } - - public Expression getSwitchExpr() { - return switchExpr; - } - - @Override + private Expression switchExpr = null; + + private Expression defaultExpr = null; + + private List<Case> cases = null; + + public SwitchExpression(final Expression switchExpr, final List<Case> cases, final Expression defaultExpr) { + this.switchExpr = switchExpr; + this.cases = cases; + this.defaultExpr = defaultExpr; + } + + @Override + protected Object evaluateInternal(final ExecutionContext ctx) { + Object switchVal = Boolean.TRUE; + if (switchExpr != null) { + switchVal = switchExpr.evaluate(ctx); + } + for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { + final Case c = iter.next(); + final Object caseCondVal = c.getCondition().evaluate(ctx); + if ((switchVal != null && equals(switchVal, caseCondVal, ctx)) || switchVal == caseCondVal) + return c.getThenPart().evaluate(ctx); + } + return defaultExpr.evaluate(ctx); + } + + private boolean equals(Object switchVal, final Object caseCondVal, ExecutionContext ctx) { + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("swtch", switchVal); + props.put("cse", caseCondVal); + return (Boolean) new ExpressionFacade(ctx).evaluate("swtch==cse", props); + } + + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + Type condType = ctx.getBooleanType(); + if (switchExpr != null) { + condType = switchExpr.analyze(ctx, issues); + } + if (condType == null) + return null; + Type returnType = defaultExpr.analyze(ctx, issues); + if (returnType == null) + return null; + for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { + final Case c = iter.next(); + final Type caseCondType = c.getCondition().analyze(ctx, issues); + if (caseCondType != null) { + if (!condType.isAssignableFrom(caseCondType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, condType.getName() + + " expected!", c.getCondition())); + } + } + final Type caseThenType = c.getThenPart().analyze(ctx, issues); + if (caseThenType != null) { + if (!returnType.isAssignableFrom(caseThenType)) { + if (caseThenType.isAssignableFrom(returnType)) { + returnType = caseThenType; + } + else { + returnType = ctx.getObjectType(); + } + } + } + } + return returnType; + } + + public List<Case> getCases() { + return cases; + } + + public Expression getDefaultExpr() { + return defaultExpr; + } + + public Expression getSwitchExpr() { + return switchExpr; + } + + @Override protected String toStringInternal() { - return "switch " + switchExpr.toStringInternal() ; - } + return "switch " + switchExpr.toStringInternal(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java index 8e89f10d..b9d4ea48 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -60,4 +58,8 @@ public abstract class SyntaxElement implements ISyntaxElement { public String getNameString(ExecutionContext context) { return toString(); } + + public final Object accept(final AbstractVisitor visitor) { + return visitor.visit(this); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java index 3620303a..ea624c8c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.ast; @@ -69,7 +67,7 @@ public class TypeSelectExpression extends FeatureCall { final Collection<Object> resultCol = new ArrayList<Object>(); final Type t = ctx.getTypeForName(typeLiteral.getValue()); if (t == null) - throw new EvaluationException("Unkown type '" + typeLiteral + "'", typeLiteral, ctx); + throw new EvaluationException("Unknown type '" + typeLiteral + "'", typeLiteral, ctx); for (final Iterator<?> iter = collection.iterator(); iter.hasNext();) { final Object ele = iter.next(); if (ele!=null && t.isAssignableFrom(ctx.getType(ele))) { @@ -80,7 +78,7 @@ public class TypeSelectExpression extends FeatureCall { } @Override - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type targetType = null; if (getTarget() == null) { final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html new file mode 100644 index 00000000..5413c988 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +AST of the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java index a35e908f..0c45c635 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java index 25abe946..ee0730b5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; @@ -143,12 +141,12 @@ public class ExpressionProposalComputer implements ProposalComputer { // members and extensions on implicit variable (this) final Variable implicitVariable = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (implicitVariable != null) { + if (implicitVariable != null && implicitVariable.getValue()!=null) { implicitVariableType = (Type) implicitVariable.getValue(); proposals.addAll(getAllMemberProposals(implicitVariableType, prefix, ctx, factory)); for (StaticProperty p : implicitVariableType.getAllStaticProperties()) { if (p.getName().startsWith(prefix)) { - proposals.add(factory.createStaticPropertyProposal((StaticProperty) p, prefix, false)); + proposals.add(factory.createStaticPropertyProposal(p, prefix, false)); } } } @@ -160,17 +158,15 @@ public class ExpressionProposalComputer implements ProposalComputer { if (extension.getParameterTypes().size() >= 1) { Type firstParameterType = extension.getParameterTypes().get(0); - if (implicitVariable != null) { + if (implicitVariable != null && implicitVariable.getValue()!=null) { implicitVariableType = (Type) implicitVariable.getValue(); if (implicitVariableType.isAssignableFrom(firstParameterType) || firstParameterType.isAssignableFrom(implicitVariableType)) { skip = true; - System.out.println("SKIP"); } } } if (!skip) { - System.out.println("NOSKIP"); proposals.add(factory.createExtensionProposal(extension, prefix)); } } @@ -184,12 +180,13 @@ public class ExpressionProposalComputer implements ProposalComputer { if (implicitVariableType!=null) { for (StaticProperty p : implicitVariableType.getAllStaticProperties()) { if (p.getName().startsWith(prefix)) { - proposals.add(factory.createStaticPropertyProposal((StaticProperty) p, prefix, false)); + proposals.add(factory.createStaticPropertyProposal(p, prefix, false)); } } } } - } else { + } + else { // members and extensions on targetType proposals.addAll(getAllMemberProposals(implicitVariableType, prefix, ctx, factory)); } @@ -221,11 +218,14 @@ public class ExpressionProposalComputer implements ProposalComputer { v.forEach = true; v.expression = expressionString; vars.push(v); - } else if (m.group(4) != null) { + } + else if (m.group(4) != null) { vars.push(null); - } else if (m.group(5) != null) { + } + else if (m.group(5) != null) { vars.pop(); - } else + } + else throw new IllegalStateException("Match:" + m.group()); } for (final Iterator<LazyVar> iter = vars.iterator(); iter.hasNext();) { @@ -240,12 +240,14 @@ public class ExpressionProposalComputer implements ProposalComputer { targetType = ((ParameterizedType) var.getValue()).getInnerType(); } } - } else { + } + else { targetType = new ExpressionFacade(ctx).analyze(expressionString, new HashSet<AnalysationIssue>()); if (v.forEach) { if (targetType instanceof ParameterizedType) { targetType = ((ParameterizedType) targetType).getInnerType(); - } else { + } + else { targetType = null; } } @@ -262,41 +264,43 @@ public class ExpressionProposalComputer implements ProposalComputer { /** * Computes the list of proposals for a type. These proposals are: * <ol> - * <li>Owned features of the type: {@link Property}, {@link StaticProperty} or {@link Operation}. + * <li>Owned features of the type: {@link Property}, {@link StaticProperty} + * or {@link Operation}. * <li>Extensions whose first parameter is of type <code>targetType</code> * <li>For parametrized types all features of the parameter type * </ol> * - * @param targetType Type to search for proposals - * @param prefix A prefix the proposals must match - * @param ctx Current execution context - * @param factory Factory to use for proposal creation - * @return All proposals matching <code>prefix</code> for <code>targetType</code> + * @param targetType + * Type to search for proposals + * @param prefix + * A prefix the proposals must match + * @param ctx + * Current execution context + * @param factory + * Factory to use for proposal creation + * @return All proposals matching <code>prefix</code> for + * <code>targetType</code> */ - private final static List<Object> getAllMemberProposals(Type targetType, final String prefix, final ExecutionContext ctx, - final ProposalFactory factory) { + private final static List<Object> getAllMemberProposals(Type targetType, final String prefix, + final ExecutionContext ctx, final ProposalFactory factory) { final List<Object> result = new ArrayList<Object>(); + final Set<String> nameCache = new HashSet<String>(); if (targetType != null) { - Set<? extends Callable> s = targetType.getAllFeatures(); - for (final Callable f : s) { - if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { - if (f instanceof Property) { - result.add(factory.createPropertyProposal((Property) f, prefix, false)); - } else if (f instanceof Operation) { - if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { - result.add(factory.createOperationProposal((Operation) f, prefix, false)); - } - } - } + Set<? extends Callable> s; + result.addAll(addFeatureProposals(targetType, prefix, factory, nameCache)); + Set<? extends Type> superTypes = targetType.getSuperTypes(); + for (final Type t : superTypes) { + result.addAll(addFeatureProposals(targetType, prefix, factory, nameCache)); } - // get all extensions whose first parameter is compatible with 'targetType' + // get all extensions whose first parameter is compatible with + // 'targetType' Set<? extends Extension> extensions = ctx.getAllExtensions(); for (Extension extension : extensions) { if (extension.getName().toLowerCase().startsWith(prefix.toLowerCase())) { if (extension.getParameterTypes().size() >= 1) { Type firstParameterType = extension.getParameterTypes().get(0); - if (targetType.equals(firstParameterType)) { + if (firstParameterType.isAssignableFrom(targetType)) { result.add(factory.createExtensionOnMemberPositionProposal(extension, prefix, false)); } } @@ -310,7 +314,8 @@ public class ExpressionProposalComputer implements ProposalComputer { if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { if (f instanceof Property) { result.add(factory.createPropertyProposal((Property) f, prefix, true)); - } else if (f instanceof Operation) { + } + else if (f instanceof Operation) { if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { result.add(factory.createOperationProposal((Operation) f, prefix, true)); } @@ -329,45 +334,78 @@ public class ExpressionProposalComputer implements ProposalComputer { return result; } + private static List<Object> addFeatureProposals(Type targetType, final String prefix, + final ProposalFactory factory, Set<String> nameCache) { + List<Object> result = new ArrayList<Object>(); + Set<? extends Callable> s = targetType.getAllFeatures(); + for (final Callable f : s) { + Object proposal = null; + if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { + if (f instanceof Property) { + proposal = factory.createPropertyProposal((Property) f, prefix, false); + } + else if (f instanceof Operation) { + if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { + proposal = factory.createOperationProposal((Operation) f, prefix, false); + } + } + } + if (proposal != null && !factory.isDuplicate(nameCache, proposal)) { + factory.addToCache(nameCache, proposal); + result.add(proposal); + } + } + return result; + } + private static List<Object> getAllCollectionOperations(final String prefix, final ProposalFactory f) { final List<Object> result = new ArrayList<Object>(); final String marked = "expression-with-e"; String s = "select(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "reject(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "selectFirst(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "collect(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "exists(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "notExists(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "forAll(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "sortBy(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "typeSelect(Type)"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf("Type"), "Type".length())); + } return result; } @@ -401,17 +439,21 @@ public class ExpressionProposalComputer implements ProposalComputer { if (isOperand(t)) { if (lastWasOperator) { lastWasOperator = false; - } else { // two operands in sequence -> stopper! + } + else { // two operands in sequence -> stopper! scanner.nextToken(); stop = true; } - } else if (".".equals(t.getText())) { + } + else if (".".equals(t.getText())) { if (!lastWasOperator) { lastWasOperator = true; - } else + } + else // errorneous expression return new String[] { prefix, expr }; - } else if (isBlockCloser(t) && lastWasOperator) { + } + else if (isBlockCloser(t) && lastWasOperator) { lastWasOperator = false; final Stack<CommonToken> s = new Stack<CommonToken>(); s.push(t); @@ -421,7 +463,8 @@ public class ExpressionProposalComputer implements ProposalComputer { return new String[] { prefix, expr }; if (temp.getType() == t.getType()) { s.push(temp); - } else if (isOpposite(temp, t)) { + } + else if (isOpposite(temp, t)) { s.pop(); } } @@ -436,7 +479,8 @@ public class ExpressionProposalComputer implements ProposalComputer { scanner.nextToken(); } } - } else { + } + else { scanner.nextToken(); // go one forward stop = true; } @@ -445,18 +489,18 @@ public class ExpressionProposalComputer implements ProposalComputer { } } return new String[] { prefix, expr }; - } catch (final Exception e) { + } + catch (final Exception e) { return new String[] { prefix, expr }; } } private final static boolean isMethodName(final CommonToken token) { - if (token != null) { + if (token != null) return token.getType() == XtendLexer.Identifier || methodNames.contains(token.getText()); - } else { + else return false; } - } private final static boolean isOpposite(final CommonToken left, final CommonToken right) { final String temp = blockTokens.get(left.getText()); @@ -470,9 +514,8 @@ public class ExpressionProposalComputer implements ProposalComputer { } private final static boolean isOperand(final CommonToken t) { - return t.getType() == XtendLexer.Identifier || - t.getType() == XtendLexer.IntLiteral || - t.getType() == XtendLexer.StringLiteral || operands.contains(t.getText()); + return t.getType() == XtendLexer.Identifier || t.getType() == XtendLexer.IntLiteral + || t.getType() == XtendLexer.StringLiteral || operands.contains(t.getText()); } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java index 9bb62dd3..b66d18e6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; @@ -25,6 +23,7 @@ public class ExtensionImportProposalComputer { return p; } + @SuppressWarnings("unchecked") public List<Object> computeProposals(String part, ExecutionContext ctx, ProposalFactory factory, Set<String> extensionFileNames) { String prefix = computePrefix(part); List result = new ArrayList(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java index 145ddf75..26c183a4 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java index 042b4738..8bf89e60 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java index afeb978b..1a1ef6e2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java index 5b70b292..8f524ac9 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; +import java.util.Set; + import org.eclipse.internal.xtend.xtend.ast.Extension; import org.eclipse.xtend.typesystem.Operation; import org.eclipse.xtend.typesystem.Property; @@ -22,9 +22,13 @@ public interface ProposalFactory { /** * Creates an proposal for a static property - * @param p The property for which a proposal should be created - * @param prefix Current evaluation text prefix - * @param onCollection <code>true</code>: Proposal is computed on a collection + * + * @param p + * The property for which a proposal should be created + * @param prefix + * Current evaluation text prefix + * @param onCollection + * <code>true</code>: Proposal is computed on a collection * @return A proposal for the content assist */ public Object createStaticPropertyProposal(StaticProperty p, String prefix, boolean onCollection); @@ -33,7 +37,7 @@ public interface ProposalFactory { public Object createCollectionSpecificOperationProposal(String insertString, String displayString, String prefix, int cursor, int marked); - + public Object createDefinitionProposal(final String insertStr, final String displayStr, final String prefix); public Object createExtensionProposal(Extension p, String prefix); @@ -56,4 +60,7 @@ public interface ProposalFactory { public Object createExtensionImportProposal(final String insertStr, final String displayStr, final String prefix, final int cursor, final int marked); + public boolean isDuplicate(Set<String> nameCache, Object proposal); + + public void addToCache(Set<String> nameCache, Object proposal); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java index 262d9d9a..1d8943a7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; +import java.util.Set; + import org.eclipse.internal.xtend.xtend.ast.Extension; import org.eclipse.xtend.expression.Variable; import org.eclipse.xtend.typesystem.Operation; @@ -80,4 +80,31 @@ public class ProposalFactoryDefaultImpl implements ProposalFactory { return new ProposalImpl(prefix, insertStr, displayStr, displayStr); } + public boolean isDuplicate(Set<String> nameCache, Object proposal) { + if (nameCache == null || proposal == null) + throw new IllegalArgumentException(); + + ProposalImpl p = castToProposal(proposal); + if (p != null) { + if (nameCache.contains(p.getDisplayString())) + return true; + else + return false; + } + return true; + } + + public void addToCache(Set<String> nameCache, Object proposal) { + ProposalImpl p = castToProposal(proposal); + if (p != null) { + nameCache.add(p.getDisplayString()); + } + } + + private ProposalImpl castToProposal(Object obj) { + if (obj instanceof ProposalImpl) + return (ProposalImpl) obj; + + return null; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java index 7db665bf..c4438a0e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java index de289da6..0fe705c8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java index 20837669..19f834dc 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html new file mode 100644 index 00000000..70ef09d6 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Parser for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java index b8e953d1..62e46328 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java index 77625c26..d08bf381 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java index fe71a2d9..1c46e413 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.debug; @@ -27,6 +25,7 @@ import org.eclipse.emf.mwe.core.debug.processing.ElementAdapter; import org.eclipse.internal.xtend.expression.ast.ChainExpression; import org.eclipse.internal.xtend.expression.ast.Expression; import org.eclipse.internal.xtend.expression.ast.FeatureCall; +import org.eclipse.internal.xtend.expression.ast.ISyntaxElement; import org.eclipse.internal.xtend.expression.ast.Literal; import org.eclipse.internal.xtend.expression.ast.OperationCall; import org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver; @@ -92,15 +91,17 @@ public class ExpressionElementAdapter implements ElementAdapter { public boolean shallSuspend(Object element, int flag) { boolean result = true; - for (BaseSpecialTreatment special : specials) + for (BaseSpecialTreatment special : specials) { result &= !(special.shallNotSuspend(element, flag, context)); + } return result; } public SyntaxElement createElementTO(Object element) { - SyntaxElement to = pres.getStartPresentation((org.eclipse.internal.xtend.expression.ast.SyntaxElement) element, context); - for (BaseSpecialTreatment special : specials) + SyntaxElement to = pres.getStartPresentation((ISyntaxElement) element, context); + for (BaseSpecialTreatment special : specials) { special.adaptSyntaxElement(to, element); + } return to; } @@ -132,9 +133,8 @@ public class ExpressionElementAdapter implements ElementAdapter { } public List<NameValuePair> getVariables(Object element) { - if (element instanceof ChainExpression || element instanceof Literal) { + if (element instanceof ChainExpression || element instanceof Literal) return Collections.EMPTY_LIST; - } if (element instanceof OperationCall) { ArrayList<NameValuePair> result = getAllVisibleVariables(); @@ -161,9 +161,8 @@ public class ExpressionElementAdapter implements ElementAdapter { return result; } - if (element instanceof FeatureCall) { + if (element instanceof FeatureCall) return evaluateFeatureCall((FeatureCall) element); - } if (element instanceof Collection) { List<NameValuePair> result = new ArrayList<NameValuePair>(); Collection col = (Collection) element; @@ -216,9 +215,12 @@ public class ExpressionElementAdapter implements ElementAdapter { return getAllPropertiesFor(type, evaluate); } - // Hint: We don't use the AbstractTypeImpl collection of all properties, because it collects methods with the - // same name from superclasses twice. We take only the most specialized method here (as in Java) - // Is this a bug or intended that way in AbstractTypeImpl? (TODO: ask Sven or Arno) + // Hint: We don't use the AbstractTypeImpl collection of all properties, + // because it collects methods with the + // same name from superclasses twice. We take only the most specialized + // method here (as in Java) + // Is this a bug or intended that way in AbstractTypeImpl? (TODO: ask Sven + // or Arno) private List<NameValuePair> getAllPropertiesFor(Type type, Object element) { ArrayList<NameValuePair> result = new ArrayList<NameValuePair>(); @@ -228,7 +230,8 @@ public class ExpressionElementAdapter implements ElementAdapter { Object value = null; try { value = p.get(element); - } catch (Exception e) { + } + catch (Exception e) { value = "Error: " + e.getMessage(); } if (value != null) { @@ -250,15 +253,17 @@ public class ExpressionElementAdapter implements ElementAdapter { public final Set<Callable> getAllFeatures(Type type) { Map<String, Callable> allFeatures; - if (typeCache.containsKey(type)) + if (typeCache.containsKey(type)) { allFeatures = typeCache.get(type); + } else { allFeatures = new HashMap<String, Callable>(); Callable[] contribs = ((AbstractTypeImpl) type).getContributedFeatures(); addIfNotExist(allFeatures, Arrays.asList(contribs)); for (Type superType : type.getSuperTypes()) { - if (superType != null) + if (superType != null) { addIfNotExist(allFeatures, getAllFeatures(superType)); + } } typeCache.put(type, allFeatures); } @@ -270,8 +275,9 @@ public class ExpressionElementAdapter implements ElementAdapter { private void addIfNotExist(Map<String, Callable> all, Collection<Callable> more) { for (Callable one : more) { String name = one.getName(); - if (!all.containsKey(name)) + if (!all.containsKey(name)) { all.put(name, one); + } } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java index 00b3fa53..e1b1f029 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java index 94ad4a33..d3bce726 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html new file mode 100644 index 00000000..1d6fbb8c --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Debugger support for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html new file mode 100644 index 00000000..52d87ac9 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java index 0bfbc7fb..4fb99031 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java index fff1a1d0..b46a410c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html new file mode 100644 index 00000000..4cdd6270 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:35 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Parser for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java index 1472b72d..88531fc1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; @@ -21,20 +19,7 @@ import java.util.Map; import java.util.Set; 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; -import org.eclipse.internal.xtend.type.baseimpl.types.FeatureTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.IntegerTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.ListTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.ObjectTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.OperationTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.PropertyTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.RealTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.SetTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.StaticPropertyTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.StringTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.TypeTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.VoidType; +import org.eclipse.internal.xtend.type.baseimpl.types.*; import org.eclipse.internal.xtend.util.Cache; import org.eclipse.xtend.expression.TypeSystem; import org.eclipse.xtend.typesystem.MetaModel; @@ -182,58 +167,128 @@ public final class BuiltinMetaModel implements MetaModel { _knownTypes = new HashSet<Type>(_builtinTypes.values()); } + /** + * Returns the name of the metamodel. + * + * @return name of metamodel + */ public String getName() { return "built-in"; } + /** + * Returns the type for objects. + * + * @return type for objects + */ public final Type getObjectType() { return objectType; } + /** + * Returns the type for boolean objects. + * + * @return type for boolean objects + */ public final Type getBooleanType() { return booleanType; } + /** + * Returns the type for integer objects. + * + * @return type for integer objects + */ public final Type getIntegerType() { return integerType; } + /** + * Returns the type for real objects. + * + * @return type for real objects + */ public Type getRealType() { return realType; } + /** + * Returns the type for string objects. + * + * @return type for string objects + */ public final Type getStringType() { return stringType; } + /** + * Returns the type for type objects. + * + * @return type for type objects + */ public final Type getTypeType() { return typeType; } + /** + * Returns the type for feature objects. + * + * @return type for feature objects + */ public final Type getFeatureType() { return featureType; } + /** + * Returns the type for property objects. + * + * @return type for property objects + */ public final Type getPropertyType() { return propertyType; } + /** + * Returns the type for operation objects. + * + * @return type for operation objects + */ public final Type getOperationType() { return operationType; } + /** + * Returns the type for static property objects. + * + * @return type for static property objects + */ public Type getStaticPropertyType() { return staticPropertyType; } + /** + * Returns the type for collection objects. + * + * @return type for collection objects + */ public final ParameterizedType getCollectionType(final Type innerType) { return new CollectionTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.COLLECTION); } + /** + * Returns the type for list objects. + * + * @return type for list objects + */ public final ParameterizedType getListType(final Type innerType) { return new ListTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.LIST); } + /** + * Returns the type for set objects. + * + * @return type for set objects + */ public final ParameterizedType getSetType(final Type innerType) { return new SetTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.SET); } @@ -242,57 +297,55 @@ public final class BuiltinMetaModel implements MetaModel { @Override protected Type createNew(Object obj) { - if (obj == null) { + if (obj == null) return getVoidType(); - } - if (obj instanceof Set) { + if (obj instanceof Set) return getSetType(getObjectType()); - } - if (obj instanceof List) { + if (obj instanceof List) return getListType(getObjectType()); - } - if (obj instanceof Collection) { + if (obj instanceof Collection) return getCollectionType(getObjectType()); - } // datatypes - if (stringType.isInstance(obj)) { + if (stringType.isInstance(obj)) return stringType; - } - if (integerType.isInstance(obj)) { + if (integerType.isInstance(obj)) return integerType; - } - if (booleanType.isInstance(obj)) { + if (booleanType.isInstance(obj)) return booleanType; - } - if (realType.isInstance(obj)) { + if (realType.isInstance(obj)) return realType; - } - if (typeType.isInstance(obj)) { + if (typeType.isInstance(obj)) return typeType; - } - if (propertyType.isInstance(obj)) { + if (propertyType.isInstance(obj)) return propertyType; - } - if (operationType.isInstance(obj)) { + if (operationType.isInstance(obj)) return operationType; - } - if (staticPropertyType.isInstance(obj)) { + if (staticPropertyType.isInstance(obj)) return staticPropertyType; - } - + return objectType; } }; + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getType(java.lang.Object) + */ public Type getType(final Object obj) { return typeCache.get(obj); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeForName(java.lang.String) + */ public Type getTypeForName(final String typeName) { return _builtinTypes.get(typeName); } HashSet<Type> _knownTypes; + + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getKnownTypes() + */ public Set<Type> getKnownTypes() { return _knownTypes; } @@ -303,23 +356,35 @@ public final class BuiltinMetaModel implements MetaModel { final char c = javaclassname.charAt(i); if (c == '.') { sb.append(SyntaxConstants.NS_DELIM); - } else { + } + else { sb.append(c); } } return sb.toString(); } + /** + * Returns the type for void objects. + * + * @return type for void objects + */ public Type getVoidType() { return voidType; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#setTypeSystem(org.eclipse.xtend.expression.TypeSystem) + */ public void setTypeSystem(final TypeSystem typeSystem) { if (typeSystem != null) { this.typeSystem = typeSystem; } } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getNamespaces() + */ public Set<String> getNamespaces() { // TODO: provide real implementation return new HashSet<String>(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java index 43ef87b6..36a610f5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java index 01907b30..b204b918 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; @@ -24,6 +22,7 @@ public abstract class OperationImpl extends FeatureImpl implements Operation { private Type owner; + @SuppressWarnings("unchecked") public OperationImpl(final Type owner, final String name, final Type returnType, final Type... paramTypes) { super(name, returnType); this.paramTypes = paramTypes == null ? new ArrayList() : Arrays.asList(paramTypes); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java index 1a39cc60..3dafe851 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; @@ -61,6 +59,7 @@ public class PolymorphicResolver { return getFeature(callables, Callable.class, name, paramTypes); } + @SuppressWarnings("unchecked") public static <T> Set<T> select(final Set<? extends Callable> features, final Class<T> type) { final Set<T> result = new HashSet<T>(); for (Callable callable : features) { @@ -71,6 +70,7 @@ public class PolymorphicResolver { return result; } + @SuppressWarnings("unchecked") public final static Callable getFeature(final Set<? extends Callable> features, final Class type, final String name, final List<? extends Type> paramTypes) { final List<Callable> possFeatures = new ArrayList<Callable>(); @@ -88,12 +88,25 @@ public class PolymorphicResolver { else if (possFeatures.isEmpty()) return null; else { - // sort features by specialization - Collections.sort(possFeatures, paramFeatureComparator); - if (paramFeatureComparator.compare(possFeatures.get(1), possFeatures.get(0)) > 0) { - return possFeatures.get(0); + // remove assignable features + for (int c1 = 0; c1 < possFeatures.size() - 1; ++c1) { + Callable feature1 = possFeatures.get(c1); + for (int c2 = c1 + 1; c2 < possFeatures.size(); ++c2) { + Callable feature2 = possFeatures.get(c2); + if (paramFeatureComparator.compare(feature2, feature1) > 0) { + possFeatures.remove(c2); + --c2; + } else if (paramFeatureComparator.compare(feature1, feature2) > 0) { + possFeatures.remove(c1); + --c1; + break; + } + } } + if (possFeatures.size() == 1) + return possFeatures.get(0); + for (Callable callable : possFeatures) { if (callable instanceof Extension) { throw new RuntimeException("Ambiguous operations " + possFeatures.get(0).toString() + " and " + possFeatures.get(1).toString() diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java index 1dcae7d8..c7a85a28 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java index 7df5a017..8d65b02c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java index 84c114a1..e8ab1ef8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html new file mode 100644 index 00000000..e0886998 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic abstractions of the type system +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java index 022d8490..e37a178f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -28,6 +26,7 @@ public final class BooleanTypeImpl extends BuiltinBaseType implements Type { return o instanceof Boolean; } + @SuppressWarnings("unchecked") @Override public Object convert(final Object src, final Class targetType) { if (targetType == Boolean.class || targetType == Boolean.TYPE) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java index b27d7da1..92193adc 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java index e34e8358..bc988ec8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -19,6 +17,8 @@ import java.util.Iterator; 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.xtend.expression.TypeSystem; @@ -30,298 +30,316 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") 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."; - } + private static final Log LOG = LogFactory.getLog(CollectionTypeImpl.class); + + 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) { + if (target == null) { + LOG.warn("toList called with Null argument. Will return an empty list."); + return new ArrayList<Object>(0); + } + 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) { + if (target == null) { + LOG.warn("toSet called with Null argument. Will return an empty set."); + return new ArrayList<Object>(0); + } + return new java.util.LinkedHashSet<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) { + if (target == null) { + LOG.warn("isEmpty called with Null argument. Will return true."); + return Boolean.TRUE; + } + 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); + if (params != null && params[0] != null) { + r.addAll((Collection) params[0]); + } + else { + LOG.warn("Invoking union() with Null as argument. Will return the source collection."); + } + 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 flattened List."; + } @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; - } + 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.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java index 9f3af2ee..66cfb932 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java index c80ec008..b59a242b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -189,7 +187,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type { @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." + + "the value of the specified Integer, incremented by one.<br/>" + "e.g. '1.upTo(5)' evaluates to {1,2,3,4,5}"; } @@ -210,7 +208,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type { @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." + + "the value of the first paramter, incremented by the second parameter.<br/>" + "e.g. '1.upTo(10, 2)' evaluates to {1,3,5,7,9}"; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java index c77fdf6b..857d75d8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -69,7 +67,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { } return null; } - }, new OperationImpl(this, "reverse", getInnerType(), new Type[0]) { + }, new OperationImpl(this, "reverse", getTypeSystem().getCollectionType(getInnerType()), new Type[0]) { @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { @@ -90,6 +88,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { return null; } }, new OperationImpl(this, "withoutFirst", this, new Type[0]) { + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { @@ -103,6 +102,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { return null; } }, new OperationImpl(this, "withoutLast", this, new Type[0]) { + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java index 474e3292..48c85b61 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -25,6 +23,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class ObjectTypeImpl extends BuiltinBaseType implements Type { public ObjectTypeImpl(final TypeSystem ts, final String name) { @@ -111,6 +110,7 @@ public class ObjectTypeImpl extends BuiltinBaseType implements Type { + "or greater than the specified object."; } + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target == null) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java index 5086c001..e5aa603c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java index f9016d42..03de84da 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java index 0280c048..32893b08 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java index 67616037..2b95b70f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java index 6971038a..862eb563 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java index abc8d176..924a4c79 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -30,6 +28,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class StringTypeImpl extends BuiltinBaseType implements Type { final Log log = LogFactory.getLog(getClass()); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java index 165737cf..fd011c75 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; @@ -25,6 +23,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class TypeTypeImpl extends BuiltinBaseType { public TypeTypeImpl(final TypeSystem ts, final String name) { @@ -157,7 +156,7 @@ public class TypeTypeImpl extends BuiltinBaseType { } }, - new OperationImpl(this, "newInstance", getTypeSystem().getObjectType(), new Type[0]) { + new OperationImpl(this, "newInstance", getTypeSystem().getObjectType()) { @Override public Object evaluateInternal(final Object target, final Object[] params) { return ((Type) target).newInstance(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java index 9e29701a..9c3ee7ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html new file mode 100644 index 00000000..fbe7d91a --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic builtin types +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java index ada5aa34..af1e36ba 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java index ba7ce7da..d7786633 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; @@ -36,10 +34,16 @@ public class JavaMetaModel implements MetaModel, TypeFinder { private TypeSystem typeSystem; + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeSystem() + */ public TypeSystem getTypeSystem() { return typeSystem; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#setTypeSystem(org.eclipse.xtend.expression.TypeSystem) + */ public void setTypeSystem(final TypeSystem typeSystem) { if (typeSystem != null) { this.typeSystem = typeSystem; @@ -59,13 +63,12 @@ public class JavaMetaModel implements MetaModel, TypeFinder { @Override protected Type createNew(Class<?> clazz) { JavaTypeImpl impl = new JavaTypeImpl(JavaMetaModel.this, clazz, getName(clazz), _strategy); - if (List.class.isAssignableFrom(clazz)) { + if (List.class.isAssignableFrom(clazz)) return typeSystem.getListType(typeSystem.getObjectType()); - } else if (Set.class.isAssignableFrom(clazz)) { + else if (Set.class.isAssignableFrom(clazz)) return typeSystem.getSetType(typeSystem.getObjectType()); - } else if (Collection.class.isAssignableFrom(clazz)) { + else if (Collection.class.isAssignableFrom(clazz)) return typeSystem.getCollectionType(typeSystem.getObjectType()); - } return impl; } }; @@ -84,7 +87,8 @@ public class JavaMetaModel implements MetaModel, TypeFinder { try { Class<?> loadedClass = ResourceLoaderFactory.createResourceLoader().loadClass(classname); return loadedClass == null ? NOCLASS : loadedClass; - } catch (Exception e1) { + } + catch (Exception e1) { // FIXME: This catch block should really be removed - the // built-in ResosurceLoader implementation // never throws an exception, and contributed implementations @@ -94,6 +98,9 @@ public class JavaMetaModel implements MetaModel, TypeFinder { } }; + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetTypeForName(java.lang.String) + */ public Type builtinAwareGetTypeForName(final String typeName) { Type type = typeSystem.getTypeForName(typeName); if (type == null) { @@ -102,14 +109,19 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeForName(java.lang.String) + */ public Type getTypeForName(final String typeName) { final Class<?> clazz = classCache.get(typeName); - if (clazz == NOCLASS) { + if (clazz == NOCLASS) return null; - } return getTypeForClass(clazz); } + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetType(java.lang.Object) + */ public Type builtinAwareGetType(final Object obj) { Type type = typeSystem.getType(obj); if (type == null) { @@ -118,13 +130,18 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getType(java.lang.Object) + */ public Type getType(final Object obj) { - if (obj == null) { + if (obj == null) return null; - } return getTypeForClass(obj.getClass()); } + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetTypeForClass(java.lang.Class) + */ public Type builtinAwareGetTypeForClass(final Class<?> clazz) { Type type = typeSystem.getTypeForName(getName(clazz)); if (type == null) { @@ -133,19 +150,40 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * Returns the corresponding type for an <code>EClass</code> object. + * + * @param clazz + * the <code>EClass</code> object + * @return the corresponding type + */ public Type getTypeForClass(final Class<?> clazz) { return cache.get(clazz); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getKnownTypes() + */ public Set<Type> getKnownTypes() { final Collection<Type> col = cache.getValues(); return (Set<Type>) (col instanceof Set ? col : new HashSet<Type>(col)); } + /** + * Returns the metamodel name. + * + * @return the metamodel name + */ public String getName() { return _name; } + /** + * Sets the type strategy. + * + * @param strategy + * the type strategy + */ public void setTypeStrategy(final JavaTypeStrategy strategy) { _strategy = strategy; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java index 053c5067..41e2bdef 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java index 66d4ac02..348f34e5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java index d92dcb6a..ec516e6b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java index f5785f77..59211233 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; @@ -54,6 +52,7 @@ public class JavaTypeImpl extends AbstractTypeImpl implements Type { return features; } + @SuppressWarnings("unchecked") @Override public Set<Type> getSuperTypes() { if (superTypes == null) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java index 514c3e68..420b3e0c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java index 7bc9be0b..bde02afa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java index a3062cc5..578f1d26 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.java.beans; @@ -54,6 +52,7 @@ public class JavaBeansStrategy implements JavaTypeStrategy { * <li> Java5 enumeration literals for defined enum types * </ul> */ + @SuppressWarnings("unchecked") public Feature[] getFeatures(final TypeFinder typeFinder, final Class clazz, final Type t) { final List<FeatureImpl> result = new ArrayList<FeatureImpl>(); @@ -80,45 +79,80 @@ public class JavaBeansStrategy implements JavaTypeStrategy { if (pd.getReadMethod() != null) { usedMethods.add(pd.getReadMethod()); } - result.add(new JavaPropertyImpl(t, propName, typeFinder.builtinAwareGetTypeForClass(pd.getPropertyType()), pd.getReadMethod(), pd + // Problem: pd.getPropertyType() does not allow to get information about generics. When having a generic collection as property type + // the property type is just of the collection interface, e.g. java.util.List + result.add(new JavaPropertyImpl(t, pd.getName(), typeFinder.builtinAwareGetTypeForClass(pd.getPropertyType()), pd.getReadMethod(), pd .getWriteMethod())); } } - final Method[] meths = clazz.getDeclaredMethods(); + Set<Class<?>> classSet = new HashSet<Class<?>>(); + List<Method> methodList = new ArrayList<Method>(); + + if (Modifier.isPublic(clazz.getModifiers())) { + classSet.add(clazz); + } else { + Set<Class<?>> superClasses = getSuperClasses(clazz); + if (superClasses != null) { + classSet = superClasses; + } else { + classSet.add(clazz.getEnclosingClass()); + } + } + + // Methods + for (final Class<?> c : classSet) { + final Method[] meths = c.getDeclaredMethods(); for (int i = 0; i < meths.length; i++) { final Method method = meths[i]; - if (Modifier.isPublic(method.getModifiers()) && !usedMethods.contains(method)) { - // leave the accessor methods in: they don't hurt, and this way + if (Modifier.isPublic(method.getModifiers()) + && !usedMethods.contains(method)) { + // leave the accessor methods in: they don't hurt, and this + // way // we can e.g. call "set" methods try { // special handling for accessor method for boolean // properties, whose return type is // the wrapper type 'Boolean' (not 'boolean') if (isNonStandardBooleanProperty(method)) { - handleNonStandardBooleanProperty(typeFinder, t, result, pdArr, method); + handleNonStandardBooleanProperty(typeFinder, t, + result, pdArr, method); } else { - Type returnType = typeFinder.builtinAwareGetTypeForClass(method.getReturnType()); - result.add(new JavaOperationImpl(t, method.getName(), returnType, createTypes(method.getParameterTypes(), typeFinder), method)); + Type returnType = typeFinder + .builtinAwareGetTypeForClass(method + .getReturnType()); + result + .add(new JavaOperationImpl(t, method + .getName(), returnType, + createTypes(method + .getParameterTypes(), + typeFinder), method)); } } catch (final RuntimeException e) { // ignore } } } + } // staticProps - final Field[] fields = clazz.getFields(); + for (final Class<?> c : classSet) { + final Field[] fields = c.getFields(); for (int i = 0; i < fields.length; i++) { final Field field = fields[i]; final int mod = field.getModifiers(); - if (Modifier.isPublic(mod) && Modifier.isStatic(mod) && Modifier.isFinal(mod)) { - result.add(new JavaStaticPropertyImpl(t, field.getName(), typeFinder.builtinAwareGetTypeForClass(field.getType()), field)); + if (Modifier.isPublic(mod) && Modifier.isStatic(mod) + && Modifier.isFinal(mod)) { + result.add(new JavaStaticPropertyImpl(t, field.getName(), + typeFinder.builtinAwareGetTypeForClass(field + .getType()), field)); + } } } // Java 5 enums - final Object[] enumValues = clazz.getEnumConstants(); + for (final Class<?> c : classSet) { + final Object[] enumValues = c.getEnumConstants(); if (enumValues != null) { for (Object o : enumValues) { final Enum<?> curEnum = (Enum<?>) o; @@ -129,7 +163,7 @@ public class JavaBeansStrategy implements JavaTypeStrategy { }); } } - + } return result.toArray(new Feature[result.size()]); } @@ -205,4 +239,19 @@ public class JavaBeansStrategy implements JavaTypeStrategy { return result; } + private Set<Class<?>> getSuperClasses(Class<?> clazz) { + final Set<Class<?>> superClasses = new HashSet<Class<?>>(); + final Class<?> superClass = clazz.getSuperclass(); + if (superClass != null) { + superClasses.add(superClass); + } + + final Class<?>[] superInterfaces = clazz.getInterfaces(); + if (superInterfaces != null) { + for (Class<?> i: superInterfaces) { + superClasses.add(i); + } + } + return superClasses; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html new file mode 100644 index 00000000..41c65580 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Classes for Java beans support +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html new file mode 100644 index 00000000..33218b35 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Typesystem implementation for Java types +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java index 2dac33ab..db6b671f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.type.impl.oawclassic; @@ -38,6 +36,7 @@ public class OAWClassicStrategy implements JavaTypeStrategy { return false; } + @SuppressWarnings("unchecked") public Feature[] getFeatures(final TypeFinder typeFinder, final Class clazz, final Type owner) { final List<FeatureImpl> result = new ArrayList<FeatureImpl>(); final Method[] methods = clazz.getMethods(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html new file mode 100644 index 00000000..a6f148d1 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Typesystem implementation for oAW classic +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java index 5d6f886c..dc8e1c0e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java index e1910f3f..83e2da6e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java index 41e082de..d11d4fa6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java index 8bcf64bf..aaaa4fb2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; @@ -19,6 +17,7 @@ import org.eclipse.xtend.expression.ExecutionContextImpl; import org.eclipse.xtend.expression.ExpressionFacade; public class HigherOrder { + @SuppressWarnings("unchecked") public static <T> Collection<T> select(Collection<T> col, String closure) { return (Collection<T>) facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); } @@ -35,6 +34,7 @@ public class HigherOrder { return (Boolean)facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); } + @SuppressWarnings("unchecked") public static <T> T first(Collection<T> col, String closure) { Collection<T> re = (Collection<T>) facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); if (re!=null && re.size()>0) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java index be86ce3a..32412285 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java index 70640709..9aa37822 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; @@ -51,7 +49,7 @@ public class ProfileCollector { _out = new PrintWriter (new OutputStreamWriter (out, "utf-8")); _out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - _out.println("<m2t-profile>"); + _out.println("<oaw-profile>"); } catch (UnsupportedEncodingException exc) {} } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java index 1fc32276..94cbd3af 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java index 1a86df32..8cb5bd74 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java index be97ba2b..7b350eb2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java index e0e9aed6..9da5f832 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java index 37278da0..e102e3c7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java index 8f7ed015..f2a18f67 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java index e513a371..feac31ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java index cb0725b1..5e8c7e48 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java index 59306e5e..3c3f34d8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java index 92ff0d21..e9956564 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java index c29d6e50..9ec97635 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html new file mode 100644 index 00000000..99f551c6 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Utility classes +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java index 49a88fa0..d2892902 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java index cf8a5a65..75da47b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java index 9a891181..766e632f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java index 4403a857..9c08df58 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java index 54eb9e1a..091ecdbd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java index 6fa9137e..036114ed 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java index 5e89b383..3ab0c7b1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java index 080c297f..8848c841 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java index c1e3a853..f57be676 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java index 1ab696c6..15c04e7f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java index 2865ea71..077fc9e1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java index 0812da62..7a541906 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java index 7a38a11c..8ec34609 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java index cd8ce0d6..032ccba1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java index e235e4fa..627335fd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java index 7249e593..5d37e4cf 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java index 06571dd2..33f01fb1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java index 7edf7f39..3bf62cbf 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java index ea3aba5d..99eefa02 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java index e9708509..befe0897 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java index 7489881c..65371e8c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java index 82c2eb2e..e5ceb261 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java @@ -1,4 +1,11 @@ -// $ANTLR 3.0 /Users/huebner/Entwicklung/workspace-oaw5/org.eclipse.xtend/bin/org/eclipse/internal/xtend/xtend/parser/Xtend.g 2008-11-24 17:55:04 +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java index 733707bc..bfd1d748 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java index ab44d964..419c25b0 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java @@ -1,4 +1,11 @@ -// $ANTLR 3.0 /Users/huebner/Entwicklung/workspace-oaw5/org.eclipse.xtend/bin/org/eclipse/internal/xtend/xtend/parser/Xtend.g 2008-11-24 17:55:03 +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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 + * + *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java index 7e552762..b670d831 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java index afdd4069..bfe98460 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java index ea21a825..fda9f4ea 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) 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.internal.xtend.xtend.types; |