private void print(ObjectLiteral node) throws IOException { writer.append('{').ws(); if (node.getElements() != null && !node.getElements().isEmpty()) { print(node.getElements().get(0)); for (int i = 1; i < node.getElements().size(); ++i) { writer.append(',').ws(); print(node.getElements().get(i)); } } writer.ws().append('}'); }
@Override public boolean isDestructuring() { return node.isDestructuring(); }
ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); pn.setElements(elems); pn.setLineno(lineno); return pn;
private Node transformObjectLiteral(ObjectLiteral node) { if (node.isDestructuring()) { return node; List<ObjectProperty> elems = node.getElements(); Node object = new Node(Token.OBJECTLIT); Object[] properties;
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("{"); if (elements != null) { printList(elements, sb); } sb.append("}"); return sb.toString(); }
/** * Adds an element to the list, and sets its parent to this node. * @param element the property node to append to the end of the list * @throws IllegalArgumentException} if element is {@code null} */ public void addElement(ObjectProperty element) { assertNotNull(element); if (elements == null) { elements = new ArrayList<ObjectProperty>(); } elements.add(element); element.setParent(this); }
/** * Sets the element list, and updates the parent of each element. * Replaces any existing elements. * @param elements the element list. Can be {@code null}. */ public void setElements(List<ObjectProperty> elements) { if (elements == null) { this.elements = null; } else { if (this.elements != null) this.elements.clear(); for (ObjectProperty o : elements) addElement(o); } }
ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); pn.setElements(elems); pn.setLineno(lineno); return pn;
private Node transformObjectLiteral(ObjectLiteral node) { if (node.isDestructuring()) { return node; List<ObjectProperty> elems = node.getElements(); Node object = new Node(Token.OBJECTLIT); Object[] properties;
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("{"); if (elements != null) { printList(elements, sb); } sb.append("}"); return sb.toString(); }
/** * Adds an element to the list, and sets its parent to this node. * @param element the property node to append to the end of the list * @throws IllegalArgumentException} if element is {@code null} */ public void addElement(ObjectProperty element) { assertNotNull(element); if (elements == null) { elements = new ArrayList<ObjectProperty>(); } elements.add(element); element.setParent(this); }
/** * Sets the element list, and updates the parent of each element. * Replaces any existing elements. * @param elements the element list. Can be {@code null}. */ public void setElements(List<ObjectProperty> elements) { if (elements == null) { this.elements = null; } else { if (this.elements != null) this.elements.clear(); for (ObjectProperty o : elements) addElement(o); } }
private void print(ObjectLiteral node) throws IOException { writer.append('{').ws(); if (node.getElements() != null && !node.getElements().isEmpty()) { print(node.getElements().get(0)); for (int i = 1; i < node.getElements().size(); ++i) { writer.append(',').ws(); print(node.getElements().get(i)); } } writer.ws().append('}'); }
ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); pn.setElements(elems); pn.setLineno(lineno); return pn;
private Node transformObjectLiteral(ObjectLiteral node) { if (node.isDestructuring()) { return node; List<ObjectProperty> elems = node.getElements(); Node object = new Node(Token.OBJECTLIT); Object[] properties;
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(); sb.append(makeIndent(depth)); sb.append("{"); if (elements != null) { printList(elements, sb); } sb.append("}"); return sb.toString(); }
/** * Adds an element to the list, and sets its parent to this node. * @param element the property node to append to the end of the list * @throws IllegalArgumentException} if element is {@code null} */ public void addElement(ObjectProperty element) { assertNotNull(element); if (elements == null) { elements = new ArrayList<ObjectProperty>(); } elements.add(element); element.setParent(this); }
/** * Sets the element list, and updates the parent of each element. * Replaces any existing elements. * @param elements the element list. Can be {@code null}. */ public void setElements(List<ObjectProperty> elements) { if (elements == null) { this.elements = null; } else { if (this.elements != null) this.elements.clear(); for (ObjectProperty o : elements) addElement(o); } }
/** * Visits this node, then visits each child property node, in lexical * (source) order. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (ObjectProperty prop : getElements()) { prop.visit(v); } } } }
ObjectLiteral pn = new ObjectLiteral(pos, ts.tokenEnd - pos); if (objJsdocNode != null) { pn.setJsDocNode(objJsdocNode); pn.setElements(elems); pn.setLineno(lineno); return pn;