List comprehension

[ y | y : Assignment in AssignmentSubmission.getAssignment(AssignmentCollectionSubmission.getSubsForGradeN(this)) where Expressions.nullSafeBoolean(Expressions.eq_One_One(x, y)) ]

accesses x which is defined in a list comprehension around it. The generated code does not have access to x.

Full WebDSL statement:

return ( Expressions.first([ x | x : Assignment in [ x | x : Assignment in AssignmentCollection.getAssignments(AssignmentCollectionSubmission.getAssignment2(this)) where Expressions.nullSafeBoolean(Expressions.eq_One_One(Expressions.count([ y | y : Assignment in AssignmentSubmission.getAssignment(AssignmentCollectionSubmission.getSubsForGradeN(this)) where Expressions.nullSafeBoolean(Expressions.eq_One_One(x, y)) ]), 0)) ] order by Assignment.getWeight(x) ], Expressions.minus_Integer(( Expressions.choice_One_One(AssignmentCollection.getPassNSubAssignments(AssignmentCollectionSubmission.getAssignment2(this)), 0) as Int ), Expressions.count(AssignmentCollectionSubmission.getSubsForGradeN(this)))) as List<Assignment> );

Inner list comprehension generated code (formatted):

package webdsl.generated.functions;

import java.io.*;
import java.util.HashMap;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import utils.*;
import webdsl.generated.templates.*;
import webdsl.generated.domain.*;
import java.io.PrintWriter;
import org.webdsl.lang.Environment;

@SuppressWarnings("all")
public class ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_
		implements org.webdsl.lang.IFunction {
	public static java.util.List<webdsl.generated.domain.Assignment> ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_(
			webdsl.generated.domain.AssignmentCollectionSubmission ent_AssignmentCollectionSubmission_renamedthis16_) {
		java.util.List<webdsl.generated.domain.Assignment> res_ = new java.util.ArrayList<webdsl.generated.domain.Assignment>();
		res_ = new java.util.ArrayList<webdsl.generated.domain.Assignment>();
		java.util.List<webdsl.generated.domain.Assignment> thecollection_ = webdsl.generated.domain.AssignmentSubmission
				.$static$getAssignmentList_AssignmentSubmission__(webdsl.generated.domain.AssignmentCollectionSubmission
						.$static$getSubsForGradeNAssignmentCollectionSubmission_(
								ent_AssignmentCollectionSubmission_renamedthis16_));
		if (!org.webdsl.tools.Utils.equal(thecollection_, null)) {
			java.util.Collection<? extends webdsl.generated.domain.Assignment> exp109 = thecollection_;
			java.util.ArrayList<webdsl.generated.domain.Assignment> lst109 = new java.util.ArrayList<webdsl.generated.domain.Assignment>(
					exp109);
			int removedcount99 = 0;
			Object[] array208 = lst109.toArray();
			for (int i208 = 0; i208 < array208.length; i208++) {
				webdsl.generated.domain.Assignment y_ = (webdsl.generated.domain.Assignment) array208[i208];
				if (!lib.icedust.Expressions.nullSafeBoolean(lib.icedust.Expressions.eq_One_One(x_, y_))) {
					lst109.remove(i208 - removedcount99);
					removedcount99++;
				}
			}
			Object[] array209 = lst109.toArray();
			for (int i209 = 0; i209 < array209.length; i209++) {
				webdsl.generated.domain.Assignment y_ = (webdsl.generated.domain.Assignment) array209[i209];
				res_.add(y_);
			}
		} else {
		}
		return res_;
	}

	public Object apply(Object[] args) {
		return ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_
				.ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_(
						(webdsl.generated.domain.AssignmentCollectionSubmission) args[0]);
	}
}

error:

/Users/daco/weblab/.servletapp/src-generated/webdsl/generated/functions/ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_.java:19: error: cannot find symbol
if(!lib.icedust.Expressions.nullSafeBoolean(lib.icedust.Expressions.eq_One_One(x_,y_))){
                                                                               ^
  symbol:   variable x_
  location: class ent_AssignmentCollectionSubmission_listCompr13AssignmentCollectionSubmission_
Submitted by Daco Harkes on 26 April 2017 at 11:27


On 26 April 2017 at 15:49 Danny Groenewegen closed this issue.

Log in to post comments