summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2016-02-02 16:47:34 -0500
committerKarsten Thoms2016-02-02 16:48:03 -0500
commitc4c5f5a81b76cc6084d12bd7fec95c1bc6e88c21 (patch)
tree4f24895963cdae6a4da561b03b9a55cdf74dd8fc
parent97308e37a12d7b2ce4291bf2fc376bdb89dceae4 (diff)
downloadorg.eclipse.xpand-c4c5f5a81b76cc6084d12bd7fec95c1bc6e88c21.tar.gz
org.eclipse.xpand-c4c5f5a81b76cc6084d12bd7fec95c1bc6e88c21.tar.xz
org.eclipse.xpand-c4c5f5a81b76cc6084d12bd7fec95c1bc6e88c21.zip
[482602] Avoid NPE on comments on breakpoints and defines
Change-Id: Ie95f2df37abae08697a9e76d24c687dde9b2df15 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java23
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java9
2 files changed, 27 insertions, 5 deletions
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 f6b4e2c1..60da4eb3 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
@@ -31,8 +31,9 @@ import org.eclipse.xtend.typesystem.Type;
* @author Sven Efftinge (http://www.efftinge.de)
* @author Arno Haase
* @author Bernd Kolb
- * @author Karsten Thoms - maintenance
+ * @author Karsten Thoms (itemis) - maintenance
* @author Ed Merks - Bug#418156,418240
+ * @author Aykut Kilic (itemis) - Bug#480758
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public class CollectionExpression extends FeatureCall {
@@ -145,8 +146,12 @@ public class CollectionExpression extends FeatureCall {
}
List<Pair> pairs = new ArrayList<Pair>();
final String elementName = getElementName();
+ ExecutionContext _ctx;
for (Object o : collection) {
- pairs.add(new Pair(o, closure.evaluate(ctx.cloneWithVariable(new Variable(elementName, o)))));
+ _ctx = ctx.cloneWithVariable(new Variable(elementName, o));
+ _ctx.preTask(this);
+ pairs.add(new Pair(o, closure.evaluate(_ctx)));
+ _ctx.postTask(this);
}
Collections.sort(pairs);
List<Object> result = new ArrayList(pairs.size());
@@ -162,7 +167,9 @@ public class CollectionExpression extends FeatureCall {
String elementName = getElementName();
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
_ctx = _ctx.cloneWithVariable(new Variable(elementName, iter.next()));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (!Boolean.TRUE.equals(result)) {
return Boolean.FALSE;
}
@@ -175,7 +182,9 @@ public class CollectionExpression extends FeatureCall {
String elementName = getElementName();
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
_ctx = _ctx.cloneWithVariable(new Variable(elementName, iter.next()));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (Boolean.TRUE.equals(result)) {
return Boolean.TRUE;
}
@@ -188,7 +197,9 @@ public class CollectionExpression extends FeatureCall {
String elementName = getElementName();
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
_ctx = _ctx.cloneWithVariable(new Variable(elementName, iter.next()));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (Boolean.TRUE.equals(result)) {
return Boolean.FALSE;
}
@@ -203,7 +214,9 @@ public class CollectionExpression extends FeatureCall {
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
final Object ele = iter.next();
_ctx = _ctx.cloneWithVariable(new Variable(elementName, ele));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (Boolean.TRUE.equals(result)) {
resultCol.remove(ele);
}
@@ -218,7 +231,9 @@ public class CollectionExpression extends FeatureCall {
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
final Object ele = iter.next();
_ctx = _ctx.cloneWithVariable(new Variable(elementName, ele));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (Boolean.TRUE.equals(result)) {
resultCol.add(ele);
}
@@ -233,7 +248,9 @@ public class CollectionExpression extends FeatureCall {
for (final Iterator iter = collection.iterator(); iter.hasNext();) {
final Object ele = iter.next();
_ctx = _ctx.cloneWithVariable(new Variable(elementName, ele));
+ _ctx.preTask(this);
final Object result = closure.evaluate(_ctx);
+ _ctx.postTask(this);
if (Boolean.TRUE.equals(result)) {
resultCol.add(ele);
}
@@ -251,7 +268,9 @@ public class CollectionExpression extends FeatureCall {
for (final Iterator iter = Collections.unmodifiableCollection(collection).iterator(); iter.hasNext();) {
final Object ele = iter.next();
_ctx = _ctx.cloneWithVariable(new Variable(elementName, ele));
+ _ctx.preTask(this);
resultCol.add(closure.evaluate(_ctx));
+ _ctx.postTask(this);
}
return resultCol;
}
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 e0663fdb..b0626399 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
@@ -25,6 +25,7 @@ import org.eclipse.emf.mwe.core.debug.model.NameValuePair;
import org.eclipse.emf.mwe.core.debug.model.SyntaxElement;
import org.eclipse.emf.mwe.core.debug.processing.ElementAdapter;
import org.eclipse.internal.xtend.expression.ast.ChainExpression;
+import org.eclipse.internal.xtend.expression.ast.CollectionExpression;
import org.eclipse.internal.xtend.expression.ast.Expression;
import org.eclipse.internal.xtend.expression.ast.FeatureCall;
import org.eclipse.internal.xtend.expression.ast.ISyntaxElement;
@@ -46,7 +47,7 @@ import org.eclipse.xtend.typesystem.Type;
* @author Bernd Kolb
* @author Clemens Kadura (zAJKa)
* @author Karsten Thoms (itemis) - maintenance
- * @author Aykut Kilic (itemis) - Bug#465802,480646,480645
+ * @author Aykut Kilic (itemis) - Bug#465802,480646,480645,482602
*/
public class ExpressionElementAdapter implements ElementAdapter {
@@ -119,7 +120,7 @@ public class ExpressionElementAdapter implements ElementAdapter {
*/
public boolean shallAddToCallStack(Object element) {
- if( element instanceof FeatureCall ) return false;
+ if( element instanceof FeatureCall && !(element instanceof CollectionExpression)) return false;
return true;
}
@@ -190,7 +191,9 @@ public class ExpressionElementAdapter implements ElementAdapter {
return result;
}
- if(element instanceof AbstractExtensionDefinition || element instanceof LetExpression) {
+ if(element instanceof AbstractExtensionDefinition
+ || element instanceof LetExpression
+ || element instanceof CollectionExpression) {
final Type type = context.getType(element);
List<NameValuePair> props = getAllPropertiesFor(type, element);
for (Entry<String, Variable> entry : context.getVisibleVariables().entrySet()) {