001/* 002 * Copyright (c) 2012-2018 Institut National des Sciences Appliquées de Lyon (INSA Lyon) and others 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License 2.0 which is available at 006 * http://www.eclipse.org/legal/epl-2.0. 007 * 008 * SPDX-License-Identifier: EPL-2.0 009 */ 010 011package org.eclipse.golo.compiler.parser; 012 013import java.util.List; 014import java.util.ArrayList; 015import static java.util.Collections.unmodifiableList; 016 017public class ASTDestructuringAssignment extends GoloASTNode { 018 019 private ASTLetOrVar.Type type; 020 private final List<String> names = new ArrayList<>(); 021 private boolean isVarargs = false; 022 023 public ASTDestructuringAssignment(int id) { 024 super(id); 025 } 026 027 public ASTDestructuringAssignment(GoloParser p, int id) { 028 super(p, id); 029 } 030 031 public ASTLetOrVar.Type getType() { 032 return type; 033 } 034 035 public void setType(ASTLetOrVar.Type type) { 036 this.type = type; 037 } 038 039 public List<String> getNames() { 040 return unmodifiableList(names); 041 } 042 043 public void setNames(List<String> names) { 044 this.names.clear(); 045 this.names.addAll(names); 046 } 047 048 public void setVarargs(boolean b) { 049 this.isVarargs = b; 050 } 051 052 public boolean isVarargs() { 053 return this.isVarargs; 054 } 055 056 @Override 057 public String toString() { 058 return String.format("ASTDestructuringAssignment{type=%s, names=%s, varargs=%s}", 059 type, names, isVarargs); 060 } 061 062 @Override 063 public Object jjtAccept(GoloParserVisitor visitor, Object data) { 064 return visitor.visit(this, data); 065 } 066}