|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| StaticMethodCall.java | 25% | 46.2% | 50% | 44% |
|
||||||||||||||
| 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 static method call nodes of the syntax tree. | |
| 39 | * For example: "SomeClass.foo(x, y+3)" | |
| 40 | * | |
| 41 | * @author Stephane Hillion | |
| 42 | * @version 1.0 - 1999/05/01 | |
| 43 | */ | |
| 44 | ||
| 45 | public class StaticMethodCall extends MethodCall { | |
| 46 | /** | |
| 47 | * The type on which this method call applies | |
| 48 | */ | |
| 49 | private TypeName methodType; | |
| 50 | ||
| 51 | /** | |
| 52 | * Creates a new node. | |
| 53 | * @param typ the type 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 | * @exception IllegalArgumentException if typ is null or mn is null | |
| 58 | */ | |
| 59 | 0 | public StaticMethodCall(TypeName typ, Option<List<TypeName>> targs, String mn, List<? extends Expression> args) { |
| 60 | 0 | this(typ, targs, mn, args, SourceInfo.NONE); |
| 61 | } | |
| 62 | ||
| 63 | /** | |
| 64 | * Creates a new node. | |
| 65 | * @param typ the type on which this method call applies | |
| 66 | * @param mn the field name | |
| 67 | * @param args the arguments. Can be null. | |
| 68 | * @exception IllegalArgumentException if typ is null or mn is null | |
| 69 | */ | |
| 70 | 0 | public StaticMethodCall(TypeName typ, String mn, List<? extends Expression> args) { |
| 71 | 0 | this(typ, Option.<List<TypeName>>none(), mn, args, SourceInfo.NONE); |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * Creates a new node | |
| 76 | * @param typ the type on which this method call applies | |
| 77 | * @param targs type arguments | |
| 78 | * @param mn the field name | |
| 79 | * @param args the arguments. Can be null. | |
| 80 | * @exception IllegalArgumentException if typ is null or mn is null | |
| 81 | */ | |
| 82 | 71 | public StaticMethodCall(TypeName typ, Option<List<TypeName>> targs, String mn, List<? extends Expression> args, |
| 83 | SourceInfo si) { | |
| 84 | 71 | super(targs, mn, args, si); |
| 85 | 0 | if (typ == null) throw new IllegalArgumentException("typ == null"); |
| 86 | 71 | methodType = typ; |
| 87 | } | |
| 88 | ||
| 89 | /** | |
| 90 | * Creates a new node | |
| 91 | * @param typ the type on which this method call applies | |
| 92 | * @param mn the field name | |
| 93 | * @param args the arguments. Can be null. | |
| 94 | * @exception IllegalArgumentException if typ is null or mn is null | |
| 95 | */ | |
| 96 | 18 | public StaticMethodCall(TypeName typ, String mn, List<? extends Expression> args, SourceInfo si) { |
| 97 | 18 | this(typ, Option.<List<TypeName>>none(), mn, args, si); |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * Returns the type on which this method call applies | |
| 102 | */ | |
| 103 | 53 | public TypeName getMethodType() { |
| 104 | 53 | return methodType; |
| 105 | } | |
| 106 | ||
| 107 | /** | |
| 108 | * Sets the declaring type of the method | |
| 109 | * @exception IllegalArgumentException if t is null | |
| 110 | */ | |
| 111 | 0 | public void setMethodType(ReferenceTypeName t) { |
| 112 | 0 | if (t == null) throw new IllegalArgumentException("t == null"); |
| 113 | 0 | methodType = t; |
| 114 | } | |
| 115 | ||
| 116 | /** | |
| 117 | * Allows a visitor to traverse the tree | |
| 118 | * @param visitor the visitor to accept | |
| 119 | */ | |
| 120 | 100 | public <T> T acceptVisitor(Visitor<T> visitor) { |
| 121 | 100 | return visitor.visit(this); |
| 122 | } | |
| 123 | /** | |
| 124 | * Implementation of toString for use in unit testing | |
| 125 | */ | |
| 126 | 0 | public String toString() { |
| 127 | 0 | return "("+getClass().getName()+": "+getTypeArgs()+" "+getMethodName()+" "+getArguments()+" "+getMethodType()+")"; |
| 128 | } | |
| 129 | } |
|
||||||||||