|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ObjectMethodCall.java | 50% | 71.4% | 77.8% | 70.4% |
|
||||||||||||||
| 1 | /* | |
| 2 | * DynamicJava - Copyright (C) 1999-2001 | |
| 3 | * | |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 | * copy of this software and associated documentation files | |
| 6 | * (the "Software"), to deal in the Software without restriction, including | |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, | |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 | * persons to whom the Software is furnished to do so, subject to the | |
| 10 | * following conditions: | |
| 11 | * The above copyright notice and this permission notice shall be included | |
| 12 | * in all copies or substantial portions of the Software. | |
| 13 | * | |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 17 | * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 20 | * DEALINGS IN THE SOFTWARE. | |
| 21 | * | |
| 22 | * Except as contained in this notice, the name of Dyade shall not be | |
| 23 | * used in advertising or otherwise to promote the sale, use or other | |
| 24 | * dealings in this Software without prior written authorization from | |
| 25 | * Dyade. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | package koala.dynamicjava.tree; | |
| 30 | ||
| 31 | import java.util.*; | |
| 32 | ||
| 33 | import edu.rice.cs.plt.tuple.Option; | |
| 34 | ||
| 35 | import koala.dynamicjava.tree.visitor.*; | |
| 36 | ||
| 37 | /** | |
| 38 | * This class represents the method call nodes of the syntax tree. | |
| 39 | * For example: "obj.foo(x, y+3)" | |
| 40 | * | |
| 41 | * @author Stephane Hillion | |
| 42 | * @version 1.0 - 1999/04/24 | |
| 43 | */ | |
| 44 | ||
| 45 | public class ObjectMethodCall extends MethodCall implements ExpressionContainer { | |
| 46 | /** | |
| 47 | * The expression on which this method call applies | |
| 48 | */ | |
| 49 | private Expression expression; | |
| 50 | ||
| 51 | /** | |
| 52 | * Creates a new node | |
| 53 | * @param exp the expression on which this method call applies | |
| 54 | * @param targs type arguments | |
| 55 | * @param mn the field name | |
| 56 | * @param args the arguments. Can be null. | |
| 57 | */ | |
| 58 | 178 | public ObjectMethodCall(Expression exp, Option<List<TypeName>> targs, String mn, |
| 59 | List<? extends Expression> args, SourceInfo si) { | |
| 60 | 178 | super(targs, mn, args, si); |
| 61 | 0 | if (exp == null) { throw new IllegalArgumentException("exp == null"); } |
| 62 | 178 | expression = exp; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Creates a new node | |
| 67 | * @param exp the expression on which this method call applies | |
| 68 | * @param mn the field name | |
| 69 | * @param args the arguments. Can be null. | |
| 70 | */ | |
| 71 | 178 | public ObjectMethodCall(Expression exp, String mn, List<? extends Expression> args, SourceInfo si) { |
| 72 | 178 | this(exp, Option.<List<TypeName>>none(), mn, args, si); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Creates a new node | |
| 77 | * @param exp the expression on which this method call applies | |
| 78 | * @param targs type arguments | |
| 79 | * @param mn the field name | |
| 80 | * @param args the arguments. Can be null. | |
| 81 | */ | |
| 82 | 0 | public ObjectMethodCall(Expression exp, Option<List<TypeName>> targs, String mn, |
| 83 | List<? extends Expression> args) { | |
| 84 | 0 | this(exp, targs, mn, args, SourceInfo.NONE); |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Creates a new node | |
| 89 | * @param exp the expression on which this method call applies | |
| 90 | * @param mn the field name | |
| 91 | * @param args the arguments. Can be null. | |
| 92 | */ | |
| 93 | 0 | public ObjectMethodCall(Expression exp, String mn, List<? extends Expression> args) { |
| 94 | 0 | this(exp, Option.<List<TypeName>>none(), mn, args, SourceInfo.NONE); |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * Returns the expression on which this method call applies | |
| 99 | */ | |
| 100 | 258 | public Expression getExpression() { |
| 101 | 258 | return expression; |
| 102 | } | |
| 103 | ||
| 104 | /** | |
| 105 | * Sets the expression on which this method call applies | |
| 106 | */ | |
| 107 | 91 | public void setExpression(Expression e) { |
| 108 | 0 | if (e == null) { throw new IllegalArgumentException("e == null"); } |
| 109 | 91 | expression = e; |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * Allows a visitor to traverse the tree | |
| 114 | * @param visitor the visitor to accept | |
| 115 | */ | |
| 116 | 236 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 117 | 236 | return visitor.visit(this); |
| 118 | } | |
| 119 | ||
| 120 | 22 | public String toString() { |
| 121 | 22 | return "("+getClass().getName()+": "+toStringHelper()+")"; |
| 122 | } | |
| 123 | ||
| 124 | /** | |
| 125 | * Implementation of toString for use in unit testing | |
| 126 | */ | |
| 127 | 22 | public String toStringHelper() { |
| 128 | 22 | return getTypeArgs()+" "+getMethodName()+" "+getArguments()+" "+getExpression(); |
| 129 | } | |
| 130 | } |
|
||||||||||