View Javadoc
Minimize
Table

1   /*
2    * Copyright 2003-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.groovy.ast.expr;
17  
18  import java.util.List;
19  
20  import org.codehaus.groovy.ast.GroovyCodeVisitor;
21  import org.codehaus.groovy.ast.Parameter;
22  
23  /**
24   * Represents one or more arguments being passed into a method
25   * 
26   * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
27   * @version $Revision: 15807 $
28   */
29  public class ArgumentListExpression extends TupleExpression {
30  
31      public static final Object[] EMPTY_ARRAY = {
32      };
33      
34      public static final ArgumentListExpression EMPTY_ARGUMENTS = new ArgumentListExpression();
35  
36      public ArgumentListExpression() {
37      }
38  
39      public ArgumentListExpression(List<Expression> expressions) {
40          super(expressions);
41      }
42  
43      public ArgumentListExpression(Expression[] expressions) {
44          super(expressions);
45      }
46  
47      public ArgumentListExpression(Parameter[] parameters) {
48          for (int i = 0; i < parameters.length; i++) {
49              Parameter parameter = parameters[i];
50              addExpression(new VariableExpression(parameter.getName()));
51          }
52      }
53      
54      public ArgumentListExpression(Expression expr) {
55          super(expr);
56      }
57  
58      public ArgumentListExpression(Expression expr1, Expression expr2) {
59          super(expr1, expr2);
60      }
61  
62      public ArgumentListExpression(Expression expr1, Expression expr2, Expression expr3) {
63          super(expr1, expr2, expr3);
64      }
65  
66      public Expression transformExpression(ExpressionTransformer transformer) {
67          Expression ret = new ArgumentListExpression(transformExpressions(getExpressions(), transformer));
68          ret.setSourcePosition(this);
69          return ret;
70      }
71      
72      public void visit(GroovyCodeVisitor visitor) {
73          visitor.visitArgumentlistExpression(this);
74      }
75  }