public ComponentConfig provide() throws QuickFixException {
AuraContext context = Aura.getContextService().getCurrentContext();
BaseComponent<?, ?> component = context.getCurrentComponent();
ComponentConfig cc = new ComponentConfig();
List<Component> components = Lists.newArrayList();
InstanceStack iStack = context.getInstanceStack();
Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
m.put("body", components);
cc.setAttributes(m);
AttributeSet atts = component.getAttributes();
Iterable<?> value = atts.getValue("items", Iterable.class);
if (value != null) {
List<?> items = Lists.newArrayList(value);
if (!items.isEmpty()) {
String var = atts.getValue("var", String.class);
String indexVar = atts.getValue("indexVar", String.class);
int realstart = 0;
int realend = items.size();
ComponentDefRefArrayImpl template = atts.getValue("body", ComponentDefRefArrayImpl.class);
m.put("template",template);
Integer start = getIntValue(atts.getValue("start"));
Integer end = getIntValue(atts.getValue("end"));
if (start == null && end == null) {
// int page = (Integer)atts.getValue("page");
// int pageSize = (Integer)atts.getValue("pageSize");
} else {
if (start != null && start > realstart) {
realstart = start;
}
if (end != null && end < realend) {
realend = end;
}
}
// boolean reverse = (Boolean)atts.getValue("reverse");
iStack.setAttributeName("body");
for (int i = realstart; i < realend; i++) {
iStack.setAttributeIndex(i);
iStack.pushInstance(component, component.getDescriptor());
iStack.setAttributeName("body");
Map<String, Object> providers = Maps.newHashMap();
providers.put(var, items.get(i));
if (indexVar != null) {
providers.put(indexVar, i);
}
components.addAll(template.newInstance(atts.getValueProvider(), providers));
iStack.clearAttributeName("body");
iStack.popInstance(component);
iStack.clearAttributeIndex(i);
}
iStack.clearAttributeName("body");
}
}
return cc;
}